Xenova HF staff commited on
Commit
6142562
·
verified ·
1 Parent(s): 03b7d05

Update README.md

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