Instructions to use citan/plgec-herbert-large with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use citan/plgec-herbert-large with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("token-classification", model="citan/plgec-herbert-large")# Load model directly from transformers import AutoTokenizer, AutoModelForTokenClassification tokenizer = AutoTokenizer.from_pretrained("citan/plgec-herbert-large") model = AutoModelForTokenClassification.from_pretrained("citan/plgec-herbert-large", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- plgec-herbert-large — Polish grammar error correction
plgec-herbert-large — Polish grammar error correction
plgec-herbert-large is a GECToR-style token-edit classifier over
HerBERT-large. It reads a
Polish sentence and proposes minimal, conservative edits (replace, append,
delete), each tagged with an error class (orth, infl, agree, punct,
conf, spell) and a raw confidence. It was built as an advisory WARN-level
gate for document pipelines: flag suspected errors for a human, never rewrite
on its own.
It is not a general-purpose corrector and does not try to be. The design goal was a low spurious-edit rate you can trust as a linter, per-edit classes you can route, and honest per-class numbers — including the weak classes, which are weak and documented as such below.
Model identity
- Checkpoint
model.safetensorssha256:fc609b7184c858203d9ca3ee8e73e00999e2f266be317ee5b10e73b4c8fa0204 - ONNX export
onnx/model.onnxsha256:d2ceee6db7464f0832379039748473c34184b0121d1ee7a4020bb64b21bba2da - Encoder: allegro/herbert-large-cased, tokenizer HerbertTokenizerFast, max_len 128
- Label vocabulary: 6,680 GECToR tags; measured coverage of distinct real-error edit forms: 0.90
- Decode triple (fixed at publication): keep_confidence_bias 0.30, min_error_probability 0.30, max_iters 1, re-ranker disabled
- ONNX equivalence: 100.0% argmax agreement, max probability delta 1.1e-05 (gate: >= 99.9% and <= 1e-3)
Results
Two instruments, reported side by side because they disagree, and both are real. The token-level (detection) instrument asks: did the model flag the right token? It is the training-validation instrument. The char-span (correction) instrument asks: did the applied correction strictly overlap the gold correction's character span? It is the instrument used for the LanguageTool comparison and the phase-over-phase comparisons on this card. Detection is easier than correction; the gap between the two tables is the correction-quality debt, stated per class.
Measured on the frozen 180-sentence curated test set (190 gold errors) at the published decode triple.
| class | detection recall | detection precision |
|---|---|---|
| orth | 0.368 (95% CI [0.234, 0.527], n=38)† | 0.333 (95% CI [0.138, 0.609], n=12)† |
| infl | 0.438 (95% CI [0.282, 0.607], n=32)† | 0.400 (95% CI [0.219, 0.613], n=20)† |
| agree | 0.967 (95% CI [0.833, 0.994], n=30)† | 0.875 (95% CI [0.719, 0.950], n=32)† |
| punct | 0.645 (95% CI [0.469, 0.789], n=31)† | 0.800 (95% CI [0.490, 0.943], n=10)† |
| conf | 0.133 (95% CI [0.053, 0.297], n=30)† | 0.115 (95% CI [0.040, 0.290], n=26)† |
| spell | 0.767 (95% CI [0.591, 0.882], n=30)† | 0.933 (95% CI [0.702, 0.988], n=15)† |
† All per-class cells: not statistically significant at n=30–38 — treat point estimates as characterization, not ranking. Instrument: token-level per_class_detection (training-validation instrument; attribution-derived precision).
| class | correction recall | correction precision |
|---|---|---|
| orth | 0.108 (95% CI [0.043, 0.247], n=37)† | 0.333 (95% CI [0.138, 0.609], n=12)† |
| infl | 0.250 (95% CI [0.133, 0.421], n=32)† | 0.400 (95% CI [0.219, 0.613], n=20)† |
| agree | 0.933 (95% CI [0.787, 0.982], n=30)† | 0.875 (95% CI [0.719, 0.950], n=32)† |
| punct | 0.258 (95% CI [0.137, 0.432], n=31)† | 0.800 (95% CI [0.490, 0.943], n=10)† |
| conf | 0.100 (95% CI [0.035, 0.256], n=30)† | 0.115 (95% CI [0.040, 0.290], n=26)† |
| spell | 0.467 (95% CI [0.302, 0.639], n=30)† | 0.933 (95% CI [0.702, 0.988], n=15)† |
† All per-class cells: not statistically significant at n=30–38 — treat point estimates as characterization, not ranking. Instrument: strict char-span overlap of applied corrections (the LanguageTool-comparison instrument).
On both tables the per-class detection/correction precision columns carry identical values. That is not a copy-paste error: on this evaluation, attribution-derived per-class detection precision (an edit credited to a class only when the gold edit at that position is of the same class) coincides cell-for-cell with char-span correction precision — same walk, same counts (verified at render time from the committed artifacts).
A caveat before the deltas: the curated test set was consumed three times
end-to-end — the initial final evaluation (run 2816dd83), the re-gate
(ae553941, the numbers above), and the ONNX equivalence gate — and the
decode re-selection was informed by the first test-set read. That is adaptive
reuse: the shipped operating point was chosen after seeing test data. Read
the per-class point estimates with that in mind; the confidence intervals do
not undo it.
The decode parameters themselves were retuned over a 135-combination grid (keep_confidence_bias −0.10…0.30, min_error_probability 0.20…0.60, 1–3 iterations). The adopted triple moved min_error_probability from 0.60 to 0.30 at bias 0.30, trading a measured slice of validation F0.5 for validation recall — the trade quoted in the spurious section below.
The two accepted regressions
orth is the accepted flagship-class regression, stated on a corrected dual-instrument basis. Token-level detection recall is at exact parity with the previous phase's model: 0.368 both (14 of 38 orth detections in both models). On the char-span instrument, corrections fell from 7/37 to 4/37 — recall 0.189 → 0.108, not statistically significant at n=37 — while precision fell 0.636 → 0.333. The char-span F0.5 delta of −0.197 decomposes as −0.143 precision effect (73%) plus −0.054 recall effect (27%): the loss is mostly the model applying orth-shaped edits where none belong, not lost detections. The owner accepted this regression on exactly this corrected basis (2026-09-12, after an earlier rationale that conflated the two instruments was corrected — see the corrigendum shipped alongside this card). A Polish RoBERTa-large ablation is the v2 candidate for the encoder question.
infl recall fell 0.531 → 0.4375 (−0.094). The delta is 3 sentences on 32 gold infl errors — not statistically significant at that n. A causality split attributed the drop to the encoder swap itself (−0.125 recall even at default decode settings, so no decode-side lever recovers it), but encoder attribution is a hypothesis, not an established cause; the controlled ablation is deferred to v2. If you need the previous behavior: the Phase-4 fallback checkpoint (HerBERT-base) is a separate deployment with different decode defaults — not a drop-in replacement for this model, and it needs its own thresholds file.
Comparison with LanguageTool
Self-hosted LanguageTool (pl-PL) ran on the same curated set as a baseline. Framing rules for reading that comparison:
- LanguageTool produced 341 matches on the 180 sentences; 165 of 341 (48%) had no mapping to this project's six classes and are excluded from per-class credit. Every per-class LT comparison in this section is computed on the mapped remainder only.
- LanguageTool's 0.0 recall on
orth,infl,agree, andconfis a class-map artifact: those classes' LT rules largely sit in the unmapped bucket. It is never evidence that LT cannot handle those error types, and this card does not claim so. - Where mapping exists, LT wins on spelling outright: LT corrects 0.90 (27/30) of spell errors where this model corrects 0.47 (14/30) on the same char-span instrument. Keep the rule engine; this model is the complement, not the replacement.
The honest summary: on the mapped slice the two systems trade wins by class (this model corrects 0.933 of agreement errors; LT's agreement activity sits in the unmapped bucket), LT wins spell outright, and on the unmapped half of LT's activity there is no per-class comparison at all, only the aggregate statement that 48% of LT matches fell outside this project's class map.
Spurious edits on clean text
On 200 clean held-out sentences the model made 18 unsolicited edits — 0.09 per sentence, 0.0049 of tokens edited. The absolute claim this card makes: the model edits under 0.01 of tokens on clean text (measured 0.0049). No relative-threshold claim is implied.
Per class (this run's attribution):
| class | spurious edits |
|---|---|
| orth | 1 |
| infl | 7 |
| agree | 3 |
| punct | 0 |
| conf | 7 |
| spell | 0 |
The operating point traded spurious headroom for validation recall: relative to the earlier argmax-F0.5 triple (0.30/0.60/1), the clean-text edited-token fraction rose from 0.0016 to 0.0049 — about three times — alongside the recall gain the decode section describes. (The historical grid run is bc35d532; the adopted triple comes from the combined selection.)
On in-domain document text
A second measurement ran the model over 200 clean sentences sampled from a Polish document-analysis pipeline (PDF-to-text output; clean = zero LanguageTool matches per sentence, checked by a fail-closed client — an LT outage aborts rather than marks clean; first-occurrence dedup, document order, no RNG). Result: 0.12 mean edits per sentence (24 edits over 3518 tokens, 0.0068 of tokens; p99 = 1 edit per sentence), per class: orth 7, infl 8, agree 2, punct 0, conf 6, spell 1.
That is about a third higher than the 0.09 clean-test rate. This measurement had no pre-agreed pass threshold: it is disclosed for what it is — the rate you should actually expect on document pipeline text, aggregates only (no sample text is published).
Failure examples
Real failure modes, captured from the published ONNX model with the shipped decode on handwritten synthetic sentences (never production text). Each edit below is the model's actual output, with its real confidence. The captures predate the schema-version-2 update (calibration + blocklist): confidences shown are raw, and the decode itself is unchanged — calibration is argmax-preserving, so the model still proposes the same edits today.
1. orth — a valid semicolon "corrected" to a comma.
Rada przyjęła budżet w marcu; rewizja odbyła się we wrześniu.
{"token_idx": 5, "original": ";", "replacement": ",", "tag": "$REPLACE_,",
"class": "orth", "confidence": 0.586}
The semicolon is correct Polish punctuation. The model swaps it for a comma
at 0.586 confidence — an edit shape that dominates the orth class's
clean-text failures (punctuation-adjacent swaps attributed to orth by the
shipped tag-to-class map), and roughly one in three orth flags on clean text
looked like this at publication. This exact pattern is what the shipped
blocklist now removes: with schema version 2 the ; to , swap is dropped
after decoding (the semicolon sits past the position guard), so this edit
no longer reaches the consumer — see the punctuation blocklist section for
the measured suppression and the one-line opt-out.
2. conf — a confident confusable false positive, the class that ships disabled.
Może morze będzie spokojne.
{"token_idx": 1, "original": "morze", "replacement": "może",
"tag": "$REPLACE_może", "class": "conf", "confidence": 0.949}
Both words are used correctly. The model "fixes" the valid morze into
może at 0.949 — the highest confidence in this whole probe, on a sentence
with no error. This is the conf class in one example: char-span precision
0.115 (3 tp / 23 fp), 7 of the 18 clean-text spurious edits. That is why
conf ships disabled by default in thresholds.yaml — with the shipped
file this edit is dropped before output; set conf.enabled: true to opt in.
3. infl — a soft inflection "correction" between two valid forms.
W sklepiku kupił cukier i mąkę.
{"token_idx": 1, "original": "sklepiku", "replacement": "sklepie",
"tag": "$REPLACE_sklepie", "class": "infl", "confidence": 0.376}
W sklepiku is a correct locative; w sklepie is the more frequent collocation. The model nudges toward the frequent form at 0.376 — a preference, not a correction. With infl char-span precision at 0.400, flags like this are the class's main cost.
For scale: across 39 handwritten clean probe sentences, 4 drew exactly one spurious edit each — right at the ~0.1-per-sentence rate the clean-text measurement reports. The decoder stayed silent on the other 35.
Confidence calibration
Shipped: per-edit confidence is calibrated by a single global temperature applied to logits before decoding, softmax(logits / T) with T = 0.7598, fitted on 4,000 held-out clean sentences (80,371 candidate positions, L-BFGS on negative log-likelihood). The transform is argmax-preserving: it rescales confidence, never which edit is chosen. Because T < 1 the fit sharpens rather than cools — the raw model was underconfident on clean text.
| surface | role | raw ECE (uncalibrated) | calibrated ECE | positions | sentences |
|---|---|---|---|---|---|
| clean held-out fit set | ship gate | 0.0114 | 0.0030 | 80,371 | 4,000 |
| punctuation slice | drift report | 0.0455 | 0.0430 | 502 | 30 |
| confusable slice | drift report | 0.0371 | 0.0196 | 550 | 30 |
| curated test set | drift report | 0.0389 | 0.0388 | 2,906 | 180 |
Ship decision (pre-registered gate): the paired sentence-level Wilson 95% CI on the fraction of sentences whose calibration error improved is 0.966 (95% CI [0.960, 0.971], n=4,000; 3,865 improved) — it excludes the 0.5 zero-effect point and the fit-set ECE decreased, so T ships. The three drift rows are report-only: their reference labels come from deployment text, so absolute ECE there mixes model error with calibration and is not a calibration claim — the paired before/after delta on identical inputs is the evidence.
This T applies to the FP32/ONNX logits this repository publishes. A second constant, for a future INT8 build, is reserved as calibration.t_int8: null in thresholds.yaml; null means identity for that runtime until it is separately fitted. Consumers read calibration.temperature from thresholds.yaml instead of hard-coding the value.
The punctuation blocklist
thresholds.yaml (schema version 2) also ships a blocklist section with exactly one rule: REPLACE-shaped ; to , edits are dropped after decoding, in the same filter stage as the per-class bars; the blocklist never re-decodes. The rule carries a position guard (min_tokens_before: 3): it fires only when the semicolon sits at least 3 tokens into the clause, so short enumeration lists keep their genuine ; to , corrections.
Measured on the document-pipeline corpus that motivated the rule: the flagged pattern fell from 29 emissions to 1 (96.6% suppressed, 28 of 29) — suppressed with 1 documented residual. The surviving emission is a documented, owner-accepted residual: it sits at the same early token position as a known gold correction of the same shape, and the rule schema (an exact token pair with a position guard) cannot suppress one without the other.
Zero gold recall loss, proven pairwise: on the punctuation audit slice, recall with the rule on equals recall with it off (0.354839 both legs); the one gold ; to , correction in the slice survives the guard. This was a single-pattern read-only verification, not a re-benchmark of the model; no verdict is drawn from it.
The rule is opinionated about register, and it is one yaml line to disagree: literary or flexible-register consumers who WANT ; to , corrections set that rule's enabled: false — no code, no re-decode, the edit simply reaches the consumer again (the same opt-out shape as the conf class).
INT8 quantization
What was attempted, and why you cannot download it. Before this
revision we built a dynamic-quantization INT8 variant of the ONNX graph
(ONNX Runtime quantize_dynamic, per-channel INT8 weights, UINT8
activations) and held it to the same discipline as the FP32 graph: a
paired per-class F0.5 equivalence gate on the frozen curated test set,
a separately fitted confidence temperature for the quantized logits,
and a serving benchmark row on the identical rig, corpus, and batch as
the FP32 rows in the serving table. The point of the exercise was the
classic INT8 trade — a smaller memory footprint and higher CPU
throughput in exchange for a bounded quality delta. The quality side of
that trade did not hold up under the equivalence bar this project
pre-registered for itself, so the INT8 graph is not published: no INT8
file exists in this repository, nothing downstream depends on one, and
the FP32 graph above stays the recommended default. The attempt is
disclosed below exactly as it measured — a negative result, recorded
the same way a shipped feature would be.
The per-class equivalence gate rejected the INT8 variant: the conf class alone regressed by 13.0% relative F0.5 (FP32 0.115 → INT8 0.100, support 30), past the automatic no-ship bound for cliff-size regressions (any class beyond 10% relative ends the attempt, no exceptions argued after the fact). Under the same policy the bar is 5% relative per class; punct sat inside it at +1.9%, and the remaining classes — orth, infl, agree, spell — actually scored higher under INT8. A rejection on one class is still a rejection: the quantized graph is not published, and no INT8 file exists in this repository.
| class | FP32 F0.5 | INT8 F0.5 | relative F0.5 change |
|---|---|---|---|
| orth | 0.449 | 0.495 | −10.2% (higher under INT8) |
| infl | 0.378 | 0.391 | −3.6% (higher under INT8) |
| agree | 0.870 | 0.906 | −4.1% (higher under INT8) |
| punct | 0.772 | 0.757 | +1.9% (within the 5% bar) |
| conf | 0.115 | 0.100 | +13.0% — regressed past the 10% cliff bound |
| spell | 0.865 | 0.885 | −2.4% (higher under INT8) |
An aggregate argmax-agreement tripwire also flagged: 98.68% of positions kept the same top tag across the two graphs, below the 99.0% advisory threshold set for catching catastrophic breakage. It is advisory by design and never blocks a verdict; with 4 of 6 classes scoring higher under INT8, breakage is not the reading — it is flagged here because it flagged.
The rare-tag confusion audit (bottom training-frequency decile) observed no confused pairs — nothing to report there.
Serving benchmark, same rig, corpus, and batch as the FP32 rows in the serving table: 50.5 sentences/s on the CPU provider with 1495 MB peak RSS (FP32 CPU: 18.8 sentences/s, 3032 MB). Two disclosures come with that number. First, dynamic INT8 quantization (UINT8 activations) has no CUDA kernels for its quantized matmuls in ONNX Runtime 1.29.0 — a GPU session silently falls back to the CPU execution provider for the quantized subgraph, so there is no honest INT8 GPU row to quote, and the figure above is a CPU figure. Second, since the graph is not published, the row measures an artifact you cannot download from this repository — recorded as evidence, not as an offering.
Confidence calibration for the INT8 logits was fitted separately, and the fit itself passed its ship gate: t_int8 = 0.7523 (3,921 of 4,000 carve-out sentences improved, 95% CI [0.975, 0.984]; carve-out ECE 0.0072 → 0.0013) — close to the FP32 temperature, meaning quantization barely moved the temperature optimum. None of it is published: with the graph withheld, calibration.t_int8 in thresholds.yaml stays null (identity), and an INT8-fitted constant applied to FP32 logits would mis-calibrate them rather than improve them.
FP32 stays the published and recommended graph. The attempt may be revisited in a future revision with a different quantization configuration, and if it is, it will go through this same gate.
Limitations
The conf class is disabled by default. Shipped thresholds.yaml sets conf.enabled: false; opt in with that one key. Why: conf edits were 7 of the 18 clean-text spurious edits (39%) while the class corrects just 4 of 30 curated confusable errors at the shipped bar (token recall 0.133, char-span precision 3 tp / 23 fp = 0.115). Disabling cuts clean-text spurious edits from 18 to 11 (−39%) at the cost of those 4 catches — a trade this card reports rather than hides. Per-edit confidence does not rescue it: see the 0.949-confidence false positive in the failure examples.
- Per-edit confidence is the calibrated probability (
softmax(logits/T), calibration section above). The constant was fitted on clean in-domain text; on error-bearing text confidence is only partially calibrated (see the drift rows) — do not read 0.9 as a 90% correctness chance. - Only 3 of 6 classes are at lint-gate quality (
agree,punct,spell);orth,infl,confare below it — the per-class tables above are the contract, not the headline. - The label vocabulary covers 0.90 of distinct real-error edit forms (append-extended, measured). Errors whose correction falls in the uncovered 0.10 cannot be proposed at all — a structural ceiling on what the model can fix.
- The curated gold set is machine-verified only (generator + LanguageTool cross-checks; no human linguistic review).
- One confidence knob serves all classes: at the same 0.30 bar, conf token recall is 0.133 while spell is 0.767 — the uniform threshold is biased against weak classes (that is partly what the per-class thresholds file exists to correct).
- GPU serving measured a 4.07 GB VRAM increment — this model is not a sub-2-GB GPU resident.
- Encoder attribution of the infl regression (recall 0.531 → 0.4375) is a hypothesis, not an established cause; the controlled RoBERTa-large ablation is deferred to v2.
Serving performance (measured)
| device | sentences/s | batch | threads | peak memory | duration (1,000 sentences) |
|---|---|---|---|---|---|
| CPU (ONNX Runtime) | 18.822 | 32 | 8 | RSS 3032 MB | 53.1 s |
| CUDA (ONNX Runtime) | 118.728 | 32 | 8 | VRAM increment 4.07 GB | 8.4 s |
| CPU (INT8 — attempted, not shipped; see the INT8 section) | 50.474 | 32 | 8 | RSS 1495 MB | 19.8 s |
Measured, not projected (run 06-serve-benchmark, 1,000-sentence batch): an NVIDIA GB10-class ARM host with unified memory, in-container, ONNX Runtime CPU / CUDA execution providers; VRAM via cudaMemGetInfo (peak 11302 MB over a 7233 MB baseline). Two honest notes: the CPU figure is below the 20 sentences/s design target (18.8 measured — above the 10 sentences/s floor where the design would have been reconsidered, but a miss is a miss), and the CUDA path uses a 4.07 GB VRAM increment, not the sub-2-GB footprint originally aimed for. If your budget is tighter than these numbers, the numbers win, not the aims.
Training lineage
Seven runs, in order. IDs are internal experiment-registry run identifiers; each row pins the committed evidence manifest the run is recorded in. The released checkpoint is the Stage-III epoch-1 model, re-gated and exported to ONNX with 100% argmax agreement.
| run ID | run name | purpose | evidence manifest |
|---|---|---|---|
53037324 |
05-large-stage1-smoke | Stage-I dry-run: step-time sizing for the HerBERT-large lease | stage1_dryrun.json 45ce810a3665 |
f776e7ea |
05-large-stage1 | Stage-I pretrain on ~1.2M synthetic pairs | stage1_run.json e0d25dc662af |
cb3c8925 |
05-large-stage2 | Stage-II error-tagged fine-tune (epoch 2 selected) | stage2_run.json 7f00720b6e0f |
ee310124 |
05-large-stage3 | Stage-III curated fine-tune (epoch 1 selected — the released checkpoint) | stage3_selection.json a0df09bf2042 |
bc35d532 |
05-threshold-sweep | 135-combination decode-grid sweep | threshold_sweep.json 568b4c35cdcb |
57952735 |
05-rerank-calibrate | Re-ranker calibration + combined decode selection (adopted triple) | rerank_calibration.json 520b944a09a3 |
ae553941 |
05-large-eval-regate | Final re-gate evaluation — the numbers on this card | delta_05.json 7b8ac3457106 |
Full run IDs (for provenance): 53037324eec24de981d5e084bb30b057, f776e7eab7ad48bf9488339a8ba3bb3d, cb3c89250de94758a6d12747bb738fe3, ee3101243ae848c6bd4e5edca87f4890, bc35d532f3724bb3971efe76b695c98e, 57952735b055462ea6bd96c037050921, ae553941ea654e6eb6b96464f29c0eda.
Data and training
Training pairs (~1.2M) were generated by injecting synthetic errors into clean Polish sentences (CC100-pl and Polish Wikipedia sources, plus a licensed corpus staged internally; no dataset is redistributed with this model). Errors come from a Morfeusz2-driven generator: inflection and agreement corruptions derived from morphological analysis, curated confusable-pair swaps, single-character orthography swaps (ż/rz, ó/u, ch/h, ą/ę), punctuation, and spelling. The evaluation set is a frozen 180-sentence curated set, machine-verified against the generator and LanguageTool but never reviewed by a human linguist. The GECToR label vocabulary (6,680 tags) covers 0.90 of distinct real-error edit forms — the ceiling is measured, not assumed.
Intended use
A WARN-level advisory gate for Polish prose in document pipelines: each sentence gets zero or more flagged edits with class, span, and confidence; a human accepts or dismisses. Conservative by construction — the decoder only emits an edit when its raw probability clears a high bar (about 0.6 at the shipped settings). Not suitable for unattended rewriting, for literary editing, or for languages other than Polish. Self-hosted LanguageTool remains the deterministic first gate; this model is the neural second opinion on the error classes rules structurally miss.
License
The model weights are published under CC BY-NC 4.0 (non-commercial, attribution). The base encoder, allegro/herbert-large-cased, is CC BY 4.0. Training included a licensed corpus that is not redistributed here; no datasets ship with this model.
Citation
@software{plgec_herbert_large_2026,
title = {plgec-herbert-large: a Polish GECToR grammar-error
corrector over HerBERT-large},
author = {Krystian Lewandowski},
year = {2026},
url = {https://huggingface.co/citan/plgec-herbert-large},
note = {Per-class detection and correction results with 95% CIs on a
180-sentence curated Polish set; conservative decode,
per-class thresholds}
}
Usage
Minimal standalone inference — public dependencies only (onnxruntime,
tokenizers; no deep-learning framework, no serving stack):
pip install onnxruntime tokenizers
hf download citan/plgec-herbert-large --local-dir plgec-herbert-large
cd plgec-herbert-large
python inference_example.py "Myślę że masz rację."
inference_example.py ships in this repository, next to this card. It
loads the ONNX model, tokenizer, label vocabulary and thresholds.yaml
from its own directory and prints one JSON object per sentence — per
edit: token index, character span on the source text (an insertion after
the final token reports a span end one codepoint past the text),
original → replacement, tag, class, and confidence (the chosen tag's
probability after the published temperature calibration, under the
published single-pass decode settings). With the
shipped defaults the sentence above returns no edits: the missing comma
before że is detected, but as a conf-class edit — and conf ships
disabled:
{"sentence": "Myślę że masz rację.", "corrected": "Myślę że masz rację.", "edits": []}
Inspect it with the consumer-side filter off, then see a class that is on by default:
python inference_example.py --thresholds none "Myślę że masz rację."
python inference_example.py "Mieszkam w Warszawa od pięciu lat."
{"sentence": "Myślę że masz rację.", "corrected": "Myślę , że masz rację .", "edits": [{"token_idx": 0, "char_span": [5, 6], "original": "Myślę", "replacement": ",", "tag": "$APPEND_,", "class": "conf", "confidence": 0.9222806692123413, "iteration": 1}]}
{"sentence": "Mieszkam w Warszawa od pięciu lat.", "corrected": "Mieszkam w Warszawie od pięciu lat .", "edits": [{"token_idx": 2, "char_span": [11, 19], "original": "Warszawa", "replacement": "Warszawie", "tag": "$REPLACE_Warszawie", "class": "infl", "confidence": 0.9642210006713867, "iteration": 1}]}
thresholds.yaml (schema version 2) is the consumer-side filter, applied
after decoding: per-class min_error_probability and enabled keys (conf
off by default), a calibration block carrying the shipped temperature, and
a blocklist section carrying the ; to , rule — the last two sections
above document those. Edit the shipped file (or pass --thresholds with
your own, or --thresholds none) — the model decode itself never changes:
default:
min_error_probability: 0.30
enabled: true
conf:
min_error_probability: 0.30
enabled: false # opt in to confusable-class edits
# schema_version, calibration, blocklist sections follow in the
# shipped file — see the two sections above
Note the corrected-text field joins edit-applied tokens with single
spaces ("Myślę , że masz rację ."); consumers that care about
typography should apply the per-edit char_spans to the source text
instead.
- Downloads last month
- 48
Model tree for citan/plgec-herbert-large
Base model
allegro/herbert-large-cased