Basics

How neural machine translation turns one language into another

A plain-language guide to machine translation: transformers, attention, training data, LLM translation, and what makes one app more accurate than another.

Published 2026-07-29 · Updated 2026-07-30

How it works

Inside a neural machine translation model (transformer)
UNDERSTANDING THE SOURCEWRITING THE TRANSLATIONcross-attention: the decoder consults the encoded source at every stepquality controls applied around the modelSource textTyped, spoken, or OCR textTokenizerSplits into sub-word units (BPE)EmbeddingsEach token becomes a vector ofnumbersEncoder stackSelf-attention layers buildmeaning ×NDecoder stackPredicts one token at a time ×NSoftmaxProbability for every word inthe vocabularyBeam searchKeeps several candidatesentences aliveDetokenizerRebuilds natural textGlossary / do-not-translateLocks names and termsFormality controlFormal vs informal registerContext windowPrevious turns of the conversation

The encoder reads the whole source sentence at once; cross-attention lets the decoder look back at any source word while writing each target word. That is why modern MT handles long sentences and word-order changes so well.

What is machine translation?

Machine translation (MT) is software that automatically converts text from one language to another. Early systems used hand-written rules and dictionaries; the next generation stitched together statistical phrase tables. Since around 2016, every major app has used neural machine translation (NMT): a single neural network, trained on hundreds of millions of translated sentence pairs, that reads the whole sentence and writes the translation word by word.

Attention: the idea that changed everything

The breakthrough behind modern MT is a mechanism called attention. As the model writes each word of the translation, it looks back across the entire source sentence and decides which source words matter right now. Translating the French word 'avocat', attention to nearby words tells the model whether the sentence is about a lawyer or an avocado.

Transformers — the architecture behind Google Translate, DeepL, and today's large language models — are built almost entirely out of attention layers. Because they read the whole sentence in parallel instead of word by word, they handle long sentences, idioms, and languages with very different word orders far better than anything before them.

How the model is trained

An NMT model starts out knowing nothing: its millions of internal weights are random. Training shows it a source sentence, lets it guess a translation, measures how far the guess is from a human reference translation, and nudges every weight slightly in the direction that would have made the guess better. Repeat this billions of times across a parallel corpus — books, subtitles, parliamentary proceedings, crawled websites — and the network gradually encodes the patterns of both languages.

This is why training data is destiny in MT: English–Spanish has vast parallel corpora and reads fluently, while English–Icelandic or English–Sinhala has far less data, so models guess more and hallucinate more.

The training loop
Parallel corpusMillions ofhuman-translatedsentence pairsModel guessesForward pass withcurrent weightsCompareLoss: how far from thehuman reference?BackpropagationNudge every weight toreduce the errorUpdated modelSlightly better — repeatbillions of times

One pass of this loop changes the model imperceptibly. Billions of passes over millions of sentence pairs produce a system that has absorbed the patterns of both languages.

LLM translation: the new wave

The newest shift is translation by large language models — the same family of systems behind AI chat assistants. Instead of being trained only on sentence pairs, LLMs learn language broadly and can follow instructions: keep this term untranslated, use informal tone, this is a medical conversation. They are noticeably better at whole-document coherence, slang, and context that spans several sentences.

The trade-offs are cost and speed — LLMs are much larger than dedicated MT models — and a higher risk of confident, fluent output that quietly drops or invents a detail. Several apps now blend the two: a fast NMT engine for instant results, with an LLM pass for tone, context, or difficult passages.

How translation quality is measured

Researchers score MT systems by comparing their output with human references. The classic metric, BLEU, counts overlapping word sequences; newer neural metrics like COMET use a trained model to judge meaning rather than surface overlap, which tracks human judgment much better. Ultimately, blind human evaluation — bilingual raters comparing systems side by side — remains the gold standard, and it is the basis for claims like DeepL's advantage in European languages.

Why accuracy differs by language pair

Translation quality depends on how much training data exists for a language pair, how similar the languages are, and whether the vendor invested in that pair. English–Spanish is well covered; English–Icelandic has less data and can be less fluent. Some apps also specialize: DeepL is known for nuanced European languages, Papago for Korean, Japanese, and Chinese, while Google Translate covers the broadest set of languages.

Frequently asked questions

Is machine translation safe for medical use?

It can help with basic communication, but never rely on it alone for diagnosis or treatment decisions. Use a professional interpreter for high-stakes medical conversations.

Can machine translation replace human translators?

For casual, short, or repetitive text it is very useful. For legal, literary, or highly nuanced content, human translators are still preferred.

What is a transformer?

The neural network architecture used by virtually all modern translation systems and large language models. Its attention layers let the model weigh every word of the input when producing each word of the output.

Why do translations sometimes invent details?

Neural models are trained to produce fluent text, and when they are uncertain — rare words, low-resource languages, garbled input — fluency can win over faithfulness. This is called hallucination, and it is why critical text should be back-translated or checked by a human.

Apps with this feature

← All guides