Instructions to use stefan-it/zeitunks-lm-v1-ner-onb with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use stefan-it/zeitunks-lm-v1-ner-onb with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("token-classification", model="stefan-it/zeitunks-lm-v1-ner-onb", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForTokenClassification model = AutoModelForTokenClassification.from_pretrained("stefan-it/zeitunks-lm-v1-ner-onb", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Zeitunks-LM Fine-Tuned On ONB
BiXL-Kron (stefan-it/zeitunks-lm-v1), a bidirectional KronLSTM encoder pretrained on
historical German newspapers, fine-tuned for named entity recognition on ONB (Austrian National Library).
Attention-free and without positional embeddings; the fine-tuning head is a LayerNorm and a linear
classifier on the first piece of every word.
Dataset
- ONB (Austrian National Library): https://aclanthology.org/P18-2020/
- German Europeana NER corpus from the Austrian National Library (ONB), introduced in "A Named Entity Recognition Shootout for German" (Riedl & Padó, ACL 2018).
- Preprocessing: as distributed (Flair
NER_GERMAN_EUROPEANA_ONB) - Entity types:
LOC,ORG,PER(IOB2 tagging, 7 labels includingO) - Splits used for fine-tuning:
| split | sentences | tokens |
|---|---|---|
| train | 1,145 | 27,511 |
| dev | 143 | 3,430 |
| test | 143 | 3,781 |
Fine-tuning
| base model | stefan-it/zeitunks-lm-v1 |
| task head | LayerNorm → dropout 0.1 → linear, on the first piece of each word (pooling: first) |
| optimiser | AdamW (β = 0.9 / 0.999, ε = 1e-8), weight decay 0.0 |
| learning rate | 3e-5, linear warmup over the first 10 % of the steps, then linear decay to 0 |
| batch size | 16 sentences |
| epochs | 10 (model selection: best dev F1, here epoch 8) |
| gradient clipping | 1.0 |
| encoder dropout | 0.1 |
| max length | 512 pieces per chunk (longer sentences are split and re-joined) |
| precision | bf16 autocast |
| seed | 10 |
- Learning rate selected from the grid {5e-6, 1e-5, 2e-5, 3e-5, 5e-5, 1e-4, 2e-4, 4e-4}: every rate was run with 10 seeds (seeds 1 to 10), and the rate with the best mean dev F1 over the seeds was taken. Batch size and number of epochs were not tuned
- This checkpoint is the seed with the best dev F1 at that rate; the test set played no part in the choice
- Fine-tuning ran in deterministic mode: this checkpoint was trained again with saving enabled and wrote the same dev and test predictions, byte for byte, as the run of the grid with the same seed
- Same fine-tuning stack as for every encoder in the BiXL comparison (
finetuning/finetune_ner.pyin the BiXL repository)
Results
Span-level micro F1 (IOB2) on the official splits:
| dev F1 | test F1 | |
|---|---|---|
| this checkpoint | 90.05 | 88.22 (P 87.13 / R 89.34) |
| mean ± std over 10 seeds at this learning rate | 88.90 ± 0.78 | 86.94 ± 1.14 |
- The checkpoint row is a single seed, selected on dev among the seeds; the row below it is the result of the model on this dataset
Learning-rate grid
Mean ± standard deviation (population value) of the span-level F1 over 10 seeds per learning rate; the selected rate is in bold:
| learning rate | dev F1 | test F1 |
|---|---|---|
| 5e-6 | 87.89 ± 0.41 | 85.38 ± 0.74 |
| 1e-5 | 88.70 ± 0.56 | 86.33 ± 0.83 |
| 2e-5 | 88.87 ± 0.64 | 86.82 ± 1.34 |
| 3e-5 | 88.90 ± 0.78 | 86.94 ± 1.14 |
| 5e-5 | 88.84 ± 0.57 | 85.53 ± 1.56 |
| 1e-4 | 86.70 ± 0.85 | 84.92 ± 0.73 |
| 2e-4 | 82.32 ± 1.07 | 80.12 ± 1.56 |
| 4e-4 | 72.56 ± 1.08 | 71.60 ± 1.13 |
Usage
pip install torch transformers 'flash-linear-attention @ git+https://github.com/NX-AI/KronLSTM.git@3d800c9a153a88ee9624fe6acf7f39a58017a17e'
from transformers import AutoModelForTokenClassification, AutoTokenizer, pipeline
name = "stefan-it/zeitunks-lm-v1-ner-onb"
tokenizer = AutoTokenizer.from_pretrained(name)
model = AutoModelForTokenClassification.from_pretrained(name, trust_remote_code=True)
nlp = pipeline("token-classification", model=model, tokenizer=tokenizer, aggregation_strategy="first")
sentence = "Man zeigt an, schreibt der Constitutionnel, daß Staatsrath Langlais das Portefeuille der Mexikanischen Finanzen angenommen hat, das ihm, wie uns aus Paris telegraphirt wurde, vom Kaiser Maximilian angeboten worden ist."
for entity in nlp(sentence):
print(f"{entity['entity_group']:<10} {entity['score']:.3f} {sentence[entity['start']:entity['end']]}")
Output (a sentence from the ONB (Austrian National Library) training split):
ORG 0.997 Constitutionnel
PER 1.000 Langlais
LOC 0.999 Paris
PER 0.999 Maximilian
aggregation_strategy="first"reproduces the training setup (one label per word from its first piece)- The KronLSTM kernels come from the pinned NX-AI fork of
flash-linear-attention(import namefla): Triton on CUDA, a reference implementation on CPU;xlstmis not needed - Right-padding only; inputs are padded to a multiple of 64 pieces internally
License
Apache 2.0
AI provenance
The packaging script and this card were generated by Claude Fable 5.1 (claude-fable-5-1) and Claude Fable 5.2 (claude-fable-5-2); the fine-tuning recipe, the numbers and the dataset choice are the author's. See the base model card for the full provenance of the encoder.
- Downloads last month
- 28
Model tree for stefan-it/zeitunks-lm-v1-ner-onb
Base model
stefan-it/zeitunks-lm-v1