metadata
base_model: facebook/nllb-200-distilled-600M
library_name: transformers.js
pipeline_tag: translation
https://huggingface.co/facebook/nllb-200-distilled-600M with ONNX weights to be compatible with Transformers.js.
Usage (Transformers.js)
If you haven't already, you can install the Transformers.js JavaScript library from NPM using:
npm i @xenova/transformers
You can then perform multilingual translation like this:
import { pipeline } from '@xenova/transformers';
// Create a translation pipeline
const translator = await pipeline('translation', 'Xenova/nllb-200-distilled-600M');
// Translate text from Hindi to French
const output = await translator('जीवन एक चॉकलेट बॉक्स की तरह है।', {
src_lang: 'hin_Deva', // Hindi
tgt_lang: 'fra_Latn', // French
});
console.log(output);
// [{ translation_text: 'La vie est comme une boîte à chocolat.' }]
See here for the full list of languages and their corresponding codes.
Note: Having a separate repo for ONNX weights is intended to be a temporary solution until WebML gains more traction. If you would like to make your models web-ready, we recommend converting to ONNX using 🤗 Optimum and structuring your repo like this one (with ONNX weights located in a subfolder named onnx
).