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