Downloads · 30 days
10
100% of all-time downloads
RobBobin/torah-embed
torah-embed is a sentence similarity model from RobBobin. 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 cc-by-nc-4.0.
A 768-dimensional embedding model for retrieval over the Babylonian Talmud, fine-tuned from bge-base-en-v1.5 on a relevance dataset compiled in the sixteenth century.
Downloads · 30 days
10
100% of all-time downloads
All-time downloads
10
Public
Parameters
109M
700 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors438 MB · 62%
From the Hugging Face model README
A 768-dimensional embedding model for retrieval over the Babylonian Talmud,
fine-tuned from bge-base-en-v1.5
on a relevance dataset compiled in the sixteenth century.
Ships as a complete RAG: model, corpus, prebuilt index, query script, and a
persona file (RABBI.md) that assembles retrieved passages into an answer.
Point your Claude at RABBI.md and ask a question — see
below.
Printed in the margin of every page of the Vilna Talmud is a cross-reference apparatus, ein mishpat / ner mitsvah, mapping each passage of talmudic argument to the places in the medieval legal codes that rule from it.
In modern terms it is a hand-curated, cross-register relevance dataset:
50,214 such pairs were extracted from the Sefaria link graph; 27,013 connect Maimonides' Mishneh Torah to the Talmud with English on both sides. This model is trained on them.
552 queries from two entirely held-out tractates (Sanhedrin, Yevamot), retrieved over all 81,481 English Bavli segments — no pruning, no tractate hint. MRR:
| Query form | BM25 | bge-base zero-shot | torah-embed | gain |
|---|---|---|---|---|
| ruling | 0.430 | 0.412 | 0.462 | +12.2% |
| practical question | 0.090 | 0.175 | 0.211 | +20.0% |
| conceptual question | 0.042 | 0.086 | 0.116 | +35.9% |
R@10 on conceptual questions: 0.161 → 0.221 (+37.1%).
| register | token overlap with target | MRR gain |
|---|---|---|
| ruling | 0.41 | +12% |
| practical question | 0.30 | +20% |
| conceptual question | 0.21 | +36% |
Improvement rises as lexical overlap falls — the model gained most exactly where surface matching helps least. A memorising model shows the opposite gradient.
Fixed before training: beat zero-shot on held-out question queries by a margin exceeding the ruling-query gain. A model improving only on rulings has learned the benchmark, not the task.
| credit rule | rulings | questions | verdict |
|---|---|---|---|
| strict | +12.2% | +27.9% | pass |
| sugya-level | +14.2% | +28.9% | pass |
RABBI.mdThis repo ships a complete retrieval system, not just weights: the model, the
corpus, a prebuilt index over all 81,481 segments, a query script, and
RABBI.md — a persona file that turns raw search results into an answer.
# 1. get everything
pip install sentence-transformers numpy
hf download RobBobin/torah-embed --local-dir torah-embed
# 2. ask the index directly
python3 torah-embed/scripts/ask.py "Can I pray in the bathroom?" -k 8
[0.753] Berakhot 26a:3
...Rav Ḥisda said: One may stand opposite a bathroom and pray...
[0.703] Shabbat 10b:1
the bathroom is different, as it is disgusting. Once a place is called a
bathroom it is disgusting and no longer fit for prayer...
That is retrieval. It gives you passages, not an answer.
Open Claude Code (or any agent that can read files and run commands) in the directory, and say:
Read RABBI.md and follow it. Then answer: <your question>
The agent will run several searches from different angles, read what comes back, discard the misses, and assemble the passages into coherent paragraphs — quoting the text, preserving disagreements between the Sages rather than averaging them away, and clearly separating what the Gemara says from what it makes of it.
albert.txt is a full worked example: one question, six searches, the answer
that resulted, and an index of every passage retrieved.
RABBI.md isA teacher in the manner of the Accidental Talmudist — not a rabbinic authority, but someone who reads the page and tells you what is in it and what they make of it. It is permitted to interpret, and required to show the seam:
Berakhot 26a says one may stand opposite a bathroom and pray. ← the text
What strikes me about that is… ← the reader's guide
It also carries the rules that make the output trustworthy rather than merely fluent:
RABBI.md names three we measured:
homonyms (a question about talents returned a passage about a unit of
weight), counterfactual grammar, and single-word lexical hooks.RABBI.md is one voice. The retrieval is indifferent to it — write
SCHOLAR.md, CHAVRUTA.md, SKEPTIC.md and point the agent at that instead.
The instructions worth keeping in any of them are the honesty rules above, not
the personality.
from sentence_transformers import SentenceTransformer
m = SentenceTransformer("RobBobin/torah-embed")
q = m.encode("Represent this sentence for searching relevant passages: "
"Can I say my prayers in the bathroom?", normalize_embeddings=True)
docs = m.encode(["<talmud segment>", "..."], normalize_embeddings=True)
Queries take the BGE instruction prefix; passages do not.
RESULTS.md and paper/questions.pdf.| Path | What it is |
|---|---|
model.safetensors | the model, 768-dim, 438 MB |
RABBI.md | the persona file — point your agent at this |
albert.txt | a full worked example: one question, six searches, the answer |
scripts/ask.py | query the index from the command line |
index/bavli_en.json.gz | the corpus: 81,481 English Bavli segments |
index/emb_torah-embed.npy | prebuilt embeddings, 81,481 × 768 float32 |
index/segment_refs.json | Sefaria refs, row-aligned to the above |
paper/talmud_retrieval.pdf | the paper (10pp) |
paper/questions.pdf | 26 questions answered before and after fine-tuning |
data/gold_pairs.json | 50,214 ein mishpat reference pairs |
data/questions_train.json · questions_test.json | 1,752 rulings × 2 generated questions |
data/split.json | the tractate-level split |
data/eval_results.json | every number in this card |
scripts/ | fetch, split, train, evaluate |
RESULTS.md · PLAN.md · LESSONS.md | results, 52 numbered decisions, and the mistakes behind them |
PHASE1.md · THIN-SLICE.md · PHASE2A-*.md · QUESTION-TEST.md | the measurements, in the order taken |
cc-by-nc-4.0, inherited from the source texts. Non-commercial use only.
RobBobin/math-embed — the prior
work this method adapts: knowledge-graph-guided contrastive fine-tuning for
mathematical retrieval.
Robin Langer, with Claude (Anthropic) running the experiments.