Abstract
Retrieval-Augmented Generation (RAG) is a powerful technique for grounding Large Language Models (LLMs) in external knowledge. However, its effectiveness often diminishes in specialized domains like medicine or computer science due to significant distribution shifts and the scarcity of high-quality labeled data. We present SimRAG, a self-improving framework that enables LLMs to adapt to specialized domains by bootstrapping their own training data from unlabeled text. By training a model to both answer and generate questions, and employing a "round-trip consistency" filter, SimRAG achieves performance gains of up to 8.6% over existing baselines without requiring expensive proprietary models for data generation.
Introduction
While LLMs excel in general knowledge tasks, specialized domains present a unique challenge. Technical jargon and complex reasoning patterns often fall outside the model's initial training distribution. The standard solution—fine-tuning on domain-specific question-answering (QA) pairs—is frequently hindered by the extreme scarcity of expert-labeled data. Current state-of-the-art methods often rely on powerful "teacher" models like GPT-4 to generate synthetic data, which introduces high costs, privacy risks, and potential quality control issues. SimRAG addresses these challenges by asking: Can a model become its own teacher using only the unlabeled text available in a specific domain?
Methodology
SimRAG introduces a two-stage fine-tuning process that transforms a standard LLM into a self-improving system capable of domain adaptation.
Stage I: Retrieval-Oriented Fine-Tuning
The backbone model (e.g., Llama-3 or Gemma-2) is first trained on general-domain data for three core tasks: instruction following, context-aware QA, and question generation (QG). This dual-task capability is essential, as it allows the model to understand the relationship between a query and its supporting evidence from both directions.
Stage II: Domain-Adaptive Fine-Tuning with Self-Training
In the second stage, the model specializes itself using an unlabeled domain corpus (e.g., PubMed articles):
- Synthetic Data Generation: The model generates candidate answers and corresponding questions from the unlabeled text.
- Round-Trip Consistency Filtering: To ensure data quality, SimRAG employs a retrieval-based check. A retriever is used to see if the generated question can successfully retrieve the original source document. If the ground-truth answer is present in the top-retrieved results, the QA pair is retained; otherwise, it is discarded to prevent the inclusion of hallucinations.
- Continuous Fine-Tuning: The model is then fine-tuned on this filtered, high-quality synthetic data.
Experimental Setup
SimRAG was evaluated across 11 datasets in three domains:
- Medical: PubMedQA, BioASQ, MedQA, MedMCQA, MMLU-med, LiveQA, and MedicationQA.
- Scientific: MMLU-sci, ARC-challenge, and SciQ.
- Computer Science: CS-Bench.
Unlabeled corpora for self-training included medical textbooks, PubMed, Wikipedia CS subsets, and arXiv articles.
Key Results and Discussion
SimRAG consistently outperformed baselines across all evaluated datasets. In the medical domain, SimRAG 8B (based on Llama-3) improved performance by an average of 8.01%. Notably, the Gemma-2-27B variant of SimRAG achieved between 86.6% and 98.9% of GPT-4’s performance on medical benchmarks, despite being significantly more efficient.
The Power of Self-Knowledge
A key insight from our ablation studies is that the "round-trip consistency" filter is vital for success. Removing this stage leads to a significant performance drop, confirming that the model's ability to verify its own generated questions is a robust quality control mechanism. Furthermore, SimRAG 8B outperformed models like RAFT and EvidenceRAG that use GPT-4 for data generation, suggesting that a model's internal domain knowledge may be more effective for its own fine-tuning than data from a generic, albeit larger, teacher model.
Conclusion and Future Work
SimRAG demonstrates that LLMs can effectively adapt to specialized domains through self-improvement and retrieval-based filtering. This approach offers a privacy-preserving and cost-effective alternative to relying on proprietary APIs. Future work will explore iterative self-improvement cycles and the effectiveness of this framework on smaller "edge" models (1B-3B parameters), which may face greater challenges in generating high-quality synthetic data.
Summary updated