Instructions to use stefan-it/zeitunks-lm-v1-ner-lft 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-lft 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-lft", 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-lft", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Zeitunks-LM Fine-Tuned On LFT
BiXL-Kron (stefan-it/zeitunks-lm-v1), a bidirectional KronLSTM encoder pretrained on
historical German newspapers, fine-tuned for named entity recognition on LFT (Dr Friedrich Teßmann 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
- LFT (Dr Friedrich Teßmann library): https://aclanthology.org/P18-2020/
- German Europeana NER corpus from the Dr Friedrich Teßmann library (South Tyrol), introduced in "A Named Entity Recognition Shootout for German" (Riedl & Padó, ACL 2018).
- Preprocessing: as distributed (Flair
NER_GERMAN_EUROPEANA_LFT) - Entity types:
LOC,MISC,ORG,PER(IOB2 tagging, 8 labels includingO) - Splits used for fine-tuning:
| split | sentences | tokens |
|---|---|---|
| train | 2,812 | 69,774 |
| dev | 352 | 8,803 |
| test | 352 | 7,947 |
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 | 2e-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 | 9 |
- 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 | 80.52 | 80.33 (P 78.07 / R 82.73) |
| mean ± std over 10 seeds at this learning rate | 79.86 ± 0.52 | 79.90 ± 0.36 |
- 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 | 77.71 ± 0.41 | 78.57 ± 0.88 |
| 1e-5 | 79.00 ± 0.61 | 79.00 ± 0.78 |
| 2e-5 | 79.86 ± 0.52 | 79.90 ± 0.36 |
| 3e-5 | 79.53 ± 0.57 | 79.91 ± 0.95 |
| 5e-5 | 79.21 ± 0.67 | 79.50 ± 0.95 |
| 1e-4 | 76.80 ± 0.68 | 76.81 ± 1.24 |
| 2e-4 | 72.35 ± 0.62 | 71.87 ± 1.60 |
| 4e-4 | 63.73 ± 0.68 | 64.67 ± 1.11 |
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-lft"
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 = "Ueber dringliche Einladung des Herrn Oberhammer, Präsidenten des Bauern bundes, fand heute abends im Sekretariat des Bmiernbundes eine Besprechung der Herren Oberhammer, Meniz-Marlengo und Hartmann - Mlaia bassa statt."
for entity in nlp(sentence):
print(f"{entity['entity_group']:<10} {entity['score']:.3f} {sentence[entity['start']:entity['end']]}")
Output (a sentence from the LFT (Dr Friedrich Teßmann library) training split):
PER 0.999 Oberhammer
ORG 0.999 Bauern bundes
ORG 0.999 Bmiernbundes
PER 0.997 Oberhammer
PER 0.924 -
LOC 0.990 Marlengo
PER 0.999 Hartmann
PER 0.998 -
LOC 0.997 Mlaia bassa
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
- 26
Model tree for stefan-it/zeitunks-lm-v1-ner-lft
Base model
stefan-it/zeitunks-lm-v1