Concepts / Transformer Encoder and Decoder Blocks

Transformer Encoder and Decoder Blocks

Do not conclude that GPT has no encoder because the design is simpler.

  • Programming

Guessing Translation From Next-Word Training

Imagine building a model whose entire training objective is to guess the next word in a passage of text. Nobody gives it translation exercises, bilingual dictionaries, or labeled pairs of sentences in two languages. Its only job is continuing text, one word at a time. The question this article works through is whether such a model could later turn a sentence from one language into another.

What do you think happens?

Before reading on, make a guess: could a model trained only to predict the next word later translate a sentence from one language into another? Note the reasoning behind your guess.

Reveal answer
Answer:

Yes. GPT models, which are trained on next-word prediction, can translate even though translation was never part of their training objective.

The source explains that this ability is not trained directly. It arises as a natural consequence of the model being exposed to vast quantities of multilingual text across diverse contexts. The reasoning behind your guess matters because the rest of this article explains why the result is less strange than it first looks.

What Makes a Behavior Emergent

Definition

An emergent behavior is an ability a model shows without having been explicitly trained to perform that task.

The defining feature is the word explicitly. An emergent ability is not taught as a direct target during training. Instead it appears as a byproduct of other learning. In the case of GPT models, the ability to translate is not something the training process aims at. It arises because the model is exposed to a very large amount of text that includes many languages, appearing in many different contexts.

Key point

The test for whether a behavior is emergent is not whether it is useful or impressive. The test is whether the task was part of the training objective. If it was not, and the model can still perform it, the behavior is emergent.

Encoder and Decoder in the Original Transformer

The original transformer was built with two halves: an encoder and a decoder. The encoder reads an input sentence, and the decoder produces the output sentence. This design was made explicitly for language translation, so translation was the purpose the architecture was shaped around from the start.

Input sentencetext to readEncoderreads the inputDecoderproduces the outputOutput sentencetranslated texttokens inencoded inputgenerated words
How does information move from the input sentence through the encoder and into the decoder that generates the output?

Decoder-Only GPT and Its Narrow Objective

GPT models take a different route. They use a decoder-only architecture, which is simpler in structure than the original two-part design, and their training aim is next-word prediction. The architecture is larger in scale, but it is not built around translation. The surprise is that a model shaped for one narrow purpose ends up able to handle a task outside that purpose.

PropertyOriginal transformerGPT model
StructureEncoder and decoder halvesDecoder-only
Designed forLanguage translationNext-word prediction
Translation statusPurpose of the architectureEmergent, not a training target
ScaleNot the focus of this comparisonLarger in scale

Contrast between the original transformer and the GPT approach, as described in the source

Tracing the Path From Multilingual Text to Translation

Follow the path that information takes. The training data contains large amounts of text in many languages, used in many different situations. The only training signal is next-word prediction. The source describes the translation ability as a natural consequence of exposure to this multilingual data. When a model has seen many languages used in many situations, patterns that connect one language to another become part of what it has absorbed. Translation then becomes something the model can carry out when asked, even though no translation lesson was part of its training.

Multilingual textmany languages, manycontextsNext-word objectivethe only training targetOne trained modelabsorbs cross-languagepatternsTranslation abilityappears when askedtraining signallearningemerges
How does a model trained only to predict the next word end up carrying out translation, and what path does information take from training data to that ability?

Notice what the diagram does not include. There is no translation task node feeding into training. The translation ability sits at the end of the path as an outcome. The source does not describe further internal mechanics of how the patterns are stored, so this article does not claim any.

Emergent Versus Directly Trained Behavior

It helps to set emergent behavior beside the more familiar case, in which a model is trained directly on a task. In direct training, the task appears in the training objective and the model is scored on it. In emergent behavior, the task is absent from the objective, and the capability shows up anyway.

Task in objectiveTask absent fromobjectiveModel scored on taskByproduct of otherlearningCapability acquiredCapability appearstargetedtrainednot targetedarises anyway
What is the difference between an ability a model acquires from task-specific training and one that appears without it?

Worked Example: Reasoning About an Unseen Task

Worked example

Classifying a new task as emergent or direct

A team trains a model only on next-word prediction over multilingual text. Later they find it can translate short sentences. Is this ability emergent? Explain using the definition.

  1. 1
    Check the training objective

    The only stated objective is next-word prediction. Translation is not part of it.

  2. 2
    Check whether the task was trained directly

    No translation exercises or labeled sentence pairs were part of training, so the task was not a direct target.

  3. 3
    Check whether the ability appeared anyway

    The model can translate when asked, so the capability is present without being targeted.

  4. 4
    Apply the definition

    An emergent behavior is an ability a model shows without having been explicitly trained to perform that task. All three conditions match.

Result

The ability is emergent. It arose from exposure to multilingual data under a next-word objective, not from translation training.

Why One Model Can Cover Many Tasks

The practical consequence is the main benefit the source highlights. If a single large generative language model can pick up tasks it was not trained for, then one model can serve many purposes. A separate specialized model does not have to be built, trained, and maintained for each task. The source states this directly: diverse tasks can be performed without using diverse models for each.

Several capabilities can therefore share one training objective and one set of learned patterns. Translation is the only task the source names explicitly. The general claim is that the same model is not limited to a single job.

Mistakes Beginners Make About Emergence

  • Common mistake

    Assuming a model must have been trained on every task it can perform

    What it looks like

    Concluding that a next-word model cannot translate because nobody gave it translation exercises

    Why it fails

    Emergent behavior is defined as an ability shown without explicit training for that task

    Do this instead

    Ask whether the task was part of the training objective, not whether it was trained on directly

  • Common mistake

    Treating GPT's translation as evidence it was built as a translator

    What it looks like

    Describing GPT as a translation architecture because it can translate

    Why it fails

    The original transformer was designed for translation, but GPT is decoder-only and trained on next-word prediction

    Do this instead

    Keep the architecture and the objective separate from the ability that emerges

  • Common mistake

    Thinking emergence means the ability is random or unexplained

    What it looks like

    Saying translation just happened by accident

    Why it fails

    The source describes the ability as a natural consequence of exposure to multilingual data across diverse contexts

    Do this instead

    Describe emergence as an outcome of training data and objective, even when the internal details are not spelled out

  • Common mistake

    Believing each new task needs its own model when one generative model may already cover it

Practice: Predict and Explain

MEDIUM

A model is trained only to predict the next word in English and French text, with no translation examples. A user asks it to translate a short French sentence into English, and it does so. Explain in your own words whether this is emergent behavior, and identify which part of the source's explanation supports your answer.

Hints
  • Start by asking whether translation was part of the training objective.
  • Look for the role of exposure to multilingual data in the source's explanation.

Key Takeaways

  • An emergent behavior is an ability a model shows without having been explicitly trained to perform that task.
  • GPT models are decoder-only and trained on next-word prediction, yet they can translate because they were exposed to vast quantities of multilingual data in many contexts.
  • The original transformer's encoder and decoder were designed for translation, while GPT's translation ability is a byproduct of its objective and data.
  • Because such abilities emerge from one large generative model, that single model can cover diverse tasks without a separate model for each.

Related concepts

More concepts starting with T