Xenova HF staff commited on
Commit
ac54bd9
1 Parent(s): e5f9b9f

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +27 -0
README.md CHANGED
@@ -6,4 +6,31 @@ pipeline_tag: translation
6
 
7
  https://huggingface.co/facebook/nllb-200-distilled-600M with ONNX weights to be compatible with Transformers.js.
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  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`).
 
6
 
7
  https://huggingface.co/facebook/nllb-200-distilled-600M with ONNX weights to be compatible with Transformers.js.
8
 
9
+ ## Usage (Transformers.js)
10
+
11
+ 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:
12
+ ```bash
13
+ npm i @xenova/transformers
14
+ ```
15
+
16
+ You can then perform multilingual translation like this:
17
+ ```js
18
+ import { pipeline } from '@xenova/transformers';
19
+
20
+ // Create a translation pipeline
21
+ const translator = await pipeline('translation', 'Xenova/nllb-200-distilled-600M');
22
+
23
+ // Translate text from Hindi to French
24
+ const output = await translator('जीवन एक चॉकलेट बॉक्स की तरह है।', {
25
+ src_lang: 'hin_Deva', // Hindi
26
+ tgt_lang: 'fra_Latn', // French
27
+ });
28
+ console.log(output);
29
+ // [{ translation_text: 'La vie est comme une boîte à chocolat.' }]
30
+ ```
31
+
32
+ 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.
33
+
34
+ ---
35
+
36
  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`).