ctranslate2-rs
This library provides Rust bindings for OpenNMT/CTranslate2. At this time, it has only been tested and confirmed to work on macOS and Linux.
Compilation
For macOS, users should utilize the built-in Accelerate framework, eliminating the need for additional libraries.
On Linux, users have the option to use either OpenBLAS or Intel MKL:
- If using OpenBLAS, please add the path to the directory containing
libopenblas.ato theLIBRARY_PATHenvironment variable. - If using Intel MKL, ensure to enable the
mklfeature.
Both macOS and Linux require the installation of CMake to compile the library.
Model Conversion for CTranslate2
To use model files with CTranslate2, they must first be converted.
Below is an example of how to convert the nllb-200-distilled-600M model:
pip install ctranslate2
ct2-transformers-converter --model facebook/nllb-200-distilled-600M --output_dir nllb-200-distilled-600M --copy_files tokenizer.json
For more details, please refer to the CTranslate2's docs.
Example of text translation
The following example translates English to German and Japanese using the previously converted
model nllb-200-distilled-600M.
use Result;
use ;
use ;
Output
Hallo Welt!<unk>, (score: Some(-0.5597002))
このライブラリでは,CTranslate2 の Rust バインディングが提供されています., (score: Some(-0.56321025))
Example of text generation
License
This application is released under the MIT License. For details, see the LICENSE file.