Xenova HF Staff commited on
Commit
a10cc15
·
verified ·
1 Parent(s): c38281e

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +28 -0
README.md CHANGED
@@ -68,6 +68,34 @@ pip install trl
68
  trl chat --model_name_or_path HuggingFaceTB/SmolLM2-360M-Instruct --device cpu
69
  ```
70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  ## Evaluation
72
 
73
  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.
 
68
  trl chat --model_name_or_path HuggingFaceTB/SmolLM2-360M-Instruct --device cpu
69
  ```
70
 
71
+ ### Transformers.js
72
+
73
+ ```bash
74
+ npm i @huggingface/transformers
75
+ ```
76
+
77
+ ```js
78
+ import { pipeline } from "@huggingface/transformers";
79
+
80
+ // Create a text generation pipeline
81
+ const generator = await pipeline(
82
+ "text-generation",
83
+ "HuggingFaceTB/SmolLM2-135M-Instruct",
84
+ );
85
+
86
+ // Define the list of messages
87
+ const messages = [
88
+ { role: "system", content: "You are a helpful assistant." },
89
+ { role: "user", content: "What is the capital of France?" },
90
+ ];
91
+
92
+ // Generate a response
93
+ const output = await generator(messages, { max_new_tokens: 128 });
94
+ console.log(output[0].generated_text.at(-1).content);
95
+ // "The capital of France is Paris."
96
+ ```
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.