jncraton commited on
Commit
dc3dfe2
1 Parent(s): da1ca1a

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. README.md +60 -13
  2. generation_config.json +8 -0
  3. model.bin +1 -1
README.md CHANGED
@@ -1,12 +1,21 @@
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 +24,35 @@ language:
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-1.7B-Instruct.
 
24
 
25
- ### Generation
 
 
26
  ```bash
27
  pip install transformers
28
  ```
@@ -37,18 +67,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
 
49
- # Limitations
 
 
 
 
50
 
51
- 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.
52
 
53
  # Citation
54
  ```bash
 
1
  ---
 
2
  license: apache-2.0
3
+ base_model: HuggingFaceTB/SmolLM-1.7B
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
+ # SmolLM-1.7B-Instruct
 
19
 
20
  <center>
21
  <img src="https://huggingface.co/datasets/HuggingFaceTB/images/resolve/main/banner_smol.png" alt="SmolLM" width="1100" height="600">
 
24
 
25
  ## Model Summary
26
 
27
+ SmolLM is a series of small language models available in three sizes: 135M, 360M, and 1.7B parameters.
28
+
29
+ These models are pre-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).
30
+
31
+ To build SmolLM-Instruct, we finetuned the base models on publicly available datasets.
32
+
33
+ ## Changelog
34
+
35
+
36
+ |Release|Description|
37
+ |-|-|
38
+ |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.|
39
+ |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)|
40
+
41
+ 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/).
42
 
43
+ You can load v0.1 checkpoint by specifying `revision="v0.1"` in the transformers code:
44
+ ```python
45
+ model = AutoModelForCausalLM.from_pretrained("HuggingFaceTB/SmolLM-1.7B-Instruct", revision="v0.1")
46
+ ```
47
+
48
+ ## Usage
49
 
50
+ ### Local Applications
51
+ ⚡ 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
52
 
53
+ 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.
54
+
55
+ ### Transformers
56
  ```bash
57
  pip install transformers
58
  ```
 
67
  # for multiple GPUs install accelerate and do `model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map="auto")`
68
  model = AutoModelForCausalLM.from_pretrained(checkpoint).to(device)
69
 
70
+ messages = [{"role": "user", "content": "What is the capital of France."}]
71
  input_text=tokenizer.apply_chat_template(messages, tokenize=False)
72
  print(input_text)
73
+ inputs = tokenizer.encode(input_text, return_tensors="pt").to(device)
74
+ outputs = model.generate(inputs, max_new_tokens=50, temperature=0.2, top_p=0.9, do_sample=True)
75
  print(tokenizer.decode(outputs[0]))
76
  ```
77
 
78
+ ### Chat in TRL
79
+ You can also use the TRL CLI to chat with the model from the terminal:
80
+ ```bash
81
+ pip install trl
82
+ trl chat --model_name_or_path HuggingFaceTB/SmolLM-1.7B-Instruct --device cpu
83
+ ```
84
+
85
+ ## Limitations
86
+
87
+ 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).
88
+
89
+ ## Training parameters
90
+ We train the models using the [alignment-handbook](https://github.com/huggingface/alignment-handbook) with the datasets mentioned in the changelog, using these parameters v0.2 (most of them are from Zephyr Gemma recipe):
91
 
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
+ "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:39cecd3f93a1bca3b25b3e834638c94896735f769ab68ca1cfd02e3c46af1e65
3
  size 1714250730
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8d2ebee8d42eec9bc8793f021f8db667b3aa4a40ed689fa1fd554e3cbb77924f
3
  size 1714250730