Downloads · 30 days
120
50% of all-time downloads
bugBug04S/legal-embed-modernbert-v2
legal-embed-modernbert-v2 is a sentence similarity model from bugBug04S. 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 apache-2.0.
Embedding model for legal retrieval: matches plain-English legal questions to the passages that answer them, and clause-type descriptions to the contract clauses that match. Fine-tuned from nomic-ai/modernbert-embed-b…
Downloads · 30 days
120
50% of all-time downloads
All-time downloads
240
Public
Parameters
149M
596 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors596 MB · 99%
From the Hugging Face model README
Embedding model for legal retrieval: matches plain-English legal questions to the passages that answer them, and clause-type descriptions to the contract clauses that match. Fine-tuned from nomic-ai/modernbert-embed-base.
Use it for: legal Q&A search, contract clause lookup, RAG over legal corpora. Supports Matryoshka embeddings — truncate to 512/256/128/64 dims for cheaper search at modest quality cost.
v2 changes over v1: hard-negative mining, contract-clause training data, Australian legal QA, and a general-domain slice to limit domain drift.
All three models evaluated under identical settings (max_seq_length=256,
nomic prefixes applied). Best per column in bold.
Legal Q&A — 1,000 held-out Law StackExchange pairs, never seen in training, retrieval among 1,000 candidates:
| Model | Accuracy@1 | Recall@10 | MRR |
|---|---|---|---|
| legal-embed-modernbert-v2 | 0.904 | 0.994 | 0.938 |
| legal-embed-modernbert-v1 | 0.893 | 0.994 | 0.931 |
| nomic-ai/modernbert-embed-base | 0.800 | 0.948 | 0.856 |
Contractual Clause Retrieval (isaacus) — 45 clause types, 90 clauses:
| Model | Accuracy@1 | Recall@10 | MRR |
|---|---|---|---|
| legal-embed-modernbert-v2 | 0.844 | 0.978 | 0.900 |
| legal-embed-modernbert-v1 | 0.622 | 0.889 | 0.708 |
| nomic-ai/modernbert-embed-base | 0.644 | 0.933 | 0.733 |
LegalBench Consumer Contracts QA (mteb):
| Model | Accuracy@1 | Recall@10 | MRR |
|---|---|---|---|
| legal-embed-modernbert-v1 | 0.556 | 0.922 | 0.672 |
| legal-embed-modernbert-v2 | 0.528 | 0.902 | 0.643 |
| nomic-ai/modernbert-embed-base | 0.525 | 0.907 | 0.650 |
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("bugBug04S/legal-embed-modernbert-v2")
query = "search_query: can the client terminate early without cause?"
docs = [
"search_document: Either party may terminate this Agreement upon thirty (30) days prior written notice.",
"search_document: The Licensee shall indemnify and hold harmless the Licensor against all claims.",
]
q = model.encode(query, normalize_embeddings=True)
d = model.encode(docs, normalize_embeddings=True)
print(q @ d.T) # higher = more relevant
Required: prepend search_query: to queries and search_document: to
passages. The model is trained with these prefixes and degrades noticeably
without them.