Run this model with HF Jobs
Run Sefaria/BeRTevot on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/Sefaria/BeRTevot. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/Sefaria/BeRTevot on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
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), v6 (Nov 25, 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) |
book_tables.json |
optional per-book tables: the readings a book uses for its own abbreviations (see below) |
roshei_tevot/ |
the inference code (predict.py, book_tables.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, tokenizers, 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: answers best first (probability summed over the answer's spellings, text its most probable spelling, readings every spelling with its share, freq and cosine, label the English gloss; a number the token spells is one answer with kind: "number" and the label "the number N"), and top_cosine, the largest raw cosine between the context and any reading (before the prior and book boost). A low top_cosine suggests the token is not an abbreviation at all (a quoted word, a name): the softmax always sums to 1 and hides that. A token the lexicon has no reading for gets empty senses and no top_cosine.
Per-book tables (optional). If you know the book a passage is from, pass its English index title: rt.expand(text, book="Mishnah Berurah") (or rt.score(rows) with a book in each row). A book with a table also gets its own readings of the key offered as candidates when the lexicon lacks them (table_inject) and boosted by table_boost (5.0 for a book's own table; 6.0 for the Rashi, Tosafot and Rishonim-on-Talmud family tables, 4.0 for the Mishnah-commentary and Malbim family tables; leave-one-out over 49 books: 89.9% top-1 for the model alone, about 95% with the tables). Five families have one table each that serves every volume, layered under a volume's own table: Rashi on the Talmud, Tosafot, Rishonim on the Talmud (159 volumes; leave-one-volume-out 93.6% -> 96.1%), Mishnah commentaries (185 volumes; 91.0% -> 96.6%) and Malbim (44 volumes; 87.8% -> 90.2%). Tables cover 494 works, and some include an author's own book titles (Malbim's ืื"ืฉ = ืืืืช ืืฉืืจ). rt.book_tables.titles() lists the books. Tables were built from passages whose readings two independent LLM readers agreed on (not human gold) and are strictly a prior: without a book nothing changes.
Transformers 4 and 5. This release loads the tokenizer from tokenizer.json itself (roshei_tevot.encoding.load_tokenizer). BEREL's file defines its own pre-tokenizer, which keeps abbreviations like ืชื "ื and ืจ"ืฉ whole; transformers 5's AutoTokenizer ignores it, splits abbreviations into pieces the model never saw, and loses about 10 points of top-1 (on 250 majority-sense validation rows: 95.6% with the correct tokenization against 85.2% with AutoTokenizer under transformers 5.21, at prior weight 0). If you write your own loading code, do not use AutoTokenizer.from_pretrained on this folder with transformers 5; use load_tokenizer.
What the code does around the model (and why you should not skip it)
- Detect tokens that look like abbreviations, with attached prefix letters (up to four; ื may stand before ื or ืฉ, as in
ืืืืื"ืง,ืืฉืืงื"ื,ืืืืฉ"ืก, unless the whole token is a common word such asืืืืื"ื); drop letter, vowel and divine names written with gershayim (ืื"ืฃ, ืื"ื, ืืืื"ื, ืงื"ืฅ, ืฆืืจ"ื, ืืื"ื, also behind up to three prefix letters including ื): 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). On the validation split the prior is worth about 1.3 points of top-1 (94.2% at weight 0, 95.5% at 0.5), but the gain comes from the frequent readings and the rarer ones pay for it: for answers that are under 10% of their key's examples (104 validation rows) top-1 is 81.7% at weight 0 and 76.0% at 0.5. Do not raise it much above 0.5. 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 answer and sum probabilities: a number the token spells is one answer by value (
ืืจืืขื,ืืจืืขforื'); otherwise the reading's sense class insenses.json, looked up without the token's prefix (ืืืืืจืofืืืื'isืืืจืofืื'), bare keys before prefixed ones, geresh marks ignored; a reading no class lists joins the readings equal to it once the prefix and geresh marks are taken off. Nothing looser:ืจืื/ืจืandืืืืขืืจ/ืืืขืืจstay apart. - Not an abbreviation here? Every token gets
not_abbreviation_pfrom a small logistic head (nonabbrev_head.json) over the same query vector plus five cheap features (vocabulary frequency of the whole token, gershayim, no candidate, top_cosine, length). It catches gershayim-marked words and names (ืกืื"ื,ืืื"ื,ืืืืจื"ื, gematria-marked words) that the reading probabilities cannot: on such tokens the top reading's probability is 0.9 or more half the time. It was trained on 9,030 tokens two blind LLM readers (Opus 5.5, gpt-6.1-terra) agreed on (5,061 not abbreviations, 3,969 abbreviations). In 5-fold cross-validation grouped by surface, at 0.9 it flags 81% of non-abbreviations and 1.1% of abbreviations (on tokens that have candidates: 64% and 0.6%). On 1,198 ordinary tokens from an independent audit it flagged 3.3%, including 10 of 18 tokens judged not to be abbreviations and 5 of 380 tokens the model reads correctly. It only scores; candidates are unchanged. Suggested use: treatnot_abbreviation_p >= 0.9as "probably a marked word, not an abbreviation". - Letter play. Some gershayim tokens are not abbreviations but letters to read as letters (divine-name groups such as
ืืืืืื ื"ื,ืืฆืค"ืฅ; ciphers such asืืืื"ื; day letters such asืื"ื), or a real word marked for gematria or a hint (ืืจื"ืช,ืฉืง"ืจ).score/expandaddletter_play: "letter_group" | "marked_word"to such tokens (absent otherwise), fromletter_play.json(a reviewed list of 48 surfaces mined from LLM-labelled scope text, a few known groups, 4+ letter alef-bet runs) and, in books listed there (Bnei Yissaschar), common words marked for emphasis that the lexicon barely knows as abbreviations and the head does not score as one. On labels from two blind LLM readers it tagged 87 of 641 notarikon / letter-group tokens and 0 of 4,340 agreed abbreviations (2 of 625 random controls). Candidates are unchanged; suggested use: show the token as letters or as the word, not expanded.
Training and data
- Base
dicta-il/BEREL_3.0; one epoch of 600,000 rows sampled from 1,062,365 (weight 1/count(key)^0.5, synthetic rows 0.5, sense balancing ฮฒ 0.5); spot A100, Nov 25, 2026. Runrt-numbers-v6-siamese-2026-11-25. Code:train-roshei-tevotin Sefaria/ML-Workflows; this release is assembled byapp/roshei_tevot/publish_hf.pythere. - Data: Sefaria's roshei tevot dataset (v6, 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_v6.shrebuilds it). - v6 = v5b plus: 108 lexicon readings from two rounds of gap sweeps over the library;
ืืฉื ื,ืืฉื ืืandืืฉืชืremoved from the readings ofื'(they came from first-letter alignment: the key is the number two, and the prefixed forms are not readings of it), andืคืงื"ื=ืคืจืง ืงื"ื(a citation pattern) removed. The model was trained on the dataset built before these last removals took effect (a later build step had put three readings back); theindex/here is built from the corrected lexicon with the same model. The hyperparameters and the training procedure are the same as v5b. - Dec 3 parser update (no retraining): stacked ืื/ืืฉ prefixes and more letter/vowel names, as in step 1. On an 11,765-passage library sample, 258 of 304k abbreviation tokens parse differently (right top reading 189 -> 221, 3 worse), and 512 more letter-name tokens are no longer expanded (248 of the 259 checked by two readers confirmed as names).
- Dec 3:
not_abbreviation_phead (step 6), no retraining of the model. - Dec 4:
letter_playtag (step 7,letter_play.json,roshei_tevot/letter_play.py), no retraining. - Dec 4 (later): reviewed lexicon and book-table additions, no retraining. 22 lexicon readings (9 new expansions embedded into
index/), 146 book-table rows and 23 weak rows (newweak_table/weak_boostinbook_tables.json: readings a book uses alongside the key's usual one get a smaller boost, default 2), 10 family rows; the user's review decisions plus rules inferred from them. When a token has no candidates, the lexicon also tries its gershayim moved to the standard place before the last letter (ืืจ"ืืื->ืืจืื"ื), unless everything before the mark is prefix letters (an opening quotation mark). On 3,738 scope tokens two blind LLM readers agreed on, top-1 60.8% -> 62.3%. senses.jsonalso holds 405 readings that were added to the lexicon after the dataset's sense classes were built, merged into the class of their spelling variants (or into a new class of their own) after two rounds of independent model readers agreed; the other candidate merges (inflected forms and the like) were left separate.
Evaluation (v6 splits; top-1 over rows with 2+ candidates and the label among them; prior weight 0.5)
| split | answerable | v6 | v5b |
|---|---|---|---|
| val | 3,210 | 95.5 | 95.6 |
| test_seen_keys | 4,900 | 95.5 | 95.4 |
| test_unseen_keys | 336 | 89.6 | 88.7 |
Both models were scored on the same rows with the same code, v5b's index and v6's. The two are equal within noise. On val the balanced top-1 (mean over the majority, common and rare sense bands) is 87.8 for v6 and 88.7 for v5b at prior weight 0.5 (89.2 against 88.8 at weight 0); that gap is 6 rows. On the 554 val rows of the common and rare bands, 20 are right only for v5b and 14 only for v6 (McNemar p = 0.39); the rows v6 loses are mostly ambiguous rabbi names (ืจ"ื as ืืืกื, ืืืื ื or ืืืื; ืืืืจ"ื as ื ืืื or ื ืชื), and v6 wins rows of the same kind. The +0.9 on unseen keys is 3 rows of 336 and is not significant. v6's value is the corrected lexicon, not a measured accuracy gain.
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
- 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 (89.6%). - Rabbi names written as the same abbreviation (
ืจ"ื) remain the largest source of errors; a book table or the author's other works help only where the book's habit is stable.
- Downloads last month
- 135
Model tree for Sefaria/BeRTevot
Base model
dicta-il/BEREL_3.0