<p>Neural machine translation models have a limited vocabulary. The reason is that you get the distribution over the target vocabulary tokens by multiplying the hidden state of the encoder by a matrix that has one row for each vocabulary token. The paper that you mention uses hidden state of 1000 dimensions. If you wanted to cover English reasonably, you would need a vocabulary of at least 200k tokens, which would mean 800MB only for this matrix.</p>
<p>The paper that you mention is an outdated solution from 2015 and tries to find how to have the vocabulary as big as possible. However, increasing the vocabulary capacity did not appear to be the best solution because, with increasing vocabulary size, you add rarer and rarer words into the vocabulary and there is less and less training signal for embeddings of these words, so the model eventually does not learn to use those words properly.</p>
<p>State-of-the art machine translation uses a segmentation into subwords that was <a href="https://aclanthology.org/P16-1162/" rel="nofollow noreferrer">introduced in 2016</a> with the BPE algorithm. In parallel, Google came with an alternative solution named WordPiece for their <a href="https://arxiv.org/abs/1609.08144" rel="nofollow noreferrer">first production neural machine translation system</a>. Later, Google came with an improved segmentation algorithm <a href="https://aclanthology.org/D18-2012" rel="nofollow noreferrer">SentencePiece in 2018</a>.</p>
<p>The main principle of the subword vocabulary is that the frequent words remain intact, whereas rarer words get segmented into smaller units. Rare words are often proper names that do not really get translated. For languages with complex morphology, subword segmentation allows the models to learn how to create different forms of the same words.</p>
Machine translation transformer output - "unknown" tokens?
<p>When decoding / translating a test dataset after training on the base Transformer model (Vaswani et. al.), I sometimes see this token &quot;unk&quot; in the ouput.</p>
<p>&quot;unk&quot; here refers to an unknown token, but my question is what is the reasoning behind that? Based on <a href="https://nlp.stanford.edu/pubs/acl15_nmt.pdf" rel="nofollow noreferrer">https://nlp.stanford.edu/pubs/acl15_nmt.pdf</a>, does it mean that the vocab I built for the training set does not contain the word present in the test set?</p>
<p>For reference, I built the <code>Vocab</code> using <code>Spacy</code> <code>en_core_web_sm</code> and <code>de_core_news_sm</code> for a German to English translation task.</p>
<p>Example output:</p>
<pre><code>ground truth = ['a', 'girl', 'in', 'a', 'jean', 'dress', 'is', 'walking', 'along', 'a', 'raised', 'balance', 'beam', '.']

predicted = ['a', 'girl', 'in', 'a', '&lt;unk&gt;', 'costume', 'is', 'jumping', 'on', 'a', 'clothesline', '.', '&lt;eos&gt;']
</code></pre>
<p>As you can see, the <em>jean</em> is &quot;unk&quot; here.</p>