Downloads · 30 days
134
28% of all-time downloads
usama1111/e5-pakistani-legal
e5-pakistani-legal is a sentence similarity model from usama1111. Use it when you need a score for how close two texts are. It is set up for sentence-transformers. The card lists the license as mit.
A dense retriever for Pakistani statutory law, fine-tuned from intfloat/multilingual-e5-base on 4,692 verified question–statute pairs in English and Urdu script. It maps a legal question to the statute section that go…
Downloads · 30 days
134
28% of all-time downloads
All-time downloads
474
Public
Parameters
278M
2.2 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors1.1 GB · 98%
From the Hugging Face model README
A dense retriever for Pakistani statutory law, fine-tuned from intfloat/multilingual-e5-base on 4,692 verified question–statute pairs in English and Urdu script. It maps a legal question to the statute section that governs it.
This is the general model of the FIT 2026 paper In-Distribution Gains Do Not Transfer: Leakage-Free Evaluation of Retrieval Interventions for Low-Resource Legal Question Answering. The paper's headline finding is about this model, so please read Evaluation before relying on it. It improves strongly on questions like its training data, but not on every new source of questions.
Use revision
0efe7b2b(or later). Revision445e441dof this repository, from before 2026-08-07 15:12 UTC, holds a different model: the constitutional-only model, now published as usama1111/e5-pak-legal-constitutional. The weights evaluated in the paper have SHA-256a3e7e4c1b650051b….
As with the base model, prefix queries with query: and passages with passage: .
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("usama1111/e5-pakistani-legal", revision="0efe7b2b")
model.max_seq_length = 224 # the length used in training
queries = ["query: What is the punishment for theft?"]
passages = ["passage: 379. Punishment for theft. Whoever commits theft shall be punished ..."]
q = model.encode(queries, normalize_embeddings=True)
p = model.encode(passages, normalize_embeddings=True)
print(q @ p.T) # cosine similarity
| Base model | intfloat/multilingual-e5-base |
| Training pairs | 4,692 (query, gold statute passage) |
| Held-out pairs | 1,191, split so that no gold passage appears in both halves |
| Legal domains | 5 (constitutional, criminal, evidence, civil procedure, family) |
| Urdu-script queries | 32% |
| Loss | Multiple-negatives ranking loss, with hard negatives mined from the deployed retriever |
| Hyperparameters | 2 epochs, batch size 12, learning rate 2 × 10⁻⁵, max sequence length 224 |
| Runs | 1 (seed variance is unmeasured) |
Where the pairs come from. The pairs come from 11,195 Pakistani legal Q&A pairs with machine-parseable citations (e.g., PPC s.467). The answers were LLM-generated, so only the citation is used. Four filters were applied:
5,883 pairs survive. Passages are statute chunks from the Pakistan Laws Dataset (ODC-BY) and the official Pakistan Code.
Every number below is dense retrieval only (no BM25). It ranks a fixed 9,042-passage corpus, with normalised embeddings and the prefixes above. A gold passage below rank 10 counts as a miss. Significance is McNemar's exact test on paired Hit@1 outcomes, and intervals are 95% bootstrap CIs.
| Test set | n | Hit@1, base → this model | Δ Hit@1 (95% CI) | p | MRR@10, base → this model |
|---|---|---|---|---|---|
| Own held-out citation pairs | 1,191 | 41.5% → 68.0% | +26.5 (23.5 to 29.6) | < 10⁻⁵⁰ | 0.516 → 0.758 |
| … Urdu-script queries | 389 | 16.7% → 64.0% | +47.3 | < 10⁻⁴⁷ | 0.255 → 0.718 |
| … English queries | 802 | 53.5% → 70.0% | +16.5 | < 10⁻¹⁷ | 0.643 → 0.778 |
| LEGAL-UQA questions (a different generator), English | 128 | 52.3% → 54.7% | +2.3 (−6.2 to 10.9) | 0.72 | 0.605 → 0.632 |
| Same LEGAL-UQA questions, Urdu (the dataset's own translation) | 128 | 18.0% → 42.2% | +24.2 | < 10⁻⁵ | — |
| Same LEGAL-UQA questions, Roman Urdu (LLM-written) | 126 | 21.4% → 38.9% | +17.5 | 0.0003 | — |
| Developer-written queries (a third source) | 25 | 20.0% → 60.0% | +40.0 | 0.002 | 0.285 → 0.620 |
What this means.
An in-distribution number does not predict which of these you will see. Evaluate on your own questions before deploying.
Zero-shot BAAI/bge-m3 (dense, length 512) scores 51.9% on the held-out citation pairs, against 68.0% for this model. It matches this model on Urdu LEGAL-UQA (41.4% vs 42.2%).
@inproceedings{usama2026indistribution,
title = {In-Distribution Gains Do Not Transfer: Leakage-Free Evaluation of Retrieval
Interventions for Low-Resource Legal Question Answering},
author = {Usama, Muhammad and Khan, Muhammad Amir Zarmaan Ullah},
booktitle = {Proc. International Conference on Frontiers of Information Technology (FIT)},
year = {2026},
note = {To appear}
}
Base model: L. Wang et al., Multilingual E5 Text Embeddings: A Technical Report, arXiv:2402.05672 (MIT licence).