File size: 19,871 Bytes
7c4a055
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bebe402
7c4a055
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bebe402
 
 
 
 
 
 
 
7c4a055
 
 
 
bebe402
7c4a055
 
 
 
 
 
 
 
 
 
bebe402
 
 
 
 
 
 
 
 
 
 
 
7c4a055
bebe402
 
7c4a055
 
 
 
 
bebe402
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7c4a055
 
bebe402
 
 
 
 
7c4a055
 
 
 
 
bebe402
7c4a055
 
bebe402
7c4a055
bebe402
7c4a055
 
 
 
 
 
 
 
 
 
bebe402
7c4a055
bebe402
7c4a055
 
 
 
bebe402
 
 
 
7c4a055
 
bebe402
7c4a055
bebe402
7c4a055
 
 
bebe402
7c4a055
 
 
 
 
 
 
 
bebe402
 
7c4a055
bebe402
7c4a055
bebe402
7c4a055
 
 
 
 
 
 
 
 
bebe402
7c4a055
bebe402
7c4a055
 
 
bebe402
7c4a055
 
bebe402
7c4a055
bebe402
7c4a055
 
 
 
 
 
 
 
 
563000f
7c4a055
bebe402
7c4a055
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
---
license: apache-2.0
language:
- it
base_model: dbmdz/bert-base-italian-xxl-cased
pipeline_tag: token-classification
library_name: onnx
tags:
- grammatical-error-correction
- gector
- onnx
- on-device
datasets:
- wikimedia/wikipedia
---

# Proofbird Grammar — Italian

`gector-bert-it` · on-device Italian grammar correction

