ariG23498 HF Staff commited on
Commit
4558846
·
verified ·
1 Parent(s): 6f9ad5e

Upload HuggingFaceTB_SmolLM3-3B_4.txt with huggingface_hub

Browse files
Files changed (1) hide show
  1. HuggingFaceTB_SmolLM3-3B_4.txt +28 -0
HuggingFaceTB_SmolLM3-3B_4.txt ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ```CODE:
2
+ # prepare the model input
3
+ prompt = "Give me a brief explanation of gravity in simple terms."
4
+ messages_think = [
5
+ {"role": "user", "content": prompt}
6
+ ]
7
+
8
+ text = tokenizer.apply_chat_template(
9
+ messages_think,
10
+ tokenize=False,
11
+ add_generation_prompt=True,
12
+ )
13
+ model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
14
+
15
+ # Generate the output
16
+ generated_ids = model.generate(**model_inputs, max_new_tokens=32768)
17
+
18
+ # Get and decode the output
19
+ output_ids = generated_ids[0][len(model_inputs.input_ids[0]) :]
20
+ print(tokenizer.decode(output_ids, skip_special_tokens=True))
21
+ ```
22
+
23
+ ERROR:
24
+ Traceback (most recent call last):
25
+ File "/tmp/HuggingFaceTB_SmolLM3-3B_4XJRKFp.py", line 22, in <module>
26
+ text = tokenizer.apply_chat_template(
27
+ ^^^^^^^^^
28
+ NameError: name 'tokenizer' is not defined