Dhara reranker: Indian criminal law
A small cross-encoder that scores how well a passage from a Supreme Court of India criminal judgment, or a section of the criminal codes, answers a legal question. It is a MiniLM-L6 (22.7M parameters) distilled from bge-reranker-v2-m3 fine-tuned on question–passage pairs mined from the Dhara corpus. It is the reranker in the Dhara research tool, live at dhara.aravarun.in, where it runs on a CPU.
It was built for the 1 July 2024 change of codes (IPC, CrPC and the Evidence Act replaced by BNS, BNSS and BSA). Questions are asked with new-code section numbers, but most judgments cite the old ones, so the model has to judge a passage on what it says, not on the number it quotes.
Use
from sentence_transformers import CrossEncoder
model = CrossEncoder("AravArun/dhara-reranker", max_length=512)
question = "Can a conviction under BNS 103 rest on circumstantial evidence alone?"
passages = [
"Where the case rests on circumstantial evidence, the chain must be so complete that it excludes every hypothesis but guilt...",
"The appellant was granted anticipatory bail subject to conditions...",
]
scores = model.predict([(question, p) for p in passages])
Higher is more relevant. In Dhara it rereads the top 50 passages from a rank fusion of BM25, a citation-graph retriever and bge-m3 dense and sparse search, in about 0.7 seconds on a laptop CPU, and its order is then fused by rank with the retrieval order, so a landmark judgment that every retriever finds is not pushed below later judgments quoting it.
Training
- Questions: written for training-split judgments and sections only, the same way as the DharaBench benchmark, so no judgment or section in dev or test is seen in training. 3,188 questions, of which 2,756 give usable pairs, about 14,200 in all.
- Positives: passages of the source judgment that cite the provisions behind the question, or the provision's own text for statute questions.
- Hard negatives: top results from the live retriever that are not the answer, plus passages citing a neighbouring section of the same code (murder against culpable homicide or attempt). A passage from another judgment citing the same law is never a negative, since it is often a right answer too.
- Teacher: bge-reranker-v2-m3 fine-tuned with binary cross-entropy for one epoch, learning rate 2e-5, effective batch 16, 512 tokens, mixed precision on a T4.
- Student (this model): trained to reproduce the teacher's scores (mean squared error on its logits) over the same pairs, two epochs, learning rate 5e-5, batch 32, 512 tokens.
Evaluation
DharaBench, 450 precedent questions per split, each answered by a known Supreme Court judgment, many phrased with new-code numbers for a judgment that cites only the old code. Right judgment in the top 10, reranking the top 50 of the rank fusion:
| Setup | Dev | Test |
|---|---|---|
| Rank fusion, no reranker | 0.37 | 0.36 |
| bge-reranker-base, off the shelf | 0.41 | |
| bge-reranker-v2-m3, off the shelf | 0.47 | |
| bge-reranker-base, fine-tuned | 0.38 | 0.42 |
| bge-reranker-v2-m3, fine-tuned (the teacher) | 0.38 | 0.41 |
| LLM reranker | 0.40 | 0.40 |
| This model | 0.40 | 0.45 |
| This model, its order fused with the retrieval order (as served) | 0.43 | 0.44 |
With 450 questions a figure carries about ±0.023 of noise. On dev this model ties the base-sized rerankers and trails the off-the-shelf v2-m3, which is 25 times larger and too slow for a CPU server. It was chosen on dev for being as accurate as the base-sized models at a fifth of their cost; test was scored afterwards. Full tables: eval/results.
On 40 questions typed the way people ask them, mostly without a section number and each answered by a landmark judgment no training question came from, Dhara's served setup puts the landmark in the top 10 for 33 (0.83), against 26 for this model's order alone and 27 for dense search alone.
Dhara also uses its top score over the retrieved sections to decline questions outside criminal law. With a threshold fitted on dev to answer 95% of in-scope questions, it declines 9 of the 20 out-of-scope ones (civil, tax, family law).
Limits
- Trained on Supreme Court criminal judgments and the six criminal codes only; other courts and areas of law are out of its domain.
- English only.
- Questions were generated from headnotes, so they are cleaner than real queries.
- A ranking aid for research, not legal advice.