Views
No views yet
| Metric | Score | vs Base Model |
|---|---|---|
| NDCG@10 | 0.9236 | +517% (5.2x better) 🔥 |
| MRR@10 | 0.8991 | +714% (7.1x better) 🔥 |
| Recall@10 | 0.9961 | +250% (2.5x better) 🔥 |
| Recall@100 | 1.0000 | Perfect - never misses docs |
pip install "transformers>=4.48" "peft>=0.14" "huggingface_hub>=0.27" torchImportant: ModernBERT requirestransformers >= 4.48. Older versions will fail withKeyError: 'modernbert'.
| Library | Minimum Version | Notes |
|---|---|---|
transformers | >= 4.48 | ModernBERT architecture support |
peft | >= 0.14 | Compatible hf_hub_download API |
huggingface_hub | >= 0.27 | No deprecated use_auth_token |
torch | >= 2.0 | CUDA support |
pip install "transformers>=4.48" "peft>=0.14" "huggingface_hub>=0.27" torchanswerdotai/ModernBERT-base), NOT from this adapter repo. The adapter repo stores LoRA weights only; the tokenizer lives with the base model.AutoModel.from_pretrained("answerdotai/ModernBERT-base"), you may see warnings about UNEXPECTED keys (head.norm.weight, head.dense.weight, decoder.bias). These are the base model's MLM (masked language model) head weights that exist in the pretrained checkpoint but are not used by AutoModel (which loads only the encoder backbone). This is completely normal and safe to ignore.1from transformers import AutoModel, AutoTokenizer
2from peft import PeftModel
3import torch
4
5# Load model
6base_model = AutoModel.from_pretrained(
7 "answerdotai/ModernBERT-base",
8 trust_remote_code=True
9)
10model = PeftModel.from_pretrained(
11 base_model,
12 "sugiv/modernbert-us-stablecoin-encoder"
13)
14model.eval()
15
16# IMPORTANT: Load tokenizer from BASE MODEL, not from adapter repo
17tokenizer = AutoTokenizer.from_pretrained(
18 "answerdotai/ModernBERT-base",
19 trust_remote_code=True
20)
21
22def encode(text, max_length=512):
23 inputs = tokenizer(
24 text, padding=True, truncation=True,
25 max_length=max_length, return_tensors="pt"
26 )
27 with torch.no_grad():
28 outputs = model(**inputs)
29 embeddings = outputs.last_hidden_state.mean(dim=1)
30 embeddings = embeddings / embeddings.norm(dim=1, keepdim=True)
31 return embeddings
32
33# Example
34query = "What are reserve requirements for stablecoin issuers?"
35query_emb = encode(query)