Views
No views yet
1# pip install transformers
2import torch
3from transformers import AutoModelForCausalLM, AutoTokenizer
4checkpoint = "HuggingFaceTB/SmolLM2-1.7B-intermediate-checkpoints"
5revision = "step-125000" # 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]))nb_tokens = nb_step * GBS1@misc{allal2025smollm2smolgoesbig,
2 title={SmolLM2: When Smol Goes Big -- Data-Centric Training of a Small Language Model},
3 author={Loubna Ben Allal and Anton Lozhkov and Elie Bakouch and Gabriel Martín Blázquez and Guilherme Penedo and Lewis Tunstall and Andrés Marafioti and Hynek Kydlíček and Agustín Piqueres Lajarín and Vaibhav Srivastav and Joshua Lochner and Caleb Fahlgren and Xuan-Son Nguyen and Clémentine Fourrier and Ben Burtenshaw and Hugo Larcher and Haojun Zhao and Cyril Zakka and Mathieu Morlon and Colin Raffel and Leandro von Werra and Thomas Wolf},
4 year={2025},
5 eprint={2502.02737},
6 archivePrefix={arXiv},
7 primaryClass={cs.CL},
8 url={https://arxiv.org/abs/2502.02737},
9}