Proofbird Grammar — Danish

gector-bert-da · on-device Danish grammar correction

Try it in your browser: coming soon on proofbird.app.

Version 2.0.0 · run 2026-12-01-2311 · 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, a new training run or changed guards and rules the second, card or metadata fixes the third.

A GECToR-style sequence tagger for Danish 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.

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 word's ending, put a letter's marks 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-da", "quickstart.py"))
quickstart = importlib.util.module_from_spec(spec)
spec.loader.exec_module(quickstart)

model = quickstart.Gector("proofbird/gector-bert-da")
corrected, suggestions = model.correct("Børnene var rolig og bilen er nyt.")
print(corrected)
print(suggestions)
Børnene var rolige og bilen er ny.
[{"start": 12, "length": 5, "original": "rolig", "replacement": "rolige"}, {"start": 30, "length": 3, "original": "nyt", "replacement": "ny"}]

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 "Børnene var rolig og bilen er nyt." prints every step below.

What it corrects

en and et (en hus → et hus, et bil → en bil), the adjective's form after en/et, after a definite word and before a noun (et stor hus → stort, De gammel huse → gamle, Min nyt bil → nye), the adjective after er/var/bliver in gender and number (Bilen er nyt → ny, Børnene var rolig → rolige, Huset er gammel → gammelt), the present tense and the infinitive (Jeg lære dansk → lærer, Jeg vil gerne lærer → lære, at læser → læse), compounds written apart (jern banen → jernbanen, skatte lettelse → skattelettelse), -ene and -ende (drengende → drengene, en spændene film → spændende), a closed set of words that are often confused (ligger/lægger in clear frames, nogen/nogle, af/ad, end/en, I/i: større en mig → end, en ting af gangen → ad), missing æ, ø and å (Vi skal kore → køre, pa → på), a word written twice, and a capital at the start of a sentence. It reads a sentence typed without a final full stop the same way as one with it.

How it was trained

  • Base encoder: NbAiLab/nb-bert-base (NB-BERT, the National Library of Norway, CC BY 4.0). It was chosen by measurement: on 1 200 Danish sentence pairs (one correct, one with an error) it preferred the correct one 99.0% of the time, the best of the encoders tried. A tagging head (391 edit labels) and an error-detection head sit on top.

  • Data: synthetic only. Three sources, 3 047 281 sentences in all:

    • 1 500 000 sentences from Danish Wikipedia (wikimedia/wikipedia, 20231101.da);
    • 1 500 000 sentences from the proceedings of the European Parliament (Europarl v8 through OPUS, sessions before June 2011): speech in the first and second person, questions and argument, the register encyclopedic text lacks;
    • 47 281 sentences from Tatoeba, everyday Danish (all that pass the length filter, less the sentences held out for the checks below).

    They were corrupted by hand-written Danish 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 Danish (det er mere en teknisk sag is right, so en → end is taught only in a comparison); the training data was checked for contradictions, so that the same words are not an error in one sentence and correct in the next. The word lists the rules use (the gender of 11 605 nouns, 1 862 adjectives and their forms, 13 089 compounds, 1 024 pairs of -ende and -ene forms, the words with æ, ø and å) were counted on all three sources and read before use. Real sentences that carry a pattern the model needs (a plural subject with its adjective, a verb after a modal, a compound) were added again with the error placed exactly there, and 150 000 template sentences teach patterns the corpora rarely contain. 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 in the fine-tuning. No user text was used.

  • One epoch (131 307 steps, batch 64, learning rate 3e-5) on one NVIDIA L4. Run id 2026-12-01-2311; the published weights are the end of the run.

How it was measured

Check Result
Gold set (244 hand-written sentences: 128 with one error each, 116 correct) 128 fixed, 116 left alone, 0 missed, 0 made worse
Wrong corrections on 4 000 everyday Tatoeba sentences (held out from training) 0. 5 sentences changed: 4 real mistakes in the test sentences fixed (At have ubeskyttet sex er farlig → farligt, Den original opdrætter kakerlakker → originale, Jeg ved hvor vigtigt hun er for dig → vigtig), 1 where both forms are defensible
Wrong corrections on 4 000 sentences from European Parliament sessions the model never saw (from June 2011) 1 (0.025%). 8 sentences changed: 6 real mistakes fixed (Denne pakke er vigtigt → vigtig, så kan vi går over → gå, en princip → et princip), 1 defensible, 1 wrong
Wrong corrections on 10 000 sentences of the last part of Danish Wikipedia (never in training) 10 (0.1%). 106 sentences changed: 84 real mistakes in the text fixed (en lange række → lang, et amorf stof → amorft, foran sit lejlighed → sin, stempel fabrik → stempelfabrik), 12 where both forms are defensible, 10 wrong
One error planted in each of 600 unseen Wikipedia sentences 93.2% fixed
One error planted in each of 600 unseen European Parliament sentences 99.2% fixed
One error of each trained pattern placed in unseen sentences (612) 98.5% fixed
Stability: the gold re-run with one extra token in front of each sentence (the model alone) 0 sentences change result (the 3 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 the model fixes the same 128 gold errors and more real mistakes in the three sets (114 instead of 94), and makes more wrong corrections (29 instead of 15 before the word-pair guards below). 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. A noun given the wrong gender (dette projekt med en skilift → et, en prøveperiode på et årstid → en); a foreign word read as Danish (Et häkte → En, lucky losere → løsere); an adjective that agrees with the wrong word (New Directions er sejrrig → sejrrige); two words the writer meant apart joined into one (Electron transfer → Electrontransfer, nyt land bugten Dollart → landbugten). A word that is already misspelled can be changed into another wrong word (idet de havder erfaret → hævder); the spell checker flags those words separately.

Known misses. A single error in a Wikipedia sentence of 40 words or more is missed about 7 times in 100. The gold set was written for this model and has not yet been reviewed by a native speaker. 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 word is deleted only when it is written twice, and til til and mange mange stay (Lav en til til mig); sjal, skod and brod are words of their own and are not changed to sjæl, skød and brød (Mary strikkede et sjal, the town Brod); a word is replaced only by a word the dictionary knows; a number is never deleted.

Files

File What it is
model.onnx The tagger (fp32, opset 17). Inputs input_ids, attention_mask; outputs logits_labels [1, T, 391] 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, and a text without one gets one for the model only.
verb-form-vocab.txt Empty for Danish: verb forms are corrected with ending tags, not a verb table.
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. One tag family is specific to this model: $TRANSFORM_DIA_<n><letter> puts a mark back on the n-th letter with that base letter (kore + 1ø → køre; æ and ø count as a and o); quickstart.py shows how it is applied.

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 391 tags such as $KEEP, $DELETE, $APPEND_for, $REPLACE_ad 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. The sentence goes in as written (a text typed without a final full stop is shown to the model with one, which is taken off again - language-rules.json): Børnene var rolig og bilen er nyt..

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  Børnene  var  rolig  og  bilen  er  nyt  .
tokens          [CLS] B ##ør ##nene var roli ##g og bilen er nyt . [SEP]
input_ids       [101, 139, 18437, 75160, 10299, 30252, 10240, 10156, 109842, 10163, 58921, 119, 102]
attention_mask  [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]

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

3. The response. Two outputs (float32): logits_labels [1, 13, 391], a score for each of the 391 edits at every token, and logits_d [1, 13, 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: Børnene var rolig og bilen er nyt.

Word Wrong Chosen edit Probability
$START 0.0% $KEEP 100.0%
Børnene 0.0% $KEEP 100.0%
var 0.0% $KEEP 100.0%
rolig 100.0% $TRANSFORM_SUF__e 100.0%
og 0.0% $KEEP 100.0%
bilen 0.0% $KEEP 100.0%
er 0.0% $KEEP 100.0%
nyt 100.0% $TRANSFORM_SUF_t_ 99.9%
. 0.0% $KEEP 100.0%

→ Børnene var rolige og bilen er ny.

Pass 2: Børnene var rolige og bilen er ny.

Word Wrong Chosen edit Probability
$START 0.0% $KEEP 100.0%
Børnene 0.0% $KEEP 100.0%
var 0.0% $KEEP 100.0%
rolige 0.0% $KEEP 100.0%
og 0.0% $KEEP 100.0%
bilen 0.0% $KEEP 100.0%
er 0.0% $KEEP 100.0%
ny 0.0% $KEEP 100.0%
. 0.0% $KEEP 100.0%

→ Børnene var rolige og bilen er ny. — 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 Danish 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 Creative Commons Attribution 4.0 International licence (CC BY 4.0), the licence of the base encoder. If you redistribute the model or a model built from it, keep the NOTICE file with it.

The base encoder is NB-BERT, NbAiLab/nb-bert-base, by Per E. Kummervold, Javier de la Rosa, Freddy Wetjen and Svein Arne Brygfjeld (the National Library of Norway), CC BY 4.0: Operationalizing a National Digital Library: The Case for a Norwegian Transformer Model, NoDaLiDa 2021.

The fine-tuning 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 proceedings of the European Parliament, © European Union, 1996–2011, reused under the European Parliament's legal notice, through the Europarl corpus (statmt.org/europarl, Philipp Koehn, Europarl: A Parallel Corpus for Statistical Machine Translation, MT Summit 2005) as distributed by OPUS (opus.nlpl.eu, Jörg Tiedemann, Parallel Data, Tools and Interfaces in OPUS, LREC 2012). 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:

@misc{hartnett2026gectorda,
  author       = {Hartnett, Patrick Andrew},
  title        = {Proofbird GECToR grammar model (Danish)},
  year         = {2026},
  publisher    = {Hugging Face},
  howpublished = {\url{https://huggingface.co/proofbird/gector-bert-da}},
  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
126
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for proofbird/gector-bert-da

Quantized
(2)
this model

Dataset used to train proofbird/gector-bert-da