loubnabnl HF staff commited on
Commit
d914289
1 Parent(s): 5512b3b

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +104 -73
README.md CHANGED
@@ -1,77 +1,108 @@
1
  ---
2
- base_model: HuggingFaceTB/cosmo2-350M-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
- - argilla/dpo-mix-7k
13
- model-index:
14
- - name: cosmo2-350M-webinst-sc2-dpo-argilla-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/z5gb262b)
22
- # cosmo2-350M-webinst-sc2-dpo-argilla-ep1
23
-
24
- This model is a fine-tuned version of [HuggingFaceTB/cosmo2-350M-webinst-sc2](https://huggingface.co/HuggingFaceTB/cosmo2-350M-webinst-sc2) on the argilla/dpo-mix-7k dataset.
25
- It achieves the following results on the evaluation set:
26
- - Loss: 0.6834
27
- - Rewards/chosen: -0.0086
28
- - Rewards/rejected: -0.0304
29
- - Rewards/accuracies: 0.5938
30
- - Rewards/margins: 0.0218
31
- - Logps/rejected: -418.5675
32
- - Logps/chosen: -442.4709
33
- - Logits/rejected: -0.7106
34
- - Logits/chosen: -0.5211
35
- - IFEval prompt loose 17.01
36
- - IFEval prompt strict 14.05
37
- ## Model description
38
-
39
- More information needed
40
-
41
- ## Intended uses & limitations
42
-
43
- More information needed
44
-
45
- ## Training and evaluation data
46
-
47
- More information needed
48
-
49
- ## Training procedure
50
-
51
- ### Training hyperparameters
52
-
53
- The following hyperparameters were used during training:
54
- - learning_rate: 5e-06
55
- - train_batch_size: 2
56
- - eval_batch_size: 4
57
- - seed: 42
58
- - distributed_type: multi-GPU
59
- - num_devices: 8
60
- - gradient_accumulation_steps: 8
61
- - total_train_batch_size: 128
62
- - total_eval_batch_size: 32
63
- - optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
64
- - lr_scheduler_type: cosine
65
- - lr_scheduler_warmup_ratio: 0.1
66
- - num_epochs: 1
67
-
68
- ### Training results
69
-
70
-
71
-
72
- ### Framework versions
73
-
74
- - Transformers 4.42.3
75
- - Pytorch 2.1.2
76
- - Datasets 2.20.0
77
- - Tokenizers 0.19.1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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">
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
+ This is the SmolLM-360M-Instruct.
31
+
32
+ ### Generation
33
+ ```bash
34
+ pip install transformers
35
+ ```
36
+
37
+ #### Running the model on CPU/GPU/multi GPU
38
+ * _Using full precision_
39
+ ```python
40
+ # pip install git+https://github.com/huggingface/transformers.git # TODO: merge PR to main
41
+ from transformers import AutoModelForCausalLM, AutoTokenizer
42
+ checkpoint = "HuggingFaceTB/SmolLM-135M"
43
+ device = "cuda" # for GPU usage or "cpu" for CPU usage
44
+ tokenizer = AutoTokenizer.from_pretrained(checkpoint)
45
+ # for multiple GPUs install accelerate and do `model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map="auto")`
46
+ model = AutoModelForCausalLM.from_pretrained(checkpoint).to(device)
47
+ inputs = tokenizer.encode("def print_hello_world():", return_tensors="pt").to(device)
48
+ outputs = model.generate(inputs)
49
+ print(tokenizer.decode(outputs[0]))
50
+ ```
51
+ ```bash
52
+ >>> print(f"Memory footprint: {model.get_memory_footprint() / 1e6:.2f} MB")
53
+ Memory footprint: 12624.81 MB
54
+ ```
55
+ * _Using `torch.bfloat16`_
56
+ ```python
57
+ # pip install accelerate
58
+ import torch
59
+ from transformers import AutoTokenizer, AutoModelForCausalLM
60
+ checkpoint = "HuggingFaceTB/SmolLM-135M"
61
+ tokenizer = AutoTokenizer.from_pretrained(checkpoint)
62
+ # for fp16 use `torch_dtype=torch.float16` instead
63
+ model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map="auto", torch_dtype=torch.bfloat16)
64
+ inputs = tokenizer.encode("def print_hello_world():", return_tensors="pt").to("cuda")
65
+ outputs = model.generate(inputs)
66
+ print(tokenizer.decode(outputs[0]))
67
+ ```
68
+ ```bash
69
+ >>> print(f"Memory footprint: {model.get_memory_footprint() / 1e6:.2f} MB")
70
+ Memory footprint: 269.03 MB
71
+ ```
72
+
73
+ #### Quantized Versions through `bitsandbytes`
74
+ * _Using 8-bit precision (int8)_
75
+
76
+ ```python
77
+ # pip install bitsandbytes accelerate
78
+ from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
79
+ # to use 4bit use `load_in_4bit=True` instead
80
+ quantization_config = BitsAndBytesConfig(load_in_8bit=True)
81
+ checkpoint = "HuggingFaceTB/SmolLM-135M"
82
+ tokenizer = AutoTokenizer.from_pretrained(checkpoint)
83
+ model = AutoModelForCausalLM.from_pretrained(checkpoint, quantization_config=quantization_config)
84
+ inputs = tokenizer.encode("def print_hello_world():", return_tensors="pt").to("cuda")
85
+ outputs = model.generate(inputs)
86
+ print(tokenizer.decode(outputs[0]))
87
+ ```
88
+ ```bash
89
+ >>> print(f"Memory footprint: {model.get_memory_footprint() / 1e6:.2f} MB")
90
+ # load_in_8bit
91
+ Memory footprint: 162.87 MB
92
+ # load_in_4bit
93
+ >>> print(f"Memory footprint: {model.get_memory_footprint() / 1e6:.2f} MB")
94
+ Memory footprint: 109.78 MB
95
+ ```
96
+
97
+ # Limitations
98
+
99
+ 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.
100
+
101
+ # Citation
102
+ ```bash
103
+ @misc{allal2024SmolLM,
104
+ title={SmolLM - blazingly fast and remarkably powerful},
105
+ author={Loubna Ben Allal and Anton Lozhkov and Elie Bakouch and Leandro von Werra and Thomas Wolf},
106
+ year={2024},
107
+ }
108
+ ```