CoolFace
Modelpublic

Mannas/legal-bge-in

sourceHugging Facemitupdated 3mo agoView on Hugging Face
1likes92downloads
Model Card

Mannas/legal-bge-in — an embedding model for Indian legal search

A fine-tune of `BAAI/bge-base-en-v1.5` specialised for retrieval over Indian case law (Supreme Court of India + Delhi High Court). It embeds legal text so that a lawyer's question lands near the judgments that answer it — better than the generic base model on the distinctions that matter in law (e.g. §138 NI Act cheque-bounce vs §420 IPC cheating, anticipatory vs regular bail).

  • —Base: BAAI/bge-base-en-v1.5 (109M params, 768-dim, 512 max tokens)
  • —Domain: Indian judgments (English)
  • —Output: 768-dim normalized embeddings (dot product = cosine similarity)
  • —License: MIT (inherits the base model's license; training data is public-domain Indian judgments)

Results

Measured on a held-out set of 447 legal questions, searched against a fixed candidate pool (leakage-checked; the model never saw the eval judgments during training). Δ vs vanilla bge-base-en-v1.5 on the identical pool:

MetricVanilla bge-baseThis modelImprovement
Recall@100.71810.7897+7.2 pts
MRR@100.51370.6009+8.7 pts

≈ 25% fewer missed cases, and correct judgments ranked meaningfully higher. Trained locally on a single consumer GPU (RTX 5060 Ti, 16 GB), no paid APIs.

Usage

python
from sentence_transformers import SentenceTransformer

model = SentenceTransformer("Mannas/legal-bge-in")

# For SHORT search queries, prepend the BGE instruction (passages are embedded bare):
QUERY_PREFIX = "Represent this sentence for searching relevant passages: "
query = QUERY_PREFIX + "notice requirements for cheque dishonour under Section 138"
passages = [
    "The complaint under Section 138 of the Negotiable Instruments Act, 1881 ...",
    "Anticipatory bail under Section 438 CrPC is granted where ...",
]
q = model.encode(query, normalize_embeddings=True)
p = model.encode(passages, normalize_embeddings=True)
scores = p @ q   # cosine similarities; higher = more relevant

Training

  • —Data: ~9,585 (question, passage) pairs built for free from the corpus — AI-generated headnote ISSUES: lines and synthetic queries (a local LLM reading passages and writing the question each answers), paired with the relevant judgment chunk. No human labelling.
  • —Loss: MultipleNegativesRankingLoss (in-batch negatives).
  • —Config: 2 epochs, batch 32, lr 2e-5, bf16, maxseqlength 384. ~5 minutes on one RTX 5060 Ti.
  • —Method: eval set frozen before training; leakage verified; every result is a fair A/B vs the base model on the identical pool.

Honest caveats

  • —Absolute scores above are on a reduced candidate pool; the delta vs the base model is the trustworthy signal.
  • —Evaluation queries are AI-generated legal-issue questions — a strong proxy for lawyer queries, not a substitute for real user logs.
  • —Scope: tuned on Supreme Court + Delhi High Court judgments; other courts / practice areas may benefit from further tuning.

Attribution

Built on BAAI's BGE. If you use this model, a link back is appreciated.