**Try it in your browser:** coming soon on [proofbird.app](https://proofbird.app).

**Version 2.1.0** · run `2026-12-04-0500` · tag [`v2.1.0`](https://huggingface.co/proofbird/gector-bert-it/tree/v2.1.0), the files the Proofbird app downloads. Pin it with `revision="v2.1.0"`. Earlier versions stay available under their tags. Versions: a new training recipe or a change to the model's design raises the first number (2 = the recipe of November 2026: a second, spoken corpus beside Wikipedia, targeted training pairs, mostly one error per sentence), a new training run or changed guards, rules or settings the second, card or metadata fixes the third.

A GECToR-style sequence tagger for Italian grammatical error correction, exported to ONNX (fp32) to run on the CPU.
It is the on-device grammar model of [Proofbird](https://proofbird.app), a writing assistant that works wherever you write, and it is
published here so anyone can inspect what runs on their machine.

GECToR does not rewrite text. For each token it predicts one edit tag (keep, delete, replace with a word, append a
word, change case, change a verb form), and the edits are applied and the sentence re-tagged up to five times. The
tagger only proposes local edits; it never paraphrases.

## Quick start

[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/#fileId=https%3A//huggingface.co/proofbird/gector-bert-it/blob/main/quickstart.ipynb)

No API key, no GPU. One file, [`quickstart.py`](quickstart.py), downloads the model and runs it with ONNX Runtime.

```bash
pip install onnxruntime tokenizers huggingface_hub
```

```python
import importlib.util
from huggingface_hub import hf_hub_download

spec = importlib.util.spec_from_file_location("quickstart", hf_hub_download("proofbird/gector-bert-it", "quickstart.py"))
quickstart = importlib.util.module_from_spec(spec)
spec.loader.exec_module(quickstart)

model = quickstart.Gector("proofbird/gector-bert-it")
corrected, suggestions = model.correct("La ragazza sono molto stanco.")
print(corrected)
print(suggestions)
```

```text
La ragazza è molto stanca.
[{"start": 11, "length": 4, "original": "sono", "replacement": "è"}, {"start": 22, "length": 6, "original": "stanco", "replacement": "stanca"}]
```

Each suggestion gives the character position in **your** text (`start`, `length`), what is there now (`original`) and what to put instead (`replacement`), so you can underline it and offer the fix. From the command line: `python quickstart.py "La ragazza sono molto stanco."` prints every step below.

## What it corrects

Gender and number agreement (articles, adjectives, participles, including across a clause), subject-verb agreement in
the present and the past (`Gli infermieri controlla ogni paziente` → `controllano`, `La legge vietano il fumo` →
`vieta`, `Gli studenti disse che` → `dissero`, `I senatori votò contro la legge` → `votarono`), the person of `essere`
and `avere` (`Noi è stanchi` → `siamo`), articulated prepositions (`di il` → `del`), elision (`lo amico` → `l'amico`,
`una analisi` → `un'analisi`), accents (`perche` → `perché`, `perchè` → `perché`, `e` → `è` where the sentence requires
it), `il`/`lo` and `i`/`gli` (`il studente` → `lo studente`), plurals of `-co/-go/-ca/-ga` words, doubled words,
capitalisation at the start of a sentence, and everyday-register errors in questions, imperatives and the first and
second person. It finds a single error in a long sentence about as often as in a short one.

## How it was trained

- **Base encoder:** [`dbmdz/bert-base-italian-xxl-cased`](https://huggingface.co/dbmdz/bert-base-italian-xxl-cased) (MIT).
  A tagging head (1 921 edit labels) and an error-detection head sit on top.
- **Data: synthetic only.** Three sources, 3 250 000 sentences in all:
  - 1 500 000 sentences from Italian Wikipedia
    ([`wikimedia/wikipedia`](https://huggingface.co/datasets/wikimedia/wikipedia), `20231101.it`);
  - 1 500 000 sentences from the proceedings of the European Parliament (Europarl v8, sessions before May 2011):
    speech in the first and second person, questions and argument, and long sentences, the register encyclopedic
    text lacks;
  - 250 000 sentences from [Tatoeba](https://tatoeba.org), everyday Italian (the sentences held out for the checks
    below are excluded).

  They were corrupted by hand-written Italian error rules, mostly one error per sentence whatever its length; about 10%
  stay clean, so the model learns to leave correct text alone. Each rule was run over real text and read on real
  sentences first, and changed wherever the "error" it made also occurs as correct Italian: a change that Italian writes
  both ways (`di applicazione` and `d'applicazione`, `sono lieta` and `sono lieto`) is not made an error; an accent is
  dropped only from the 2 245 everyday words counted on all three sources, never from a name; a name or a word the
  model's dictionary does not know is never doubled; `la` becomes `il` (and `le` becomes `i`) only before a known noun
  or adjective, so a name, an acronym or the pronoun `la` is left alone; an adjective after an infinitive of `essere`
  is not changed unless its subject is in view. The training data was checked for contradictions, so that the same
  words are not an error in one sentence and correct in the next. Real sentences that carry a pattern the model needs (a
  verb whose number must match its subject, in the present and the past, the person of `essere` and `avere`, an
  articulated preposition, an elision, an accent, `il`/`lo`) were added again with the error placed exactly there, and
  210 000 template sentences teach questions, imperatives, the first and second person and errors in a later clause.
  15% of the training sentences lose their final full stop, so the model also works on text typed without one.
- **No learner corpora** and no non-commercial data of any kind. No user text was used.
- One epoch (168 527 steps, batch 64, learning rate 3e-5) on one NVIDIA L4. Run id `2026-12-04-0500`; the published
  weights are the end of the run.

## How it was measured

| Check | Result |
|---|---|
| Gold set (736 hand-written sentences: 544 with one error each, 192 correct) | **544 fixed, 192 left alone, 0 missed, 0 made worse** |
| Wrong corrections on 4 000 everyday Tatoeba sentences (held out from training) | 0. 1 sentence changed: a real mistake in the test sentence fixed (`Sei stato obbligata a firmare` → `obbligato`) |
| Wrong corrections on 20 000 sentences of the last part of Italian Wikipedia (never in training) | 42 (0.21%). 184 sentences changed: 121 real mistakes in the text fixed (`le corolle dei fiori è colorata` → `sono colorate`, `una altezza` → `un'altezza`, `in la collaborazione` → `nella`, `portando con sè` → `sé`, `che la ha vista` → `l'ha`), 25 where both forms are defensible, 42 wrong - 9 of those an apostrophe inside an English contraction or a transliterated name (see *Known wrong corrections*) |
| Wrong corrections on 20 000 sentences from European Parliament sessions the model never saw (May 2011 on) | 7 (0.035%). 75 sentences changed: 62 real mistakes in the text fixed (`questi due nuove Stati` → `nuovi`, `fuorchè` → `fuorché`, `una applicazione` → `un'applicazione`, `l'aumento dei prezzi del carburante rendono` → `rende`), 7 where both forms are defensible, 7 wrong |
| One error planted in each of 600 unseen Wikipedia sentences (199 under 20 words, 206 of 20–39, 195 of 40 or more) | 94.0% fixed (94.5%, 93.2%, 94.4%) |
| One error planted in each of 600 unseen European Parliament sentences (200, 201, 199) | 98.8% fixed (98.5%, 99.5%, 98.5%) |
| One error of each trained pattern placed in unseen sentences (360) | 95.6% fixed (a verb's number in the past 95.0%, in the present 87.5%) |
| Stability: the gold re-run with one extra token in front of each sentence (the model alone) | 4 of 302 sentences change result (the 6 capitalisation rows change by construction and are not counted) |

The scores are with the model's own confidence setting (`min_error_prob` 0.8 in `gector-meta.json`: an edit the model
is less than 80% sure of is not made) and the apply-side guards in `gector-guards.json`. Every changed sentence was
checked by hand, by one reader who is not a native speaker. Without the setting and the guards the model fixes 542 of the 544 gold errors (it writes `gioci` for
`giochi`) and 96.2% / 99.0% of the planted ones, and in the three sets above it fixes more real mistakes (242 instead of
184) and makes more than twice the wrong corrections (108 instead of 49). The model was trained for precision: a missed
error costs less than a wrong correction.

**How to read the wrong-correction rates.** The confidence setting and the guards were chosen on the same test sentences
they are scored on, so a fresh sample is likely to read a little higher. The gold set and the planted errors do not
depend on that choice.

**Known wrong corrections.** An adjective or participle that agrees with the wrong noun (`La terapia cognitivo
comportamentale` → `cognitiva`, `I servizi di sicurezza nazionale` → `nazionali`, `con i medici generici trattative` →
`generiche`); the gender of a person the sentence does not name nearby (`si è piazzato 8º` → `piazzata`, `prima che fosse
eletta membro del Parlamento` → `eletto`); `e` and `è` taken for each other in a correct
sentence (`Il gioco di Hex e il teorema` → `è`, `nei vari Stati membri è differente` → `e`); a straight single quote used
as a quotation mark deleted (`riceve uno 'strike'`); a word of another language deleted or changed (`Spinoza en de
radicale verlichting`); a word that stands twice and is correct that way loses one (`il braccio lungo lungo
l'orizzonte`). An apostrophe inside an English contraction or a transliterated name is read as an Italian elision and
split off (`I'm` → `I m`, `Il'ič` → `L'ič`): this happens in the app's text preparation, before the model, and is 9 of
the 42 Wikipedia ones.

**Known misses.** A verb in the present whose number is wrong is left alone about once in ten, for example when its
subject has no article (`Cittadini e imprese deve avere il diritto`), and a verb whose subject is not in view is left
alone on purpose (see *The guards*). A single
planted error is left untouched 4 times in 100 on Wikipedia and less than once in 100 on European Parliament text, at
every sentence length. It does not add a missing word. It has not been measured on learner essays.

**The guards.** `gector-guards.json` holds back edits we measured as wrong in a known shape. They run in the Proofbird
app (not in `quickstart.py`) and are part of every score above. A `-co/-go` plural gets its `h` (`giochi`, never
`gioci`) and an `h` is never put on a stem that has none; a verb's number is changed only when a subject of the new
number stands before it (`Di solito spariscono.` and `La maggior parte degli aumenti coincidono` stay); `è` stays before
a singular participle (`È andata`); an elided word is not left standing beside its full form (`un'ora ora` → `un'ora`);
a number is never deleted unless it is written twice.

## Files

| File | What it is |
|---|---|
| `model.onnx` | The tagger (fp32, opset 17). Inputs `input_ids`, `attention_mask`; outputs `logits_labels` [1, T, 1921] and `logits_d` [1, T, 2]. |
| `config.json` | The edit-label vocabulary (`id2label`). |
| `vocab.txt`, `tokenizer.json`, `tokenizer_config.json` | The base encoder's WordPiece tokenizer. |
| `gector-meta.json` | Export facts: encoder, tokenizer family, run id, and the decoding defaults - among them the model's confidence setting, `min_error_prob` 0.8. |
| `gector-guards.json` | Apply-side guards: rules that hold back an edit the model gets wrong in a known way, with their word lists. Part of the measured result. |
| `language-rules.json` | Language facts the runtime needs: the final full stop stays on, a text without one gets one for the model only, and the articles a glued apostrophe is split from (`gli'avvocato` → `gli avvocato`). |
| `verb-form-vocab.txt` | The Italian verb-form table for the verb-transform tags. |
| `grammar-messages.json` | The card messages: which error each kind of change names (`Elision`, `Articulated preposition`, `Gender agreement`) and a one-line reason. Read by the Proofbird app; the model does not use it. |
| `quickstart.py` | A complete Python runner: download, tokenize, run, decode, apply, suggestions. See *Quick start*. |
| `quickstart.ipynb` | The same, as a notebook (the *Open in Colab* button). |

The Proofbird app runs the same algorithm in C# with ONNX Runtime; the files are standard, so any GECToR-style
decoder can use them.

## How it works, step by step

The model never sees letters and never writes text. It reads numbers (token ids) and answers, for every word, which **edit** to make: one of 1 921 tags such as `$KEEP`, `$DELETE`, `$APPEND_nei`, `$REPLACE_al` or `$TRANSFORM_VERB_P3P_P3S` (change a verb's form). `quickstart.py` does everything around it. This is the real run of the example above.

**1. Prepare the text.** The sentence goes in as written: `La ragazza sono molto stanco.`.

**2. The request.** The words are looked up in the model's dictionary (`vocab.txt`). A rare word is split into pieces; the edit is read at its first piece. `[CLS]` stands for a dummy first word, `$START`, so an edit on it can add a word at the very beginning; `[SEP]` marks the end.

```text
words           $START  La  ragazza  sono  molto  stanco  .
tokens          [CLS] La ragazza sono molto stanco . [SEP]
input_ids       [102, 309, 2393, 288, 617, 14408, 697, 103]
attention_mask  [1, 1, 1, 1, 1, 1, 1, 1]
```

Two inputs, both whole numbers (int64), shape `[1, 8]`: one sentence of 8 tokens.

**3. The response.** Two outputs (float32): `logits_labels` `[1, 8, 1921]`, a score for each of the 1 921 edits at every token, and `logits_d` `[1, 8, 2]`, a score for "this word is correct" and "this word is wrong". A softmax turns each row into probabilities; the most probable edit at each word's first token is the one applied.

**4. Pass by pass.** The corrected sentence goes back in, until a pass changes nothing (at most five passes). Connected errors are fixed one after the other.

*Pass 1:* `La ragazza sono molto stanco.`

| Word | Wrong | Chosen edit | Probability |
|---|---|---|---|
| $START | 0.0% | $KEEP | 100.0% |
| La | 0.0% | $KEEP | 100.0% |
| ragazza | 0.0% | $KEEP | 100.0% |
| sono | 100.0% | **$TRANSFORM_VERB_P3P_P3S** | 100.0% |
| molto | 0.0% | $KEEP | 100.0% |
| stanco | 99.9% | **$TRANSFORM_SUF_o_a** | 100.0% |
| . | 0.0% | $KEEP | 100.0% |

→ `La ragazza è molto stanca.`

*Pass 2:* `La ragazza è molto stanca.`

| Word | Wrong | Chosen edit | Probability |
|---|---|---|---|
| $START | 0.0% | $KEEP | 100.0% |
| La | 0.0% | $KEEP | 100.0% |
| ragazza | 0.0% | $KEEP | 100.0% |
| è | 0.0% | $KEEP | 100.0% |
| molto | 0.0% | $KEEP | 100.0% |
| stanca | 0.0% | $KEEP | 100.0% |
| . | 0.0% | $KEEP | 100.0% |

→ `La ragazza è molto stanca.` — no change, so it stops.

**5. The suggestions.** The original and the final words are compared, and each changed stretch becomes one suggestion with its position in the original text (unchanged text keeps its own spacing), as in the Quick start output above.

**6. Settings.** `Gector(repo, keep_confidence=None, min_error_prob=None)` takes the two GECToR precision knobs. Left out, they come from the model's own `gector-meta.json`: this model sets `min_error_prob` to 0.8, and the Proofbird app reads the same value (at most five passes):

- `keep_confidence` adds a bonus to `$KEEP` before choosing: higher means fewer, safer edits.
- `min_error_prob` ignores an edit the model is less sure of, and leaves the whole sentence alone when no word is at least that likely to be wrong. At the model's own 0.8 the example is corrected as shown: the model is 100.0% sure one word is wrong. With `min_error_prob=0` every edit the model prefers is applied (the example comes out the same): more real mistakes are fixed and more wrong corrections are made - the figures are under *How it was measured*.

**Reading `min_error_prob`.** It is a number from 0 to 1: how sure the model must be that something is wrong before it changes anything. At 0.5 it acts when it is at least 50% sure, at 0.7 when it is at least 70% sure. A higher number is stricter: fewer wrong corrections, and some real mistakes are left alone. A lower number is looser: more mistakes are fixed, and more wrong corrections are made. Each model carries the value that gave the best balance on its own tests; this one carries 0.8.

## What Proofbird adds

`quickstart.py` is the model on its own. The [Proofbird](https://proofbird.app) app runs the same algorithm in C# and adds:

- **Guards**: per-language rules that hold back edits we measured as wrong in a known shape. `gector-guards.json`, in this repository, lists which guards are on for Italian and their word lists; what each guard does is code in the app. The scores under *How it was measured* are with the guards.
- **Spelling, checked separately** by the operating system's spell checker; the guards use it so a grammar edit is not made on a word that is misspelled.
- **A card for each change** that names the error ("Subject–verb agreement") and, on request, explains it.

`quickstart.py` runs the model on its own, without the guards.


## Licence and attribution

The model weights and the files in this repository are released under the
[Apache License 2.0](LICENSE). If you redistribute the model or a model built from it, keep the
[NOTICE](NOTICE) file with it (Apache-2.0, section 4(d)).

The training data carries its own terms. Wikipedia text is © Wikipedia contributors,
[CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/). Tatoeba sentences are from
[tatoeba.org](https://tatoeba.org), [CC BY 2.0 FR](https://creativecommons.org/licenses/by/2.0/fr/). Contains text
from the proceedings of the European Parliament, © European Union, 1996–2011, reused under the European Parliament's
[legal notice](https://www.europarl.europa.eu/legal-notice/en/), through the Europarl corpus
([statmt.org/europarl](https://www.statmt.org/europarl/), Philipp Koehn, *Europarl: A Parallel Corpus for Statistical
Machine Translation*, MT Summit 2005) as distributed by [OPUS](https://opus.nlpl.eu). The base
encoder is `dbmdz/bert-base-italian-xxl-cased` by the MDZ Digital Library team (dbmdz) at the Bavarian State
Library, MIT licence. The tagging scheme follows GECToR (Omelianchuk et al., 2020, *GECToR – Grammatical Error
Correction: Tag, Not Rewrite*); the Italian verb-form table was built for this model.

## How to cite

If you use or build on this model, please cite it:

```bibtex
@misc{hartnett2026gectorit,
  author       = {Hartnett, Patrick Andrew},
  title        = {Proofbird GECToR grammar model (Italian)},
  year         = {2026},
  publisher    = {Hugging Face},
  howpublished = {\url{https://huggingface.co/proofbird/gector-bert-it}},
  note         = {Proofbird, https://proofbird.app}
}
```

If you build on this model, a link back to this page is appreciated. If you use it in a product or service, please credit it where your users can see it, for example *Grammar checking by Proofbird (https://proofbird.app)*.

## Contact

Published by Patrick Andrew Hartnett as personal work. Questions and reports: open a discussion on this repository.