Abstract
This technical report details a novel approach to combining reasoning and retrieval augmented generation (RAG) within a single, lean language model architecture. While existing RAG systems typically rely on large-scale models and external APIs, our work addresses the increasing demand for performant and privacy-preserving solutions deployable in resource-constrained or secure environments. Building on recent developments in test-time scaling and small-scale reasoning models, we develop a retrieval augmented conversational agent capable of interpreting complex, domain-specific queries using a lightweight backbone model. Our system integrates a dense retriever with fine-tuned Qwen2.5-Instruct models, using synthetic query generation and reasoning traces derived from frontier models (e.g., DeepSeek-R1) over a curated corpus, in this case, the NHS A-to-Z condition pages. We explore the impact of summarisation-based document compression, synthetic data design, and reasoning-aware fine-tuning on model performance. Evaluation against both non-reasoning and general-purpose lean models demonstrates that our domain-specific fine-tuning approach yields substantial gains in answer accuracy and consistency, approaching frontier-level performance while remaining feasible for local deployment.
Introduction
Modern artificial intelligence faces a significant "privacy vs. performance" dilemma. Frontier models such as GPT-4o or DeepSeek-R1 excel at complex reasoning and Retrieval-Augmented Generation (RAG), but their use typically necessitates transmitting sensitive data to external APIs. Conversely, while large open-source models are available, they are often too massive for local deployment in secure or resource-constrained environments like hospitals or government departments.
This research addresses the challenge of Retrieval-Augmented Reasoning (RAR). The goal is to enable "lean" models (ranging from 1.5B to 32B parameters) to not only retrieve facts but to actively reason over them to solve complex, domain-specific queries without hallucinations or the need for massive compute clusters.
Methodology
The researchers developed a multi-stage pipeline to distill the reasoning capabilities of frontier models into the Qwen2.5-Instruct family of lean models. The architecture builds upon the standard RAG framework (Figure 1) but enhances the generation phase with explicit reasoning traces.
- Synthetic Data Generation: Using GPT-4o, the team generated approximately 3,000 synthetic patient queries based on the NHS A-to-Z medical condition pages. These queries were designed with varying complexity: basic, hypochondriac (containing excessive noise), and downplay (lacking sufficient detail).
- Reasoning Distillation: The system prompted DeepSeek-R1 to generate "reasoning traces" (Chain-of-Thought) for these queries. These traces provide the step-by-step logic required to move from a patient's symptoms to a specific medical condition and a recommended disposition.
- Document Compression: To manage the context window constraints of smaller models, a 32B model was used to summarize the medical documents. This reduced document length by 85% while preserving critical diagnostic information.
- Fine-Tuning: Supervised Fine-Tuning (SFT) was performed on Qwen2.5 models (1.5B to 32B) using the distilled reasoning traces.
- Agentic RAG: The final system operates as an agent, autonomously deciding whether to invoke the retrieval tool or respond directly based on the query's requirements.
Key Insights and Results
The 14B Parameter Threshold
A critical finding was the emergence of reasoning capabilities at the 14B parameter mark. While 1.5B models showed improvement, they remained sensitive to fine-tuning alignment. However, the 1.5B model—capable of running on a standard laptop—achieved condition prediction accuracy (0.53) comparable to a 32B non-reasoning model (0.54) after reasoning-aware training.
Summarization as a Retrieval Catalyst
Counter-intuitively, indexing summarized versions of documents improved retrieval accuracy. The precision at 5 (p@5) increased from 0.68 to 0.76. By stripping away boilerplate text and noise, the dense retriever more effectively matched user queries to the core medical content.
Performance vs. Frontier Models
The fine-tuned 32B model (t0-1.1-k5-32B) achieved 56% accuracy in medical condition identification, matching the performance of the 671B parameter DeepSeek-R1 and GPT-4o when provided with the same context. Notably, the model demonstrated superior robustness to "noise"; on "hypochondriac" queries, accuracy rose to 62%, indicating that the reasoning process helped the model filter irrelevant information.
Conclusion and Future Work
This work demonstrates that domain-specific fine-tuning with reasoning traces can bridge the gap between lean local models and massive frontier systems. By reducing "underestimation errors" by over 40% compared to general-purpose models, this approach offers a viable path for secure, high-stakes deployments.
Future research will address the retriever bottleneck, as system accuracy is currently capped by the initial document retrieval. Potential solutions include reranking and query rephrasing. Additionally, the team aims to explore multi-hop retrieval to handle complex queries that span multiple medical documents.
Summary updated