cs_ner_sm

A small, CPU-friendly spaCy pipeline for Czech named entity recognition (PER, ORG, LOC) with rule-based detection of Czech identifiers and contacts. MIT-licensed, commercial use allowed.

Feature Value
Name cs_ner_sm
Version 0.3.1
spaCy >=3.8.18,<3.9.0
Pipeline tok2vec, ner, cs_pii_rules
Statistical labels PER, ORG, LOC
Rule-based labels BIRTH_NUMBER, COMPANY_ID, VAT_ID, BANK_ACCOUNT, PHONE, EMAIL, WEB
Vectors none (tok2vec pretrained with spacy pretrain on Czech Wikinews/Wikipedia text)
License MIT
Author Luis Reyes Aldaco (legalatlas.io)

Installation

pip install https://huggingface.co/LuisRey6/cs_ner_sm/resolve/main/cs_ner_sm-0.3.1-py3-none-any.whl

Usage

import spacy

nlp = spacy.load("cs_ner_sm")
doc = nlp("Smlouvu podepsal Petr Dvořák z firmy Škoda Auto a.s. v Mladé Boleslavi, "
          "IČO 00177041, tel. +420 777 123 456.")
print([(e.text, e.label_) for e in doc.ents])
# [('Petr Dvořák', 'PER'), ('Škoda Auto a.s.', 'ORG'), ('Mladé Boleslavi', 'LOC'),
#  ('00177041', 'COMPANY_ID'), ('+420 777 123 456', 'PHONE')]

To use only the statistical model, spacy.load("cs_ner_sm", exclude=["cs_pii_rules"]).

Components

  • Tokenizer (spacy_cs.ud_tokenizer.v1): Czech tokenization aligned with the Czech Universal Dependencies treebanks (periods split from abbreviations and initials), the same rules proposed to spaCy in explosion/spaCy#14079.
  • ner: CNN transition-based NER (spaCy TransitionBasedParser.v2).
  • cs_pii_rules (mode="ids"): regular expressions with checksum validation where one exists (rodné číslo, IČO, bank account numbers, IBAN). Identifiers win over overlapping model spans.

Accuracy

Measured on the Czech Named Entity Corpus 2.0 (CNEC), mapped to PER/ORG/LOC (person names → PER, geographical names → LOC, institutions → ORG; outermost mapped entity). CNEC was used only for evaluation, never for training. The model was chosen on the CNEC dev set and measured once on test.

CNEC 2.0 test, F1 PER ORG LOC micro
cs_ner_sm 0.3.0 0.746 0.469 0.640 0.641
cs_ner_sm 0.2.0 0.702 0.436 0.632 0.610
cs_ner_sm 0.1.0 0.696 0.416 0.624 0.599
cs-core-news-sm 0.2.1 (CC BY-NC-SA) 0.642 0.255 0.562 0.515
Claude Haiku 5.5 via API (the annotator; reference, not a local model) 0.895 0.664 0.771 —

CNEC's annotation guidelines differ from ours (e.g. media and products), which lowers ORG scores for every system. On our own held-out dev set (692 sentences, same annotation scheme as training): F 0.833.

Changes

  • 0.3.1: same model as 0.3.0, same predictions. The vocabulary string store saved by training, which listed the words of the training corpus, is now emptied (the model uses hashed embeddings and does not need it); predictions were checked to be identical on 2,596 sentences.
  • 0.3.0: text in capitals (headlines such as "PRAHA (ČTK)", surnames such as "Jarmily JEŽKOVÉ"): 3 % of the training sentences are copied in capitals and another 3 % with only the entities in capitals. Sports results ("Sokol Svádov - Černovice 2:1"): each team is now its own ORG instead of one span across the dash. More foreign names with particles ("Konstantin von Neurath"). Rules: IČO with any digit grouping; phone numbers with dashes only after a phone keyword (so "č. j. 603-123-456" is not a phone).
  • 0.2.0: names with initials ("J. Novák", "T. G. Masaryk", "George W. Bush"). The sentence splitter used to build 0.1.0's data cut sentences after initials, so the model had almost no such examples (CNEC dev: 8 of 24 names with initials found; now 19 of 24). Identifier labels ("DIČ", "IČO") are no longer tagged as organizations.
  • 0.1.0: first version (not released).

Training data

About 60,600 sentences (95,741 entities), annotated automatically with Claude Haiku 5.5 (Anthropic) using a fixed annotation guide; no human correction. Plus 600 generated lines of sports results (team names taken from the list of Czech municipalities) and capitalized copies of 6 % of the sentences.

Source License
Czech Wikinews CC BY 4.0
Czech Wikipedia CC BY-SA 4.0
Czech court decisions (rozhodnuti.justice.cz) official work, not protected by copyright (§ 3 Act No. 121/2000 Coll.)

The pipeline does not contain or redistribute the training text (since 0.3.1 not even its word list: the vocabulary string store is empty).

Limitations

  • ORG is the weakest label: long institution names are often cut, and media, products and events are not tagged as ORG.
  • The annotations are machine-made; systematic errors of the annotator are learned by the model.
  • Rule-based identifiers cover Czech formats only.
  • Text written entirely in capitals is still less reliable than normal text: names can be missed.
  • A surname that is also a place name ("Brody", "Louny") or a nickname in capitals may be missed.
Downloads last month
87
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Evaluation results

  • micro F1 on Czech Named Entity Corpus 2.0 (test, mapped to PER/ORG/LOC)
    self-reported
    0.641
  • PER F1 on Czech Named Entity Corpus 2.0 (test, mapped to PER/ORG/LOC)
    self-reported
    0.746
  • ORG F1 on Czech Named Entity Corpus 2.0 (test, mapped to PER/ORG/LOC)
    self-reported
    0.469
  • LOC F1 on Czech Named Entity Corpus 2.0 (test, mapped to PER/ORG/LOC)
    self-reported
    0.640