French 1.5.1: fuller card messages (elision, contracted articles, article gender, être/avoir forms); model and guards as 1.5.0
922ad78 verified |
Download README.md from proofbird/gector-bert-fr: direct link, hf CLI and curl.
- Browser
- Download file 20.2 kB
-
https://huggingface.co/proofbird/gector-bert-fr/resolve/main/README.md
- Command line
-
hf download hf://proofbird/gector-bert-fr/README.md
-
curl -L -o README.md https://huggingface.co/proofbird/gector-bert-fr/resolve/main/README.md
20.2 kB
| license: apache-2.0 | |
| language: | |
| - fr | |
| base_model: Geotrend/bert-base-fr-cased | |
| pipeline_tag: token-classification | |
| library_name: onnx | |
| tags: | |
| - grammatical-error-correction | |
| - gector | |
| - onnx | |
| - on-device | |
| datasets: | |
| - wikimedia/wikipedia | |
| # Proofbird Grammar — French | |
| `gector-bert-fr` · on-device French grammar correction | |
| [](https://huggingface.co/spaces/proofbird/try-grammar) | |
| **Try it in your browser:** type a sentence and see the corrections. The model runs on your own computer; nothing to install, and your text never leaves the page. | |
| **Version 1.5.1** (model as 1.4.0; guards as 1.5.0; fuller card messages) · run `2026-11-25-0014` · tag [`v1.5.1`](https://huggingface.co/proofbird/gector-bert-fr/tree/v1.5.1), the files the Proofbird app downloads. Pin it with `revision="v1.5.1"`. Earlier versions stay available under their tags. Versions: a change to the model's design (encoder, inputs, outputs) raises the first number, a new training run or changed guards, rules or settings the second, card or metadata fixes the third. | |
| A GECToR-style sequence tagger for French 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 an ending, put an accent back), 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 | |
| [](https://colab.research.google.com/#fileId=https%3A//huggingface.co/proofbird/gector-bert-fr/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-fr", "quickstart.py")) | |
| quickstart = importlib.util.module_from_spec(spec) | |
| spec.loader.exec_module(quickstart) | |
| model = quickstart.Gector("proofbird/gector-bert-fr") | |
| corrected, suggestions = model.correct("Ma sœur sont très content.") | |
| print(corrected) | |
| print(suggestions) | |
| ``` | |
| ```text | |
| Ma sœur est très contente. | |
| [{"start": 8, "length": 4, "original": "sont", "replacement": "est"}, {"start": 18, "length": 7, "original": "content", "replacement": "contente"}] | |
| ``` | |
| 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 "Ma sœur sont très content."` prints every step below. | |
| ## What it corrects | |
| Subject-verb agreement, including with a noun subject far from its verb (`Les enfants joue` → `jouent`, `Le programme | |
| doivent changer` → `doit`, `La Commission font` → `fait`, `Les résultats présentés montre` → `montrent`), the person of | |
| `être` and `avoir` after a pronoun (`Nous est arrivés` → `sommes`, `Vous a raison` → `avez`), gender and number agreement of | |
| adjectives and past participles, irregular feminines included (`Les filles sont fatigué` → `fatiguées`, `La voiture était | |
| très vieux` → `vieille`, `des principes claires` → `clairs`), the article's gender (`le voiture` → `la`, `dans la cadre` → | |
| `le`), contracted prepositions (`à le` → `au`, `de le` → `du`), elision (`le arbre` → `l'arbre`), accents, missing or wrong | |
| (`decisions` → `décisions`, `l'hotel` → `l'hôtel`, `inquiéte` → `inquiète`, `Voila` → `Voilà`), the homophones that differ by | |
| an accent or a letter (`a` / `à`, `ou` / `où`, `et` / `est`, `on` / `ont`), doubled words and articles (`la la porte`), and | |
| capitalisation at the start of a sentence. It finds a single error in a sentence of 40 words or more almost as often as in | |
| a short one. | |
| It leaves alone the spellings French writes both ways since 1990 (`connaitre` and `connaître`, `évènement` and | |
| `événement`). | |
| ## How it was trained | |
| - **Base encoder:** [`Geotrend/bert-base-fr-cased`](https://huggingface.co/Geotrend/bert-base-fr-cased) (Apache-2.0), | |
| the French reduction of multilingual BERT. A tagging head (1 995 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 French Wikipedia | |
| ([`wikimedia/wikipedia`](https://huggingface.co/datasets/wikimedia/wikipedia), `20231101.fr`); | |
| - 1 500 000 sentences from the proceedings of the European Parliament (Europarl v10, sessions before June 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 French (the sentences held out for the checks below | |
| are excluded). | |
| They were corrupted by hand-written French 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 checked against the clean text and read on | |
| real sentences first: a word is treated as an adjective only when the text shows it to be one (a lexicon of 2 314 | |
| adjectives built from the corpus), a verb's number is changed only against a subject in view (never after `qui`, where | |
| the verb agrees with a word further back), an article's gender is not swapped where both are French (`le / la même`), | |
| and a change French writes both ways is not made an error. Real sentences that carry a pattern the model needs (a verb | |
| whose number must match its subject, over 235 verbs; an adjective against its noun; an article; a contraction; an | |
| elision; an accent; `a` / `à` and `ou` / `où`) were added again with the error placed exactly there: 759 024 sentence | |
| pairs. 176 000 template sentences teach questions, imperatives, the first and second person and errors in a later clause. | |
| - **Accents as one edit, whatever the word.** A missing or wrong accent is taught as "put this accent on this letter", | |
| not as one replacement per word, so the model can restore the accent of a word it never saw in training. | |
| - **No learner corpora** and no non-commercial data in the fine-tuning. No user text was used. | |
| - One epoch (170 344 steps, batch 64, learning rate 3e-5) on one NVIDIA L4. Run id `2026-11-25-0014`; the published | |
| weights are the final step. | |
| ## How it was measured | |
| | Check | Result | | |
| |---|---| | |
| | Gold set (654 hand-written sentences: 494 with one error each, 160 correct) | **490 fixed, 160 left alone, 4 missed, 0 made worse** | | |
| | Wrong corrections on 4 000 everyday Tatoeba sentences (held out from training) | 2 (0.05%). 11 sentences changed: 9 real mistakes in the test sentences fixed, 2 wrong | | |
| | Wrong corrections on 20 000 sentences from European Parliament sessions the model never saw (June 2011 on) | 6 (0.03%). 42 sentences changed: 35 real mistakes in the text fixed, 6 wrong, 1 a spelling alternative | | |
| | One error planted in each of 600 unseen Wikipedia sentences (205 under 20 words, 220 of 20–39, 175 of 40 or more) | 82.2% fixed (84.4%, 83.6%, 77.7%) | | |
| | One error planted in each of 600 unseen European Parliament sentences (201, 204, 195) | 92.7% fixed (96.0%, 91.2%, 90.8%) | | |
| | One error of each trained pattern placed in unseen sentences (587) | 96.9% fixed (verb number 100%) | | |
| | Stability: the gold re-run with one extra token in front of each sentence (the model alone) | 3 of 257 sentences change result (the 4 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), the apply-side guards in `gector-guards.json` and the two French rules described | |
| under *What Proofbird adds*. Every changed sentence was checked by hand. Without the setting and the guards the model | |
| fixes 484 gold errors and makes 2 gold sentences worse (`Les collègues présentes ont voté` → `présents`: `collègue` is | |
| both genders), fixes 83.5% / 93.2% of the planted errors, and changes 16 Tatoeba and 73 European Parliament sentences, | |
| 7 and 22 of them wrong. The model was trained for precision: a missed error costs less than a wrong correction. | |
| **How to read the two 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 changed where the word it belongs to is not clear from the words nearby | |
| (`ce point que plusieurs personnes estiment être problématique` → `problématiques`); a word deleted next to a typo | |
| (`entre entres` → `entre`, the text meant `entre autres`); a verb's number where the subject is further back (`Cela ... | |
| mais nous a également laissés` → `avons`); an article changed when the error is in the noun (`une avancé` → `un`, the | |
| noun should be `avancée`; `le future` → `la`, the noun should be `futur`); `du` and `des` taken for each other (`qu'il | |
| y ait du progrès` → `des`). | |
| **Known misses.** `là` written `la` as the last word of a sentence (`La voiture est garée la.`); a verb's number on a | |
| verb rarely seen in training (`Le rapport proposent trois solutions` → `propose` is missed; `Le programme doivent`, | |
| `Mon frère jouent` are fixed). It does not add a missing word. It has not been measured on learner essays. | |
| **The guards.** `gector-guards.json` holds back or redirects edits we measured as wrong in a known shape. They run in | |
| the Proofbird app (not in `quickstart.py` or the demo) and are part of every score above: after a past participle, `la` | |
| is the adverb `là`, never the article `le` (`La voiture est garée la devant la maison` → `là`); after a closing quote, | |
| `est` is the verb, never `et` (`« Aix-la-Chapelle » est Aachen`); a number is never deleted unless it is written twice | |
| (`9 593 391` stays); and the word after `en tant que` keeps its ending, because it describes someone the sentence does | |
| not show (`ma position, en tant que modéré, est la bonne` stays). Each guard was measured on every set above: the last | |
| two removed 3 wrong corrections and changed nothing else. | |
| ## Files | |
| | File | What it is | | |
| |---|---| | |
| | `model.onnx` | The tagger (fp32, opset 17). Inputs `input_ids`, `attention_mask`; outputs `logits_labels` [1, T, 1995] 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 or redirect an edit the model gets wrong in a known way. Part of the measured result. | | |
| | `language-rules.json` | Language facts the runtime needs (sentence-final punctuation handling). | | |
| | `verb-form-vocab.txt` | Empty for French: verb forms are fixed by ending changes and whole-word edits. | | |
| | `grammar-messages.json` | The card messages: which error each kind of change names (`Elision`, `Contracted article`, `Article gender`, `Homophone`) 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. A decoder must know the `$TRANSFORM_DIA_` edit (put an accent on the n-th matching letter); | |
| `quickstart.py` shows it. | |
| ## 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 995 tags such as `$KEEP`, `$DELETE`, `$APPEND_de`, `$REPLACE_as` or `$TRANSFORM_SUF__e` (change a word's ending). `quickstart.py` does everything around it. This is the real run of the example above. | |
| **1. Prepare the text.** `language-rules.json` says the final full stop comes off before the model sees the sentence (it goes back on at the end): `Ma sœur sont très content`. | |
| **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 Ma sœur sont très content | |
| tokens [CLS] Ma sœur sont très content [SEP] | |
| input_ids [11, 2191, 10685, 583, 1800, 4552, 12] | |
| attention_mask [1, 1, 1, 1, 1, 1, 1] | |
| ``` | |
| Two inputs, both whole numbers (int64), shape `[1, 7]`: one sentence of 7 tokens. | |
| **3. The response.** Two outputs (float32): `logits_labels` `[1, 7, 1995]`, a score for each of the 1 995 edits at every token, and `logits_d` `[1, 7, 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:* `Ma sœur sont très content` | |
| | Word | Wrong | Chosen edit | Probability | | |
| |---|---|---|---| | |
| | $START | 0.0% | $KEEP | 100.0% | | |
| | Ma | 0.0% | $KEEP | 100.0% | | |
| | sœur | 0.0% | $KEEP | 100.0% | | |
| | sont | 100.0% | **$REPLACE_est** | 100.0% | | |
| | très | 0.0% | $KEEP | 100.0% | | |
| | content | 84.5% | **$TRANSFORM_SUF__e** | 84.9% | | |
| → `Ma sœur est très contente` | |
| *Pass 2:* `Ma sœur est très contente` | |
| | Word | Wrong | Chosen edit | Probability | | |
| |---|---|---|---| | |
| | $START | 0.0% | $KEEP | 100.0% | | |
| | Ma | 0.0% | $KEEP | 100.0% | | |
| | sœur | 0.0% | $KEEP | 100.0% | | |
| | est | 0.0% | $KEEP | 100.0% | | |
| | très | 0.0% | $KEEP | 100.0% | | |
| | contente | 0.0% | $KEEP | 100.0% | | |
| → `Ma sœur est très contente` — 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 French and their word lists; what each guard does is code in the app. The scores under *How it was measured* are with the guards. | |
| - **Two French rules** for shapes the model leaves alone, added only where the model made no change: | |
| - **`ou` → `où`** where only "where" fits: after a negated knowing verb, an asking verb, `dis-moi` or `aucune idée` with a clause after it (`je ne sais pas ou il habite` → `où`), and a sentence-final `ou.` with no comma before it. `ou` and `où` differ only by meaning; the rule takes the clear cases and leaves `oui ou non`, `un jour ou l'autre` and `Tu viens ou ?` alone. | |
| - **Elision**: `le` / `la` before a word that starts with a vowel becomes `l'` (`Je vois le arbre.` → `l'arbre`). It does not act after a hyphen (`Prenez-la avec vous`), before `h` or `y` (`le héros`, `le yaourt`), before a capital (`la US 17`), a function word (`le ou la`) or a word French writes without elision (`la une`, `le onze`, `le oui`). On 290 000 correct French sentences it made no wrong change. | |
| - **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` and the in-browser demo include the two French rules (plain text matching, no model); they run 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). The base | |
| encoder is `Geotrend/bert-base-fr-cased` by Geotrend (Abdaoui et al., 2020, *Load What You Need: Smaller Versions of | |
| Multilingual BERT*), Apache-2.0. The tagging scheme follows GECToR (Omelianchuk et al., 2020, *GECToR – Grammatical | |
| Error Correction: Tag, Not Rewrite*). | |
| ## How to cite | |
| If you use or build on this model, please cite it: | |
| ```bibtex | |
| @misc{hartnett2026gectorfr, | |
| author = {Hartnett, Patrick Andrew}, | |
| title = {Proofbird GECToR grammar model (French)}, | |
| year = {2026}, | |
| publisher = {Hugging Face}, | |
| howpublished = {\url{https://huggingface.co/proofbird/gector-bert-fr}}, | |
| 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. | |