Update README.md
Browse files
README.md
CHANGED
@@ -40,7 +40,7 @@ For more details refer to: https://github.com/huggingface/smollm. You will find
|
|
40 |
|
41 |
### How to use
|
42 |
|
43 |
-
|
44 |
```bash
|
45 |
pip install transformers
|
46 |
```
|
@@ -62,13 +62,40 @@ print(tokenizer.decode(outputs[0]))
|
|
62 |
```
|
63 |
|
64 |
|
65 |
-
|
66 |
You can also use the TRL CLI to chat with the model from the terminal:
|
67 |
```bash
|
68 |
pip install trl
|
69 |
trl chat --model_name_or_path HuggingFaceTB/SmolLM2-1.7B-Instruct --device cpu
|
70 |
```
|
71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
## Evaluation
|
73 |
|
74 |
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.
|
|
|
40 |
|
41 |
### How to use
|
42 |
|
43 |
+
#### Transformers
|
44 |
```bash
|
45 |
pip install transformers
|
46 |
```
|
|
|
62 |
```
|
63 |
|
64 |
|
65 |
+
#### Chat in TRL
|
66 |
You can also use the TRL CLI to chat with the model from the terminal:
|
67 |
```bash
|
68 |
pip install trl
|
69 |
trl chat --model_name_or_path HuggingFaceTB/SmolLM2-1.7B-Instruct --device cpu
|
70 |
```
|
71 |
|
72 |
+
#### Transformers.js
|
73 |
+
|
74 |
+
```bash
|
75 |
+
npm i @huggingface/transformers
|
76 |
+
```
|
77 |
+
|
78 |
+
```js
|
79 |
+
import { pipeline } from "@huggingface/transformers";
|
80 |
+
|
81 |
+
// Create a text generation pipeline
|
82 |
+
const generator = await pipeline(
|
83 |
+
"text-generation",
|
84 |
+
"HuggingFaceTB/SmolLM2-1.7B-Instruct",
|
85 |
+
);
|
86 |
+
|
87 |
+
// Define the list of messages
|
88 |
+
const messages = [
|
89 |
+
{ role: "system", content: "You are a helpful assistant." },
|
90 |
+
{ role: "user", content: "Tell me a joke." },
|
91 |
+
];
|
92 |
+
|
93 |
+
// Generate a response
|
94 |
+
const output = await generator(messages, { max_new_tokens: 128 });
|
95 |
+
console.log(output[0].generated_text.at(-1).content);
|
96 |
+
// "Why don't scientists trust atoms?\n\nBecause they make up everything!"
|
97 |
+
```
|
98 |
+
|
99 |
## Evaluation
|
100 |
|
101 |
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.
|