Inferensys

Glossary

Fusion-in-Decoder (FiD)

Fusion-in-Decoder (FiD) is an encoder-decoder architecture for knowledge-intensive tasks that processes each retrieved document passage independently in the encoder and performs joint reasoning over all passages in the decoder through cross-attention.
Knowledge engineer constructing knowledge base on laptop, document hierarchy visible, casual office setup.
RETRIEVAL ARCHITECTURE

What is Fusion-in-Decoder (FiD)?

Fusion-in-Decoder is an encoder-decoder architecture for knowledge-intensive tasks that processes each retrieved document passage independently in the encoder and performs joint reasoning over all passages in the decoder through cross-attention.

Fusion-in-Decoder (FiD) is a Transformer architecture designed for open-domain question answering that scales efficiently to large retrieval sets. Unlike traditional RAG approaches that concatenate all retrieved passages into a single prompt, FiD encodes each passage independently in the encoder, then fuses the resulting representations in the decoder via cross-attention, allowing the model to reason jointly over hundreds of documents without quadratic complexity blowup in the encoder.

The architecture exploits the asymmetry between encoding and decoding costs: the encoder processes each passage in isolation, making its cost linear with respect to the number of retrieved documents, while the decoder attends to all encoded passages simultaneously. This design enables FiD to leverage significantly more retrieved context than concatenation-based methods, improving factual grounding on knowledge-intensive benchmarks like Natural Questions and TriviaQA while maintaining computational tractability.

Fusion-in-Decoder (FiD)

Key Architectural Features

The core architectural innovations that enable Fusion-in-Decoder to perform joint reasoning over hundreds of retrieved passages without quadratic complexity blowup.

01

Independent Passage Encoding

Each retrieved document passage is processed independently through the encoder, producing a set of hidden representations for every passage. This avoids the quadratic complexity of concatenating all passages into a single input sequence. The encoder uses a standard T5 architecture and processes passages in parallel, scaling linearly with the number of retrieved documents.

  • Encoder input: question: token followed by passage tokens
  • Each passage produces its own set of encoder hidden states
  • Passages do not attend to each other during encoding
  • Enables scaling to 100+ retrieved passages efficiently
02

Joint Cross-Attention Decoder

The decoder performs cross-attention over the concatenated hidden states from all encoded passages simultaneously. This is the 'fusion' step—the decoder can attend to tokens across all retrieved documents when generating each output token, enabling it to synthesize evidence from multiple sources.

  • Decoder cross-attention spans the union of all passage representations
  • Enables multi-hop reasoning across disparate documents
  • No passage-level bottleneck; all evidence is accessible at every generation step
  • Contrasts with extract-then-read pipelines that isolate passages
03

Linear Scaling with Retrieval Depth

FiD's computational cost scales linearly with the number of retrieved passages (O(n)) rather than quadratically (O(n²)). This is because self-attention is confined to individual passages in the encoder, while the decoder's cross-attention cost grows linearly with the total token count across all passages.

  • Encoder self-attention: bounded by passage length, not corpus size
  • Decoder cross-attention: O(total_tokens) across all passages
  • Practical for n=100 passages at standard sequence lengths
  • Enables retrieval-augmented generation at scale without prohibitive compute
04

Sequence-to-Sequence Foundation

FiD is built on the T5 (Text-to-Text Transfer Transformer) encoder-decoder architecture. The text-to-text framing means both the input (question + passages) and output (answer) are treated as text strings, enabling a unified training objective: maximum likelihood estimation over the target answer tokens.

  • Initialized from pre-trained T5 weights (e.g., T5-base, T5-large)
  • Fine-tuned on knowledge-intensive tasks like open-domain QA
  • Output is generated autoregressively, token by token
  • Leverages T5's strong transfer learning capabilities
05

Evidence Aggregation Without Extraction

Unlike extractive QA systems that must first identify a single answer span within a specific passage, FiD performs abstractive generation by fusing information from all passages in the decoder. This allows the model to synthesize answers that are not verbatim present in any single retrieved document.

  • Generates answers that may combine facts from multiple passages
  • Handles conflicting evidence through learned weighting in cross-attention
  • No hard commitment to a single source passage
  • Produces more coherent, natural-language answers than extractive methods
06

Training with Retrieved Evidence

FiD is trained end-to-end using supervised learning on question-answer pairs where the input includes retrieved passages from a dense retriever (typically DPR). The model learns to ignore irrelevant passages and focus cross-attention on evidence-bearing tokens, developing robustness to retrieval noise.

  • Training data: (question, retrieved_passages, ground_truth_answer) triples
  • Retriever is typically frozen; FiD learns to leverage its outputs
  • Loss: standard cross-entropy over generated answer tokens
  • Naturally handles distractor passages without explicit noise modeling
ARCHITECTURAL COMPARISON

FiD vs. Alternative Retrieval-Augmented Architectures

A technical comparison of Fusion-in-Decoder against other dominant paradigms for integrating retrieved documents into language model generation, evaluated across key architectural and performance dimensions.

FeatureFusion-in-Decoder (FiD)Retrieval-Augmented Generation (RAG)REALM / DPR + Reader

Fusion Point

Decoder cross-attention over all passages jointly

Prompt concatenation before encoder input

Separate reader model processes single passage

Encoder Processing

Each passage encoded independently in parallel

All passages concatenated and encoded together

Single passage encoded per forward pass

Cross-Passage Reasoning

Computational Complexity

O(N) encoding, O(N^2) decoding attention

O(N^2) self-attention over full concatenated input

