Toward Verifiable Instruction-Following Alignment for Retrieval Augmented Generation

Guanting Dong, Xiaoshuai Song, Yutao Zhu, Runqi Qiao, Zhicheng Dou, Ji-Rong Wen

Abstract

Following natural instructions is crucial for the effective application of Retrieval-Augmented Generation (RAG) systems. Despite recent advancements in Large Language Models (LLMs), research on assessing and improving instruction-following (IF) alignment within the RAG domain remains limited. To address this issue, we propose VIF-RAG, an automated, scalable, and verifiable synthetic pipeline for instruction-following alignment in RAG systems. We start by manually crafting a minimal set of atomic instructions (<100) and developing combination rules to synthesize and verify complex instructions for a seed set. We then use supervised models for instruction rewriting while simultaneously generating code to automate the verification of instruction quality via a Python executor. Finally, we integrate these instructions with extensive RAG and general samples, scaling up to a high-quality VIF-RAG-QA dataset (>100k) through automated processes. To further bridge the gap in instruction-following auto-evaluation for RAG systems, we introduce FollowRAG Benchmark, which includes approximately 3K test samples, covering 22 categories of general instruction constraints and four knowledge-intensive QA datasets. Due to its robust pipeline design, FollowRAG can seamlessly integrate with different RAG benchmarks. Using FollowRAG and eight widely-used IF and foundational abilities benchmarks for LLMs, we demonstrate that VIF-RAG markedly enhances LLM performance across a broad range of general instruction constraints while effectively leveraging its capabilities in RAG scenarios. Further analysis offers practical insights for achieving IF alignment in RAG systems.

Introduction

Large Language Models (LLMs) have demonstrated remarkable proficiency in following complex instructions in standard conversational settings. However, their performance often degrades when integrated into Retrieval-Augmented Generation (RAG) pipelines. The introduction of external documents acts as a distractor, causing models to prioritize information retrieval over adherence to stylistic, formatting, or lexical constraints. Existing instruction-following (IF) datasets focus primarily on standard chat scenarios, leaving a significant gap in training and evaluating models that must simultaneously process retrieved documents and strictly adhere to complex user instructions.

Instruction-following failure in RAG scenarios.

The VIF-RAG Methodology

To address the alignment gap in RAG systems, we propose VIF-RAG, an automated and scalable data synthesis pipeline. The pipeline generates over 100,000 high-quality training samples starting from a minimal set of fewer than 100 manually written atomic instructions.

Instruction Synthesis and Composition

The process begins by programmatically combining atomic instructions (covering format, semantic, and lexical constraints) into complex, multi-constraint tasks using specific combination rules. This ensures the model is exposed to a wide variety of instruction types, from simple formatting to chained logical rules.

Code-Based Verification

A key innovation of VIF-RAG is the use of code-based verification to ensure data quality at scale. We utilize a powerful LLM (GPT-4-turbo) to rewrite instructions and simultaneously generate Python verification scripts. These scripts act as unit tests for the generated responses; if a response fails to meet the specific constraints (e.g., word count, specific character inclusion, or JSON formatting), the sample is discarded. This approach removes the ambiguity often found in "LLM-as-a-judge" evaluation methods.

The VIF-RAG data synthesis and verification pipeline.

Dual-Stage Verification and Integration

Verified instructions are paired with real-world queries from both RAG datasets (such as Natural Questions) and general chat datasets (such as ShareGPT). The final instruction-query-response triplets undergo a second round of Python execution checks and an LLM-based consistency check to filter out conflicting prompts, ensuring the final dataset is both challenging and logically sound.

Datasets and Benchmarking

We introduce two primary resources for the community:

  • VIF-RAG-QA: A training set of over 100,000 high-quality, instruction-constrained samples.
  • FollowRAG Benchmark: A novel evaluation suite containing approximately 2,800 test samples. It covers 22 constraint categories across four knowledge-intensive QA datasets: Natural Questions (NQ), TriviaQA (TQA), HotpotQA (HQA), and WebQuestionsSP (WebQSP).

Key Results and Insights

Our evaluation across models like Mistral-7B, Qwen1.5, and Llama3-8B reveals several critical findings:

  1. Alignment Gap: Fine-tuning models on standard IF datasets does not necessarily transfer to RAG scenarios. In fact, standard IF training can sometimes decrease a model's ability to follow instructions when retrieved documents are present.
  2. Performance Gains: VIF-RAG consistently improves average instruction-following accuracy by over 10%. For Llama3-8B-base, the improvement reached 44%.
  3. Distraction Resistance: As the number of retrieved passages increases, baseline models typically experience a sharp decline in instruction adherence. VIF-RAG models remain highly stable, demonstrating they have learned to isolate instructions from the noise of the context.
  4. Zero Foundational Degradation: By including general chat data during synthesis, VIF-RAG avoids the "alignment tax," preserving or slightly improving scores on foundational benchmarks like MMLU, GSM8K, and HumanEval.

Conclusion

VIF-RAG provides a scalable, verifiable path toward better natural instruction alignment in production RAG systems. By leveraging automated code verification, we can generate high-quality data that teaches models to respect user constraints even when processing large volumes of external information. Future work will explore scaling this approach to even larger model architectures.

Summary updated

BibTeX
@inproceedings{dong2025toward,
  author = {Guanting Dong and Xiaoshuai Song and Yutao Zhu and Runqi Qiao and Zhicheng Dou and Ji-Rong Wen},
  title = {{Toward Verifiable Instruction-Following Alignment for Retrieval Augmented Generation}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2025},
  url = {https://openreview.net/forum?id=58frzUh0S5},
}
Figure