Small language models tested for legal RAG accuracy
Researchers benchmarked five small language models in legal retrieval tasks to evaluate citation compliance and efficiency for specialized workflows.
Source: Grafy Research LabThe effectiveness of Retrieval-Augmented Generation (RAG) in the legal sector depends on more than just generating fluent text; it requires strict adherence to citations and structural validity. According to a study by Bhavya Yajush Awasthi and Amit Khaparde, evaluating how small language models (SLMs) handle these high-stakes requirements is essential for practical deployment.
What was the focus of the benchmarking study?
The research focused on testing five small language models within a local legal RAG pipeline. Unlike large-scale models that rely on massive compute, the study examined whether smaller, more efficient models could maintain the precision required for legal work. The researchers utilized the FIRE 2019 Artificial Intelligence for Legal Assistance (AILA) corpus to provide the necessary context for the models.
To facilitate the retrieval process, the researchers implemented BM25 retrieval to find relevant prior case documents. These documents were then used to construct constrained prompts, which were processed through llama.cpp to measure how the models performed during inference. The evaluation was not merely based on the quality of the prose, but on specific metrics including structural usability, how accurately the models cited their sources, and the overall efficiency of the inference process.
How are the models evaluated in legal settings?
In legal applications, the utility of an AI response is tied to its verifiability. The study by Awasthi and Khaparde highlights that a model must do more than answer a query; it must act as a reliable bridge to existing legal precedents. The researchers assessed the models across three primary dimensions:
- Structural Validity: Does the output follow the necessary format and logical structure required for legal documentation?
- Citation Compliance: Does the model correctly attribute information to the retrieved documents, or does it hallucinate or omit necessary references?
- Inference Efficiency: How quickly and with what computational cost can the model generate these responses?
By focusing on these metrics, the study aims to determine if SLMs can serve as viable, low-latency alternatives to larger models in specialized professional environments.
Why does model size matter for RAG pipelines?
Large language models (LLMs) often possess vast general knowledge, but in a RAG workflow, the model's primary job is to synthesize information provided in the retrieved context. This makes the size of the model a critical variable for efficiency. Smaller models can be run locally, reducing latency and increasing privacy, which are significant concerns in the legal industry.
However, smaller models typically have fewer parameters, which can lead to challenges in reasoning and instruction following. The research seeks to find the "sweet spot" where a model is small enough to be efficient and deployable, yet sophisticated enough to respect the constraints of a legal prompt and provide accurate, cited evidence.
What are the implications for specialized AI workflows?
The findings suggest that for professional domains like law, the metric of success is shifting from general linguistic capability to specialized reliability. A model that is highly creative but fails to cite a case correctly is of little use to a legal professional.
As RAG technology matures, the ability to deploy localized, efficient models that excel at "needle-in-a-haystack" retrieval and strict citation adherence will likely become a standard requirement. This moves the industry away from a "one size fits all" approach toward highly optimized, domain-specific pipelines where the model's architecture is tailored to the specific constraints of the data it processes.
How to apply these insights in research
For researchers and professionals working with dense, technical documents, understanding the nuances of RAG—such as how retrieval accuracy affects the final output—is vital. While this study focused on legal corpora, the principles of checking for citation compliance and structural validity apply to any field involving complex documentation.
If you are analyzing similar academic papers or legal texts, you can use Grafy Reader to interact with your documents. By uploading PDFs, you can perform research over the text, asking specific questions to see how an AI handles the retrieval and synthesis of the information provided in your specific files.
Frequently asked questions
What models were used in the study?
The researchers benchmarked five different small language models (SLMs). These models were tested within a local RAG pipeline that utilized BM25 for document retrieval and llama.cpp for the inference process to ensure a controlled and measurable environment.
What is the FIRE 2019 AILA corpus?
The FIRE 2019 Artificial Intelligence for Legal Assistance (AILA) corpus is a dataset used in the study to provide the legal context required for the RAG tasks. It serves as the foundational material from which the models must retrieve information to answer queries.
Why is citation compliance important in legal RAG?
Citation compliance ensures that every claim made by the AI is directly supported by the retrieved legal documents. In legal settings, an unverified or incorrectly cited statement can lead to significant errors, making accurate attribution a core requirement for professional utility.


