Update README.md
Browse files
README.md
CHANGED
|
@@ -65,6 +65,34 @@ pip install trl
|
|
| 65 |
trl chat --model_name_or_path HuggingFaceTB/SmolLM2-135M-Instruct --device cpu
|
| 66 |
```
|
| 67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
## Evaluation
|
| 69 |
|
| 70 |
In this section, we report the evaluation results of SmolLM2. All evaluations are zero-shot unless stated otherwise, and we use [lighteval](https://github.com/huggingface/lighteval) to run them.
|
|
|
|
| 65 |
trl chat --model_name_or_path HuggingFaceTB/SmolLM2-135M-Instruct --device cpu
|
| 66 |
```
|
| 67 |
|
| 68 |
+
### Transformers.js
|
| 69 |
+
|
| 70 |
+
```bash
|
| 71 |
+
npm i @huggingface/transformers
|
| 72 |
+
```
|
| 73 |
+
|
| 74 |
+
```js
|
| 75 |
+
import { pipeline } from "@huggingface/transformers";
|
| 76 |
+
|
| 77 |
+
// Create a text generation pipeline
|
| 78 |
+
const generator = await pipeline(
|
| 79 |
+
"text-generation",
|
| 80 |
+
"HuggingFaceTB/SmolLM2-135M-Instruct",
|
| 81 |
+
);
|
| 82 |
+
|
| 83 |
+
// Define the list of messages
|
| 84 |
+
const messages = [
|
| 85 |
+
{ role: "system", content: "You are a helpful assistant." },
|
| 86 |
+
{ role: "user", content: "What is the capital of France?" },
|
| 87 |
+
];
|
| 88 |
+
|
| 89 |
+
// Generate a response
|
| 90 |
+
const output = await generator(messages, { max_new_tokens: 128 });
|
| 91 |
+
console.log(output[0].generated_text.at(-1).content);
|
| 92 |
+
// "The capital of France is Paris."
|
| 93 |
+
```
|
| 94 |
+
|
| 95 |
+
|
| 96 |
## Evaluation
|
| 97 |
|
| 98 |
In this section, we report the evaluation results of SmolLM2. All evaluations are zero-shot unless stated otherwise, and we use [lighteval](https://github.com/huggingface/lighteval) to run them.
|