Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,102 @@
|
|
1 |
-
---
|
2 |
-
license: mit
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: mit
|
3 |
+
library_name: transformers.js
|
4 |
+
base_model: deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B
|
5 |
+
---
|
6 |
+
|
7 |
+
https://huggingface.co/deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B with ONNX weights to be compatible with Transformers.js.
|
8 |
+
|
9 |
+
|
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 |
+
|
19 |
+
**Example:** Text-generation w/ `onnx-community/DeepSeek-R1-Distill-Qwen-1.5B-ONNX`
|
20 |
+
|
21 |
+
```js
|
22 |
+
import { pipeline, TextStreamer } from "@huggingface/transformers";
|
23 |
+
|
24 |
+
// Create a text generation pipeline
|
25 |
+
const generator = await pipeline(
|
26 |
+
"text-generation",
|
27 |
+
"onnx-community/DeepSeek-R1-Distill-Qwen-1.5B-ONNX",
|
28 |
+
{ dtype: "q4f16" },
|
29 |
+
);
|
30 |
+
|
31 |
+
// Define the list of messages
|
32 |
+
const messages = [
|
33 |
+
{ role: "user", content: "Solve the equation: x^2 - 3x + 2 = 0" },
|
34 |
+
];
|
35 |
+
|
36 |
+
// Create text streamer
|
37 |
+
const streamer = new TextStreamer(generator.tokenizer, {
|
38 |
+
skip_prompt: true,
|
39 |
+
// callback_function: (text) => { }, // Optional callback function
|
40 |
+
})
|
41 |
+
|
42 |
+
// Generate a response
|
43 |
+
const output = await generator(messages, { max_new_tokens: 512, do_sample: false, streamer });
|
44 |
+
console.log(output[0].generated_text.at(-1).content);
|
45 |
+
```
|
46 |
+
|
47 |
+
<details>
|
48 |
+
<summary>See example output</summary>
|
49 |
+
|
50 |
+
```
|
51 |
+
<think>
|
52 |
+
To solve the quadratic equation \( x^2 - 3x + 2 = 0 \), I'll start by factoring the left-hand side. I need to find two numbers that multiply to 2 and add up to -3. These numbers are -1 and -2.
|
53 |
+
|
54 |
+
Next, I'll rewrite the equation as \( (x - 1)(x - 2) = 0 \).
|
55 |
+
|
56 |
+
Using the zero product property, I'll set each factor equal to zero:
|
57 |
+
1. \( x - 1 = 0 \) leads to \( x = 1 \).
|
58 |
+
2. \( x - 2 = 0 \) leads to \( x = 2 \).
|
59 |
+
|
60 |
+
Therefore, the solutions to the equation are \( x = 1 \) and \( x = 2 \).
|
61 |
+
</think>
|
62 |
+
|
63 |
+
To solve the quadratic equation:
|
64 |
+
|
65 |
+
\[
|
66 |
+
x^2 - 3x + 2 = 0
|
67 |
+
\]
|
68 |
+
|
69 |
+
**Step 1: Factor the Quadratic**
|
70 |
+
|
71 |
+
We look for two numbers that multiply to \( +2 \) and add up to \( -3 \). These numbers are \( -1 \) and \( -2 \).
|
72 |
+
|
73 |
+
\[
|
74 |
+
x^2 - 3x + 2 = (x - 1)(x - 2) = 0
|
75 |
+
\]
|
76 |
+
|
77 |
+
**Step 2: Apply the Zero Product Property**
|
78 |
+
|
79 |
+
If the product of two factors is zero, at least one of the factors must be zero.
|
80 |
+
|
81 |
+
\[
|
82 |
+
x - 1 = 0 \quad \text{or} \quad x - 2 = 0
|
83 |
+
\]
|
84 |
+
|
85 |
+
**Step 3: Solve for \( x \)**
|
86 |
+
|
87 |
+
\[
|
88 |
+
x = 1 \quad \text{or} \quad x = 2
|
89 |
+
\]
|
90 |
+
|
91 |
+
**Final Answer:**
|
92 |
+
|
93 |
+
\[
|
94 |
+
\boxed{1 \text{ and } 2}
|
95 |
+
\]
|
96 |
+
```
|
97 |
+
|
98 |
+
</details>
|
99 |
+
|
100 |
+
---
|
101 |
+
|
102 |
+
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`).
|