Proofbird Grammar — Portuguese (Brazil)

gector-bert-pt-br · on-device Brazilian Portuguese grammar correction

Try it in your browser

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 2.0.0 (the same model and files as 1.2.0, renumbered: the first number now marks the training recipe) · run 2026-11-26-0036 · tag v2.0.0, the files the Proofbird app downloads. Pin it with revision="v2.0.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 Brazilian Portuguese grammatical error correction, exported to ONNX (fp32) to run on the CPU. It is the on-device grammar model of Proofbird, a writing assistant that works wherever you write, and it is published here so anyone can inspect what runs on their machine. European Portuguese gets its own model, trained on European text.

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's form, 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

Open in Colab

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

pip install onnxruntime tokenizers huggingface_hub
import importlib.util
from huggingface_hub import hf_hub_download

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

model = quickstart.Gector("proofbird/gector-bert-pt-br")
corrected, suggestions = model.correct("A casa são muito bonito.")
print(corrected)
print(suggestions)
A casa é muito bonita.
[{"start": 7, "length": 3, "original": "são", "replacement": "é"}, {"start": 17, "length": 6, "original": "bonito", "replacement": "bonita"}]

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 "A casa são muito bonito." prints every step below.

What it corrects

Subject-verb agreement, including with a noun subject (As crianças brinca → brincam, Os meninos come → comem, Eles tem → têm), gender and number agreement (articles, adjectives, participles), article gender (um casa → uma casa), contractions (de o → do, em a → na), the crase (Vou a praia → à praia), accents and diacritics (esta cansada → está cansada, Voce → Você), the plural of -ão nouns (informaçãos → informações), doubled words (Me passa o o sal → o sal), 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 (… a proposta será enviada a comissão especial na próxima semana, depois de uma longa negociação com os governadores dos estados. → à comissão).

It is written for Brazilian Portuguese: você, ônibus, fato, contato and estar + gerund (está estudando) are correct to it. It leaves European Portuguese spelling and usage alone (facto, equipa, autocarro, está a trabalhar) rather than changing it, and it leaves a repeated name alone (Wagga Wagga).

How it was trained

  • Base encoder: neuralmind/bert-base-portuguese-cased (BERTimbau, MIT). A tagging head (1 556 edit labels) and an error-detection head sit on top.

  • Data: synthetic only. Three sources, 3 250 000 sentences:

    • 1 500 000 sentences from Portuguese Wikipedia (wikimedia/wikipedia, 20231101.pt), keeping only articles whose spelling and usage mark them as Brazilian;
    • 1 500 000 sentences from the plenary speeches of the Brazilian Chamber of Deputies (Câmara dos Deputados, open data, 2015 to the end of 2024): speech in the first and second person, questions and argument, and long sentences, the register encyclopedic text lacks;
    • 250 000 sentences from Tatoeba, Brazilian or unmarked (the sentences held out for the checks below are excluded).

    Sentences in the spelling before the 1990 spelling agreement were left out, so the model learns one direction: old spelling to new. The text was corrupted by hand-written Portuguese error rules, mostly one error per sentence whatever its length; about 10% stays clean, so the model learns to leave correct text alone. Each rule was run over real text and read on real sentences first; the adjective and verb rules use a word list built from the corpus, so an "error" is always a real Portuguese form. Real sentences that carry a pattern the model needs (a verb whose number must match its subject, a contraction, the crase, an accent, an -ão plural) were added again with the error placed exactly there. 200 000 template sentences teach patterns the corpora rarely contain (questions, imperatives, long-distance agreement), with correct twins. 15% of the training sentences lose their final full stop, so the model also works on text typed without one.

  • Accents as one edit, whatever the word. A missing or wrong accent is taught as "put this mark 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 of any kind. No user text was used.

  • One epoch (155 977 steps, batch 64, learning rate 3e-5) on one NVIDIA L4. Run id 2026-11-26-0036; the published weights are the final step.

How it was measured

Check Result
Gold set (657 hand-written sentences: 454 with one error each, 203 correct) 452 fixed, 203 left alone, 2 missed, 0 made worse
Wrong corrections on 4 000 everyday Tatoeba sentences (held out from training) 0. 3 sentences changed, all real mistakes in the test sentences (Alguem → Alguém, chegar a festa → à festa)
Wrong corrections on 20 000 sentences from Chamber of Deputies sessions the model never saw (2025–2026) 8 (0.04%). 39 sentences changed: 21 real mistakes in the text fixed, 8 wrong, 10 where both forms are defensible
Wrong corrections on 20 000 unseen Brazilian Wikipedia sentences 32 (0.16%). 222 sentences changed: 160 real mistakes in the text fixed (esta disponível → está, levada a estação → à), 32 wrong, 30 where both forms are defensible
One error planted in each of 600 unseen Wikipedia sentences (201 under 20 words, 205 of 20–39, 194 of 40 or more) 94.3% fixed (94.0%, 95.6%, 93.3%)
One error planted in each of 600 unseen Chamber of Deputies sentences (201, 206, 193) 98.2% fixed (97.5%, 98.5%, 98.4%)
One error of each trained pattern placed in unseen sentences (480) 96.9% fixed (crase 85.0%, every other pattern 95–100%)
Stability: the gold re-run with one extra token in front of each sentence (the model alone) 3 of 253 sentences change result (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) 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 all 454 gold errors, fixes 94.7% / 99.0% of the planted errors, and changes 10 Tatoeba, 86 Chamber and 421 Wikipedia sentences, 5, 36 and 130 of them wrong. 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. Wikipedia's rate is the highest because its text carries foreign names, titles and headings run into the next sentence.

