CoolFace
Modelpublic

alexgoldberg/hebrew-manuscript-provenance-ner

sourceHugging Faceapache-2.0updated 5mo agoView on Hugging Face
0likes
Model Card

Hebrew Manuscript Provenance NER

A token-classification model that extracts OWNER, DATE, and COLLECTION entities from Hebrew manuscript catalog text — primarily MARC 561 (provenance / ownership note) sentences.

Built for the Mapping Hebrew Manuscripts (MHM) pipeline (Bar-Ilan University) as part of an automated MARC → Wikidata conversion stack.

Quick stats

Basedicta-il/dictabert
ArchitectureDictaBERT + custom token-classification head (BIO tagging)
Entity typesOWNER, DATE, COLLECTION
F1 (best fold)96.17%
Training samples~12,100 (28.4% multi-entity augmented)
Max length128 tokens
Validation5-fold stratified CV

Entity types

BIO labelMeaningHebrew example
OWNERPersonal name of a manuscript owner / scribe / inscriberיעקב בן שלמה
DATEHebrew or numeric date (gregorian or AM)שנת תקפ"ב
COLLECTIONLibrary / institutional collection holding the manuscriptאוסף שוקן

How to use

python
from huggingface_hub import hf_hub_download
import torch
from transformers import AutoTokenizer, AutoModel
import torch.nn as nn

REPO = "alexgoldberg/hebrew-manuscript-provenance-ner"
ckpt_path = hf_hub_download(repo_id=REPO, filename="provenance_ner_model.pt")
ckpt = torch.load(ckpt_path, map_location="cpu", weights_only=False)
label2id = ckpt["ner_label2id"]
id2label = {v: k for k, v in label2id.items()}

class NERModel(nn.Module):
    def __init__(self, base, num_labels):
        super().__init__()
        self.bert = AutoModel.from_pretrained(base)
        self.dropout = nn.Dropout(0.3)
        hidden = self.bert.config.hidden_size
        self.ner_intermediate = nn.Linear(hidden, hidden)
        self.ner_output = nn.Linear(hidden, num_labels)
    def forward(self, input_ids, attention_mask):
        x = self.bert(input_ids, attention_mask).last_hidden_state
        x = self.dropout(torch.relu(self.ner_intermediate(x)))
        return self.ner_output(x)

BASE = "dicta-il/dictabert"
tok = AutoTokenizer.from_pretrained(BASE)
model = NERModel(BASE, num_labels=len(label2id))
model.load_state_dict(ckpt["model_state_dict"])
model.eval()

# Inference helper — see examples.py in this repo for a complete BIO-aware
# span aggregator with offset mapping.
text = 'בדף 1א ציון בעלים: "יצחק בן אברהם"'
enc = tok(text, return_tensors="pt", truncation=True, max_length=128,
          return_offsets_mapping=True)
with torch.no_grad():
    logits = model(enc["input_ids"], enc["attention_mask"])
ids = logits.argmax(-1)[0].tolist()
print([id2label[i] for i in ids])

A complete inference helper that aggregates BIO spans into entity dicts is shipped as examples.py in this repo.

Real input/output examples

Each example below comes from running the model on a real MARC 561 (provenance) sentence drawn verbatim from the National Library of Israel catalog (NLI shelfmark shown).

Example 1 — NLI 990000908210205171

MARC 561 input (990000908210205171):

ציון בעלים: ""שלמה בכ""ר אליא משה ... "" (דף 47א) ""יהודה בן שלמה קטורזי"" (דף 209א).

Model output:

TypeSpanConfidenceChar offset
OWNERשלמה בכ""ר אליא משה0.96814–33

Example 2 — NLI 990000949780205171

MARC 561 input (990000949780205171):

