How to use pretrained embedding
HI all, can someone please suggest how to use pre-trained embedding for machine translation task using Transformer. Do I need to change the source code for modalities.SymbolModality._get_weights for this?
Hi, I was actually wondering how this could work with sub-tokens.
Like, if you download some pre-trained embeddings, I would expect to get one vector per token (token = whole word). If you use sub-tokens though, now you end up with a different 'unit' to work with.
Do you also see this issue, or am I missing something here?
This is a problem not only with tokens, but generally with pre-trained embeddings: you need to make sure that they were pre-trained on data tokenized in exactly the same way as your data. Also, during your training, some embeddings will be moving away and some (rare words) will not, making them less and less useful. That's why we never made it a priority: you can just do 2-problem training instead and train your problem together with a language or translation model. This makes sure your data is tokenized in the same way, and since you're training concurrently, you're pulling all words to the same space all the time. I'd really always do this rather than use pre-trained embedding, the only problem is increased training cost.
Thanks @lukaszkaiser - indeed, that makes sense.
I suppose I was mainly interested in this because of scenarios where you have not so much data for your problem - and in these cases I was interested in trying to pre-train embeddings on bigger data source.
As you say though, it is basically a trade-off between training everything on the same small amount of data, or pre-training embeddings on much more - but somehow different - data. (not sure which one will provide the best results - without running experiments to check it)
@lukaszkaiser by 2-problem training do you mean training the randomly initialized word vectors and also the problem that is of interest?
Yes. For example, you can just do --problems=translate_ende_wmt32k-translate_enfr_wmt32k and it will train a en-de translation together with en-fr translation, which has much more data so it'll also train the English word embeddings nicely.
Same question. How to use pretrained embedding for other tasks.
@lukaszkaiser Could you please give me some instructions about how to do the 2-problem training? Do you mean that we need to train the word embedding first?
I find it in readme:
Models can be used with any dataset and input mode (or even multiple); all modality-specific processing (e.g. embedding lookups for text tokens) is done with
Modalityobjects, which are specified per-feature in the dataset/task specification.