Skip to main content

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 Screenshot

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

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:

  1. If a config file exists at /model_config.yaml, 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 details.

  1. Start everything with Docker Compose:
    docker-compose up --build
    
    This runs Triton, the API, and (optionally) LanguageTool with remote rules.

Requirements

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

grammared_language-0.1.0.tar.gz (42.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

grammared_language-0.1.0-py3-none-any.whl (58.3 kB view details)

Uploaded Python 3

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

Hashes for grammared_language-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a11375879e4409871323259d841068b191248bdd031c9b58c950ba83985dd8d5
MD5 639ff80f1d20d663850dade07c432b5b
BLAKE2b-256 d00cdc4ce16ff37d22cf19e1d414b21aa91ea354df20eef1cb82257f7fdebc9c

See more details on using hashes here.

File details

Details for the file grammared_language-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for grammared_language-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5625d1f2e55edd9b4f2e70c460f60084331fd0524e2ab718be145d330bdefbc6
MD5 41177aea1cacef1b379c590d4514eb66
BLAKE2b-256 7fc9f96fb7899226f8f082dcf9be46ad73c7e7f68bf3e48de061826acdc1a254

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page