loubnabnl HF staff commited on
Commit
52379bc
1 Parent(s): bb94f78

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +102 -74
README.md CHANGED
@@ -1,78 +1,106 @@
1
  ---
2
- base_model: HuggingFaceTB/cosmo2-135M-webinst-sc2
3
- tags:
4
- - alignment-handbook
5
- - trl
6
- - dpo
7
- - generated_from_trainer
8
- - trl
9
- - dpo
10
- - generated_from_trainer
11
- datasets:
12
- - HuggingFaceTB/Helpsteer
13
- model-index:
14
- - name: cosmo2-135M-webinst-sc2-dpo-helpsteer-ep1
15
- results: []
16
  ---
17
 
18
- <!-- This model card has been generated automatically according to the information the Trainer had access to. You
19
- should probably proofread and complete it, then remove this comment. -->
20
 
21
- [<img src="https://raw.githubusercontent.com/wandb/assets/main/wandb-github-badge-28.svg" alt="Visualize in Weights & Biases" width="200" height="32"/>](https://wandb.ai/loubnabnl/huggingface/runs/bh5ijwbx)
22
- # cosmo2-135M-webinst-sc2-dpo-helpsteer-ep1
23
-
24
- This model is a fine-tuned version of [HuggingFaceTB/cosmo2-135M-webinst-sc2](https://huggingface.co/HuggingFaceTB/cosmo2-135M-webinst-sc2) on the HuggingFaceTB/Helpsteer dataset.
25
- It achieves the following results on the evaluation set:
26
- - Loss: 0.6824
27
- - Rewards/chosen: -0.0115
28
- - Rewards/rejected: -0.0340
29
- - Rewards/accuracies: 0.5833
30
- - Rewards/margins: 0.0225
31
- - Logps/rejected: -190.0087
32
- - Logps/chosen: -147.2760
33
- - Logits/rejected: 0.1785
34
- - Logits/chosen: -0.0247
35
- - IFEval loose prompt 14.79
36
- - IFEval strict prompt 12.2
37
-
38
- ## Model description
39
-
40
- More information needed
41
-
42
- ## Intended uses & limitations
43
-
44
- More information needed
45
-
46
- ## Training and evaluation data
47
-
48
- More information needed
49
-
50
- ## Training procedure
51
-
52
- ### Training hyperparameters
53
-
54
- The following hyperparameters were used during training:
55
- - learning_rate: 5e-06
56
- - train_batch_size: 2
57
- - eval_batch_size: 4
58
- - seed: 42
59
- - distributed_type: multi-GPU
60
- - num_devices: 8
61
- - gradient_accumulation_steps: 8
62
- - total_train_batch_size: 128
63
- - total_eval_batch_size: 32
64
- - optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
65
- - lr_scheduler_type: cosine
66
- - lr_scheduler_warmup_ratio: 0.1
67
- - num_epochs: 1
68
-
69
- ### Training results
70
-
71
-
72
-
73
- ### Framework versions
74
-
75
- - Transformers 4.42.3
76
- - Pytorch 2.1.2
77
- - Datasets 2.20.0
78
- - Tokenizers 0.19.1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ library_name: transformers
3
+ license: apache-2.0
4
+ language:
5
+ - en
 
 
 
 
 
 
 
 
 
 
6
  ---
7
 
 
 
8
 
9
+ # SmolLM
10
+
11
+ <center>
12
+ <img src="https://huggingface.co/datasets/HuggingFaceTB/images/resolve/main/banner_smol.png" alt="SmolLM" width="1100" height="600">
13
+ </center>
14
+
15
+ ## Table of Contents
16
+
17
+ 1. [Model Summary](##model-summary)
18
+ 2. [Limitations](##limitations)
19
+ 3. [Training](##training)
20
+ 4. [License](##license)
21
+ 5. [Citation](##citation)
22
+
23
+ ## Model Summary
24
+
25
+ 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.
26
+
27
+ 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.
28
+ [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0)
29
+
30
+ ### Generation
31
+ ```bash
32
+ pip install transformers
33
+ ```
34
+
35
+ #### Running the model on CPU/GPU/multi GPU
36
+ * _Using full precision_
37
+ ```python
38
+ # pip install git+https://github.com/huggingface/transformers.git # TODO: merge PR to main
39
+ from transformers import AutoModelForCausalLM, AutoTokenizer
40
+ checkpoint = "HuggingFaceTB/SmolLM-135M"
41
+ device = "cuda" # for GPU usage or "cpu" for CPU usage
42
+ tokenizer = AutoTokenizer.from_pretrained(checkpoint)
43
+ # for multiple GPUs install accelerate and do `model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map="auto")`
44
+ model = AutoModelForCausalLM.from_pretrained(checkpoint).to(device)
45
+ inputs = tokenizer.encode("def print_hello_world():", return_tensors="pt").to(device)
46
+ outputs = model.generate(inputs)
47
+ print(tokenizer.decode(outputs[0]))
48
+ ```
49
+ ```bash
50
+ >>> print(f"Memory footprint: {model.get_memory_footprint() / 1e6:.2f} MB")
51
+ Memory footprint: 12624.81 MB
52
+ ```
53
+ * _Using `torch.bfloat16`_
54
+ ```python
55
+ # pip install accelerate
56
+ import torch
57
+ from transformers import AutoTokenizer, AutoModelForCausalLM
58
+ checkpoint = "HuggingFaceTB/SmolLM-135M"
59
+ tokenizer = AutoTokenizer.from_pretrained(checkpoint)
60
+ # for fp16 use `torch_dtype=torch.float16` instead
61
+ model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map="auto", torch_dtype=torch.bfloat16)
62
+ inputs = tokenizer.encode("def print_hello_world():", return_tensors="pt").to("cuda")
63
+ outputs = model.generate(inputs)
64
+ print(tokenizer.decode(outputs[0]))
65
+ ```
66
+ ```bash
67
+ >>> print(f"Memory footprint: {model.get_memory_footprint() / 1e6:.2f} MB")
68
+ Memory footprint: 269.03 MB
69
+ ```
70
+
71
+ #### Quantized Versions through `bitsandbytes`
72
+ * _Using 8-bit precision (int8)_
73
+
74
+ ```python
75
+ # pip install bitsandbytes accelerate
76
+ from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
77
+ # to use 4bit use `load_in_4bit=True` instead
78
+ quantization_config = BitsAndBytesConfig(load_in_8bit=True)
79
+ checkpoint = "HuggingFaceTB/SmolLM-135M"
80
+ tokenizer = AutoTokenizer.from_pretrained(checkpoint)
81
+ model = AutoModelForCausalLM.from_pretrained(checkpoint, quantization_config=quantization_config)
82
+ inputs = tokenizer.encode("def print_hello_world():", return_tensors="pt").to("cuda")
83
+ outputs = model.generate(inputs)
84
+ print(tokenizer.decode(outputs[0]))
85
+ ```
86
+ ```bash
87
+ >>> print(f"Memory footprint: {model.get_memory_footprint() / 1e6:.2f} MB")
88
+ # load_in_8bit
89
+ Memory footprint: 162.87 MB
90
+ # load_in_4bit
91
+ >>> print(f"Memory footprint: {model.get_memory_footprint() / 1e6:.2f} MB")
92
+ Memory footprint: 109.78 MB
93
+ ```
94
+
95
+ # Limitations
96
+
97
+ 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.
98
+
99
+ # Citation
100
+ ```bash
101
+ @misc{allal2024SmolLM,
102
+ title={SmolLM - blazingly fast and remarkably powerful},
103
+ author={Loubna Ben Allal and Anton Lozhkov and Elie Bakouch and Leandro von Werra and Thomas Wolf},
104
+ year={2024},
105
+ }
106
+ ```