Xenova HF staff commited on
Commit
82bec24
1 Parent(s): 330cd50

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +23 -2
README.md CHANGED
@@ -4,6 +4,27 @@ tags:
4
  - transformers
5
  ---
6
 
7
- https://huggingface.co/Xenova/llama2.c-stories110M 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`).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  - transformers
5
  ---
6
 
7
+ ## Usage (Transformers.js)
8
 
9
+ 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:
10
+ ```bash
11
+ npm i @xenova/transformers
12
+ ```
13
+
14
+ You can then use the model generate text like this:
15
+
16
+ ```js
17
+ import { pipeline } from "@xenova/transformers";
18
+
19
+ // Create a text-generation pipeline
20
+ const generator = await pipeline('text-generation', 'Xenova/llama2.c-stories110M');
21
+
22
+ const text = 'Once upon a time,';
23
+ const output = await generator(text);
24
+ console.log(output);
25
+ // [{ generated_text: "Once upon a time, there was a little girl named Lily. She loved to play outside in" }]
26
+
27
+ const output2 = await generator(text, { max_new_tokens: 50 });
28
+ console.log(output2);
29
+ // [{ generated_text: "Once upon a time, there was a little girl named Lily. She loved to play outside in the sunshine. One day, she saw a big, scary dog. She was scared and didn't know what to do. \nSudden" }]
30
+ ```