huggingworld commited on
Commit
614198e
·
verified ·
1 Parent(s): 6449c09

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +54 -3
README.md CHANGED
@@ -1,3 +1,54 @@
1
- ---
2
- license: llama3.2
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: meta-llama/Llama-3.2-1B-Instruct
3
+ library_name: transformers.js
4
+ license: llama3.2
5
+ pipeline_tag: text-generation
6
+ ---
7
+
8
+ https://huggingface.co/meta-llama/Llama-3.2-1B-Instruct with ONNX weights to be compatible with Transformers.js.
9
+
10
+ ## Usage (Transformers.js)
11
+
12
+ 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/@huggingface/transformers) using:
13
+ ```bash
14
+ npm i @huggingface/transformers
15
+ ```
16
+
17
+ **Example:** Text generation with `onnx-community/Llama-3.2-1B-Instruct`.
18
+
19
+ ```js
20
+ import { pipeline } from "@huggingface/transformers";
21
+
22
+ // Create a text generation pipeline
23
+ const generator = await pipeline("text-generation", "onnx-community/Llama-3.2-1B-Instruct");
24
+
25
+ // Define the list of messages
26
+ const messages = [
27
+ { role: "system", content: "You are a helpful assistant." },
28
+ { role: "user", content: "Tell me a joke." },
29
+ ];
30
+
31
+ // Generate a response
32
+ const output = await generator(messages, { max_new_tokens: 128 });
33
+ console.log(output[0].generated_text.at(-1).content);
34
+ ```
35
+
36
+ <details>
37
+
38
+ <summary>Example output</summary>
39
+
40
+ ```
41
+ Here's a joke for you:
42
+
43
+ What do you call a fake noodle?
44
+
45
+ An impasta!
46
+
47
+ I hope that made you laugh! Do you want to hear another one?
48
+ ```
49
+ </details>
50
+
51
+
52
+ ---
53
+
54
+ 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`).