https://github.com/mozilla/translation-service
1.9K
HTTP service that uses bergamot-translator and compressed neural machine translation models for fast inference on CPU.
Install Git LFS (docs). On Linux:
sudo apt-get update
sudo apt-get install -y git-lfs
sudo git lfs install
Donwload models:
git clone https://github.com/mozilla/firefox-translations-models
gzip -d firefox-translations-models/models/prod/*/*
Run service:
docker run --name translation-service -it --rm -v $(pwd)/firefox-translations-models/models/prod:/models -p 8080:8080 -e PORT=8080 mozilla/translation-service:latest
Call HTTP API:
curl --header "Content-Type: application/json" \
--request POST \
--data '{"from":"es", "to":"en", "text": "Hola Mundo"}' \
http://0.0.0.0:8080/v1/translate
See translation result:
> {"result": "Hello World"}
The directory that contains unzipped models (esen, ende etc.) should be mounted to /models in Docker container.
Environment variables to set in container:
PORT - service port (default is 8000)
LOGGING_LEVEL - ERROR, WARNING, INFO or DEBUG (default is INFO)
WORKERS - number of bergamot-translator workers (default is 1). 0 - automatically set as the number of available CPUs. It is recommended to minimize workers and scale horizontally with k8s or other orchestrators.
Please create issues on Github: https://github.com/mozilla/translation-service
Matrix channel of Firefox Translations project: https://chat.mozilla.org/#/room/#firefoxtranslations:mozilla.org
Content type
Image
Digest
Size
1.2 GB
Last updated
over 4 years ago
docker pull mozilla/translation-service