Downloads · 30 days
13
28% of all-time downloads
alexgoldberg/hebrew-manuscript-joint-ner
hebrew-manuscript-joint-ner is a token classification model from alexgoldberg. Use it when you need labels on individual words, such as names. The card lists the license as mit.
Fine-tuned DictaBERT model for joint Named Entity Recognition (NER) and Role Classification on Hebrew manuscript MARC records.
Downloads · 30 days
13
28% of all-time downloads
All-time downloads
46
Public
Repo size
2.2 GB
Likes
0
Public
Click a slice to open those files.
.bin2.2 GB · 100%
From the Hugging Face model README
Fine-tuned DictaBERT model for joint Named Entity Recognition (NER) and Role Classification on Hebrew manuscript MARC records.
This model performs two tasks simultaneously:
The joint training approach achieves superior performance compared to pipeline architectures by sharing representations between the two related tasks.
Extract person names and their roles from Hebrew manuscript catalog records, particularly MARC format bibliographic descriptions.
Primary applications:
L_total = λ * L_NER + (1 - λ) * L_classification
Where λ=0.5 balances the two tasks equally.
| Task | Metric | Score |
|---|---|---|
| NER | Precision | 88.00% |
| NER | Recall | 91.00% |
| NER | F1 Score | 89.40% |
| Classification | Accuracy | 100.00% |
| Task | Metric | Score |
|---|---|---|
| NER | Precision | 47.00% |
| NER | Recall | 81.00% |
| NER | F1 Score | 59.41% |
| Classification | Accuracy | 100.00% |
Note: The gap between validation and test F1 suggests potential overfitting to validation distribution. Future work will address this with more diverse test data.
| Model | Validation F1 | Improvement |
|---|---|---|
| Baseline NER | 55.64% | - |
| + CRF Layer | 84.39% | +28.75 pp |
| Joint Model (This) | 89.40% | +33.76 pp |
pip install transformers torch
from transformers import AutoTokenizer, AutoModelForTokenClassification
import torch
# Load model and tokenizer
model_name = "alexgoldberg/hebrew-manuscript-joint-ner"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForTokenClassification.from_pretrained(model_name)
# Example Hebrew text from manuscript catalog
text = "נכתב על ידי ר' יעקב בן משה"
# Tokenize
inputs = tokenizer(text, return_tensors="pt")
# Get predictions
with torch.no_grad():
outputs = model(**inputs)
predictions = torch.argmax(outputs.logits, dim=-1)
# Decode predictions
tokens = tokenizer.convert_ids_to_tokens(inputs["input_ids"][0])
labels = [model.config.id2label[p.item()] for p in predictions[0]]
# Print results
for token, label in zip(tokens, labels):
if token not in ['[CLS]', '[SEP]', '[PAD]']:
print(f"{token}: {label}")
def extract_entities(text, model, tokenizer):
"""Extract PERSON entities from Hebrew text"""
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
predictions = torch.argmax(outputs.logits, dim=-1)
tokens = tokenizer.convert_ids_to_tokens(inputs["input_ids"][0])
labels = [model.config.id2label[p.item()] for p in predictions[0]]
entities = []
current_entity = []
for token, label in zip(tokens, labels):
if label == 'B-PERSON':
if current_entity:
entities.append(''.join(current_entity))
current_entity = [token.replace('##', '')]
elif label == 'I-PERSON' and current_entity:
current_entity.append(token.replace('##', ''))
else:
if current_entity:
entities.append(''.join(current_entity))
current_entity = []
if current_entity:
entities.append(''.join(current_entity))
return entities
# Example
text = "כתב ר' אברהם בן דוד והעתיק משה הסופר"
entities = extract_entities(text, model, tokenizer)
print("Found entities:", entities)
# Output: ['אברהם בן דוד', 'משה הסופר']
If you use this model, please cite:
@misc{goldberg2025hebrewjoint,
author = {Goldberg, Alexander},
title = {Hebrew Manuscript Joint Entity-Role Extraction Model},
year = {2025},
publisher = {HuggingFace},
url = {https://huggingface.co/alexgoldberg/hebrew-manuscript-joint-ner}
}
MIT License - See LICENSE file for details.
Alexander Goldberg