Skip to main content

If you find this project useful, please give it a ⭐ — and contributions are always welcome! 🤗

Grammared Language 🚀

Grammared Language Cover Image: building better sentences (a beaver using a typewriter with books around)

✨ Adding Grammarly (and other) open source models to LanguageTool ✨

Demo 🎬

Demo Screenshot: Graammared Language can improve grammar error corrections such as their/ there

Try it live: https://grammared-language-demo.rayliu.ca/v2 🌐

⚠️ Heads up: Demo server is running on an Oracle ARM CPU server. It might be a bit slow—patience is a virtue! 🐢

Demo config instruction screenshot: Add the demo URL to the client settings -> Advanced settings -> Other server

Overview 📝

LanguageTool is a fantastic open-source grammar and spell-checking tool that mostly uses deterministic rules (with a sprinkle of n-grams).

One of the most common requests is to add support for smarter, self-hosted, AI/ML-based models. While not documented, LanguageTool does support remote correction servers via gRPC (see GRPCRule), configured by the remoteRulesFile option in the server.properties config file.

This project is that missing remote server! It connects LanguageTool to open-source grammatical error correction models—mainly Grammarly's GECToR and CoEdIT—because they're fast, open, and get the job done. 💪

Limitations ⚠️

  • All corrections show up as "grammar" corrections (LanguageTool doesn't use the categories from remote servers)
  • No paraphrasing support (LanguageTool clients use a hardcoded rewrite server URL)

Supported Models 🧠

Quick Start ⚡

Model Config

Config File

Check out model_config.yaml or docker/default_model_config.yaml for a template:

gector_deberta_large:
    type: gector
    backend: triton
    serving_config:
        triton_host: triton-server
        triton_port: 8001
        pretrained_model_name_or_path: "gotutiyan/gector-deberta-large-5k"
        triton_model_name: gector_deberta_large
        device: cuda # cpu, cuda, or auto

Environment Variable

Or set things up with environment variables (see demo-docker-compose.yml for real-world examples):

# See the 'environment:' section in demo-docker-compose.yml for full model config via env vars
# Example:
GRAMMARED_LANGUAGE__MODELS__GECTOR_DEBERTA_LARGE__TYPE=gector
GRAMMARED_LANGUAGE__MODELS__GECTOR_DEBERTA_LARGE__BACKEND=triton
GRAMMARED_LANGUAGE__MODELS__GECTOR_DEBERTA_LARGE__SERVING_CONFIG__TRITON_HOST=triton-server
...

For more details, see the comments in grammared_language/utils/config_parser.py.

LanguageTool Integration 🛠️

To enable remote servers with LanguageTool, you'll need a remote rule config file. Point to it with the remoteRulesFile option in your server.properties file:


How config loading works 🧩

When the service starts, it loads model configuration in this order:

  1. If /model_config.yaml exists, it loads that.
  2. If not, and environment variables starting with GRAMMARED_LANGUAGE__ are set, it loads config from those (see demo-docker-compose.yml).
  3. If neither is found, it falls back to /default_model_config.yaml.

See the get_config function in grammared_language/utils/config_parser.py for the nitty-gritty.


🚢 Start everything with Docker Compose:

docker-compose up --build

This runs Triton, the API, and (optionally) LanguageTool with remote rules. Easy!


Requirements 📦

Usage 🏃

LanguageTool Integration

To use remote servers with LanguageTool:

  1. Set up a remote rule config file (see example_language_tool_configs/remote-rule-config.json).

  2. Add this to your server.properties:

    remoteRulesFile=./remote-rule-config.json
    
  3. Run:

    java -cp languagetool-server.jar org.languagetool.server.HTTPServer --config server.properties
    

With Dockerized LanguageTool 🐳

If you're using the meyay/languagetool or erikvl87/languagetool Docker images, set:

langtool_remoteRulesFile=<remote file config path in docker>

See docker-compose.yml for a full example.

Troubleshooting 🛠️

  • Model loading or inference errors? Check Triton and API logs.
  • LanguageTool not working? Double-check your remote rule config is correct and accessible.

Vibe Coding Notice 🎨

  • One key learning objective of this project is to explore the use of various vibe coding models and tools
    • which is probably why you might see the code quality to be a bit patchy
  • Bugs and rough edges are expected, use at your own risk

Credits & References 🙏

Metadata

Release files for grammared-language 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for grammared-language 0.1.4
File Size Uploaded Provenance Actions
grammared_language-0.1.4.tar.gz 46.2 kB Without provenance Details for grammared_language-0.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for grammared-language 0.1.4
File Interpreter ABI Platform Actions
grammared_language-0.1.4-py3-none-any.whl Python 3 none any Details for grammared_language-0.1.4-py3-none-any.whl

Total release size: 106.4 kB

Release files / grammared_language-0.1.4.tar.gz

Download URL grammared_language-0.1.4.tar.gz
Size 46.2 kB
Tags Source
SHA-256 checksum
How to use checksums
cf9635028e405c0938ce17af9a097c7a38bde570d344a67ac4fd358971df847e
BLAKE2b-256 checksum
How to use checksums
dbb4262d82d5ab0ae60b9593d6fb50a9ca165a4fdd121c36d709d90c8a8fc027
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / grammared_language-0.1.4-py3-none-any.whl

Download URL grammared_language-0.1.4-py3-none-any.whl
Size 60.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
726867c86d3fd713acc9e4f6744bf7cd88c176ab6aadb3f598d38c5178110c8b
BLAKE2b-256 checksum
How to use checksums
7f4a48a55110383e0835dd21628983afde757103fa83e5d2cc963deab10bdcc5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Security for grammared-language 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page