בדף 21א: ציון בעלים: ""יוסף הלוי בכמו""ה דמר(?) יצחק הלוי זלה""ה"".|ציון בעלים (של מס' 31 מכ""י זה): ""יוסף הלוי בריה דמר יצחק הלוי זלה""ה בזמן הגרוש שהיו קוברים הספרים בקרפינטרץ"".

Model output:

TypeSpanConfidenceChar offset
OWNERיוסף הלוי בכמו""ה דמר(?) יצחק הלוי זלה""ה"".ציון0.98923–72
OWNERיוסף הלוי בריה דמר יצחק הלוי זלה""ה בזמן הגרוש שהיו קוברים הספרים בקרפינטרץ0.998103–178

Example 3 — NLI 990000554170205171

MARC 561 input (990000554170205171):

בראש כה""י ציון בעלים: אי""ש ג""ר (1א, 21א, 25א, 289ב. בדף 2ב: שטר מכירת כה""י: ""משה חיים יצ""ו בכמוהר""ר גרשון וייויני זצ""ל"" מכרו ל""אברהם יוסף שלמה גראציאנו"" בתאריך ""ששה ימים לחדש אלול שנת ת'ה'ל'ה' לבריאת העולם"" [=תל""ה].|בדף 25א הוסיף אי""ש ג""ר: ""מגנזי ... מ""ע מפאנו זצ""ל"".

Model output:

TypeSpanConfidenceChar offset
DATEשנת ת'ה'ל'ה'0.998192–204

Example 4 — NLI 990000569910205171

MARC 561 input (990000569910205171):

בראש כה""י ציון הבעלים: ""אשר ב""ר נפתלי הכהן"".|נמכר בבית המכירות של קריסטיס, ניו יורק, יוני 1999.|נמכר בבית המכירות של סוט'ביס, ניו יורק, דצמבר 2017.

Model output:

TypeSpanConfidenceChar offset
OWNERנפתלי הכהן"".נמכר0.78335–53
DATE1999.נמכר0.99894–104
DATE20170.997146–150

Example 5 — NLI 990001389110205171

MARC 561 input (990001389110205171):

בראש כה""י תוכן הענינים של כה""י מאת הבעלים ""איש ג""ר"" ורשימה על קניית כה""י על ידו מאת ""יורשי הגאון ... נתנאל טרבוט בכמה""ר בנימן טרבוט ... ע""י הסרסור ... יוסף ... בכמ""ר אדונירם מוינייולא ... פה מודונא"" (דף 5א).|בסוף כה""י רשימות על הנסים שנעשו למעתיק מנחם בן דניאל ממודינא בשנים ה'תצ""ה וה'תק""ד מאת ""חיים גרוציאנו"".|בדף 137ב-138א: רשימת לידות של משפחת מודינא מהשנים רס""ט-ש""ב, בין השאער על לידות ילדיו של ""דניאל ... בכמה""ר דויד ממודינה"" (רשימה דומה בכ""י בולוניא 2206 ואולי הועתק ממנו).

Model output:

TypeSpanConfidenceChar offset
OWNERמנחם0.568259–263
DATE22060.996478–482

Training details

  • —Architecture: bert + Linear(hidden→hidden) + ReLU + Dropout(0.3) + Linear(hidden→num_labels) on top of dicta-il/dictabert.
  • —Loss: focal loss (class-balanced) on BIO tags.
  • —Optimizer: AdamW, learning rate 1e-5, weight decay 0.01.
  • —Schedule: linear warmup, 5 epochs per fold.
  • —Validation: 5-fold stratified CV; the published checkpoint is the best-performing fold (F1 = 96.17% on its held-out fold).
  • —Token classifier: BIO with 7 tags (O, B-OWNER, I-OWNER, B-DATE, I-DATE, B-COLLECTION, I-COLLECTION).
  • —Hardware: trained on a single NVIDIA A100 (40 GB).

Limitations

  • —Trained predominantly on National Library of Israel (NLI) MARC 561 conventions. Provenance notes from other cataloging traditions (Bodleian, Vatican, JTS, etc.) may have different surface forms and yield lower recall.
  • —The MHM pipeline caps OWNER spans at 80 chars: longer spans are treated as provenance inscriptions (P7535 narrative descriptions on Wikidata) rather than P127 owner statements. This model still emits the long span — consumers must apply the length cap themselves.
  • —DATE entities are extracted as text spans (e.g., שנת תקפ"ב); converting to a calendar value is downstream (converter/wikidata/property_mapping.py:date_to_wikidata).
  • —Character offsets in the output dict are produced by tokenizer offset mapping; they may be None for spans that span sub-word tokenization edges.

Pipeline integration

In the MHM pipeline this model runs as part of Stage 2 (NER Extraction) alongside two sibling models:

  • —alexgoldberg/hebrew-manuscript-contents-ner — WORK / FOLIO / WORK_AUTHOR
  • —alexgoldberg/hebrew-manuscript-joint-ner-v2 — PERSON with role classification

The extracted OWNER / DATE / COLLECTION entities flow into Stage 3 (Authority Resolution) which queries Mazal (NLI authority), VIAF, Wikidata, and KIMA to resolve each entity to a canonical Wikidata QID.

Citation

bibtex
@software{mhm_provenance_ner_2025,
  author = {Goldberg, Alexander},
  title  = {Hebrew Manuscript Provenance NER (OWNER / DATE / COLLECTION)},
  year   = {2025},
  url    = {https://huggingface.co/alexgoldberg/hebrew-manuscript-provenance-ner},
  note   = {Mapping Hebrew Manuscripts (MHM) Pipeline, Bar-Ilan University},
}

License

Apache-2.0. The base model dicta-il/dictabert is © DICTA, used here under its published license.

Acknowledgments

  • —DICTA for the underlying DictaBERT Hebrew language model.
  • —National Library of Israel for the MARC 21 manuscript catalog.
  • —Bar-Ilan University for the MHM project.