O(N) linear scaling with passage count

Scalability to Many Passages

Scales to 100 passages efficiently

Limited by context window and quadratic attention

Requires iterative re-ranking or top-1 selection

Evidence Aggregation

Joint reasoning over all retrieved evidence

Implicit aggregation via self-attention

No aggregation; single passage per prediction

Typical Use Case

Open-domain QA with multiple supporting documents

General-purpose grounded generation

Factoid QA with single-answer extraction

Hallucination Mitigation

Strong; decoder attends to all evidence simultaneously

Moderate; prone to lost-in-the-middle effects

Weak; no cross-document verification

PRODUCTION DEPLOYMENTS

Real-World Applications of FiD

Fusion-in-Decoder (FiD) moves beyond academic benchmarks to power production systems that require synthesizing answers from massive, heterogeneous document collections. These applications leverage FiD's core strength: processing hundreds of passages independently before fusing them into a single, coherent response.

01

Open-Domain Question Answering

FiD is the foundational architecture for answering complex, fact-seeking queries against a corpus of millions of documents, such as Wikipedia.

  • Mechanism: A retriever fetches 100+ relevant passages; the encoder processes each independently; the decoder performs cross-attention over all passages simultaneously to generate a single answer.
  • Example: Answering "What is the primary function of the ribosome in a eukaryotic cell?" requires synthesizing evidence from multiple biology articles.
  • Key Advantage: Unlike RAG, which prepends text to the prompt, FiD allows the decoder to jointly reason over all evidence, mitigating the Lost-in-the-Middle problem.
100+
Passages Processed
02

Multi-Document Summarization

FiD excels at generating a concise, fluent summary from a large collection of documents on a single topic, such as news articles or financial reports.

  • Workflow: The encoder processes each document chunk independently, and the decoder generates a summary that aggregates key points, resolves contradictions, and eliminates redundancy.
  • Enterprise Use Case: Automatically generating an executive briefing from a day's worth of market reports, press releases, and analyst notes.
  • Technical Benefit: The encoder-decoder structure provides more generative control than extractive methods, producing abstractive summaries that are more coherent.
10k+
Source Documents
03

Conversational AI with Grounding

FiD powers chatbots that must answer user questions by grounding every claim in a specific, retrievable document from a knowledge base.

  • Architecture: User query and dialogue history are used to retrieve relevant support articles. FiD fuses these articles to generate a response with citation integrity.
  • Example: A customer support bot for a software company that answers technical questions by synthesizing steps from multiple documentation pages.
  • Why FiD: It reduces hallucination by forcing the decoder to attend to all provided evidence, making it ideal for regulated industries like finance and healthcare.
99.9%
Grounded Responses
04

Fact Verification & Claim Checking

FiD is used to verify the truthfulness of a claim by aggregating evidence from a corpus of trusted sources and generating a verdict.

  • Process: A claim is input, a retriever finds supporting and refuting evidence, and FiD's decoder generates a label (e.g., SUPPORTS, REFUTES, NOT ENOUGH INFO) along with a rationale.
  • Application: Automated fact-checking pipelines for newsrooms or social media platforms to combat misinformation at scale.
  • Architectural Fit: The model's ability to weigh conflicting evidence from multiple passages in the decoder is critical for nuanced verdicts.
FEVER
Benchmark Dataset
05

Clinical Evidence Synthesis

In biomedicine, FiD synthesizes answers to clinical questions from a corpus of research abstracts and trial reports, such as PubMed.

  • Task: Given a PICO (Population, Intervention, Comparison, Outcome) query, retrieve relevant studies and generate a summary of clinical efficacy.
  • Impact: Dramatically reduces the time clinicians spend on systematic literature reviews by providing an initial, evidence-grounded synthesis.
  • Domain Adaptation: FiD models are often fine-tuned on biomedical corpora to handle specialized terminology and complex entity relationships.
30M+
PubMed Abstracts
06

Legal Document Analysis

FiD processes large volumes of case law and contracts to answer complex legal questions that require reasoning over multiple precedents.

  • Mechanism: A query about a legal principle retrieves hundreds of relevant case snippets. FiD's decoder performs joint reasoning to identify the controlling precedent and generate a synthesized answer.
  • Use Case: A legal research tool that answers "Under what circumstances is a liquidated damages clause considered an unenforceable penalty?" by analyzing dozens of cases.
  • Key Requirement: The architecture's ability to handle long-range dependencies across documents is essential for tracing legal reasoning chains.
100+
Cases Analyzed
FUSION-IN-DECODER

Frequently Asked Questions

Explore the architectural mechanics and practical implications of Fusion-in-Decoder, a powerful encoder-decoder paradigm designed to scale knowledge-intensive language tasks by processing hundreds of retrieved passages independently before fusing them in the decoder.

Fusion-in-Decoder (FiD) is an encoder-decoder architecture for knowledge-intensive NLP tasks that processes each retrieved document passage independently in the encoder and performs joint reasoning over all passages in the decoder through cross-attention. Unlike traditional Retrieval-Augmented Generation (RAG) models that concatenate all retrieved documents into a single long prompt, FiD encodes every passage separately. This isolates the self-attention computation to within each passage, reducing the quadratic complexity penalty of processing long concatenated sequences. The decoder then attends to the concatenated representations of all encoded passages simultaneously, allowing the model to aggregate evidence scattered across multiple sources to generate a single, coherent answer. This design enables FiD to scale to processing hundreds of knowledge source passages, such as 100 Wikipedia paragraphs, without exceeding typical GPU memory limits during encoding.

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.