Update README.md
Browse files
README.md
CHANGED
@@ -5,4 +5,46 @@ base_model: oxyapi/oxy-1-micro
|
|
5 |
|
6 |
https://huggingface.co/oxyapi/oxy-1-micro with ONNX weights to be compatible with Transformers.js.
|
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
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`).
|
|
|
5 |
|
6 |
https://huggingface.co/oxyapi/oxy-1-micro with ONNX weights to be compatible with Transformers.js.
|
7 |
|
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/@huggingface/transformers) using:
|
12 |
+
```bash
|
13 |
+
npm i @huggingface/transformers
|
14 |
+
```
|
15 |
+
|
16 |
+
You can then use the model to generate text like this:
|
17 |
+
|
18 |
+
```js
|
19 |
+
import { pipeline } from "@huggingface/transformers";
|
20 |
+
|
21 |
+
// Create a text generation pipeline
|
22 |
+
const generator = await pipeline(
|
23 |
+
"text-generation",
|
24 |
+
"onnx-community/oxy-1-micro",
|
25 |
+
{ dtype: "q4" },
|
26 |
+
);
|
27 |
+
|
28 |
+
// Define the list of messages
|
29 |
+
const messages = [
|
30 |
+
{ role: "system", content: "You are a wise old wizard in a mystical land. A traveler approaches you seeking advice." },
|
31 |
+
{ role: "user", content: "Where is the nearest inn?" },
|
32 |
+
];
|
33 |
+
|
34 |
+
// Generate a response
|
35 |
+
const output = await generator(messages, { max_new_tokens: 256, do_sample: false });
|
36 |
+
console.log(output[0].generated_text.at(-1).content);
|
37 |
+
```
|
38 |
+
|
39 |
+
<details>
|
40 |
+
|
41 |
+
<summary>See example output</summary>
|
42 |
+
|
43 |
+
```
|
44 |
+
Greetings, traveler! I am here to guide you through this enchanted realm. The nearest inn is located not far from my humble abode. It is called "The Quiet Haven," and it is nestled on a quiet path just beyond my property. You can find it by following the winding paths of the forest. May I assist you further?
|
45 |
+
```
|
46 |
+
</details>
|
47 |
+
|
48 |
+
---
|
49 |
+
|
50 |
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`).
|