OVOS translation module for No Language Left Behind
Project description
OVOS No Language Left Behind Plugin (CTranslate2)
Language Plugin for NLLB200 language translator.
Overview
The NLLB200Translator is a translation service that uses the NLLB-200 models to translate text between different languages. It integrates with the OVOS framework and utilizes CTranslate2 for fast and efficient translation.
Model Options
Below are the available model options for the NLLB-200 Translator:
| Model Name | Source | Description |
|---|---|---|
| flores200_sacrebleu_tokenizer_spm | CTranslate2 | Tokenizer model |
| nllb-200_600M_int8 | CTranslate2 | 600M parameter model, int8 quantized |
| nllb-200_1.2B_int8 | CTranslate2 | 1.2B parameter model, int8 quantized |
| nllb-200_3.3B_int8 | CTranslate2 | 3.3B parameter model, int8 quantized |
| nllb-200-distilled-1.3B-ct2-int8 | HuggingFace Hub: OpenNMT/nllb-200-distilled-1.3B-ct2-int8 | 1.3B distilled model, int8 quantized |
| nllb-200-3.3B-ct2-int8 | HuggingFace Hub: OpenNMT/nllb-200-3.3B-ct2-int8 | 3.3B model, int8 quantized |
Usage
OVOS Integration
The plugin can be used within the OVOS framework to translate utterances or texts on demand. Below is an example configuration for integrating the translator within OVOS.
Configuration
Add the following configuration to one of the configuration files (e.g., ~/.config/mycroft/mycroft.conf):
{
"language": {
"translation_module": "ovos-translate-plugin-nllb",
"ovos-translate-plugin-nllb": {
"model": "nllb-200_600M_int8"
}
}
}
Example
Here's an example of how to use the NLLB200Translator in a Python script:
from ovos_translate_plugin_nllb import NLLB200Translator
src = "es"
tgt = "en-us"
tx = NLLB200Translator(config={"model": "nllb-200_600M_int8"})
utts = ["Hola Mundo"]
print("Translations:", tx.translate(utts, tgt, src))
utts = "hello world"
print("Translations:", tx.translate(utts, src, tgt))
Advanced Configuration
HuggingFace Integration
To use models hosted on the HuggingFace Hub, configure the model parameter with the respective HuggingFace model ID. The NLLB200Translator class handles downloading and loading the model from HuggingFace.
Additional Parameters
beam_size: Configure the beam size used for translation to balance between translation quality and speed.device: Specify the device type, either 'cpu' or 'cuda' (for GPU).
Example:
from ovos_translate_plugin_nllb import NLLB200Translator
tx = NLLB200Translator(config={
"model": "nllb-200_600M_int8",
"beam_size": 5,
"device": "cuda"
})
Using CUDA/GPU
To leverage GPU acceleration with CUDA, configure the NLLB200Translator to use the cuda device. This can significantly speed up the translation process, especially for large batches or longer texts.
Prerequisites
Ensure you have a CUDA-compatible GPU and the necessary CUDA drivers installed on your system. Refer to the CUDA Installation Guide for more details.
Example
Here's a complete example demonstrating how to configure and use the NLLB200Translator with CUDA:
from ovos_translate_plugin_nllb import NLLB200Translator
if __name__ == "__main__":
src = "es"
tgt = "en-us"
tx = NLLB200Translator(config={
"model": "nllb-200-3.3B-int8",
"beam_size": 5,
"device": "cuda"
})
utts = ["Hola Mundo"]
print("Translations:", tx.translate(utts, tgt, src))
utts = "hello world"
print("Translations:", tx.translate(utts, src, tgt))
Project details
Release history Release notifications | RSS feed
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 ovos_translate_plugin_nllb-0.0.2a4.tar.gz.
File metadata
- Download URL: ovos_translate_plugin_nllb-0.0.2a4.tar.gz
- Upload date:
- Size: 11.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef7c4220379fb9f7521d7e133f49f53153231f39ff5fc39286a04660adca76af
|
|
| MD5 |
d876a77fb50a3d09b6a5bdd406c3c4d8
|
|
| BLAKE2b-256 |
ceabdf8246acc391b4a06c326787ab76b08827a92cd3d29abc4896b7291c9d23
|
File details
Details for the file ovos_translate_plugin_nllb-0.0.2a4-py3-none-any.whl.
File metadata
- Download URL: ovos_translate_plugin_nllb-0.0.2a4-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f31453231aee5b100b28b5287d1ff344c3fb0f84e73cf5f65763697dc0dfe811
|
|
| MD5 |
fb072cb0db54267fe4e1acef816b5fd2
|
|
| BLAKE2b-256 |
29666ee20f2d36115ec8dc5d14f2d36fd3da95c6c1edf713a21b820ac3369b6f
|