Views
No views yet
nb_tokens = nb_step * GBS


1# pip install transformers
2import torch
3from transformers import AutoModelForCausalLM, AutoTokenizer
4checkpoint = "HuggingFaceTB/SmolLM3-3B-checkpoints"
5revision = "stage1-step-40000" # replace by the revision you want
6device = torch.device("cuda" if torch.cuda.is_available() else "mps" if hasattr(torch, 'mps') and torch.mps.is_available() else "cpu")
7tokenizer = AutoTokenizer.from_pretrained(checkpoint, revision=revision)
8model = AutoModelForCausalLM.from_pretrained(checkpoint, revision=revision).to(device)
9inputs = tokenizer.encode("Gravity is", return_tensors="pt").to(device)
10outputs = model.generate(inputs)
11print(tokenizer.decode(outputs[0]))1@misc{bakouch2025smollm3,
2 title={{SmolLM3: smol, multilingual, long-context reasoner}},
3 author={Bakouch, Elie and Ben Allal, Loubna and Lozhkov, Anton and Tazi, Nouamane and Tunstall, Lewis and Patiño, Carlos Miguel and Beeching, Edward and Roucher, Aymeric and Reedi, Aksel Joonas and Gallouédec, Quentin and Rasul, Kashif and Habib, Nathan and Fourrier, Clémentine and Kydlicek, Hynek and Penedo, Guilherme and Larcher, Hugo and Morlon, Mathieu and Srivastav, Vaibhav and Lochner, Joshua and Nguyen, Xuan-Son and Raffel, Colin and von Werra, Leandro and Wolf, Thomas},
4 year={2025},
5 howpublished={\url{https://huggingface.co/blog/smollm3}}
6}