Back
Content & Media Generation

A Two-Stage Grammar Correction and Error-Annotation Service for Writing Quality at the Point of Use

How Pfactorial Technologies built a grammar-correction service that pairs a transformer correction model with rule-based error annotation, so a writer gets both the fix and the reasoning behind it.

August 21, 2026
Share
ENGAGEMENT SNAPSHOT

Pfactorial_Case_Study_GrammarChecker image 1
Figure 1 - Key figures from this engagement, at a glance.
EXECUTIVE SUMMARY
Our client needed writing-quality checking built into a product used for everyday communication - official documentation, essays, chat, business correspondence - where a grammar mistake isn't cosmetic, it's a miscommunication risk in a professional or academic setting.
A correction model alone wasn't enough: a model that silently rewrites a sentence gives a user a fix with no explanation of what was wrong, and a purely rule-based checker can't handle the range of phrasing real writing produces across academic, business, and casual registers.
Pfactorial built a two-stage grammar service that pairs a fine-tuned correction model with a dataset-agnostic, rule-based error annotator, so every corrected sentence comes back with both the fix and the reasoning behind it.
Why this engagement is representative This engagement demonstrates Pfactorial's approach to pairing a generative model with a deterministic, explainable layer, so a user gets a correction they can verify rather than a black-box rewrite.
THE CHALLENGE
Building grammar correction that a user could trust meant solving problems a single model call doesn't solve on its own.

1. A correction model alone doesn't explain itself

A user given only a rewritten sentence has no way to see what was wrong or learn from the correction, which matters most in academic and professional writing.
2. Error annotation has to work across every kind of English text, not just what a model was trained on
A machine-learning annotator is only as good as its training data; the annotation layer had to be dataset-agnostic so it could annotate errors in academic writing, chat, and business correspondence alike.

3. The two halves of the pipeline have different failure modes

The correction model is right most of the time; the rule-based annotator is sometimes wrong - the system had to expose both outputs rather than let one silently mask the other's mistakes.
The real brief Not "return a corrected sentence" but "return the correction and a dataset-agnostic account of what was wrong with the original, so the user can verify and learn from the fix."
THE SOLUTION
Pfactorial built a two-stage grammar service: a transformer correction model fixes the sentence, then a rule-based annotator explains what was wrong with the original.
Pfactorial_Case_Study_GrammarChecker image 2
Figure 1 - Correction and annotation run as two independent stages, then combine into a single response.

Architectural principles

  • Correct with a model, explain with rules - A generative model handles the open-ended task of producing a fluent correction, while a rule-based tool handles the closed, auditable task of labelling what changed and why.
  • Choose the annotator for portability, not peak accuracy - ERRANT is dataset-agnostic, so unlike a model trained on a fixed error distribution, it can annotate errors across the full range of English writing the service needs to support, from resumes to casual chat.
  • Keep the original alongside every correction - The response always includes the original sentence next to the correction and its annotations, so a user is never shown a silent rewrite with no way to compare against what they typed.
CAPABILITIES DELIVERED
The service consolidates correction and explanation into capabilities that map directly onto how writers actually use it.
CAPABILITY
WHAT IT DOES
Sentence-level grammar correction
Corrects grammatical errors in a submitted sentence using the coedit-large transformer model.
Rule-based error annotation
Labels the specific errors present in the original text, independent of what the correction model was trained on.
Academic & professional writing support
Applies to formal documentation and essays, where a wrong verb tense or subject-verb mismatch reads as a credibility problem.
Business correspondence support
Applies the same correction-and-annotation pipeline to day-to-day business writing and communication.
Single unified response
One endpoint returns the corrected sentence, the error annotations, and the original text together, so a client integration only has to make one call.
Pfactorial_Case_Study_GrammarChecker image 3
Figure 2 - A single request returns the original, the correction, and the annotations in one response.
Design note The two stages are allowed to disagree: the correction model is usually right, and the rule-based annotator is sometimes wrong, but the service surfaces both rather than silently trusting one over the other - a deliberate tradeoff favoring transparency over a single polished answer.
ENGINEERING FOR SCALE AND RELIABILITY
Four decisions kept the service simple enough to integrate as one endpoint while staying explainable.

A dataset-agnostic annotator instead of a second model

ERRANT is rule-based rather than trained, so it doesn't inherit the blind spots a second machine-learning model would have relative to the correction model's own training distribution.

One combined endpoint rather than separate correction and annotation calls

The grammar-correction endpoint exposes GET and POST on a single route and returns the corrected text, annotations, and original sentence together, so an integrating client makes one call, not two.

Three small functions instead of one monolithic handler

correctGrammar, errantResult, and grammarCorrection each do one job, which keeps the correction step and the annotation step independently testable and replaceable.

An explicit flag for annotator quality

The team documented that ERRANT's annotations are sometimes wrong even when the correction is right, treating that as a known, monitored limitation rather than an assumed guarantee.
DELIVERY APPROACH
The service was built stage by stage, correction first, so the annotation layer had a reliable corrected text to work against.
1. Correction function - wiring correctGrammar to the coedit-large model and validating output on sample sentences.
2. Annotation function - integrating ERRANT via errantResult to compare original and corrected text and produce labelled errors.
3. Combined orchestration - building grammarCorrection to call both functions and return original text, correction, and annotations together.
4. Endpoint & delivery - exposing a single GET/POST endpoint for client integration.
RESULTS AND IMPACT

Pfactorial_Case_Study_GrammarChecker image 4
- Key outcomes from this engagement.
The grammar service is live behind a single endpoint, returning a coedit-large correction alongside ERRANT's rule-based error annotations for any submitted sentence.
Because the annotator is rule-based rather than trained on a fixed dataset, the service holds up across the full range of writing it needs to support - academic, business, and casual - without needing a separate annotation model per register.

What it enabled commercially

The client can now offer writing-quality feedback - not just a silent rewrite - anywhere their product accepts free text, from documentation to chat, without operating their own correction model.
WHY PFACTORIAL
This engagement reflects Pfactorial's approach to pairing a generative model with a deterministic, auditable layer, so a feature that touches user-generated text stays explainable rather than becoming a black box.
Pfactorial_Case_Study_GrammarChecker image 5
- Service lines this engagement draws on.
Engagement enquiries Pfactorial Technologies works with organisations that need language-quality features - grammar correction, error annotation, writing feedback - embedded directly into their product. If you're evaluating a text-quality feature for your platform, we're happy to give you an honest read on scope and risk before anyone commits to anything. · pfactorial.ai
APPENDIX A - TECHNOLOGY STACK
The technology stack underpinning the system, grouped by the layer it serves.
Pfactorial_Case_Study_GrammarChecker image 6

Result and Analysis

ENGAGEMENT SNAPSHOT

How Pfactorial Technologies built a grammar-correction service that pairs a transformer correction model with rule-based error annotation, so a writer gets both the fix and the reasoning behind it.

Pfactorial_Case_Study_GrammarChecker image 1
Pfactorial_Case_Study_GrammarChecker image 2
Pfactorial_Case_Study_GrammarChecker image 3
Pfactorial_Case_Study_GrammarChecker image 4
Pfactorial_Case_Study_GrammarChecker image 5
Pfactorial_Case_Study_GrammarChecker image 6