GLiNER2
Safetensors
Basque
Spanish
English
extractor
named-entity-recognition
ner
basque
euskara
pii
privacy
information-extraction
Eval Results (legacy)
Instructions to use tknika/gliner2-PII-basque with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- GLiNER2
How to use tknika/gliner2-PII-basque with GLiNER2:
from gliner2 import AutoExtractor extractor = AutoExtractor.from_pretrained("tknika/gliner2-PII-basque") # Extract entities text = "Apple CEO Tim Cook announced iPhone 15 in Cupertino yesterday." result = extractor.extract_entities(text, ["company", "person", "product", "location"]) print(result) - Notebooks
- Google Colab
- Kaggle
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -2,6 +2,9 @@
|
|
| 2 |
license: apache-2.0
|
| 3 |
base_model:
|
| 4 |
- fastino/gliner2-privacy-filter-PII-multi
|
|
|
|
|
|
|
|
|
|
| 5 |
library_name: gliner2
|
| 6 |
language:
|
| 7 |
- eu
|
|
@@ -29,12 +32,14 @@ The base model recognizes 42 PII entity types, but underperforms on Basque text:
|
|
| 29 |
Two data sources were combined (experience replay):
|
| 30 |
|
| 31 |
- **Basque NER**: the `nerc_id` split of [orai-nlp/basqueGLUE](https://huggingface.co/datasets/orai-nlp/basqueGLUE) (EIEC + naiz.eus, manually annotated PER/LOC/ORG/MISC; 2,842 sentences), mapped to the base model's existing types: `person name`, `location`, `organization`, `miscellaneous`.
|
| 32 |
-
- **Synthetic PII**: 6,000 synthetic sentences in Basque, Spanish and English covering 14 common PII types, with checksum-valid values (Spanish national IDs mod-23, IBANs mod-97, Luhn-valid cards, phone formats). This follows the synthetic-data methodology of the [GLiNER2-PII paper](https://arxiv.org/abs/2605.09973), since the original training corpus is not public.
|
| 33 |
|
| 34 |
Training used **LoRA (r=16, alpha=32)** on the boundary/task heads, merged into the base model after training; the resulting adapter is only ~13 MB. The model card repository contains the merged standalone model.
|
| 35 |
|
| 36 |
## Results
|
| 37 |
|
|
|
|
|
|
|
| 38 |
Evaluation on BasqueGLUE validation sets (500 sentences per split, exact match on type + mention string):
|
| 39 |
|
| 40 |
| Metric | Base (zero-shot) | **This model** |
|
|
@@ -43,6 +48,8 @@ Evaluation on BasqueGLUE validation sets (500 sentences per split, exact match o
|
|
| 43 |
| nerc_id/val micro F1 | 0.464 | **0.787** |
|
| 44 |
| nerc_od/val (Wikipedia) person name F1 | 0.721 | 0.813 |
|
| 45 |
|
|
|
|
|
|
|
| 46 |
On a PII probe sentence combining several entity types:
|
| 47 |
|
| 48 |
| PII type | Base (zero-shot) | **This model** |
|
|
@@ -56,6 +63,34 @@ On a PII probe sentence combining several entity types:
|
|
| 56 |
| national id | ✗ | **✓** |
|
| 57 |
| address | ✗ | **✓** |
|
| 58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
Fine-tuning a PII model on new-language NER data alone typically causes catastrophic forgetting of the original entity types. The LoRA + experience replay combination used here preserves the base model's PII detection behavior (and even improves on `national id` and `address`) while achieving strong Basque NER results.
|
| 60 |
|
| 61 |
## Usage
|
|
|
|
| 2 |
license: apache-2.0
|
| 3 |
base_model:
|
| 4 |
- fastino/gliner2-privacy-filter-PII-multi
|
| 5 |
+
datasets:
|
| 6 |
+
- orai-nlp/basqueGLUE
|
| 7 |
+
- tknika/pii-synthetic-basque
|
| 8 |
library_name: gliner2
|
| 9 |
language:
|
| 10 |
- eu
|
|
|
|
| 32 |
Two data sources were combined (experience replay):
|
| 33 |
|
| 34 |
- **Basque NER**: the `nerc_id` split of [orai-nlp/basqueGLUE](https://huggingface.co/datasets/orai-nlp/basqueGLUE) (EIEC + naiz.eus, manually annotated PER/LOC/ORG/MISC; 2,842 sentences), mapped to the base model's existing types: `person name`, `location`, `organization`, `miscellaneous`.
|
| 35 |
+
- **Synthetic PII**: the train split of [tknika/pii-synthetic-basque](https://huggingface.co/datasets/tknika/pii-synthetic-basque) — 6,000 synthetic sentences in Basque, Spanish and English covering 14 common PII types, with checksum-valid values (Spanish national IDs mod-23, IBANs mod-97, Luhn-valid cards, phone formats). This follows the synthetic-data methodology of the [GLiNER2-PII paper](https://arxiv.org/abs/2605.09973), since the original training corpus is not public.
|
| 36 |
|
| 37 |
Training used **LoRA (r=16, alpha=32)** on the boundary/task heads, merged into the base model after training; the resulting adapter is only ~13 MB. The model card repository contains the merged standalone model.
|
| 38 |
|
| 39 |
## Results
|
| 40 |
|
| 41 |
+
### Basque NER
|
| 42 |
+
|
| 43 |
Evaluation on BasqueGLUE validation sets (500 sentences per split, exact match on type + mention string):
|
| 44 |
|
| 45 |
| Metric | Base (zero-shot) | **This model** |
|
|
|
|
| 48 |
| nerc_id/val micro F1 | 0.464 | **0.787** |
|
| 49 |
| nerc_od/val (Wikipedia) person name F1 | 0.721 | 0.813 |
|
| 50 |
|
| 51 |
+
### PII detection
|
| 52 |
+
|
| 53 |
On a PII probe sentence combining several entity types:
|
| 54 |
|
| 55 |
| PII type | Base (zero-shot) | **This model** |
|
|
|
|
| 63 |
| national id | ✗ | **✓** |
|
| 64 |
| address | ✗ | **✓** |
|
| 65 |
|
| 66 |
+
### PII detection on the v2 synthetic benchmark
|
| 67 |
+
|
| 68 |
+
This model was later re-evaluated on the eval split of [pii-synthetic-basque-v2](https://huggingface.co/datasets/tknika/pii-synthetic-basque-v2) (1,000 sentences, 17 types — a benchmark this model was **not** trained on, with three educational types added after its release). Exact (type, mention) matching; gold mentions use the exact surface form (declension suffixes included):
|
| 69 |
+
|
| 70 |
+
| Model | Precision | Recall | **Micro F1** |
|
| 71 |
+
|---|---|---|---|
|
| 72 |
+
| Base (zero-shot) | 0.680 | 0.794 | 0.733 |
|
| 73 |
+
| **This model (v1)** | 0.774 | 0.882 | **0.824** |
|
| 74 |
+
| v2 ([gliner2-PII-basque-v2](https://huggingface.co/tknika/gliner2-PII-basque-v2), trained on this dataset) | 0.960 | 0.990 | 0.975 |
|
| 75 |
+
|
| 76 |
+
Per-type F1 of this model on the benchmark (types sorted by frequency):
|
| 77 |
+
|
| 78 |
+
| Type | F1 | | Type | F1 |
|
| 79 |
+
|---|---|---|---|---|
|
| 80 |
+
| person name | 0.899 | | national id | 0.897 |
|
| 81 |
+
| email | 0.774 | | location | 0.695 |
|
| 82 |
+
| phone number | 0.990 | | personal url | 0.670 |
|
| 83 |
+
| user name | 0.615 *(base 0.846)* | | city | 0.511 |
|
| 84 |
+
| date of birth | 0.916 | | zip code | 0.720 |
|
| 85 |
+
| student id | 0.937 | | bank account number | 0.844 |
|
| 86 |
+
| address | 0.866 | | age / date / credit card | 1.000 |
|
| 87 |
+
| organization | 0.744 | | | |
|
| 88 |
+
|
| 89 |
+
Two observations worth noting:
|
| 90 |
+
|
| 91 |
+
- The three **educational types** (`user name`, `personal url`, `student id`) were introduced with the v2 dataset, after this model was trained. `student id` transfers well (0.937) and `personal url` improves over the base (0.670 vs. 0.149), but `user name` **degrades below the base model** (0.615 vs. 0.846): fine-tuning on replay data that does not contain a type partially erases it — the motivation for covering all target types in the v2 replay data.
|
| 92 |
+
- `city` (0.511) is measured against gold mentions in their exact surface form (e.g. «Amorebietan»), while this model tends to output the undeclined form (e.g. «Amorebieta»), so part of that gap is an artifact of the stricter benchmark rather than pure model weakness.
|
| 93 |
+
|
| 94 |
Fine-tuning a PII model on new-language NER data alone typically causes catastrophic forgetting of the original entity types. The LoRA + experience replay combination used here preserves the base model's PII detection behavior (and even improves on `national id` and `address`) while achieving strong Basque NER results.
|
| 95 |
|
| 96 |
## Usage
|