sentencepiece icon indicating copy to clipboard operation
sentencepiece copied to clipboard

Recreate sentencepiece.bpe.model for old model trained on data created by fastBPE

Open ever4244 opened this issue 5 years ago • 1 comments

I trained a model using fairseq-train without spm, but I found that I need a "sentencepiece.bpe.model" for later task.

I used a script similar to fairseq translation example: prepare-wmt14en2de.sh, it does not generate a sentence piece model. And I prepare the data and train the old model with it.

https://github.com/pytorch/fairseq/tree/master/examples/translation

while the one that has a sentence piece model is: prepare-iwslt17-multilingual.sh python "$SPM_TRAIN" --input=$TRAIN_FILES --model_prefix=$DATA/sentencepiece.bpe --vocab_size=$BPESIZE --character_coverage=1.0 --model_type=bpe.

I am currently want to re-learn the sentencepiece.bpe.model on the training data for prepare-wmt14en2de.sh.

Since I already trained the model without the sentencepiece.bpe.model, I just want to make sure I can get the exact same training data when I reapply the spm learning script on the old data. So that my previously trained model from prepare-wmt14en2de.sh can be coupled with the newly learnt sentencepiece.bpe.model

However, In prepare-wmt14en2de.sh it use: fastBPE's learn_bpe.py, https://github.com/glample/fastBPE in prepare-iwslt17-multilingual.sh it use: sentencepiece's spm_train.py https://github.com/google/sentencepiece

They use different codes for bpe learning and encoding. They even use different BPE replacement tokens (@@ for fastBPE and _ for sentencepiece ). So how can create a sentencepiece.bpe.model that can be used together with my old model from fastBPE? (That is a sentencepiece.bpe.model which will generate the exact same training data as fastBPE)

Thank you very much!

ever4244 avatar Apr 23 '21 04:04 ever4244

Since the tokenization schema (e.g., @@ / _ ) are different, we cannot convert the model.

taku910 avatar Jun 13 '21 02:06 taku910