AI State of the Art
Fundamentals/NLP: From Classical to Modern/24 min
Section 45

BART and Encoder-Decoder Models for Generation

Listen as a podcast →

The autoencoder that can talk

BART (Bidirectional and Auto-Regressive Transformers, Facebook (now Meta) 2019) is an encoder-decoder model (see encoder and decoder) pre-trained in a particularly elegant way: as a denoising autoencoder. An autoencoder is a network trained to reproduce its own input; "denoising" means you hand it a damaged version and ask for the original.

The concept is deceptively simple:

  1. Take a clean, well-formed text
  2. Corrupt it in different ways (mask words, delete passages, permute sentences)
  3. The encoder receives this damaged text and tries to understand it despite the noise
  4. The decoder must regenerate the original, intact text

The idea is to fuse the strengths of BERT Bidirectional Encoder Representations from Transformers, which understands text even when incomplete, with those of GPT Generative Pre-trained Transformer, which produces fluent text. The encoder must extract meaning despite the corruption; the decoder must reconstruct clean text from that partial understanding. The combination proves highly effective for text transformation tasks.

Architecture: complementary encoder-decoder

BART's architecture is a standard Transformer encoder-decoder, but each part has a very distinct role:

Encoder (comprehension side):

  • Works like BERT: full bidirectional attention (each token can "see" all other tokens in the sequence, before and after it)
  • Receives the corrupted text and can look in all directions to extract maximum meaning
  • Produces a rich internal representation that captures the "true" meaning despite the noise

Decoder (generation side):

  • Works like GPT: causal attention (each token can only see previous tokens, not those that follow, which enables sequential generation)
  • Generates the reconstruction token by token, left to right
  • Uses cross-attention to consult the encoder's representations at each generation step, the bridge between comprehension and production
Figure 1 of the BART paper. In (a), BERT: a bidirectional encoder receives A _ C _ E and independently predicts the missing tokens B and D. In (b), GPT: an autoregressive decoder receives s A B C D and predicts A B C D E left to right. In (c), BART: the bidirectional encoder receives the corrupted text A _ B _ E and passes its representation through an arrow to the autoregressive decoder, which regenerates A B C D E.
Read the three boxes left to right. BERT (a) understands but cannot generate, GPT (b) generates but only sees the past, BART (c) wires the two together. The important detail in (c): the encoder input (A _ B _ E) need not be aligned with the decoder output (A B C D E), which is what allows arbitrary corruption of the input text.Source : BART paper (Lewis et al., 2019, figure 1), via the Weak Learner blog

The sizes. The paper gives the depths plus a simple rule for parameters: BART has "roughly 10% more parameters than the equivalently sized BERT model". Hence the orders of magnitude in the table: 110 million for BERT-base times 1.1 gives roughly 140 million; 340 million for BERT-large gives roughly 400 million.

VariantEncoderDecoderParameters
BART-base6 layers6 layers≈140M
BART-large12 layers12 layers≈400M
BART and T5: two ways to denoise

BART reconstructs the entire text after corruption. The target is long, so each example costs more compute, but supplies a lot of signal.

T5 reconstructs only the masked spans, not the whole text. Short target, cheaper training.

Two philosophies: BART says "understand everything and regenerate everything"; T5 says "fill in the holes." The T5 paper compared both and picked the short target on compute-cost grounds.

Technical corner: five corruption strategies tested

The BART paper's main contribution: there is no single good way to damage text. The authors systematically tested five strategies to see which produces the best representations.

Diagram of BART's five noise transformations. An original document A B C period D E period is transformed five ways: Token Masking gives A underscore C period underscore E period; Sentence Permutation gives D E period A B C period; Document Rotation gives C period D E period A B; Token Deletion gives A period C period E period; Text Infilling gives A underscore period D underscore E.
The clean document is on the left (green box), its five damaged versions on the right. Note the difference between token masking, where each missing word leaves a visible slot, and text infilling, where a single slot can hide several words and the model does not even know how many. The last two rows, permutation and rotation, delete nothing: they move text around.Source : Diagram after BART (Lewis et al., 2019), via LLM Foundations (Yangyu Tu)

