Inferensys

Glossary

Fusion-in-Decoder (FiD)

An architecture that processes multiple retrieved passages independently in the encoder and performs joint attention over the concatenated representations in the decoder to fuse evidence for generation.
Developer demonstrating multi-agent tool use, agent tool selection interface on laptop, casual tech demo moment.

What is Fusion-in-Decoder (FiD)?

Fusion-in-Decoder is a retrieval-augmented generation architecture that processes multiple retrieved passages independently in the encoder and performs joint attention over their concatenated representations solely in the decoder to fuse evidence for answer generation.

Fusion-in-Decoder (FiD) is a transformer architecture where the encoder processes each retrieved passage in isolation, and the decoder performs cross-attention over the concatenated hidden representations of all passages simultaneously. This design allows the model to scale to large numbers of retrieved documents without quadratic encoder complexity, fusing evidence only at the generation stage.

By decoupling the encoding of individual passages from their fusion, FiD enables the model to reason over hundreds of knowledge sources while keeping memory requirements linear. The decoder synthesizes a single coherent answer by jointly attending to all encoded passages, effectively performing multi-hop reasoning across disparate evidence without explicit query decomposition.

FUSION-IN-DECODER (FiD)

Key Architectural Properties

Fusion-in-Decoder is a transformer architecture that processes multiple retrieved passages independently in the encoder and performs joint attention over the concatenated representations in the decoder. This design enables the model to reason over a large set of evidence documents while keeping encoder computation linear with respect to passage count.

01

Independent Encoder Processing

Each retrieved passage is encoded separately and in parallel by the encoder, without cross-attention between passages. This means:

  • Linear scaling: Processing 100 passages costs O(n) rather than O(n²) in the encoder
  • No token limit bottleneck: Each passage can use the full encoder context window independently
  • Trivial batching: Passages are processed as independent items in a batch, maximizing GPU utilization

The encoder outputs a set of hidden representations for each passage, which are then concatenated into a single sequence for the decoder.

O(n)
Encoder Complexity
100+
Passages Processed
02

Joint Decoder Attention

The decoder performs cross-attention over the concatenated representations of all passages simultaneously. This fusion mechanism:

  • Allows the model to compare and contrast evidence from different sources
  • Enables evidence synthesis where facts from multiple documents are combined into a single answer
  • Preserves the ability to attribute generated text to specific passages through attention weight analysis

The decoder sees all evidence at once, unlike retrieve-and-read architectures that process passages sequentially or truncate to fit a single context window.

Full
Cross-Attention Scope
03

Scalability Advantage

FiD's architectural separation of encoding and fusion provides a fundamental scalability advantage over long-context approaches:

  • Encoder: Scales linearly with passage count, enabling retrieval of hundreds of documents
  • Decoder: Scales quadratically with total concatenated length, but this is manageable because only the decoder pays the O(n²) cost
  • Memory efficiency: Encoder activations can be computed once and cached, then reused across multiple decoding steps

This makes FiD particularly effective for open-domain question answering where the retriever returns dozens or hundreds of candidate passages.

O(n)
Encoder Scaling
O(n²)
Decoder Scaling
04

Training Methodology

FiD models are trained with a supervised sequence-to-sequence objective where:

  • The input is a set of retrieved passages concatenated with the question
  • The target is the ground-truth answer string
  • Teacher forcing is used during training, with the decoder attending to all encoded passages
  • The retriever and reader can be trained jointly or separately depending on the implementation

Key training considerations include passage sampling strategy (how many passages, which ones) and negative example construction to teach the model to ignore irrelevant retrieved content.

05

Comparison to Alternative Architectures

FiD occupies a distinct position in the RAG architecture landscape:

  • vs. Long-Context Models: FiD avoids the O(n²) encoder cost of processing all passages as one long sequence
  • vs. Retrieve-and-Read: FiD fuses evidence in the decoder rather than concatenating before encoding, preserving per-passage independence
  • vs. Map-Reduce: FiD performs joint reasoning rather than independent summarization followed by aggregation
  • vs. Iterative Retrieval: FiD processes all passages in one forward pass rather than sequentially refining retrieval

The trade-off is that FiD requires a fixed retrieval set before generation begins, limiting dynamic retrieval during decoding.

06

Attention Attribution and Interpretability

Because the decoder attends to all encoded passages jointly, FiD provides natural interpretability through attention analysis:

  • Passage-level attribution: Aggregate attention weights reveal which passages most influenced each generated token
  • Cross-passage dependencies: Attention patterns show how the model connects information across documents
  • Evidence provenance: Generated claims can be traced back to specific source passages for verification

This transparency is valuable for factual grounding and hallucination detection in production RAG systems, as it provides a built-in mechanism for citation generation.

ENCODER-DECODER FUSION COMPARISON

FiD vs. Alternative Fusion Strategies

Architectural comparison of Fusion-in-Decoder against early fusion and late fusion strategies for multi-document question answering.

FeatureFusion-in-Decoder (FiD)Early Fusion (Concatenation)Late Fusion (Score Aggregation)

Fusion Point

Decoder cross-attention layer

Encoder input layer

Post-encoding output layer

Encoder Processing

Independent per-passage

Single concatenated sequence

Independent per-passage

Cross-Passage Attention

Quadratic Complexity in Passage Count

Max Passages (T5-770M)

100 passages

~10 passages (truncated)

Unlimited (post-hoc)

Evidence Aggregation Granularity

Token-level in decoder

Token-level in encoder

Document-level scores

NaturalQA Exact Match

51.4%

44.1%

46.8%

Memory Footprint Scaling

Linear in passage count

Quadratic in total tokens

Linear in passage count

FUSION-IN-DECODER

Frequently Asked Questions

Core questions about the Fusion-in-Decoder architecture, its mechanisms, and its role in multi-hop retrieval-augmented generation.

Fusion-in-Decoder (FiD) is a retrieval-augmented generation architecture that processes multiple retrieved text passages independently in the encoder and fuses their representations through joint cross-attention in the decoder. The encoder processes each passage in isolation, producing a set of hidden states. These states are then concatenated into a single, large sequence that the decoder attends to jointly. This design allows the decoder to draw evidence from any passage when generating each token, effectively performing evidence fusion at the generation stage rather than during encoding. The key insight is that scaling to hundreds of retrieved passages becomes computationally tractable because the encoder's quadratic self-attention cost is linear in the number of passages—each passage is encoded separately—while the decoder's cross-attention cost scales linearly with the total concatenated length.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.