Instructions to use Sefaria/BeRTevot with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Sefaria/BeRTevot with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="Sefaria/BeRTevot")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("Sefaria/BeRTevot") model = AutoModel.from_pretrained("Sefaria/BeRTevot", device_map="auto") - Notebooks
- Google Colab
- Kaggle
BeRTevot: expanding Hebrew and Aramaic abbreviations in context (BEREL 3.0, siamese), v5b (Nov 23, 2026)
Picks the meaning of a Hebrew or Aramaic abbreviation (roshei tevot, e.g. 专"砖, or a truncated word, e.g. 讗讞专讬') in context, by ranking the sense classes the Sefaria roshei tevot lexicon lists for it.
This repository is a complete release, not just weights. The model only ranks the readings it is offered, so the lexicon, the per-reading embeddings, the sense classes and the code that builds candidates are all here, from one build, so they cannot be paired wrongly:
| path | what |
|---|---|
model.safetensors, config.json, tokenizer files, roshei_tevot_config.json |
the siamese model (BEREL 3.0 fine-tuned; logit_scale, span pooling) |
index/lexicon.json, index/embeddings.npy |
which readings a token can have (with library frequencies), one fp16 embedding per reading (135 MB) |
senses.json |
sense classes: readings that are spellings of one answer (讗讬讻讗 讚讗诪专讬 / 讗讬转 讚讗诪专讬谉) |
train_counts.json |
per key, how many training examples each reading labels: the frequency prior (2 MB) |
roshei_tevot/ |
the inference code (predict.py, candidate generation, encoding, detection) |
Use
import sys
from huggingface_hub import snapshot_download
folder = snapshot_download("Sefaria/BeRTevot")
sys.path.insert(0, folder)
from roshei_tevot.predict import RosheiTevot # needs torch, transformers, numpy
rt = RosheiTevot.from_pretrained(folder) # CPU is fine: candidates are embedded in advance
for t in rt.expand('讗诪专 专"砖 讘谉 诇拽讬砖 讘驻"讘 讚砖讘转, 讜讘住拽"讙 讻转讘 讛专诪"讗')["tokens"]:
best = t["senses"][0]
print(t["surface"], "->", best["text"], round(best["probability"], 2), best["label"])
expand returns the cleaned text and, per abbreviation found, senses: sense classes best first (probability summed over a class's spellings, readings with each spelling's share, label the English gloss). A token the lexicon has no reading for gets empty senses.
What the code does around the model (and why you should not skip it)
- Detect tokens that look like abbreviations, with attached prefix letters; drop letter and divine names written with gershayim (讗诇"祝, 讛讜讬"讛): the model read them at p~1.
- Offer candidates: the lexicon's readings for the token (as written or behind a prefix, letters must fit); the number for a numeral (
讬"讚->讗专讘注讛 注砖专, also behind a prefix, also one-letter geresh numerals讘讙');住注讬祝 拽讟谉 Xfor住拽"X; for a truncated word (诇讻转讞讬') the 8 most frequent library words that start with its letters; citation readings (住拽讬"讗), but never for a bare numeral or a token ending in a geresh (there they win with拽讬爪讜专/住讬诪谉 讬'). - Encode: the token wrapped in the added
<abbr>markers, 200 words of context each side, 512 tokens, no title or category; the model's vector is the mean over the marked span. - Score: softmax over
logit_scale * cosine + prior_weight * log(1 + count), wherecountis how many training examples of the key the reading labels (train_counts.json), as in the evaluation.prior_weightdefaults to 0.5 (0 when the counts file is absent). The prior is worth about 3 points of top-1 on a 700-row held-out val sample run through this package (92.4% at weight 0, 95.3% at 0.5, 94.9% at 1.0; with each row's exact dataset counts instead of this table it reaches 96.3% at 0.5, so the table is a slightly lossy copy). Do not raise it much above 0.5: on the full evaluation top-1 is flat from 0.5 to 2, but the gain comes from the frequent readings, and the rarer ones pay for it. On the v5b val split, accuracy on keys with few examples is 79 / 79 / 79 / 70 / 55% at weight 0 / 0.25 / 0.5 / 1 / 2, and on a token whose right reading is not the most frequent one 89 / 88 / 89 / 86 / 80%. A reading the training set never saw (a recent lexicon addition) has count 0 and is pushed down byprior_weight * log(1 + the other readings' counts): about 3.5 logits, a factor of 30, at 0.5 for a reading seen 1,000 times. Lower it, or passprior_weight=0, for text unlike the library (a different genre) or when you want the lexicon's newest readings to compete evenly. - Group by sense and sum probabilities.
Training and data
- Base
dicta-il/BEREL_3.0; one epoch of 600,000 rows sampled from 1,065,097 (weight 1/count(key)^0.5, synthetic rows 0.5, sense balancing 尾 0.5); spot A100, Nov 23, 2026. Runrt-numbers-v5b-siamese-2026-11-23. Code:train-roshei-tevotin Sefaria/ML-Workflows; this release is assembled byapp/roshei_tevot/publish_hf.pythere. - Data: Sefaria's roshei tevot dataset (v5b, not public; the lexicon, sense classes and counts it produced are in this repo). Built by Sefaria/translation-engine
experiments/expand_roshei_tevot(NUMBERS.mdhas the rounds v3, v4, v5b;rebuild_v5.shrebuilds it). - v5b = v4 plus: 92 lexicon readings the Dicta comparison found missing; 231 label fixes confirmed by two independent LLM readers (the 137 that only swap 专讘 and 专讘讬 are left out); 67 lexicon keys that were a prefix + another key (
讜专') are stripped again.
Evaluation (v5b splits; top-1 over rows with 2+ candidates and the label among them)
| split | answerable | v5b | v4 |
|---|---|---|---|
| val | 3,220 | 95.7 | 94.8 |
| test_seen_keys | 4,917 | 95.5 | 94.9 |
| test_unseen_keys | 336 | 88.7 | 89.3 |
| number_val | 2,103 | 98.3 | 98.1 |
| number_test_seen_keys | 2,063 | 98.1 | 98.4 |
| abbr_val | 1,408 | 89.6 | 89.6 |
| abbr_test_seen_keys | 1,409 | 89.1 | 89.9 |
Each model with the training-count prior at the weight the evaluation picked on val (v5b 0.5, v4 0.25), which is what the package's default reproduces. At the same prior weight the two differ by 0.5 points or less, within one training run's noise: v5b is cleaner data and a larger lexicon, not a measured accuracy gain. Top-3 on val / test_seen_keys is 99.5 / 99.6. Not measured on this revision: the comparison with Dicta (v4: 91.0% target accuracy on 500 held-out passages against Dicta's 58.0%).
Known issues
- The lexicon still holds
驻拽讬"讗=驻专拽 拽讬"讗(a citation pattern, removed from the lexicon source after this build). - Whether a token is an abbreviation at all is decided by
detect, not the model; common words with a geresh can be offered readings. - Candidates are the lexicon's: a reading it lacks cannot be chosen, and
test_unseen_keys(abbreviations never seen in training) is the weak spot (88.7%).
- Downloads last month
- -
Model tree for Sefaria/BeRTevot
Base model
dicta-il/BEREL_3.0