eliebak HF staff commited on
Commit
becaad6
1 Parent(s): 2c0f3e0

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +22 -0
README.md CHANGED
@@ -29,6 +29,28 @@ To build SmolLM-Instruct, we instruction tuned the models using publicly availab
29
 
30
  This is the SmolLM-360M-Instruct.
31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
 
33
  # Limitations
34
 
 
29
 
30
  This is the SmolLM-360M-Instruct.
31
 
32
+ ### Generation
33
+ ```bash
34
+ pip install transformers
35
+ ```
36
+
37
+ ```python
38
+ # pip install transformers
39
+ from transformers import AutoModelForCausalLM, AutoTokenizer
40
+ checkpoint = "HuggingFaceTB/SmolLM-360M-Instructt"
41
+
42
+ device = "cuda" # for GPU usage or "cpu" for CPU usage
43
+ tokenizer = AutoTokenizer.from_pretrained(checkpoint)
44
+ # for multiple GPUs install accelerate and do `model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map="auto")`
45
+ model = AutoModelForCausalLM.from_pretrained(checkpoint).to(device)
46
+
47
+ messages = [{"role": "user", "content": "List the steps to bake a chocolate cake from scratch."}]
48
+ input_text=tokenizer.apply_chat_template(messages, tokenize=False)
49
+ print(input_text)
50
+ inputs = tokenizer.encode(input_text, return_tensors="pt").to("cuda")
51
+ outputs = model.generate(inputs, max_new_tokens=100, temperature=0.6, top_p=0.92, do_sample=True)
52
+ print(tokenizer.decode(outputs[0]))
53
+ ```
54
 
55
  # Limitations
56