ner-german-historic-large
Named-entity recognition for historical German text, a drop-in for
flair/ner-german-large with the same labels (PER, LOC, ORG,
MISC). Runs on CPU with int8 ONNX, in the browser with transformers.js, or with Flair and transformers.
Licensed under CC BY-SA 4.0.
uv run https://huggingface.co/13fragments/ner-german-historic-large/resolve/main/tag_ner.py input/
Faithfulness and local CPU speed
- Long
ſworks with no preprocessing. Unicode NFKC normalization in the tokenizer readsſass, whiletag_ner.pykeeps your original surface text and character offsets intact. All 931 historical test sentences rewritten withſgave identical predictions (eval/longs_probe.json). Across 484 Berlin newspaper Fraktur OCR validation sentences withſ, entity F1 is0.776against0.754forflair/ner-german-large. - CPU, ONNX, and browser speeds. Int8 ONNX (
onnx/model_quantized.onnx,1.4 GB) tags about 2 historical sentences per second on 2 CPU cores (0.50 sper sentence of 32.4 words,onnxruntime, batch 16). Browser runs in the demo Space useonnx/model_int8.onnx(0.86 GB) withtransformers.jsat 0.15 to 0.2 s per example on WebGPU and about 1.2 s on WASM, with no text leaving the browser. - Collection. Part of Historical German text models, alongside the Wikidata/GND entity linker, the German Wikipedia index, and both browser demos.
Usage
Zero-install CPU CLI (tag_ner.py, ONNX Runtime only, Apache-2.0):
uv run https://huggingface.co/13fragments/ner-german-historic-large/resolve/main/tag_ner.py input/ --out tagged/
uv run https://huggingface.co/13fragments/ner-german-historic-large/resolve/main/tag_ner.py \
--text "Der Kaiser reiſte geſtern von Wien nach Innsbruck." --json
Flair (replace flair/ner-german-large in SequenceTagger.load):
from flair.data import Sentence
from flair.models import SequenceTagger
tagger = SequenceTagger.load("13fragments/ner-german-historic-large")
sentence = Sentence("Der Kaiser reiſte geſtern von Wien nach Innsbruck.")
tagger.predict(sentence)
print(sentence.get_spans("ner"))
transformers: pipeline("token-classification", model="13fragments/ner-german-historic-large", aggregation_strategy="first"). transformers.js
and ONNX Runtime: see eval/RESULTS.md. Demo:
historical-german-ner-demo.
Scores
Entity F1 (PER, LOC, ORG; exact span and type) on test sets, mean ± sd of 4 training seeds, against
flair/ner-german-large run by us on the same sentences:
| Test set | This model | flair/ner-german-large |
|---|---|---|
| Historical pool (SoNAR + HisGermaNER + Europeana) | 0.786 ± 0.003 | 0.680 |
| SoNAR (Berlin newspapers) | 0.664 ± 0.007 | 0.583 |
| HisGermaNER (Austrian newspapers, 1720-1840) | 0.785 ± 0.008 | 0.663 |
| Europeana Newspapers (ONB and LFT, held-out last 20 %) | 0.816 ± 0.003 | 0.710 |
| GermEval 2014 (modern German) | 0.907 ± 0.003 | 0.882 |
The release gate was written before training and checked once on the test sets; it passed.
Training data
Human-annotated data only: NewsEye German (CC BY 4.0), HisGermaNER (CC BY 4.0), Europeana Newspapers NER (CC0) and
GermEval 2014 (CC BY-SA 4.0). Base model FacebookAI/xlm-roberta-large. Attributions are in NOTICE.
Evaluation sets
SoNAR (HIPE-2022, CC BY 4.0), HisGermaNER test, our held-out Europeana split (eval/europeana_test_split.jsonl) and
GermEval 2014 test. All are newspaper text; letters, diaries and registers are not measured.
Limits
- Organisations are the weakest type. Historical validation F1 by type: LOC 0.84, PER 0.75, ORG 0.57.
- Speed on CPU. The int8 ONNX file tags about 2 historical sentences per second on 2 CPU cores (0.50 s per sentence of 32.4 words, onnxruntime, batch 16; eval/longs_probe.json).
- Span boundaries. Most errors on historical validation data are boundary errors (the entity is found, but the span is longer or shorter than the gold span): 292 of 618 errors.
- Titles are outside person spans. Like
flair/ner-german-large, the model tags "Graf Bismarck" as title + PER "Bismarck".
Every score with its seed count, the export checks and the failure cases: eval/RESULTS.md.
Publisher: 13fragments