Views
No views yet

pip install transformers1from transformers import AutoModelForCausalLM, AutoTokenizer
2checkpoint = "HuggingFaceTB/SmolLM2-135M-Instruct"
3
4device = "cuda" # for GPU usage or "cpu" for CPU usage
5tokenizer = AutoTokenizer.from_pretrained(checkpoint)
6# for multiple GPUs install accelerate and do `model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map="auto")`
7model = AutoModelForCausalLM.from_pretrained(checkpoint).to(device)
8
9messages = [{"role": "user", "content": "What is gravity?"}]
10input_text=tokenizer.apply_chat_template(messages, tokenize=False)
11print(input_text)
12inputs = tokenizer.encode(input_text, return_tensors="pt").to(device)
13outputs = model.generate(inputs, max_new_tokens=50, temperature=0.2, top_p=0.9, do_sample=True)
14print(tokenizer.decode(outputs[0]))1pip install trl
2trl chat --model_name_or_path HuggingFaceTB/SmolLM2-135M-Instruct --device cpu| Metrics | SmolLM2-135M-8k | SmolLM-135M |
|---|---|---|
| HellaSwag | 42.1 | 41.2 |
| ARC (Average) | 43.9 | 42.4 |
| PIQA | 68.4 | 68.4 |
| MMLU (cloze) | 31.5 | 30.2 |
| CommonsenseQA | 33.9 | 32.7 |
| TriviaQA | 4.1 | 4.3 |
| Winogrande | 51.3 | 51.3 |
| OpenBookQA | 34.6 | 34.0 |
| GSM8K (5-shot) | 1.4 | 1.0 |
| Metric | SmolLM2-135M-Instruct | SmolLM-135M-Instruct |
|---|---|---|
| IFEval (Average prompt/inst) | 29.9 | 17.2 |
| MT-Bench | 19.8 | 16.8 |
| HellaSwag | 40.9 | 38.9 |
| ARC (Average) | 37.3 | 33.9 |
| PIQA | 66.3 | 64.0 |
| MMLU (cloze) | 29.3 | 28.3 |
| BBH (3-shot) | 28.2 | 25.2 |
| GSM8K (5-shot) | 1.4 | 1.4 |
1@misc{allal2024SmolLM2,
2 title={SmolLM2 - with great data, comes great performance},
3 author={Loubna Ben Allal and Anton Lozhkov and Elie Bakouch and Gabriel Martín Blázquez and Lewis Tunstall and Agustín Piqueres and Andres Marafioti and Cyril Zakka and Leandro von Werra and Thomas Wolf},
4 year={2024},
5}