Polygraf / NER Stage 4: Second Model
distilbert-base-cased fine-tuned end to end for token classification on
inovruzova/polygraf-ner-stage4-expanded.
All layers were updated, not only the classification head.
This is the Stage 4 output of the Polygraf Applied NLP / NER technical task. It
replaces the Stage 3 model, which is left published at
inovruzova/polygraf-ner-stage3-model.
Labels
Eight entity types, seventeen tags including O.
PERSON, ORGANIZATION, LOCATION, TIMEDATE, PRODUCT, WORKOFART, JOB,
AMOUNT
The full annotation policy is on the dataset card.
Usage
from transformers import pipeline
ner = pipeline(
"token-classification",
model="inovruzova/polygraf-ner-stage4-model",
aggregation_strategy="simple",
)
ner("The software engineer at Google filed the patent in March 2024.")
Model facts
| Base model | distilbert-base-cased |
| Parameters | 65203985 |
| Size on disk | 249.4 MB |
| CPU memory at inference | 146.2 MB |
| Throughput on CPU | 24.3 records per second |
Throughput measured one passage at a time on CPU, after warm-up, over 100 passages from the test split.
Training
| Hardware | NVIDIA RTX 4070 Laptop GPU, 8 GB VRAM |
| Learning rate | 5e-5 |
| Batch size | 8 |
| Epochs | 30 |
| Weight decay | 0.01 |
| Maximum sequence length | 512 |
| Seed | 202608 |
| Runtime | 261 seconds |
No validation split, following the task instruction, and therefore no checkpoint selection.
Only two things changed from Stage 3: the base model, and the learning rate.
The model change was the deliberate one. Stage 3 used
google/electra-small-discriminator, which is 13.5 million parameters and
uncased. Every model below about 35 million parameters is uncased and the
smallest cased one is five times larger, so choosing the smallest reasonable
model meant giving up capitalisation. That cost was written down as a prediction
before the Stage 3 model was trained, and this stage tests it.
The learning rate is a dependent setting rather than a second experiment. A rate has to be chosen either way. Stage 3 used 1e-4 because ELECTRA small was undertrained at 5e-5; DistilBERT is five times larger and close to the size 5e-5 was designed for. Train F1 of 1.000 confirms the rate is not too low, and that check uses the training split only.
Results
Micro-averaged F1: 0.826 on test, 1.000 on train.
Test, per label
| Label | Precision | Recall | F1 | Support |
|---|---|---|---|---|
| PERSON | 0.929 | 0.942 | 0.936 | 139 |
| LOCATION | 0.884 | 0.884 | 0.884 | 112 |
| TIMEDATE | 0.849 | 0.908 | 0.878 | 142 |
| AMOUNT | 0.841 | 0.831 | 0.836 | 83 |
| JOB | 0.777 | 0.777 | 0.777 | 94 |
| PRODUCT | 0.675 | 0.800 | 0.732 | 65 |
| WORKOFART | 0.658 | 0.774 | 0.711 | 62 |
| ORGANIZATION | 0.644 | 0.774 | 0.703 | 84 |
| micro avg | 0.800 | 0.853 | 0.826 | 781 |
Compared with the Stage 3 model
The test split grew from 119 records to 156 when new records were added, so the comparison below uses only the 600 spans present in both.
| Label | Stage 3 | Stage 4 | Change |
|---|---|---|---|
| WORKOFART | 0.485 | 0.705 | +0.220 |
| ORGANIZATION | 0.545 | 0.690 | +0.145 |
| PRODUCT | 0.622 | 0.750 | +0.128 |
| PERSON | 0.850 | 0.941 | +0.091 |
| LOCATION | 0.809 | 0.867 | +0.058 |
| JOB | 0.713 | 0.748 | +0.035 |
| AMOUNT | 0.815 | 0.838 | +0.023 |
| TIMEDATE | 0.873 | 0.863 | -0.010 |
| micro avg | 0.745 | 0.817 | +0.072 |
What the gains say
The three biggest gains are the three labels that were predicted not to improve.
WORKOFART, ORGANIZATION and PRODUCT are governed by four policy rules that need knowledge outside the token sequence: whether a spec-like token belongs to a product's commercial name, whether a brand is acting as a company, whether a title refers to a game or a film, and whether a place name stands for the institution it houses. Stage 1 called those rules unlearnable, Stage 2 repeated it, and Stage 3 appeared to confirm it, since those three labels came last by a wide margin.
They moved the most. All three are proper-name labels, and capitalisation is the strongest cue for a proper name in English. The Stage 3 model was uncased and could not see it, so the binding constraint was the tokenizer, not the rules.
The alternative explanation is ruled out: those same three labels received the fewest new spans in the data expansion, so extra data cannot account for the gain.
The ceiling argument was not wrong, only premature. Those three labels are still the weakest three.
Limitations
The model memorises its training set. Train 1.000 against test 0.826 is a gap of 0.174, down from 0.254 in Stage 3 but still large. This is left uncorrected rather than fixed by shortening training, because with no validation split, shortening until the test gap closes would be selecting a training length on test performance.
It over-predicts. Recall exceeds precision on six of eight labels, and by the widest margins on ORGANIZATION, PRODUCT and WORKOFART.
Test metrics are agreement, not accuracy. The test labels were measured at 98.3 percent span precision in a 40-record hand audit, so these numbers compare the model against an imperfect reference.
Three of the ten Stage 3 failure patterns are unchanged and one regressed. Vague time expressions are still labeled, possessives are still split off establishment names, and adjacent time expressions are still merged.
Two new failure modes appeared, both label confusions on capitalised words:
Ramadan labeled PERSON where R10 makes named observances TIMEDATE, and
Apache Hadoop and Django labeled LOCATION where R16 makes software PRODUCT.
The Stage 3 model had all three right.
Those regressions share one cause. Capitalisation is a strong signal that something is a name and no signal at all about which kind of name. The uncased model missed these words; the cased model finds them and guesses wrong. That is the predictable other half of the change made in this stage.
Related repositories
| Stage | Artefact |
|---|---|
| 1 | inovruzova/polygraf-ner-stage1-cleaned |
| 2 | inovruzova/polygraf-ner-stage2-expanded |
| 3 | inovruzova/polygraf-ner-stage3-model |
| 4 | inovruzova/polygraf-ner-stage4-expanded |
Licensing
The model weights are released under Apache 2.0, matching the base model.
The training data is a collection of corpora under different terms, including share-alike obligations from ODbL and CC BY-SA. Those obligations attach to the dataset rather than to a set of trained weights, but anyone reusing this model should read the dataset card.
Produced during the Polygraf Applied NLP / NER technical task.
- Downloads last month
- 13
Model tree for inovruzova/polygraf-ner-stage4-model
Base model
distilbert/distilbert-base-cased