BERAG: Bayesian Ensemble Retrieval-Augmented Generation for Knowledge-based Visual Question Answering

Jinghong Chen, Jingbiao Mei, Guangyu Yang, Bill ByrnearXiv 2026

TL;DR

Standard Retrieval-Augmented Generation (RAG) struggles with long contexts, often losing information in the middle of a document dump and scaling poorly due to quadratic attention costs. This paper introduces BERAG (Bayesian Ensemble RAG) and BEFT (Bayesian Ensemble Fine-Tuning), a framework that processes retrieved documents independently in parallel and aggregates their contributions token-by-token using Bayes' rule. This approach completely eliminates the "lost-in-the-middle" effect, provides clear document attribution, and enables faster decoding via dynamic document pruning.

What Problem Does This Paper Address?

Most modern RAG systems use a "concatenative" approach (ConcatRAG): they take the top-$K$ retrieved documents, paste them sequentially into a single massive prompt, and feed it to a Large Language Model (LLM).

While simple, ConcatRAG has three major flaws:

  1. Poor Scaling: Attention mechanisms scale quadratically with context length. This becomes a massive bottleneck in Knowledge-Based Visual Question Answering (KB-VQA), where processing multiple images or visually rich documents rapidly exhausts GPU memory.
  2. The "Lost-in-the-Middle" Effect: LLMs are notoriously bad at recalling information buried in the middle of a long context window.
  3. Opaque Attribution: Fusing all documents into one context makes it incredibly difficult to quantify exactly which document contributed to the generated answer.

The authors tackle these challenges by shifting from a concatenative paradigm back to an ensemble-based paradigm, but with a novel Bayesian twist.

Methods

Instead of feeding all documents to the model at once, BERAG maintains $K$ independent parallel branches of next-token likelihood computations, each conditioned on a single document.

The core mechanics include:

  • Token-Level Bayesian Ensembling: Next-token probabilities are calculated by marginalizing over individual documents. The ensemble weights (document posteriors) are updated recursively at every single token step using Bayes' rule based on how well a document explains the history generated so far.
  • Bayesian Ensemble Fine-Tuning (BEFT): An end-to-end training method that optimizes the model using a weighted maximal likelihood objective, training the model to dynamically shift focus to the most relevant document during generation.
  • Top-P Document Pruning: To accelerate inference, low-probability documents are dynamically dropped during decoding once their cumulative posterior mass falls below a threshold ($1 - \frac{1}{2K}$).
  • Explainable Deflection: By introducing an empty "null" document ($z_0$) during training, the model learns to assign a high posterior to $z_0$ if the true answer isn't in the retrieved set, triggering a clean "deflection" (refusal to answer) rather than a hallucination.

Datasets

The framework was evaluated across several challenging knowledge-based and multimodal benchmarks:

  • Encyclopedia-VQA (E-VQA): A fine-grained visual question answering dataset based on Wikipedia.
  • Infoseek: A large-scale dataset requiring integration of visual data and extensive web-scale knowledge.
  • SlideVQA: A multi-modal document dataset consisting of 20-slide presentations requiring multi-slide synthesis and numerical reasoning.
  • MMNeedle (Multimodal Needle-in-a-Haystack): A benchmark testing a model's ability to find a specific sub-image panel hidden inside a larger grid of images.

Key Insights and Ideas

  • Immunity to Document Ordering: Because documents are processed in parallel branches, BERAG is mathematically invariant to the order in which documents are fed into the system. This completely resolves the "lost-in-the-middle" problem.
Figure 1: VQA scores with different ground-truth docu- ment (GT doc) position in the retrieval list, evaluated on the same set of 256 randomly sampled E-VQA questions for which the GT doc is in the Top-20 list of PreFLMR- L retrieval. GT@1-4 indicates that the GT doc is moved to the Top-4 via swapping if needed, and vice versa. The BEFT model (red) is unaffected by document ordering.
  • Dynamic Focusing: The token-level update allows the model to shift its attention fluidly. For instance, it might rely on Document A to generate the first half of a sentence and seamlessly transition to Document B for the rest.
  • Constant-Time Decoding Complexity: Thanks to Top-P pruning, the decoding time becomes virtually independent of $K$. Once the model identifies the relevant documents in the first few tokens, it discards the rest, making deep retrieval ($K=50$) highly practical.

Key Results

The authors paired their method with the Qwen2-VL-7B-Instruct model and achieved state-of-the-art results:

  • Superior VQA Accuracy: On E-VQA, BEFT achieved a top score of 70.3 BEM, significantly outperforming standard Supervised Fine-Tuning (61.5) and Direct Preference Optimization (64.1) baselines. On Infoseek, it achieved 42.8 EM, outperforming recent specialized reranking systems like EchoSight.
E-VQA performance scaling up to K=50 documents.
  • SlideVQA Breakthroughs: BEFT achieved 90.4% Evidence Selection Accuracy and 69.6% QA Exact Match, representing a massive +15.4% and +6.4% gain over previous state-of-the-art methods.
  • Massive Speedups: At $K=50$ on E-VQA, standard ConcatRAG slowed down drastically to 203.0 ms/token. BERAG with Top-P pruning maintained a blazing 44.4 ms/token—a 4.5x speedup—without sacrificing generation quality.

Limitations and Future Work

Despite its strong performance, the authors note a few key limitations:

  1. The Singleton Assumption: BERAG marginalizes over individual documents. While it can synthesize information across documents sequentially, it cannot explicitly model interactions or combinations of documents simultaneously (i.e., marginalizing over the powerset of contexts).
  2. Not Training-Free: Standard LLMs are pre-trained on concatenated text and do not natively know how to merge token-level probabilities. Consequently, BERAG requires downstream fine-tuning (BEFT) to perform well.
  3. Prefill Overhead: Currently, the shared multi-modal query context is encoded multiple times across the parallel branches. Future engineering work is required to optimize the prefill stage and avoid redundant computations in deployment.

Summary updated

BibTeX
@misc{chen2026berag,
  author = {Jinghong Chen and Jingbiao Mei and Guangyu Yang and Bill Byrne},
  title = {{BERAG: Bayesian Ensemble Retrieval-Augmented Generation for Knowledge-based Visual Question Answering}},
  year = {2026},
  eprint = {2604.22678},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2604.22678},
}
Figure