Instructions to use lexedit/herbert-polish-legal-ner with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use lexedit/herbert-polish-legal-ner with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("token-classification", model="lexedit/herbert-polish-legal-ner")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForTokenClassification tokenizer = AutoTokenizer.from_pretrained("lexedit/herbert-polish-legal-ner") model = AutoModelForTokenClassification.from_pretrained("lexedit/herbert-polish-legal-ner", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download examples/STRONG_CASES.md from lexedit/herbert-polish-legal-ner: direct link, hf CLI and curl.
- Browser
- Download file 2.33 kB
-
https://huggingface.co/lexedit/herbert-polish-legal-ner/resolve/main/examples/STRONG_CASES.md
- Command line
-
hf download hf://lexedit/herbert-polish-legal-ner/examples/STRONG_CASES.md
-
curl -L -o STRONG_CASES.md https://huggingface.co/lexedit/herbert-polish-legal-ner/resolve/main/examples/STRONG_CASES.md
Where the model shines — hard cases handled well
Difficult inputs this general-purpose model gets right. All inputs are
synthetic (fictional names); outputs are the model's actual predictions
(quantized ONNX, recall-first PER threshold 0.2). Reproduce with
strong_cases.py.
Polish inflection (declension)
Polish surnames change form by grammatical case; the model tags the full inflected surface, not just the nominative:
| Input | Case | Model |
|---|---|---|
Pozew skierowano przeciwko Jerzemu Sekule. |
dative | PER 'Jerzemu Sekule' |
Sprawa dotyczy akt Wojciecha Michalika. |
genitive | PER 'Wojciecha Michalika' |
Tricky surface forms
| Input | Why it's hard | Model |
|---|---|---|
Powódka Anna Nowak-Kowalska złożyła wniosek. |
hyphenated double surname → one span | PER 'Anna Nowak-Kowalska' |
Stawiła się ALEKSANDRA ŚWIDERSKA, pełnomocnik. |
ALL-CAPS header/signature style | PER 'ALEKSANDRA ŚWIDERSKA' |
Z poważaniem, / Iga Mełech / radca prawny |
short female first + rare surname in a low-cue signature | PER 'Iga Mełech' |
Mild / moderate OCR noise
Light scan corruption (missing diacritics, a few confusable characters) is still handled:
| Input | Behind the garble | Model |
|---|---|---|
Pozwany Damian Zotadek wniósł odpowiedź na pozew. |
Damian Żołądek (lost diacritics) | PER 'Damian Zotadek' |
Z powództwa Jiga Bękowiki przeciwko spółce. |
Jaga Bętkowski | PER 'Jiga Bękowiki' |
Pełnomocnik: Ptek Gostoiski, adwokat. |
Patryk Gostomski | PER 'Ptek Gostoiski' |
Heavy OCR garble is this variant's weak spot — see
KNOWN_LIMITATIONS.md. For scanned documents prefer the OCR-robust variant.
Multiple types + public/private distinction
Jan Kowalski, zam. ul. Słoneczna 5 w Krakowie, PESEL 02070803628.
PER 'Jan Kowalski'
LOC 'ul. Słoneczna 5' ← private address (masked)
LOC_PUB 'Krakowie' ← public city (kept by default)
ID '02070803628' ← national id (PESEL)
The model keeps the public place (Krakowie) visible while masking the private
street address — so the legal context survives anonymisation.