Views
No views yet
npm i @huggingface/transformersonnx-community/DeepSeek-R1-Distill-Qwen-1.5B-ONNX1import { pipeline, TextStreamer } from "@huggingface/transformers";
2
3// Create a text generation pipeline
4const generator = await pipeline(
5 "text-generation",
6 "LemOneLabs/DeepSeek-R1-Distill-Qwen-1.5B-ONNX",
7 { dtype: "q4f16" },
8);
9
10// Define the list of messages
11const messages = [
12 { role: "user", content: "Solve the equation: x^2 - 3x + 2 = 0" },
13];
14
15// Create text streamer
16const streamer = new TextStreamer(generator.tokenizer, {
17 skip_prompt: true,
18 // callback_function: (text) => { }, // Optional callback function
19})
20
21// Generate a response
22const output = await generator(messages, { max_new_tokens: 512, do_sample: false, streamer });
23console.log(output[0].generated_text.at(-1).content);<think>
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.
Next, I'll rewrite the equation as \( (x - 1)(x - 2) = 0 \).
Using the zero product property, I'll set each factor equal to zero:
1. \( x - 1 = 0 \) leads to \( x = 1 \).
2. \( x - 2 = 0 \) leads to \( x = 2 \).
Therefore, the solutions to the equation are \( x = 1 \) and \( x = 2 \).
</think>
To solve the quadratic equation:
\[
x^2 - 3x + 2 = 0
\]
**Step 1: Factor the Quadratic**
We look for two numbers that multiply to \( +2 \) and add up to \( -3 \). These numbers are \( -1 \) and \( -2 \).
\[
x^2 - 3x + 2 = (x - 1)(x - 2) = 0
\]
**Step 2: Apply the Zero Product Property**
If the product of two factors is zero, at least one of the factors must be zero.
\[
x - 1 = 0 \quad \text{or} \quad x - 2 = 0
\]
**Step 3: Solve for \( x \)**
\[
x = 1 \quad \text{or} \quad x = 2
\]
**Final Answer:**
\[
\boxed{1 \text{ and } 2}
\]onnx).