GolemPII v2: Hebrew PII detection

Demo: try it Blog: read the write-up GitHub: code and examples Parameters: 125M REDACT F1: 0.916 Language: Hebrew Licence: MIT Cite: BibTeX Author: liranbaba.dev

GolemPII v2 small

Version 2.0, 2026-11-13.

A smaller variant of GolemPII-v2-base: the same 15 labels and the same training data on the Hebrew encoder HalleluBERT/HalleluBERT_base (125M parameters, less than half the main model's size, at the same speed).

  • On Hebrew prose it is the strongest of the three models at telling person names from organisations and ordinary words.
  • On enterprise text it matches the main model overall and finds fewer account numbers.

The labels, the training data, the way the scores are measured and the limits are described in the main model's card. The numbers below are from the REDACT final half, scored once after training, and from NEMO, which was never trained on.

Which model should I use

Model Parameters Use it for
GolemPII-v2-base 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 (this model) 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

Usage

from transformers import pipeline

detector = pipeline(
    "token-classification",
    model="CordwainerSmith/GolemPII-v2-small",
    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

The evaluation code published with GolemPII-v2-base produced every number below, and scores any token-classification model on the same sets.

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
GolemPII-v2-small 125M 0.890 / 0.943 / 0.916 0.867 / 0.974 / 0.917

A second training run with another seed scored 0.916 and 0.919.

By category (entity level, P / R / F1)

Category GolemPII-v1 GolemPII-v2-base GolemPII-v2-small
Person 0.804 / 0.900 / 0.849 0.888 / 0.986 / 0.934 0.885 / 0.981 / 0.930
Address 0.597 / 1.000 / 0.747 0.777 / 1.000 / 0.874 0.781 / 1.000 / 0.877
Phone 0.238 / 0.969 / 0.383 0.940 / 0.993 / 0.966 0.927 / 0.993 / 0.959
Email 0.763 / 0.996 / 0.864 0.940 / 0.998 / 0.968 0.934 / 0.998 / 0.965
Account (identity, card and bank numbers) 0.265 / 0.844 / 0.403 0.762 / 0.905 / 0.827 0.723 / 0.820 / 0.768

By label (character F1)

EMAIL 0.976, PHONE_NUM 0.950, PASSPORT_NUM 0.940, LAST_NAME 0.933, ID_NUM 0.931, FIRST_NAME 0.921, CITY 0.708, CC_NUM 0.628, DATE 0.530, DRIVER_LICENSE_NUM 0.395.

Code-switching (REDACT final, character F1)

No English 0.932, light 0.901, heavy 0.915.

Person names on real text (NEMO)

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
GolemPII-v2-small 0.928 / 0.956 / 0.942 0.7

A second seed scored 0.927 / 0.960 / 0.943. NEMO was never used for training. 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

FIRST_NAME F1 0.978, LAST_NAME F1 0.957.

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.

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

All limits of the main model apply. In addition:

  • Account numbers: it finds fewer identity, card and bank numbers than the main model (entity recall 0.820 against 0.905).
  • Organisations named like people are still the most common name error on news text (93 of the 2,589 person spans it predicts on NEMO), though far less often than for the main model.

Training

Same data and settings as the main model, 3 epochs.

Citation

If you use this model in a product, a paper or a derived model, please credit it as: GolemPII-v2-small by Liran Baba, with a link to https://huggingface.co/CordwainerSmith/GolemPII-v2-small.

@misc{baba2026golempii_v2_small,
  author       = {Baba, Liran},
  title        = {GolemPII v2 small: personal information detection for Hebrew text},
  year         = {2026},
  version      = {2.0},
  publisher    = {Hugging Face},
  howpublished = {\url{https://huggingface.co/CordwainerSmith/GolemPII-v2-small}}
}

Licence and credits

MIT, copyright (c) 2026 Liran Baba. The LICENSE file holds the full text.

  • Encoder: HalleluBERT/HalleluBERT_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.
Downloads last month
58
Safetensors
Model size
0.1B params
Tensor type
F32
Β·
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for CordwainerSmith/GolemPII-v2-small

Finetuned
(1)
this model

Space using CordwainerSmith/GolemPII-v2-small 1

Evaluation results