Upload folder using huggingface_hub
Browse files- README.md +60 -12
- generation_config.json +8 -0
- model.bin +1 -1
- special_tokens_map.json +17 -23
README.md
CHANGED
@@ -1,12 +1,22 @@
|
|
1 |
---
|
2 |
-
library_name: transformers
|
3 |
license: apache-2.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
language:
|
5 |
- en
|
6 |
---
|
7 |
|
8 |
|
9 |
-
# SmolLM-Instruct
|
10 |
|
11 |
<center>
|
12 |
<img src="https://huggingface.co/datasets/HuggingFaceTB/images/resolve/main/banner_smol.png" alt="SmolLM" width="1100" height="600">
|
@@ -15,14 +25,35 @@ language:
|
|
15 |
|
16 |
## Model Summary
|
17 |
|
18 |
-
SmolLM is a series of
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
-
To build SmolLM-Instruct, we instruction tuned the models using publicly available permissive instruction datasets. We trained all three models for one epoch on the permissive subset of the WebInstructSub dataset, combined with StarCoder2-Self-OSS-Instruct. Following this, we performed DPO (Direct Preference Optimization) for one epoch: using HelpSteer for the 135M and 1.7B models, and argilla/dpo-mix-7k for the 360M model. We followed the training parameters from the Zephyr-Gemma recipe in the alignment handbook, but adjusted the SFT (Supervised Fine-Tuning) learning rate to 3e-4.
|
21 |
-
[Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0)
|
22 |
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
```bash
|
27 |
pip install transformers
|
28 |
```
|
@@ -37,17 +68,34 @@ tokenizer = AutoTokenizer.from_pretrained(checkpoint)
|
|
37 |
# for multiple GPUs install accelerate and do `model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map="auto")`
|
38 |
model = AutoModelForCausalLM.from_pretrained(checkpoint).to(device)
|
39 |
|
40 |
-
messages = [{"role": "user", "content": "
|
41 |
input_text=tokenizer.apply_chat_template(messages, tokenize=False)
|
42 |
print(input_text)
|
43 |
-
inputs = tokenizer.encode(input_text, return_tensors="pt").to(
|
44 |
-
outputs = model.generate(inputs, max_new_tokens=
|
45 |
print(tokenizer.decode(outputs[0]))
|
46 |
```
|
47 |
|
48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
|
50 |
-
|
51 |
|
52 |
# Citation
|
53 |
```bash
|
|
|
1 |
---
|
|
|
2 |
license: apache-2.0
|
3 |
+
base_model: HuggingFaceTB/SmolLM-135M
|
4 |
+
tags:
|
5 |
+
- alignment-handbook
|
6 |
+
- trl
|
7 |
+
- sft
|
8 |
+
datasets:
|
9 |
+
- Magpie-Align/Magpie-Pro-300K-Filtered
|
10 |
+
- bigcode/self-oss-instruct-sc2-exec-filter-50k
|
11 |
+
- teknium/OpenHermes-2.5
|
12 |
+
- HuggingFaceTB/everyday-conversations-llama3.1-2k
|
13 |
+
library_name: transformers
|
14 |
language:
|
15 |
- en
|
16 |
---
|
17 |
|
18 |
|
19 |
+
# SmolLM-135M-Instruct
|
20 |
|
21 |
<center>
|
22 |
<img src="https://huggingface.co/datasets/HuggingFaceTB/images/resolve/main/banner_smol.png" alt="SmolLM" width="1100" height="600">
|
|
|
25 |
|
26 |
## Model Summary
|
27 |
|
28 |
+
SmolLM is a series of small language models available in three sizes: 135M, 360M, and 1.7B parameters.
|
29 |
+
|
30 |
+
These models are trained on [SmolLM-Corpus](https://huggingface.co/datasets/HuggingFaceTB/smollm-corpus), a curated collection of high-quality educational and synthetic data designed for training LLMs. For further details, we refer to our [blogpost](https://huggingface.co/blog/smollm).
|
31 |
+
|
32 |
+
To build SmolLM-Instruct, we finetune the base models on publicly available datasets.
|
33 |
+
|
34 |
+
## Changelog
|
35 |
|
|
|
|
|
36 |
|
37 |
+
|Release|Description|
|
38 |
+
|-|-|
|
39 |
+
|v0.1| Initial release of SmolLM-Instruct. We finetune on the permissive subset of the [WebInstructSub](https://huggingface.co/datasets/TIGER-Lab/WebInstructSub) dataset, combined with [StarCoder2-Self-OSS-Instruct](https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k). Then, we perform DPO (Direct Preference Optimization) for one epoch on [HelpSteer](https://huggingface.co/datasets/nvidia/HelpSteer) for the 135M and 1.7B models, and [argilla/dpo-mix-7k](https://huggingface.co/datasets/argilla/dpo-mix-7k) for the 360M model.|
|
40 |
+
|v0.2| We changed the finetuning mix to datasets more suitable for smol models. We train on a new dataset of 2k simple everyday conversations we generated by llama3.1-70B [everyday-conversations-llama3.1-2k](https://huggingface.co/datasets/HuggingFaceTB/everyday-conversations-llama3.1-2k/), [Magpie-Pro-300K-Filtered](https://huggingface.co/datasets/Magpie-Align/Magpie-Pro-300K-Filtered), [StarCoder2-Self-OSS-Instruct](https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k), and a small subset of [OpenHermes-2.5](https://huggingface.co/datasets/teknium/OpenHermes-2.5)|
|
41 |
+
|
42 |
+
v0.2 models are better at staying on topic and responding appropriately to standard prompts, such as greetings and questions about their role as AI assistants. SmolLM-360M-Instruct (v0.2) has a 63.3% win rate over SmolLM-360M-Instruct (v0.1) on AlpacaEval. You can find the details [here](https://huggingface.co/datasets/HuggingFaceTB/alpaca_eval_details/).
|
43 |
+
|
44 |
+
You can load v0.1 models by specifying `revision="v0.1"` in the transformers code:
|
45 |
+
```python
|
46 |
+
model = AutoModelForCausalLM.from_pretrained("HuggingFaceTB/SmolLM-135M-Instruct", revision="v0.1")
|
47 |
+
```
|
48 |
|
49 |
+
## Usage
|
50 |
+
|
51 |
+
### Local Applications
|
52 |
+
⚡ For local applications, you can find optimized implementations of the model in MLC, GGUF and Transformers.js formats, in addition to fast in-browser demos in this collection: https://huggingface.co/collections/HuggingFaceTB/local-smollms-66c0f3b2a15b4eed7fb198d0
|
53 |
+
|
54 |
+
We noticed that 4bit quantization degrades the quality of the 135M and 360M, so we use `q016` for MLC and ONNX/Transformers.js checkpoints for the WebGPU demos. We also suggest using temperature 0.2 and top-p 0.9.
|
55 |
+
|
56 |
+
### Transformers
|
57 |
```bash
|
58 |
pip install transformers
|
59 |
```
|
|
|
68 |
# for multiple GPUs install accelerate and do `model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map="auto")`
|
69 |
model = AutoModelForCausalLM.from_pretrained(checkpoint).to(device)
|
70 |
|
71 |
+
messages = [{"role": "user", "content": "What is the capital of France."}]
|
72 |
input_text=tokenizer.apply_chat_template(messages, tokenize=False)
|
73 |
print(input_text)
|
74 |
+
inputs = tokenizer.encode(input_text, return_tensors="pt").to(device)
|
75 |
+
outputs = model.generate(inputs, max_new_tokens=50, temperature=0.2, top_p=0.9, do_sample=True)
|
76 |
print(tokenizer.decode(outputs[0]))
|
77 |
```
|
78 |
|
79 |
+
### Chat in TRL
|
80 |
+
You can also use the TRL CLI to chat with the model from the terminal:
|
81 |
+
```bash
|
82 |
+
pip install trl
|
83 |
+
trl chat --model_name_or_path HuggingFaceTB/SmolLM-135M-Instruct --device cpu
|
84 |
+
```
|
85 |
+
|
86 |
+
## Limitations
|
87 |
+
|
88 |
+
Additionally, the generated content may not always be factually accurate, logically consistent, or free from biases present in the training data, we invite users to leverage them as assistive tools rather than definitive sources of information. We find that they can handle general knowledge questions, creative writing and basic Python programming. But they are English only and may have difficulty with arithmetics, editing tasks and complex reasoning. For more details about the models' capabilities, please refer to our [blog post](https://huggingface.co/blog/smollm).
|
89 |
+
|
90 |
+
## Training parameters
|
91 |
+
We train the models using the [alignment-handbook](https://github.com/huggingface/alignment-handbook) with the datasets mentioned in the changelog, using these parameters for v0.2 (most of them are from Zephyr Gemma recipe):
|
92 |
+
- 1 epoch
|
93 |
+
- lr 1e-3
|
94 |
+
- cosine schedule
|
95 |
+
- warmup ratio 0.1
|
96 |
+
- global batch size 262k tokens
|
97 |
|
98 |
+
You can find the training recipe here: https://github.com/huggingface/alignment-handbook/tree/smollm/recipes/smollm
|
99 |
|
100 |
# Citation
|
101 |
```bash
|
generation_config.json
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_from_model_config": true,
|
3 |
+
"bos_token_id": 1,
|
4 |
+
"eos_token_id": 2,
|
5 |
+
"pad_token_id": 2,
|
6 |
+
"transformers_version": "4.42.3"
|
7 |
+
"max_new_tokens": 40,
|
8 |
+
}
|
model.bin
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
size 135397276
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5bfec03fc2df511d9536d1bef600072c4b1b5303147018b4d56f77df847a4f24
|
3 |
size 135397276
|
special_tokens_map.json
CHANGED
@@ -1,29 +1,23 @@
|
|
1 |
{
|
2 |
"additional_special_tokens": [
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
],
|
6 |
-
"bos_token":
|
7 |
-
|
8 |
-
|
9 |
-
"normalized": false,
|
10 |
-
"rstrip": false,
|
11 |
-
"single_word": false
|
12 |
-
},
|
13 |
-
"eos_token": {
|
14 |
-
"content": "<|im_end|>",
|
15 |
-
"lstrip": false,
|
16 |
-
"normalized": false,
|
17 |
-
"rstrip": false,
|
18 |
-
"single_word": false
|
19 |
-
},
|
20 |
-
"pad_token": {
|
21 |
-
"content": "<|im_end|>",
|
22 |
-
"lstrip": false,
|
23 |
-
"normalized": false,
|
24 |
-
"rstrip": false,
|
25 |
-
"single_word": false
|
26 |
-
},
|
27 |
"unk_token": {
|
28 |
"content": "<|endoftext|>",
|
29 |
"lstrip": false,
|
|
|
1 |
{
|
2 |
"additional_special_tokens": [
|
3 |
+
{
|
4 |
+
"content": "<|im_start|>",
|
5 |
+
"lstrip": false,
|
6 |
+
"normalized": false,
|
7 |
+
"rstrip": false,
|
8 |
+
"single_word": false
|
9 |
+
},
|
10 |
+
{
|
11 |
+
"content": "<|im_end|>",
|
12 |
+
"lstrip": false,
|
13 |
+
"normalized": false,
|
14 |
+
"rstrip": false,
|
15 |
+
"single_word": false
|
16 |
+
}
|
17 |
],
|
18 |
+
"bos_token": "<|im_start|>",
|
19 |
+
"eos_token": "<|im_end|>",
|
20 |
+
"pad_token": "<|im_end|>",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
"unk_token": {
|
22 |
"content": "<|endoftext|>",
|
23 |
"lstrip": false,
|