jncraton commited on
Commit
0b0e861
1 Parent(s): f9da622

Upload folder using huggingface_hub

Browse files
Files changed (4) hide show
  1. README.md +62 -12
  2. generation_config.json +8 -0
  3. model.bin +1 -1
  4. 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">
@@ -14,15 +24,37 @@ language:
14
 
15
 
16
  ## Model Summary
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
- SmolLM is a series of state-of-the-art small language models available in three sizes: 135M, 360M, and 1.7B parameters. These models are built on Cosmo-Corpus, a meticulously curated high-quality training dataset. Cosmo-Corpus includes Cosmopedia v2 (28B tokens of synthetic textbooks and stories generated by Mixtral), Python-Edu (4B tokens of educational Python samples from The Stack), and FineWeb-Edu (220B tokens of deduplicated educational web samples from FineWeb). For duther details, we refer to our blogpost TODO.
 
 
 
 
 
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
- This is the SmolLM-360M-Instruct.
24
 
25
- ### Generation
26
  ```bash
27
  pip install transformers
28
  ```
@@ -37,17 +69,35 @@ 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": "List the steps to bake a chocolate cake from scratch."}]
41
  input_text=tokenizer.apply_chat_template(messages, tokenize=False)
42
  print(input_text)
43
- inputs = tokenizer.encode(input_text, return_tensors="pt").to("cuda")
44
- outputs = model.generate(inputs, max_new_tokens=100, temperature=0.6, top_p=0.92, do_sample=True)
45
  print(tokenizer.decode(outputs[0]))
46
  ```
47
 
48
- # Limitations
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
 
50
- While SmolLM models have been trained on a diverse dataset including educational content and synthetic texts, they have limitations. The 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. For a more comprehensive discussion of the models' capabilities and limitations, please refer to our full blog post.
51
 
52
  # Citation
53
  ```bash
 
1
  ---
 
2
  license: apache-2.0
3
+ base_model: HuggingFaceTB/SmolLM-360M
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-360M-Instruct
20
 
21
  <center>
22
  <img src="https://huggingface.co/datasets/HuggingFaceTB/images/resolve/main/banner_smol.png" alt="SmolLM" width="1100" height="600">
 
24
 
25
 
26
  ## Model Summary
27
+ Chat with the model at: https://huggingface.co/spaces/HuggingFaceTB/instant-smol
28
+
29
+ SmolLM is a series of language models available in three sizes: 135M, 360M, and 1.7B parameters.
30
+
31
+ 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).
32
+
33
+ To build SmolLM-Instruct, we finetune the base models on publicly available datasets.
34
+
35
+ ## Changelog
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-Filtere](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
+
43
+ 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/).
44
 
45
+ You can load v0.1 models by specifying `revision="v0.1"` in the transformers code:
46
+ ```python
47
+ model = AutoModelForCausalLM.from_pretrained("HuggingFaceTB/SmolLM-360M-Instruct", revision="v0.1")
48
+ ```
49
+
50
+ ## Usage
51
 
52
+ ### Local Applications
53
+ 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
54
 
55
+ 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.
56
 
57
+ ### Transformers
58
  ```bash
59
  pip install transformers
60
  ```
 
69
  # for multiple GPUs install accelerate and do `model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map="auto")`
70
  model = AutoModelForCausalLM.from_pretrained(checkpoint).to(device)
71
 
72
+ messages = [{"role": "user", "content": "What is the capital of France."}]
73
  input_text=tokenizer.apply_chat_template(messages, tokenize=False)
74
  print(input_text)
75
+ inputs = tokenizer.encode(input_text, return_tensors="pt").to(device)
76
+ outputs = model.generate(inputs, max_new_tokens=50, temperature=0.2, top_p=0.9, do_sample=True)
77
  print(tokenizer.decode(outputs[0]))
78
  ```
79
 
80
+ ### Chat in TRL
81
+ You can also use the TRL CLI to chat with the model from the terminal:
82
+ ```bash
83
+ pip install trl
84
+ trl chat --model_name_or_path HuggingFaceTB/SmolLM-360M-Instruct --device cpu
85
+ ```
86
+
87
+ ## Limitations
88
+
89
+ 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).
90
+
91
+ ## Training parameters
92
+ 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):
93
+ - 1 epoch
94
+ - lr 1e-3
95
+ - cosine schedule
96
+ - warmup ratio 0.1
97
+ - global batch size 262k tokens
98
+
99
+ You can find the training recipe here: https://github.com/huggingface/alignment-handbook/tree/smollm/recipes/smollm
100
 
 
101
 
102
  # Citation
103
  ```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
+ "max_new_tokens": 40,
7
+ "transformers_version": "4.42.3"
8
+ }
model.bin CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:3ba5d423e69c082de36aa85a2e0d64610c06c1f337fb22e5e82d02b057d08a13
3
  size 363216360
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0a238daf6e0553314fe5b8d2f28807e69079b3fbda095b1fbe5bbae1b447fa43
3
  size 363216360
special_tokens_map.json CHANGED
@@ -1,29 +1,23 @@
1
  {
2
  "additional_special_tokens": [
3
- "<|im_start|>",
4
- "<|im_end|>"
 
 
 
 
 
 
 
 
 
 
 
 
5
  ],
6
- "bos_token": {
7
- "content": "<|im_start|>",
8
- "lstrip": false,
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,