ACER: Automatic Language Model Context Extension via Retrieval

Luyu Gao, Yunyi Zhang, Jamie Callan · Submission to ICLR 2025 · Rejected

TL;DR

Current open-weight long-context language models struggle with practical tasks like reading comprehension and retrieval-augmented generation (RAG) because high-quality, long-context human data is scarce. ACER (Automatic Context Extension via Retrieval) overcomes this by using a short-context model to rank text chunks and synthesize chain-of-thought answers, and then fine-tuning a long-context model directly on the full context paired with these synthetic answers. Surprisingly, the fine-tuned model bootstraps beyond its synthetic supervisor, outperforming both generalist open-weight models and the heuristic retrieval pipeline used to create the training data.

What Problem Does This Paper Address?

Modern Large Language Models (LLMs) are typically given long-context capabilities via an unsupervised context extension stage followed by post-training. However, open-weight generalist models frequently stumble on practical long-context tasks, such as multi-document RAG.

The core bottleneck is data scarcity: humans rarely produce massive, coherent texts that mirror real-world multi-document reasoning tasks, making natural training data rare and human annotation prohibitively expensive. As a result, relying purely on unsupervised continuation or standard instruction tuning leaves models ill-equipped to filter and synthesize information scattered across tens of thousands of tokens.

Methods

ACER introduces an automated, two-stage framework that bootstraps long-context abilities without human annotation:

[Full Long Context] ---> [Chunk & Rank via Short-Context LM] 
                             |
                             v
                     [Top-M Chunks] ---> [Short-Context CoT Generator] 
                                                  |
                                                  v
[Full Long Context] + [Synthesized CoT Answer] ---> [Fine-Tune Long-Context LM]
  1. Automatic Data Synthesis (Map-Reduce Style):
  2. Relevance Ranking: Unlabeled long contexts (e.g., 100 retrieved Wikipedia passages or full books) are sliced into chunks. A standard short-context instruction model (Llama-3-8B-Instruct) scores and ranks the chunks based on their relevance to a target question.
  3. CoT Generation: The top $M$ ranked chunks that fit into the short-context window are fed back to the generator. Prompted to generate a step-by-step Chain-of-Thought (CoT), the model identifies relevant evidence and writes an answer.
  4. Lossless Long-Context Fine-Tuning:
  5. The intermediate retrieval ranking is discarded. An unsupervised context-extended model (Llama-3-8B-ProLong-Base) is fine-tuned on the entire unfiltered context paired with the question and the synthesized CoT answer.
  6. Fine-tuning uses standard teacher-forcing log-likelihood loss applied exclusively to the answer tokens (masking out context tokens) across sequences up to 32k–64k tokens using 3D parallelism on Cloud TPUv4 hardware.

Datasets

The authors evaluated ACER across two core long-context task setups:

  • Long-Context RAG: Natural Questions (NQ) and TriviaQA (TQA), where the context consists of 100 retrieved Wikipedia passages (evaluated using Exact Match, EM). Both dense retrieval (BGE) and sparse retrieval (BM25) settings were evaluated.
  • Long-Context Reading Comprehension: NarrativeQA (from the LongBench benchmark), evaluating understanding over entire books (measured by token-level F1).

Key Insights and Ideas

  • Bootstrapping Beyond Imperfect Supervision: ACER does not merely memorize the retrieval pipeline; it transcends it. When evaluated on test sets, ACER outperforms the test-time retrieval-and-read pipeline (Llama3-8B-Instruct (RAG)) that generated its training data.
  • Overcoming Long-Context Decay: When tested across increasing context lengths (from 5 to 100 passages), baseline generalist models like Llama-3.1-8B-Instruct degrade in accuracy as input size grows. In contrast, ACER steadily improves, showing it successfully learns to digest additional information rather than being distracted by noise.
  • Model Size $\neq$ Long-Context Task Fitness: The 12B parameter Mistral-Nemo was outperformed by the 8B ACER model across RAG tasks and NarrativeQA, illustrating that targeted task-adaptation is more critical than raw parameter scale for long contexts.
  • Retriever Agnostic: Training with an unsupervised BM25 retriever instead of a dense retriever yielded a model that still outperformed baseline models using dense retrieval.

Key Results

Setting / Model NQ (EM) TQA (EM) NarrativeQA (F1)
Supervised Open Data: Llama-3-8B-ProLong-512k-Instruct 0.260 0.457 0.150
Supervised Closed Data: Llama3-8B-Instruct (RAG heuristic) 0.408 0.611 0.161
Supervised Closed Data: Llama3.1-8B-Instruct 0.312 0.518 0.217
Supervised Closed Data: Mistral-Nemo-Instruct-2407 (12B) 0.365 0.534 0.072
Self-Supervised: ACER (Ours) 0.446 0.648 0.189
  • On Natural Questions and TriviaQA, ACER achieved 0.446 and 0.648 EM, exceeding native Llama-3.1-8B-Instruct (0.312 / 0.518) and the heuristic RAG baseline (0.408 / 0.611).
  • Under the weaker BM25 retrieval setup, ACER retained strong performance (0.383 on NQ and 0.632 on TQA), matching or surpassing baselines evaluated with dense retrieval.

Limitations and Future Work

  • Reliance on Base Synthesizer Heuristics: The data synthesis quality is constrained by the short-context model’s capability to rank chunks accurately and reason over multiple passages.
  • Task Scope: Experiments primarily focused on question answering and long-context RAG up to 64k tokens; evaluation did not include synthetic stress tests (such as Needle-in-a-Haystack or RULER) or complex multi-hop agent tasks.
  • Future Directions: Developing more sophisticated iterative data generation pipelines and exploring alternative synthesis paths for broader long-context reasoning tasks.

Summary updated

Abstract

Long-context modeling is one of the critical capabilities of language AI for digesting and reasoning over complex information pieces. In practice, long-context capabilities are typically built into a pre-trained language model (LM) through a carefully designed context extension stage, with the goal of producing generalist long-context capabilities. In our preliminary experiments, however, we discovered that the current open-weight generalist long-context models are still lacking in practical long-context processing tasks. While this means perfectly effective long-context modeling demands task-specific data, the cost can be prohibitive. In this paper, we draw inspiration from how humans process a large body of information: a lossy retrieval stage ranks a large set of documents while the reader ends up reading deeply only the top candidates. We build an automatic data synthesis pipeline that mimics this process using short-context LMs. The short-context LMs are further tuned using these self-generated data to obtain task-specific long-context capabilities. Similar to how pre-training learns from imperfect data, we hypothesize and further demonstrate that the short-context model can bootstrap over the synthetic data, outperforming not only long-context generalist models but also the retrieval and read pipeline used to synthesize the training data.
BibTeX
@misc{gao2024acer,
  author = {Luyu Gao and Yunyi Zhang and Jamie Callan},
  title = {{ACER: Automatic Language Model Context Extension via Retrieval}},
  year = {2024},
  eprint = {2410.09141},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2410.09141},
}

Loading related content...

Figure