https://huggingface.co/facebook/nllb-200-distilled-600M with ONNX weights to be compatible with Transformers.js.
If you haven't already, you can install the
Transformers.js JavaScript library from
NPM using:
1import { pipeline } from '@huggingface/transformers';
2
3// Create a translation pipeline
4const translator = await pipeline('translation', 'huggingworld/nllb-200-distilled-600M');
5
6// Translate text from Hindi to French
7const output = await translator('जीवन एक चॉकलेट बॉक्स की तरह है।', {
8 src_lang: 'hin_Deva', // Hindi
9 tgt_lang: 'fra_Latn', // French
10});
11console.log(output);
12// [{ 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).