Instructions to use CordwainerSmith/GolemPII-v2-base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use CordwainerSmith/GolemPII-v2-base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("token-classification", model="CordwainerSmith/GolemPII-v2-base")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForTokenClassification tokenizer = AutoTokenizer.from_pretrained("CordwainerSmith/GolemPII-v2-base") model = AutoModelForTokenClassification.from_pretrained("CordwainerSmith/GolemPII-v2-base", device_map="auto") - Notebooks
- Google Colab
- Kaggle
GolemPII v2 base
Version 2.0, 2026-11-13.
A token classifier that finds personal information in Hebrew text, including Hebrew mixed with English as it appears in enterprise systems: emails, tickets, chat, key-value records, JSON and logs.
- Encoder:
xlm-roberta-base(277M parameters) - Labels: 15 (below), BIO tagging
- Languages: Hebrew, and English embedded in Hebrew text
- Replaces:
CordwainerSmith/GolemPII-v1
Which model should I use
| Model | Parameters | Use it for |
|---|---|---|
| GolemPII-v2-base (this model) | 277M | Hebrew mixed with English in enterprise text (emails, tickets, logs, JSON), and the best recall of the three on identity, card and bank numbers |
| GolemPII-v2-small | 125M | Hebrew prose: the best of the three at telling person names from organisations, at less than half the size of base and the same speed |
| GolemPII-v2-tiny | 45M | When speed or size matters most (about five times faster), with lower accuracy on enterprise text |
Labels
| Group | Labels |
|---|---|
| Person | FIRST_NAME, LAST_NAME |
| Identity documents | ID_NUM, PASSPORT_NUM, DRIVER_LICENSE_NUM |
| Financial | BANK_ACCOUNT_NUM, IBAN, CC_NUM, CC_PROVIDER |
| Contact | PHONE_NUM, EMAIL |
| Address | STREET, CITY, POSTAL_CODE |
| Other | DATE |
Masked card numbers (**** **** **** 1234) are labelled CC_NUM. Organisations, job titles, countries, and reference numbers such as order, ticket and employee numbers are not labelled.
Usage
from transformers import pipeline
detector = pipeline(
"token-classification",
model="CordwainerSmith/GolemPII-v2-base",
aggregation_strategy="simple",
stride=128, # lets the pipeline handle texts longer than 512 tokens
)
TEXT = """Χ ΧΧ©Χ: RE: ticket #48213 - Χ’ΧΧΧΧ Χ€Χ¨ΧΧ ΧΧ§ΧΧ
ΧΧΧ Χ¨ΧΧ ΧΧͺ,
ΧΧΧ§ΧΧ ΧΧΧΧ ΧΧ ΧΧΧ (Χͺ.Χ. 034567891) ΧΧͺΧ§Χ©Χ¨ ΧΧΧΧ§Χ¨ ΧΧΧΧ§Χ© ΧΧ’ΧΧΧ ΧΧͺ ΧΧΧͺΧΧΧͺ ΧΧΧ©ΧΧΧ: Χ¨ΧΧΧ ΧΧ¨Χ¦Χ 42, Χ¨ΧΧͺ ΧΧ, ΧΧΧ§ΧΧ 5244302.
ΧΧ€Χ©Χ¨ ΧΧΧ©ΧΧ ΧΧΧͺΧ Χ-054-7731920 ΧΧ ΧΧΧΧΧ yoav.bendavid@example.com.
ΧΧΧΧΧ ΧΧΧΧΧ©Χ ΧΧ¨Χ ΧΧΧ¨ΧΧΧ‘ ΧΧΧΧ 4580 1234 5678 9015, ΧΧΧΧΧΧΧ ΧΧΧ’ΧΧ¨ ΧΧΧ©ΧΧΧ IL620108000000099999999.
order_id=ORD-2024-88127, Χ‘ΧΧΧ: 349.90 Χ©"Χ, ΧͺΧΧ¨ΧΧ ΧΧΧΧ ΧΧΧΧΧΧͺ: 14/03/1987.
ΧͺΧΧΧ,
Dana Levi | Customer Success"""
EDGE_PUNCTUATION = " .,;:!?()[]{}\"'-"
def clean_spans(text, entities):
"""Trim punctuation from span edges and join spans of one label that touch or overlap."""
spans = []
for entity in entities:
start, end, label = entity["start"], entity["end"], entity["entity_group"]
while start < end and text[start] in EDGE_PUNCTUATION:
start += 1
while end > start and text[end - 1] in EDGE_PUNCTUATION:
end -= 1
if start == end:
continue
if spans and spans[-1][2] == label and start <= spans[-1][1]:
spans[-1] = (spans[-1][0], max(end, spans[-1][1]), label)
else:
spans.append((start, end, label))
return spans
def redact(text, spans):
pieces, position = [], 0
for start, end, label in spans:
pieces += [text[position:start], f"[{label}]"]
position = end
return "".join(pieces) + text[position:]
spans = clean_spans(TEXT, detector(TEXT))
for start, end, label in spans:
print(f"{label:<12} {TEXT[start:end]}")
print(redact(TEXT, spans))
The detected spans:
FIRST_NAME Χ¨ΧΧ ΧΧͺ
FIRST_NAME ΧΧΧΧ
LAST_NAME ΧΧ ΧΧΧ
ID_NUM 034567891
STREET Χ¨ΧΧΧ ΧΧ¨Χ¦Χ 42
CITY Χ¨ΧΧͺ ΧΧ
POSTAL_CODE 5244302
PHONE_NUM 054-7731920
EMAIL yoav.bendavid@example.com
CC_PROVIDER ΧΧΧΧ
CC_NUM 4580 1234 5678 9015
IBAN IL620108000000099999999
DATE 14/03/1987
FIRST_NAME Dana
LAST_NAME Levi
The redacted text. The ticket number, the order id and the amount are left alone:
Χ ΧΧ©Χ: RE: ticket #48213 - Χ’ΧΧΧΧ Χ€Χ¨ΧΧ ΧΧ§ΧΧ
ΧΧΧ [FIRST_NAME],
ΧΧΧ§ΧΧ [FIRST_NAME] [LAST_NAME] (Χͺ.Χ. [ID_NUM]) ΧΧͺΧ§Χ©Χ¨ ΧΧΧΧ§Χ¨ ΧΧΧΧ§Χ© ΧΧ’ΧΧΧ ΧΧͺ ΧΧΧͺΧΧΧͺ ΧΧΧ©ΧΧΧ: [STREET], [CITY], ΧΧΧ§ΧΧ [POSTAL_CODE].
ΧΧ€Χ©Χ¨ ΧΧΧ©ΧΧ ΧΧΧͺΧ Χ-[PHONE_NUM] ΧΧ ΧΧΧΧΧ [EMAIL].
ΧΧΧΧΧ ΧΧΧΧΧ©Χ ΧΧ¨Χ ΧΧΧ¨ΧΧΧ‘ [CC_PROVIDER] [CC_NUM], ΧΧΧΧΧΧΧ ΧΧΧ’ΧΧ¨ ΧΧΧ©ΧΧΧ [IBAN].
order_id=ORD-2024-88127, Χ‘ΧΧΧ: 349.90 Χ©"Χ, ΧͺΧΧ¨ΧΧ ΧΧΧΧ ΧΧΧΧΧΧͺ: [DATE].
ΧͺΧΧΧ,
[FIRST_NAME] [LAST_NAME] | Customer Success
clean_spans is optional. The pipeline groups sub-word tokens, so a raw span can carry a bracket, a hyphen or a full stop at its edge, or arrive in two pieces; the function trims and joins them. The scores on this page were measured on the raw pipeline output, without it.
With Microsoft Presidio
A ready recognizer for Presidio is in the GitHub repo. It registers this model for language he, maps the labels to Presidio entity names, and works with the standard analyze and anonymize calls.
Results
All numbers below are from text the model was not trained on. REDACT is an external benchmark of enterprise-style Hebrew text. Its Hebrew part was split once into two halves: select, used for every decision during development, and final, scored once after the model was frozen. The numbers here are from final (311 records, 4,936 entities).
Two measures are reported. Character level counts every character of a span. Entity level counts an entity as found when a span of the right category touches it, so it does not depend on where span boundaries are drawn. REDACT has five categories; our 15 labels are mapped onto them, and a CITY span on its own is not counted as an address.
REDACT final, five categories
| Model | Parameters | Character P / R / F1 | Entity P / R / F1 |
|---|---|---|---|
| GolemPII-v1 | 277M | 0.592 / 0.884 / 0.709 | 0.601 / 0.913 / 0.725 |
| GolemPII-v2-base | 277M | 0.886 / 0.951 / 0.917 | 0.872 / 0.983 / 0.924 |
A second training run with another seed scored 0.914 and 0.927.
REDACT final, by category (entity level, P / R / F1)
| Category | GolemPII-v1 | GolemPII v2 |
|---|---|---|
| Person | 0.804 / 0.900 / 0.849 | 0.888 / 0.986 / 0.934 |
| Address | 0.597 / 1.000 / 0.747 | 0.777 / 1.000 / 0.874 |
| Phone | 0.238 / 0.969 / 0.383 | 0.940 / 0.993 / 0.966 |
| 0.763 / 0.996 / 0.864 | 0.940 / 0.998 / 0.968 | |
| Account (identity, card and bank numbers) | 0.265 / 0.844 / 0.403 | 0.762 / 0.905 / 0.827 |
REDACT final, by label (character F1)
| Label | Entities | F1 |
|---|---|---|
EMAIL |
454 | 0.975 |
PHONE_NUM |
288 | 0.951 |
LAST_NAME |
1,025 | 0.937 |
ID_NUM |
203 | 0.932 |
FIRST_NAME |
1,208 | 0.918 |
PASSPORT_NUM |
35 | 0.915 |
CITY |
261 | 0.745 |
CC_NUM |
53 | 0.671 |
DATE |
571 | 0.530 |
DRIVER_LICENSE_NUM |
13 | 0.411 |
REDACT has no entities for BANK_ACCOUNT_NUM, IBAN, CC_PROVIDER, STREET and POSTAL_CODE under our mapping, so those labels have no external score. DATE and CITY conventions differ between REDACT and our labels, which lowers both.
Code-switching (REDACT final, character F1)
| Amount of English in the text | GolemPII-v1 | GolemPII v2 |
|---|---|---|
| None | 0.704 | 0.930 |
| Light | 0.677 | 0.906 |
| Heavy | 0.739 | 0.916 |
Person names on real text
NEMO is a human-labelled corpus of Hebrew news sentences (6,143 sentences, 2,588 person mentions). It was never used for training, and it was read once, after the model was chosen.
| Model | Person P / R / F1 | False phone, email and account spans per 1,000 sentences |
|---|---|---|
| GolemPII-v1 | 0.541 / 0.824 / 0.653 | 3.3 |
| GolemPII-v2-base | 0.853 / 0.925 / 0.887 | 1.3 |
A second seed scored 0.898 / 0.891 / 0.895. The training data includes real sentences from another news and encyclopedia corpus (IAHLT), which helps on text of this kind.
Names the model has never seen
On held-out templates filled with 1,436 first and last names that appear nowhere in training: FIRST_NAME F1 0.972, LAST_NAME F1 0.954.
Speed and size
Measured on an Apple M4 Pro (48 GB, macOS 27.0.1, torch 2.15.0, transformers 5.22.1) over 1,000 synthetic enterprise-style texts with a mean length of 1,512 characters, with the pipeline settings shown under Usage and batch size 8. Median of three runs; other programs were running, so treat differences of a few percent as noise.
| Model | Parameters | File size | Seconds per 1,000 texts, Apple GPU (MPS) | Seconds per 1,000 texts, CPU |
|---|---|---|---|---|
| GolemPII-v2-base | 277M | 1,110 MB | 63.8 | 115.6 |
| GolemPII-v2-small | 125M | 502 MB | 65.8 | 120.9 |
| GolemPII-v2-tiny | 45M | 179 MB | 13.0 | 15.6 |
The small model is less than half the size of the base model on disk and in memory, and runs at the same speed: both have a 12-layer encoder, and the base model's extra parameters are its larger vocabulary table. The tiny model is about five times faster on the GPU and seven times faster on the CPU.
Training data
The model is trained on synthetic text only for everything except names in context.
- Templates: 3,000 texts with placeholders, written by an LLM (Gemini Flash) in enterprise formats, half Hebrew-only and half mixed with English. The LLM never writes a PII value. Each template is filled six times by a script: names, cities and streets from lexicons, numbers generated with valid checksums (Israeli identity numbers, cards, IBAN). Templates also contain placeholders for look-alike values that are not PII (order numbers, amounts, timestamps, IP addresses, company names), which are left unlabelled.
- Real sentences with swapped names: 20,000 texts from the IAHLT named-entity corpus (news, Wikipedia, Knesset). In 70% of them every person name is replaced with a lexicon name; 30% keep their original names. Organisations and titles stay unlabelled. Places and time expressions are trained as "not a person name".
- 38,000 training examples in total, 3 epochs, learning rate 3e-5, batch size 16.
No real personal data from any private source was used.
The real sentences come from the IAHLT Hebrew named-entity dataset (github.com/IAHLT/hebrew_named_entities_open_dataset, Apache-2.0).
Intended use and out of scope
Intended use: finding personal information in Hebrew text, and in Hebrew mixed with English, to assist redaction, masking and data-loss-prevention review.
Out of scope or not evaluated:
- Other languages. Arabic, and English text on its own, were not evaluated.
- Other sources. Speech transcripts, OCR output and handwriting were not evaluated.
- Anonymisation. The model is a detector that assists redaction, not a guarantee of anonymisation or of compliance with any privacy law. Text that must be anonymised needs human review.
- Other entity types. Organisations, job titles, countries and reference numbers (order, ticket and employee numbers) are not labelled.
Limits
- Organisations named like people. On news text the model tags some sports clubs, companies and firms named after their founders as people. This is its main error on NEMO, and the amount differs between training runs.
- Account numbers: 0.905 of the identity, card and bank numbers in REDACT are found. Reference numbers such as customer and student numbers are not labelled by this model, by design. Known misses: references to the last four digits of a card ("ending 4821"), tax file numbers, passport numbers inside a machine-readable line, and identity numbers glued to other text. Obfuscated emails ("name AT domain DOT com") are missed.
- Driver licence and card numbers score low on REDACT (0.411 and 0.671 character F1, on 13 and 53 entities).
- Dates:
DATEscores 0.530 on REDACT, whose date labelling differs from ours; treat date detection as weak. - Span boundaries: address spans are often shorter than REDACT's (the street name without the word "street"), which lowers character-level address scores while the entities are still found.
- Only names are tested on real text. Numeric PII in real enterprise text is tested only on REDACT, which is itself synthetic, and on our own held-out templates.
Smaller variants
Trained on the same data with the same settings, except that the tiny model is trained for 10 epochs; REDACT final.
| Model | Encoder | Parameters | Character F1 | Entity F1 | NEMO person P / R / F1 |
|---|---|---|---|---|---|
| GolemPII-v2-base (this model) | xlm-roberta-base |
277M | 0.917 | 0.924 | 0.853 / 0.925 / 0.887 |
| GolemPII-v2-small | HalleluBERT_base |
125M | 0.916 | 0.917 | 0.928 / 0.956 / 0.942 |
| GolemPII-v2-tiny | dictabert-tiny |
45M | 0.884 | 0.874 | 0.856 / 0.945 / 0.899 |
GolemPII-v2-small is stronger on Hebrew prose and weaker on account numbers. GolemPII-v2-tiny is about five times faster than this model on a GPU; GolemPII-v2-small runs at the same speed as this model.
Reproducing the numbers
The evaluation/ folder holds the scoring code used for every number on this page. With uv installed, from that folder:
# REDACT, character level (add --redact-split select for the decision half)
uv run compare.py --redact-split final --model v2=CordwainerSmith/GolemPII-v2-base:golempii_v2
# REDACT, entity level
uv run independent_checks.py --redact-split final --model v1=CordwainerSmith/GolemPII-v1:golempii --model v2=CordwainerSmith/GolemPII-v2-base:golempii_v2
# Person names on NEMO (needs the NEMO files, see the docstring of real_text_check.py)
uv run real_text_check.py --model v1=CordwainerSmith/GolemPII-v1:golempii --model v2=CordwainerSmith/GolemPII-v2-base:golempii_v2
REDACT is a gated dataset (guneeshv/REDACT-PII-Benchmark); the scripts need an HF_TOKEN with access to it. compare.py scores GolemPII-v1 by default; any other token-classification model can be added with --model NAME=REPO:LABEL_MAP, where the label map is golempii or golempii_v2.
Citation
If you use this model in a product, a paper or a derived model, please credit it as: GolemPII-v2-base by Liran Baba, with a link to https://huggingface.co/CordwainerSmith/GolemPII-v2-base.
@misc{baba2026golempii_v2_base,
author = {Baba, Liran},
title = {GolemPII v2 base: personal information detection for Hebrew text},
year = {2026},
version = {2.0},
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/CordwainerSmith/GolemPII-v2-base}}
}
Licence and credits
MIT, copyright (c) 2026 Liran Baba. The LICENSE file holds the full text.
- Encoder:
FacebookAI/xlm-roberta-base(MIT). - Real training sentences: IAHLT Hebrew named-entity dataset,
github.com/IAHLT/hebrew_named_entities_open_dataset(Apache-2.0), with person names replaced as described above. - Evaluation: REDACT PII Benchmark, NEMO corpus.
- Downloads last month
- 37
Model tree for CordwainerSmith/GolemPII-v2-base
Base model
FacebookAI/xlm-roberta-baseSpace using CordwainerSmith/GolemPII-v2-base 1
Evaluation results
- Precision (character level) on REDACT PII Benchmark (Hebrew, held-out half)Evaluation code in GolemPII-v2-base0.886
- Recall (character level) on REDACT PII Benchmark (Hebrew, held-out half)Evaluation code in GolemPII-v2-base0.951
- F1 (character level) on REDACT PII Benchmark (Hebrew, held-out half)Evaluation code in GolemPII-v2-base0.917
- Precision (entity level) on REDACT PII Benchmark (Hebrew, held-out half)Evaluation code in GolemPII-v2-base0.872
- Recall (entity level) on REDACT PII Benchmark (Hebrew, held-out half)Evaluation code in GolemPII-v2-base0.983
- F1 (entity level) on REDACT PII Benchmark (Hebrew, held-out half)Evaluation code in GolemPII-v2-base0.924
- Precision (person) on NEMO corpus, person namesEvaluation code in GolemPII-v2-base0.853
- Recall (person) on NEMO corpus, person namesEvaluation code in GolemPII-v2-base0.925