Known wrong corrections. An accent added to a foreign-looking name (Mario → Mário, O Universitario → Universitário; a rule against it would also block real fixes such as California → Califórnia); the gender of a participle after a name the sentence does not explain (Carey foi negociado → negociada); a verb's number where the subject comes after it (sob as ilhas dorme um enorme dragão → dormem); e read as é between two clauses (quem protege vagabundo e quem combate a impunidade → é). 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 or the demo) and are part of every score above: an accent is added only when the result is a word (Montorio stays); a capitalised word written twice inside a sentence is a name, not a doubled word (Wagga Wagga; Em Em 2014 at the start of a sentence is still fixed); o/a estudante, o/a colega and a colour name (o groselha) take either article; an accent is never put on a verb that is already a correct form; and a number is never deleted unless it is written twice. Each guard was measured on every set above.

Files

File What it is
model.onnx The tagger (fp32, opset 17). Inputs input_ids, attention_mask; outputs logits_labels [1, T, 1556] 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, decoding defaults (min_error_prob 0.8), run id.
gector-guards.json Apply-side guards: which guards are on for Portuguese (Brazil) and their word lists (see How it was measured).
language-rules.json Language facts the runtime needs (the final full stop is kept: the model was trained with and without it).
grammar-messages.json The Portuguese card messages: which error each kind of change names (Crase, Contraction, está or esta, Plural of an -ão word) and a one-line reason. Read by the Proofbird app; the model does not use it.
verb-form-vocab.txt The Portuguese verb-form table for the $TRANSFORM_VERB_* tags (about 800 verbs, built for this model).
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 556 tags such as $KEEP, $DELETE, $APPEND_da, $REPLACE_as 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: A casa são muito bonito..

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.

words           $START  A  casa  são  muito  bonito  .
tokens          [CLS] A casa são muito bonito . [SEP]
input_ids       [101, 177, 1105, 453, 785, 22003, 119, 102]
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, 1556], a score for each of the 1 556 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: A casa são muito bonito.

Word Wrong Chosen edit Probability
$START 0.0% $KEEP 100.0%
A 0.0% $KEEP 100.0%
casa 0.0% $KEEP 100.0%
são 100.0% $TRANSFORM_VERB_P3P_P3S 100.0%
muito 0.0% $KEEP 100.0%
bonito 99.9% $TRANSFORM_SUF_o_a 99.9%
. 0.0% $KEEP 100.0%

→ A casa é muito bonita.

Pass 2: A casa é muito bonita.

Word Wrong Chosen edit Probability
$START 0.0% $KEEP 100.0%
A 0.0% $KEEP 100.0%
casa 0.0% $KEEP 100.0%
é 0.0% $KEEP 100.0%
muito 0.0% $KEEP 100.0%
bonita 0.0% $KEEP 100.0%
. 0.0% $KEEP 100.0%

→ A casa é muito bonita. — 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 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 Portuguese (Brazil) 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", "Crase", "Contraction") with a one-line reason from grammar-messages.json, and, on request, a longer explanation.

quickstart.py and the in-browser demo run 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. If you redistribute the model or a model built from it, keep the 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. Tatoeba sentences are from tatoeba.org, CC BY 2.0 FR. Contains text from the plenary speeches of the Câmara dos Deputados (Brazilian Chamber of Deputies), from its open data portal, which the Câmara publishes in the public domain with credit to the Câmara dos Deputados (terms). The base encoder is BERTimbau, neuralmind/bert-base-portuguese-cased, by Fábio Souza, Rodrigo Nogueira and Roberto Lotufo (NeuralMind), MIT licence: BERTimbau: Pretrained BERT Models for Brazilian Portuguese, BRACIS 2020. The tagging scheme follows GECToR (Omelianchuk et al., 2020, GECToR – Grammatical Error Correction: Tag, Not Rewrite); the Portuguese verb-form table was built for this model.

How to cite

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

@misc{hartnett2026gectorptbr,
  author       = {Hartnett, Patrick Andrew},
  title        = {Proofbird GECToR grammar model (Portuguese, Brazil)},
  year         = {2026},
  publisher    = {Hugging Face},
  howpublished = {\url{https://huggingface.co/proofbird/gector-bert-pt-br}},
  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.

Downloads last month
179
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for proofbird/gector-bert-pt-br

Quantized
(21)
this model

Dataset used to train proofbird/gector-bert-pt-br

Space using proofbird/gector-bert-pt-br 1