1. Token Masking (like BERT)

Replaces individual tokens with [MASK].

OriginalNoisy
Token Masking"The black cat sleeps""The [MASK] cat [MASK]"

Verdict: Effective but basic.

2. Token Deletion

Simply deletes tokens. The model must guess what is missing AND where.

OriginalNoisy
Token Deletion"The black cat sleeps""The cat sleeps" (lost "black")

Verdict: Difficult. The model must infer the position too.

3. Text Infilling

Replaces a run of consecutive tokens (a span) with a single [MASK]. Unlike BERT, which masks each token separately, one marker here hides several words, and the model does not even know how many.

OriginalNoisy
Text Infilling"The black cat sleeps""The [MASK] sleeps" (one [MASK] replaces "black cat")

Verdict: Very effective. The model must reconstruct multiple tokens, not just one.

4. Sentence Permutation

Shuffles the order of sentences (not tokens).

OriginalNoisy
Sentence Permutation"Cat sleeps. Owner reads.""Owner reads. Cat sleeps."

Verdict: Forces the model to understand inter-sentence coherence.

5. Document Rotation

Cuts the document at a random point and rotates it.

OriginalNoisy
Document Rotation"The cat sleeps on couch""on couch The cat sleeps"

Verdict: Forces an understanding of narrative flow.

The recipe they settled on

Having tested each strategy alone and then in combination, the paper adopts, for the large model:

  • Text infilling (the most effective) combined with sentence permutation;
  • 30% of the tokens in each document are masked. The threshold is a balance: too little corruption and the model learns almost nothing; too much and the text becomes unreadable, hence unrecoverable. BERT masked 15%, but with less aggressive corruption.
  • Masked span lengths are drawn from a Poisson distribution with mean 3 tokens. In plain terms: most holes hide two or three words, some a single one, a few many more. That variety is deliberate, a fixed-length hole would be a free hint.

Data: 160 GB of news, books, stories and web text, the same corpus as RoBERTa.

Why text infilling wins

Masking one token at a time is too easy: the model learns to swap a word for a word. Text infilling is hard, because the model has to decide how many words to produce and then produce them in the right order. That is a generation task, not a classification task, and harder training tasks yield better representations.

Strengths: excellent generation

