7.2.2 Deploying your own scalable Machine Translation API
TWB-MT-fastapi is an open-source REST API designed for serving multiple machine translation models in production environments. It offers a range of features and supports various translation system types, including ctranslate2 models, Transformers-based models from Hugging Face, and custom rule-based translators.
Features
Minimal REST API interface for using many models
Batch translation
Low-code specification for loading various types of models at start-up
Automatic downloading of huggingface models
Multilingual model support
Model Chaining
Translation pipeline specification (lowercasing, tokenization, subwording, recasing)
Automatic sentence splitting (uses nltk library)
Manual sentence splitting with punctuation
Supports sentence piece and byte-pair-encoding models
GPU support
Easy deployment with docker-compose
Usage Instructions
Model Configuration: In the
config.json
file, you can specify the translation models, their settings, pre- and post-processors. You can configure various translation model types such as ctranslate2, Hugging Face transformer models, and custom rule-based translators.Custom Configuration Examples: The repository README provides example configurations for different model types, including ctranslate2, OPUS and OPUS-big models of Helsinki-NLP, NLLB models, and M2M100 models. These examples demonstrate how to set up the config.json file for each model type.
Advanced Configuration Features: The README explains how to use advanced features like alternative model loading, model chaining, and sentence splitting. These features allow you to customize your translation pipelines and choose appropriate models for various translation tasks.
Building and Running: The README guides you through the process of building and running the API. You can run it locally using a virtual environment and Python 3.8, or you can utilize Docker Compose for easy deployment.
Example API Calls: The README provides example cURL and Python code snippets to demonstrate how to use the API for simple translation, using alternative models, and performing batch translations. Additionally, it explains how to retrieve the list of supported languages and model pairs.
Last updated