File size: 1,581 Bytes
b5f4e4a
d7ca6d5
c55aaf7
 
b5f4e4a
 
c55aaf7
b5f4e4a
 
ac54bd9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b5f4e4a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
---
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](https://huggingface.co/docs/transformers.js) JavaScript library from [NPM](https://www.npmjs.com/package/@xenova/transformers) using:
```bash
npm i @xenova/transformers
```

You can then perform multilingual translation like this:
```js
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](https://github.com/facebookresearch/flores/blob/main/flores200/README.md#languages-in-flores-200) 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](https://huggingface.co/docs/optimum/index) and structuring your repo like this one (with ONNX weights located in a subfolder named `onnx`).