Skip to content

Conversation

@xenova
Copy link
Collaborator

@xenova xenova commented Sep 12, 2025

New models:

Example usage:

import { pipeline, TextStreamer } from "@huggingface/transformers";

// Create a text generation pipeline
const generator = await pipeline(
  "text-generation",
  "onnx-community/MobileLLM-R1-140M-ONNX",
  { dtype: "fp32" },
);

// Define the list of messages
const messages = [
  { role: "user", content: "Solve x^2 - x - 6 = 0." },
];

// Generate a response
const output = await generator(messages, {
  max_new_tokens: 4096,
  do_sample: false,
  streamer: new TextStreamer(generator.tokenizer, {
    skip_prompt: true,
    skip_special_tokens: true,
  }),
});
console.log(output[0].generated_text.at(-1).content);
See example output
<think>
Okay, so I need to solve the quadratic equation x squared minus x minus 6 equals zero. Let me think about how to approach this. Hmm, quadratic equations can be solved using the quadratic formula, right? The standard form is ax² + bx + c = 0, so here it's x² - x - 6 = 0. 

First, I remember that to solve a quadratic equation, I need to find the roots. The quadratic formula is x = [-b ± √(b² - 4ac)] / (2a). In this case, a is 1, b is -1, and c is -6. Let me plug those values into the formula.

So, plugging in the values: x = [-(-1) ± √((-1)² - 4*1*(-6))]/(2*1). Let me compute the discriminant first. The discriminant is b² - 4ac. Plugging in the numbers: (-1)² is 1, and 4ac is 4*1*(-6) which is -24. So the discriminant is 1 - (-24) = 1 + 24 = 25. 

Now, the square root of 25 is 5. So the square root part is 5. Then, the numerator becomes -(-1) is 1, and the denominator is 2. So putting it all together, the solutions are [1 ± 5]/2. 

Calculating the two possibilities: 1 + 5 is 6, divided by 2 is 3. And 1 - 5 is -4, divided by 2 is -2. So the solutions are 3 and -2. 

Wait, let me check if I did everything correctly. The quadratic formula is x = [-b ± √(b² - 4ac)]/(2a). So in this case, a is 1, b is -1, c is -6. So plugging in: -(-1) is 1, and 4ac is 4*1*(-6) = -24. So discriminant is 1 - (-24) = 1 +24=25. Square root of 25 is 5. So yes, the roots are [1 ±5]/2. So 1+5 is 6, divided by 2 is 3, and 1-5 is -4 divided by 2 is -2. That seems right. 

I don't think I made any mistakes here. Let me verify by plugging in a value. Let's take x=3. Then the equation is 3² -3 -6 = 9 -3 -6 = 0. Yep, that works. What about x=-2? (-2)^2 - (-2) -6 = 4 +2 -6 = 0. Also works. So the solutions are 3 and -2. 

I think that's all. The quadratic formula gives the roots, and plugging in the values checks out. So the answer should be 3 and -2.
</think>To solve the quadratic equation \(x^2 - x - 6 = 0\), we use the quadratic formula \(x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}\), where \(a = 1\), \(b = -1\), and \(c = -6\).

First, we calculate the discriminant:
\[
b^2 - 4ac = (-1)^2 - 4(1)(-6) = 1 + 24 = 25
\]
The square root of the discriminant is:
\[
\sqrt{25} = 5
\]

Next, we substitute \(a\), \(b\), and \(c\) into the quadratic formula:
\[
x = \frac{-(-1) \pm \sqrt{(-1)^2 - 4(1)(-6)}}{2(1)} = \frac{1 \pm \sqrt{1 + 24}}{2} = \frac{1 \pm \sqrt{25}}{2} = \frac{1 \pm 5}{2}
\]

This gives us two solutions:
\[
x = \frac{1 + 5}{2} = \frac{6}{2} = 3
\]
\[
x = \frac{1 - 5}{2} = \frac{-4}{2} = -2
\]

Thus, the solutions to the equation \(x^2 - x - 6 = 0\) are:
\[
\boxed{3} \quad \text{and} \quad \boxed{-2}
\]

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@xenova xenova merged commit df905b4 into main Sep 12, 2025
4 checks passed
@xenova xenova deleted the add-llama4_text branch September 12, 2025 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants