Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

codecov

OVOS No Language Left Behind Plugin (CTranslate2)

This is a language plugin for NLLB-200, a translation model from Meta AI.

Overview

NLLB200Translator translates text between languages with the NLLB-200 models. It plugs into the OVOS framework and uses CTranslate2 to run translation fast and efficiently.

Model Options

The table below lists the available models 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

Install

Install the plugin with pip:

pip install ovos-translate-plugin-nllb

Usage

OVOS Integration

Use the plugin inside OVOS to translate utterances and text on demand. Add this configuration to one of the configuration files, for example ~/.config/mycroft/mycroft.conf:

{
  "language": {
    "translation_module": "ovos-translate-plugin-nllb",
    "ovos-translate-plugin-nllb": {
      "model": "nllb-200_600M_int8"
    }
  }
}

Python Script

This example shows how to use 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 a model hosted on the HuggingFace Hub, set the model parameter to the HuggingFace model ID. NLLB200Translator downloads and loads the model from HuggingFace.

Additional Parameters

  • beam_size: the beam size used for translation. A larger value trades speed for translation quality.
  • device: the device to run on, either cpu or cuda (GPU).
from ovos_translate_plugin_nllb import NLLB200Translator
tx = NLLB200Translator(config={
    "model": "nllb-200_600M_int8",
    "beam_size": 5,
    "device": "cuda"
})

Using CUDA/GPU

Set NLLB200Translator to the cuda device to use GPU acceleration. This can speed up translation for large batches or long texts.

Prerequisites

You need a CUDA-compatible GPU and the CUDA drivers for your system. See the CUDA Installation Guide for details.

Example

This example configures and runs 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))

License

This project is licensed under the Apache License 2.0.

Metadata

Release files for ovos-translate-plugin-nllb 0.0.3a1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ovos-translate-plugin-nllb 0.0.3a1
File Size Uploaded
ovos_translate_plugin_nllb-0.0.3a1.tar.gz 12.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ovos-translate-plugin-nllb 0.0.3a1
File Interpreter ABI Platform
ovos_translate_plugin_nllb-0.0.3a1-py3-none-any.whl Python 3 none any Details

Total release size: 24.6 kB

Release files / ovos_translate_plugin_nllb-0.0.3a1.tar.gz

Download URL ovos_translate_plugin_nllb-0.0.3a1.tar.gz
Size 12.0 kB
Tags Source
SHA-256 checksum
How to use checksums
92f72b33568af218fe8140a7529c0d9e0b114b7d25b7385c4b70779867184a71
BLAKE2b-256 checksum
How to use checksums
87fe02b2704e512e01e0b368bc8701121f651d621f5116ae2dbb9f1cb000d4af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / ovos_translate_plugin_nllb-0.0.3a1-py3-none-any.whl

Download URL ovos_translate_plugin_nllb-0.0.3a1-py3-none-any.whl
Size 12.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b2be30b1276cfcbd26c55f8072aac2dbbe985e185080a4064a039e5f5d7da5f6
BLAKE2b-256 checksum
How to use checksums
7373c33a933da8fbab37dc731989d06c897f9036794023d1f884f7e9314623c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page