Grammar error correction backend with Triton and FastAPI/ GRPC integration
Project description
Grammared Language
Adding Grammarly (and other) open source models to LanguageTool
Demo
Demo server: https://grammared-language-demo.rayliu.ca/v2
Warning: Demo server is hosted on an Oracle ARM CPU server. It may be slow!
Overview
Limitations
- The correction will always show up as grammar corrections
- LanguageTool does not use the correction categories supplied by the remote servers
- No paraphrasing support
- LanguageTool clients request to a hard coded rewrite server url
Supported Models
GECToRmodels from gotutiyan/gectortext2text-generationmodels- for example, Grammarly's CoEdIT models
Quick Start
Model Config
Config File
See model_config.yaml or docker/default_model_config.yaml as 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 you can also set via 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, see the comments in grammared_language/utils/config_parser.py.
LanguageTool
To enable remote servers with LanguageTool we will need a remote rule config file, which could be enabled via the remoteRulesFile option in the server.properties file
How config loading works
When the service starts, it loads model configuration in this order:
- If a config file exists at
/model_config.yaml, it loads that. - If not, and environment variables starting with
GRAMMARED_LANGUAGE__are set, it loads config from those (seedemo-docker-compose.yml). - 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 details.
- Start everything with Docker Compose:
docker-compose up --build
This runs Triton, the API, and (optionally) LanguageTool with remote rules.
Requirements
- Python 3.11+
- Docker (for containers)
- Triton Inference Server (for model serving)
- See
pyproject.tomlfor details
Usage
LanguageTool Integration
To use remote servers with LanguageTool, set up a remote rule config file (see example_language_tool_configs/remote-rule-config.json) and add this to your server.properties:
remoteRulesFile=./remote-rule-config.json
Then 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
- For model loading or inference errors, check Triton and API logs
- For LanguageTool integration, make sure your remote rule config is correct and accessible
License
See LICENSE.md.
Credits & References
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file grammared_language-0.1.0.tar.gz.
File metadata
- Download URL: grammared_language-0.1.0.tar.gz
- Upload date:
- Size: 42.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a11375879e4409871323259d841068b191248bdd031c9b58c950ba83985dd8d5
|
|
| MD5 |
639ff80f1d20d663850dade07c432b5b
|
|
| BLAKE2b-256 |
d00cdc4ce16ff37d22cf19e1d414b21aa91ea354df20eef1cb82257f7fdebc9c
|
File details
Details for the file grammared_language-0.1.0-py3-none-any.whl.
File metadata
- Download URL: grammared_language-0.1.0-py3-none-any.whl
- Upload date:
- Size: 58.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5625d1f2e55edd9b4f2e70c460f60084331fd0524e2ab718be145d330bdefbc6
|
|
| MD5 |
41177aea1cacef1b379c590d4514eb66
|
|
| BLAKE2b-256 |
7fc9f96fb7899226f8f082dcf9be46ad73c7e7f68bf3e48de061826acdc1a254
|