Overview
In the translation task, a sentence (consisting of tokens ) in the source language is to be translated into a sentence (consisting of tokens ) in the target language. The source and target tokens (which in the simple event are used for each other in order for a particular game ] vectors, so they can be processed mathematically. NMT models assign a probability to potential translations y and then search a subset of potential translations for the one with the highest probability. Most NMT models are ''auto-regressive'': They model the probability of each target token as a function of the source sentence and the previously predicted target tokens. The probability of the whole translation then is the product of the probabilities of the individual predicted tokens: NMT models differ in how exactly they model this function , but most use some variation of the ''encoder-decoder'' architecture: They first use an encoder network to process and encode it into a vector or matrix representation of the source sentence. Then they use a decoder network that usually produces one target word at a time, taking into account the source representation and the tokens it previously produced. As soon as the decoder produces a special ''end of sentence'' token, the decoding process is finished. Since the decoder refers to its own previous outputs during, this way of decoding is called ''auto-regressive''.History
Early approaches
In 1987, Robert B. Allen demonstrated the use of feedforward neural network, feed-forward neural networks for translating auto-generated English sentences with a limited vocabulary of 31 words into Spanish. In this experiment, the size of the network's input and output layers was chosen to be just large enough for the longest sentences in the source and target language, respectively, because the network did not have any mechanism to encode sequences of arbitrary length into a fixed-size representation. In his summary, Allen also already hinted at the possibility of using auto-associative models, one for encoding the source and one for decoding the target. Lonnie Chrisman built upon Allen's work in 1991 by training separate recursive auto-associative memory (RAAM) networks (developed by Jordan B. Pollack) for the source and the target language. Each of the RAAM networks is trained to encode an arbitrary-length sentence into a fixed-size hidden representation and to decode the original sentence again from that representation. Additionally, the two networks are also trained to share their hidden representation; this way, the source encoder can produce a representation that the target decoder can decode. Forcada and Ñeco simplified this procedure in 1997 to directly train a source encoder and a target decoder in what they called a ''recursive hetero-associative memory''. Also in 1997, Castaño and Casacuberta employed an Elman's recurrent neural network in another machine translation task with very limited vocabulary and complexity. Even though these early approaches were already similar to modern NMT, the computing resources of the time were not sufficient to process datasets large enough for the computational complexity of the machine translation problem on real-world texts. Instead, other methods likeHybrid approaches
During the time when statistical machine translation was prevalent, some works used neural methods to replace various parts in the statistical machine translation while still using the log-linear approach to tie them together. For example, in various works together with other researchers, Holger Schwenk replaced the usual n-gram language model with a neural one and estimated phrase translation probabilities using a feed-forward network.seq2seq
In 2013 and 2014, end-to-end neural machine translation had their breakthrough with Kalchbrenner & Blunsom using aTransformer
Another network architecture that lends itself to parallelization is theGenerative LLMs
Instead of fine-tuning a pre-trained language model on the translation task, sufficiently large generative models can also be directly prompted to translate a sentence into the desired language. This approach was first comprehensively tested and evaluated for GPT 3.5 in 2023 by Hendy et al. They found that "GPT systems can produce highly fluent and competitive translation outputs even in the zero-shot setting especially for the high-resource language translations". The WMT23 evaluated the same approach (but usingComparison with statistical machine translation
NMT has overcome several challenges that were present in statistical machine translation (SMT): * NMT's full reliance on continuous representation of tokens overcame sparsity issues caused by rare words or phrases. Models were able to generalize more effectively. * The limited n-gram length used in SMT's n-gram language models caused a loss of context. NMT systems overcome this by not having a hard cut-off after a fixed number of tokens and by using attention to choosing which tokens to focus on when generating the next token. * End-to-end training of a single model improved translation performance and also simplified the whole process. * The huge n-gram models (up to 7-gram) used in SMT required large amounts of memory, whereas NMT requires less.Training procedure
Cross-entropy loss
NMT models are usually trained to maximize the likelihood of observing the training data. I.e., for a dataset of source sentences and corresponding target sentences , the goal is finding the model parameters that maximize the sum of the likelihood of each target sentence in the training data given the corresponding source sentence: Expanding to token level yields: Since we are only interested in the maximum, we can just as well search for the maximum of the logarithm instead (which has the advantage that it avoids floating point underflow that could happen with the product of low probabilities). Using the fact that the logarithm of a product is the sum of the factors’ logarithms and flipping the sign yields the classic cross-entropy loss: In practice, this minimization is done iteratively on small subsets (mini-batches) of the training set usingTeacher forcing
During inference, auto-regressive decoders use the token generated in the previous step as the input token. However, the vocabulary of target tokens is usually very large. So, at the beginning of the training phase, untrained models will pick the wrong token almost always; and subsequent steps would then have to work with wrong input tokens, which would slow down training considerably. Instead, ''teacher forcing'' is used during the training phase: The model (the “student” in the teacher forcing metaphor) is always fed the previous ground-truth tokens as input for the next token, regardless of what it predicted in the previous step.Translation by prompt engineering LLMs
As outlined in the history section above, instead of using an NMT system that is trained on parallel text, one can also prompt a generative LLM to translate a text. These models differ from an encoder-decoder NMT system in a number of ways: * Generative language models are not trained on the translation task, let alone on a parallel dataset. Instead, they are trained on a language modeling objective, such as predicting the next word in a sequence drawn from a large dataset of text. This dataset can contain documents in many languages, but is in practice dominated by English text. After this pre-training, they are fine-tuned on another task, usually to follow instructions. * Since they are not trained on translation, they also do not feature an encoder-decoder architecture. Instead, they just consist of a transformer's decoder. * In order to be competitive on the machine translation task, LLMs need to be much larger than other NMT systems. E.g., GPT-3 has 175 billion parameters, while mBART has 680 million and the original transformer-big has “only” 213 million. This means that they are computationally more expensive to train and use. A generative LLM can be prompted in a zero-shot fashion by just asking it to translate a text into another language without giving any further examples in the prompt. Or one can include one or several example translations in the prompt before asking to translate the text in question. This is then called one-shot or few-shot learning, respectively. For example, the following prompts were used by Hendy et al. (2023) for zero-shot and one-shot translation:### Translate this sentence fromource language The Ource () is a long river in northeastern France, a right tributary of the river Seine. Its source is in the Haute-Marne department, 2 km south of Poinson-lès-Grancey. It flows generally northwest. It joins the Seine at Bar-sur-Seine. ...toarget language Arget (; ) is a Communes of France, commune in Pyrénées-Atlantiques, a Departments of France, department in the Nouvelle-Aquitaine region of south-western France. It is part of the traditional province of Béarn. Geography Arget is located some ...Source:ource sentence The Ource () is a long river in northeastern France, a right tributary of the river Seine. Its source is in the Haute-Marne department, 2 km south of Poinson-lès-Grancey. It flows generally northwest. It joins the Seine at Bar-sur-Seine. ...### Target:
Translate this into 1.arget language Arget (; ) is a Communes of France, commune in Pyrénées-Atlantiques, a Departments of France, department in the Nouvelle-Aquitaine region of south-western France. It is part of the traditional province of Béarn. Geography Arget is located some ...hot 1 source1.hot 1 reference Hot commonly refers refer to: *Heat, a hot temperature *Pungency, in food, a spicy or hot quality Hot or HOT may also refer to: Places * Hot district, a district of Chiang Mai province, Thailand ** Hot subdistrict, a sub-district of Hot Distri ...Translate this into 1.arget language Arget (; ) is a Communes of France, commune in Pyrénées-Atlantiques, a Departments of France, department in the Nouvelle-Aquitaine region of south-western France. It is part of the traditional province of Béarn. Geography Arget is located some ...nput1.
Literature
* Koehn, Philipp (2020)See also
*References
{{Artificial intelligence navbox Applications of artificial intelligence Computational linguistics Machine translation Tasks of natural language processing