Abstractive summarization (BART's flagship task)

This is where BART shines the most, particularly abstractive summarization, meaning the ability to rephrase a text in its own words, not simply extract sentences from it.

StepContent
Input (article)1,000 words about health policy
BART-large output4 coherent lines summarizing key points, with rephrasing
ROUGE score (Recall-Oriented Understudy for Gisting Evaluation)Best known result at publication

ROUGE measures how many of the word runs in the reference summary (the n-grams, groups of n consecutive words) turn up in the produced summary. That is recall: the share of the reference actually recovered. A crude measure, blind to a correct rephrasing, but automatic. Its cousin BLEU (Bilingual Evaluation Understudy), used in translation, measures the reverse quantity: the share of the produced text that appears in the reference.

Why is BART so strong at summarization? Because pre-training via text infilling is structurally identical to the summarization task. During pre-training, the model learns to understand a long incomplete text (encoder) then regenerate a coherent text (decoder). Summarization is exactly that: understand a long article, then produce a short, faithful version.

On the CNN/DailyMail and XSum benchmarks, BART set new records at its publication.

Question answering, generative style

Not extractive QA (locate the span of text containing the answer), but generative QA: build the answer in the model's own words from the text. The reference dataset for the extractive version is SQuAD (Stanford Question Answering Dataset).

Context: Article about insects

Question: "How do ants communicate?"

Answer to generate: "Ants exchange chemical pheromones..."

BART outperforms pure encoders because it must generate, not classify.

Translation: a creative architectural approach

BART was pre-trained on English. To translate into English, you must feed it a sentence in another language, which its encoder has never seen.

The paper's solution: keep BART as it is, and stack in front of it a new encoder, randomly initialized, trained on bitext (pairs of sentences that are translations of each other). Its job is not to understand the source sentence in the abstract, but to project it into a form BART knows how to denoise.

Source text (other language)⟶New learned encoder⟶"Noised" input for BART⟶BART (encoder + decoder)⟶English text\text{Source text (other language)} \longrightarrow \text{New learned encoder} \longrightarrow \text{"Noised" input for BART} \longrightarrow \text{BART (encoder + decoder)} \longrightarrow \text{English text}

In other words: present the foreign sentence to BART as if it were damaged English, and let it do what it was trained to do, repair it.

Generating or classifying: two different tools

BART is for producing new text: summarization, translation, rewriting. BERT is for classifying or extracting: sentiment, named entity recognition (NER), field extraction.

"BERT or BART?" always reduces to "what is the task?" Generating means BART. Classifying means BERT.

Fine-tuning BART: task-specific adaptation

Sequence to sequence (translation, summarization)

Seq2seq, for sequence to sequence: a text sequence in, a text sequence out. This is BART's natural use.

  1. Fine-tune on (source text, summary/translation target) pairs
  2. Train to predict the target given the source
  3. Inference: pass the source to encoder+decoder, generate

Natural. No tricks needed.

Classification (yes, it's possible!)

Fun fact: BART can also classify. How?

Text to classify→EncoderFull representation→DecoderClass as text (positive, neutral, negative)\text{Text to classify} \xrightarrow{\text{Encoder}} \text{Full representation} \xrightarrow{\text{Decoder}} \text{Class as text (positive, neutral, negative)}

But how do you use the output? Two approaches:

  1. By generation: let the decoder produce the word "positive", token by token, and read the first one.
  2. By vector: take the decoder's internal representation of its last token (its embedding) and pass it through a plain linear classification layer.

The second is more common: it exploits both the encoder's bidirectional reading and the overview the decoder has accumulated.

mBART: multilingual BART

mBART (Facebook, January 2020) extends BART to 25 languages.

An important point, often misreported: pre-training runs on monolingual corpora, ordinary text in each of the 25 languages, with no aligned translations. It is the same denoising as BART, applied to 25 languages at once. Parallel data only enters later, when the model is fine-tuned on a specific language pair.

Result:

  • solid translation scores, including for low-resource pairs where bitext is scarce;
  • cross-lingual transfer: what is learned in one language carries into another.
The encoder-decoder ecosystem, and what remains of it

At their peak, around 2020-2022, the landscape read like this: T5 for versatility, BART for summarization and generation, mBART and mT5 for multilingual work, GPT for raw flexibility.

By July 2026 that division has largely dissolved. Large instruction-tuned decoder-only models handle translation, summarization and extraction without anyone picking an architecture per task. Encoder-decoder is no longer the first reflex for a new system; encoder-only, by contrast, holds a solid place for understanding and search.

Comparison table

AspectBERT (encoder)GPT (decoder)BART (encoder-decoder)
AttentionBidirectionalCausalBidirectional then causal
StrengthComprehensionFree generationTargeted generation
OutputVectors or labelsFree textText guided by the input
Flagship taskClassificationDialogueSummarization, translation

Why this matters

BART demonstrates a fundamental principle: the nature of pre-training determines the model's strengths. By combining several ways of damaging text rather than one, BART yields a robust and versatile encoder-decoder. Text infilling trains precisely the ability to reconstruct meaning from fragments, which is exactly what summarization, translation and rewriting demand.

Where BART stands in July 2026

Let us be blunt: BART is no longer a starting choice for a new system. Between 2019 and the early 2020s it had a solid argument, a 400-million-parameter model that summarized better than much larger ones, because it had been pre-trained for exactly that. That argument has been erased by large instruction-tuned models, compact versions included, which summarize and translate at least as well without per-task fine-tuning.

What does survive from BART is solid and now everywhere: the nature of pre-training determines the model's strengths. If you want a model that reconstructs meaning from fragments, you train it to reconstruct meaning from fragments. That lesson still holds whenever you design a training objective today, and it is the main thing to carry away from this page.

Check your understanding0 / 4

1. What is BART's pre-training principle?

2. Why did text infilling beat BERT-style token masking?

3. What data is mBART pre-trained on?

4. Why did BART excel at summarization in particular?