Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,144 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
datasets:
|
4 |
+
- HumanLLMs/Human-Like-DPO-Dataset
|
5 |
+
language:
|
6 |
+
- en
|
7 |
+
base_model:
|
8 |
+
- HuggingFaceTB/SmolLM2-135M-Instruct
|
9 |
+
pipeline_tag: text-generation
|
10 |
+
library_name: transformers
|
11 |
+
tags:
|
12 |
+
- safetensors
|
13 |
+
- humanized
|
14 |
+
- smollm
|
15 |
+
---
|
16 |
+
|
17 |
+
|
18 |
+
# SmolLM2-135M-Humanized
|
19 |
+
|
20 |
+
## Table of Contents
|
21 |
+
|
22 |
+
1. [Model Summary](##model-summary)
|
23 |
+
2. [Limitations](##limitations)
|
24 |
+
3. [Training](##training)
|
25 |
+
4. [License](##license)
|
26 |
+
5. [Citation](##citation)
|
27 |
+
|
28 |
+
## Model Summary
|
29 |
+
|
30 |
+
**SmolLM2-135M-Humanized** is a fine-tuned version of the [SmolLM2-135M-Instruct](https://huggingface.co/HuggingFaceTB/SmolLM2-135M-Instruct) model, optimized using the Direct Preference Optimization (DPO) method.
|
31 |
+
|
32 |
+
Unlike traditional fine-tuning approaches that aim to improve specific benchmarks or metrics, DPO fine-tuning focuses on aligning the model's behavior with human preferences. This process enhances the model's ability to generate more natural, human-like responses, making it particularly well-suited for conversational applications.
|
33 |
+
|
34 |
+
By emphasizing response quality and relatability, SmolLM2-135M-Humanized is designed to deliver an engaging and intuitive user experience in dialogue-based scenarios.
|
35 |
+
|
36 |
+
|
37 |
+
### How to use
|
38 |
+
|
39 |
+
### Transformers
|
40 |
+
```bash
|
41 |
+
pip install transformers
|
42 |
+
```
|
43 |
+
|
44 |
+
```python
|
45 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
46 |
+
checkpoint = "HuggingFaceTB/SmolLM2-135M-Instruct"
|
47 |
+
|
48 |
+
device = "cuda" # for GPU usage or "cpu" for CPU usage
|
49 |
+
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
|
50 |
+
# for multiple GPUs install accelerate and do `model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map="auto")`
|
51 |
+
model = AutoModelForCausalLM.from_pretrained(checkpoint).to(device)
|
52 |
+
|
53 |
+
messages = [{"role": "user", "content": "What is gravity?"}]
|
54 |
+
input_text=tokenizer.apply_chat_template(messages, tokenize=False)
|
55 |
+
print(input_text)
|
56 |
+
inputs = tokenizer.encode(input_text, return_tensors="pt").to(device)
|
57 |
+
outputs = model.generate(inputs, max_new_tokens=50, temperature=0.2, top_p=0.9, do_sample=True)
|
58 |
+
print(tokenizer.decode(outputs[0]))
|
59 |
+
```
|
60 |
+
|
61 |
+
### Chat in TRL
|
62 |
+
You can also use the TRL CLI to chat with the model from the terminal:
|
63 |
+
```bash
|
64 |
+
pip install trl
|
65 |
+
trl chat --model_name_or_path HuggingFaceTB/SmolLM2-135M-Instruct --device cpu
|
66 |
+
```
|
67 |
+
|
68 |
+
## Evaluation
|
69 |
+
|
70 |
+
In this section, we report the evaluation results of SmolLM2. All evaluations are zero-shot unless stated otherwise, and we use [lighteval](https://github.com/huggingface/lighteval) to run them.
|
71 |
+
|
72 |
+
## Base pre-trained model
|
73 |
+
|
74 |
+
| Metrics | SmolLM2-135M-8k | SmolLM-135M |
|
75 |
+
|:-------------------|:----------------:|:------------:|
|
76 |
+
| HellaSwag | **42.1** | 41.2 |
|
77 |
+
| ARC (Average) | **43.9** | 42.4 |
|
78 |
+
| PIQA | 68.4 | 68.4 |
|
79 |
+
| MMLU (cloze) | **31.5** | 30.2 |
|
80 |
+
| CommonsenseQA | **33.9** | 32.7 |
|
81 |
+
| TriviaQA | 4.1 | **4.3** |
|
82 |
+
| Winogrande | 51.3 | 51.3 |
|
83 |
+
| OpenBookQA | **34.6** | 34.0 |
|
84 |
+
| GSM8K (5-shot) | **1.4** | 1.0 |
|
85 |
+
|
86 |
+
|
87 |
+
## Instruction model
|
88 |
+
|
89 |
+
| Metric | SmolLM2-135M-Instruct | SmolLM-135M-Instruct |
|
90 |
+
|:-----------------------------|:---------------------:|:--------------------:|
|
91 |
+
| IFEval (Average prompt/inst) | **29.9** | 17.2 |
|
92 |
+
| MT-Bench | **19.8** | 16.8 |
|
93 |
+
| HellaSwag | **40.9** | 38.9 |
|
94 |
+
| ARC (Average) | **37.3** | 33.9 |
|
95 |
+
| PIQA | **66.3** | 64.0 |
|
96 |
+
| MMLU (cloze) | **29.3** | 28.3 |
|
97 |
+
| BBH (3-shot) | **28.2** | 25.2 |
|
98 |
+
| GSM8K (5-shot) | 1.4 | 1.4 |
|
99 |
+
|
100 |
+
|
101 |
+
|
102 |
+
## Limitations
|
103 |
+
|
104 |
+
SmolLM2 models primarily understand and generate content in English. They can produce text on a variety of topics, but the generated content may not always be factually accurate, logically consistent, or free from biases present in the training data. These models should be used as assistive tools rather than definitive sources of information. Users should always verify important information and critically evaluate any generated content.
|
105 |
+
|
106 |
+
## Training
|
107 |
+
|
108 |
+
### Model
|
109 |
+
|
110 |
+
- **Architecture:** Transformer decoder
|
111 |
+
- **Pretraining tokens:** 2T
|
112 |
+
- **Precision:** bfloat16
|
113 |
+
|
114 |
+
### Hardware
|
115 |
+
|
116 |
+
- **GPUs:** 64 H100
|
117 |
+
|
118 |
+
### Software
|
119 |
+
|
120 |
+
- **Training Framework:** [nanotron](https://github.com/huggingface/nanotron/tree/main)
|
121 |
+
|
122 |
+
## License
|
123 |
+
|
124 |
+
[Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0)
|
125 |
+
|
126 |
+
## Citation
|
127 |
+
```bash
|
128 |
+
@misc{allal2024SmolLM2,
|
129 |
+
title={SmolLM2 - with great data, comes great performance},
|
130 |
+
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},
|
131 |
+
year={2024},
|
132 |
+
}
|
133 |
+
```
|
134 |
+
```bash
|
135 |
+
@misc{çalık2025enhancinghumanlikeresponseslarge,
|
136 |
+
title={Enhancing Human-Like Responses in Large Language Models},
|
137 |
+
author={Ethem Yağız Çalık and Talha Rüzgar Akkuş},
|
138 |
+
year={2025},
|
139 |
+
eprint={2501.05032},
|
140 |
+
archivePrefix={arXiv},
|
141 |
+
primaryClass={cs.CL},
|
142 |
+
url={https://arxiv.org/abs/2501.05032},
|
143 |
+
}
|
144 |
+
```
|