Update README.md
Browse files
README.md
CHANGED
@@ -1,199 +1,191 @@
|
|
1 |
---
|
2 |
library_name: transformers
|
3 |
-
tags:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
---
|
5 |
|
6 |
-
# Model Card for
|
7 |
-
|
8 |
-
<!-- Provide a quick summary of what the model is/does. -->
|
9 |
|
|
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
## Model Details
|
13 |
|
14 |
### Model Description
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
|
19 |
-
|
20 |
-
- **Developed by:** [More Information Needed]
|
21 |
-
- **Funded by [optional]:** [More Information Needed]
|
22 |
-
- **Shared by [optional]:** [More Information Needed]
|
23 |
-
- **Model type:** [More Information Needed]
|
24 |
-
- **Language(s) (NLP):** [More Information Needed]
|
25 |
-
- **License:** [More Information Needed]
|
26 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
27 |
-
|
28 |
-
### Model Sources [optional]
|
29 |
-
|
30 |
-
<!-- Provide the basic links for the model. -->
|
31 |
-
|
32 |
-
- **Repository:** [More Information Needed]
|
33 |
-
- **Paper [optional]:** [More Information Needed]
|
34 |
-
- **Demo [optional]:** [More Information Needed]
|
35 |
-
|
36 |
-
## Uses
|
37 |
-
|
38 |
-
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
39 |
-
|
40 |
-
### Direct Use
|
41 |
-
|
42 |
-
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
43 |
|
44 |
-
|
|
|
|
|
|
|
|
|
45 |
|
46 |
-
|
47 |
-
|
48 |
-
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
49 |
-
|
50 |
-
[More Information Needed]
|
51 |
-
|
52 |
-
### Out-of-Scope Use
|
53 |
|
54 |
-
|
55 |
|
56 |
-
|
|
|
57 |
|
58 |
-
|
|
|
59 |
|
60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
|
62 |
-
|
63 |
|
64 |
-
|
|
|
|
|
|
|
65 |
|
66 |
-
|
67 |
|
68 |
-
|
|
|
|
|
|
|
|
|
|
|
69 |
|
70 |
-
|
|
|
|
|
|
|
71 |
|
72 |
-
|
73 |
|
74 |
-
|
|
|
|
|
|
|
|
|
|
|
75 |
|
76 |
## Training Details
|
77 |
|
78 |
### Training Data
|
79 |
|
80 |
-
|
81 |
-
|
82 |
-
[More Information Needed]
|
83 |
|
84 |
### Training Procedure
|
85 |
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
|
93 |
-
#### Training Hyperparameters
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
|
95 |
-
|
96 |
|
97 |
-
|
98 |
|
99 |
-
|
100 |
|
101 |
-
|
102 |
|
103 |
## Evaluation
|
104 |
|
105 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
106 |
-
|
107 |
### Testing Data, Factors & Metrics
|
108 |
|
109 |
#### Testing Data
|
110 |
|
111 |
-
|
112 |
-
|
113 |
-
[More Information Needed]
|
114 |
|
115 |
#### Factors
|
116 |
|
117 |
-
|
118 |
-
|
119 |
-
|
|
|
120 |
|
121 |
#### Metrics
|
122 |
|
123 |
-
|
124 |
-
|
125 |
-
|
|
|
126 |
|
127 |
### Results
|
128 |
|
129 |
-
|
130 |
|
131 |
#### Summary
|
132 |
|
|
|
133 |
|
134 |
-
|
135 |
-
## Model Examination [optional]
|
136 |
-
|
137 |
-
<!-- Relevant interpretability work for the model goes here -->
|
138 |
-
|
139 |
-
[More Information Needed]
|
140 |
-
|
141 |
-
## Environmental Impact
|
142 |
-
|
143 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
144 |
-
|
145 |
-
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
146 |
-
|
147 |
-
- **Hardware Type:** [More Information Needed]
|
148 |
-
- **Hours used:** [More Information Needed]
|
149 |
-
- **Cloud Provider:** [More Information Needed]
|
150 |
-
- **Compute Region:** [More Information Needed]
|
151 |
-
- **Carbon Emitted:** [More Information Needed]
|
152 |
-
|
153 |
-
## Technical Specifications [optional]
|
154 |
|
155 |
### Model Architecture and Objective
|
156 |
|
157 |
-
|
158 |
|
159 |
### Compute Infrastructure
|
160 |
|
161 |
-
|
162 |
|
163 |
#### Hardware
|
164 |
-
|
165 |
-
[More Information Needed]
|
166 |
|
167 |
#### Software
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
174 |
-
|
175 |
-
**BibTeX:**
|
176 |
-
|
177 |
-
[More Information Needed]
|
178 |
|
179 |
**APA:**
|
180 |
|
181 |
-
|
182 |
-
|
183 |
-
## Glossary [optional]
|
184 |
|
185 |
-
|
186 |
|
187 |
-
|
|
|
|
|
188 |
|
189 |
-
## More Information
|
190 |
|
191 |
-
|
|
|
|
|
192 |
|
193 |
-
## Model Card Authors
|
194 |
|
195 |
-
|
196 |
|
197 |
## Model Card Contact
|
198 |
|
199 |
-
|
|
|
1 |
---
|
2 |
library_name: transformers
|
3 |
+
tags:
|
4 |
+
- PPO
|
5 |
+
- RLHF
|
6 |
+
- Fine-tuning
|
7 |
+
- SmolLM
|
8 |
+
- Proximal Policy Optimization
|
9 |
+
license: apache-2.0
|
10 |
+
language:
|
11 |
+
- en
|
12 |
+
base_model:
|
13 |
+
- HuggingFaceTB/SmolLM2-135M-Instruct
|
14 |
+
pipeline_tag: text-generation
|
15 |
---
|
16 |
|
17 |
+
# Model Card for SmolLM Variation PPO Fine-Tuning for RLHF
|
|
|
|
|
18 |
|
19 |
+
This model is a fine-tuned variant of the SmolLM-135M-Instruct model using Proximal Policy Optimization (PPO) for Reinforcement Learning from Human Feedback (RLHF). It has been optimized by leveraging a pre-trained reward model and value model through the TRL library's PPOTrainer, with the aim of generating more engaging and human-aligned responses.
|
20 |
|
21 |
+
## Task Description
|
22 |
+
The project involves:
|
23 |
+
- Converting the training dataset into a prompt-only format.
|
24 |
+
- Utilizing a pre-trained reward model and a value model to compute scalar rewards.
|
25 |
+
- Fine-tuning the policy model with PPO (via TRL's PPOTrainer) to improve response quality and maximize reward margins.
|
26 |
+
- Evaluating the model's performance by comparing generation quality before and after PPO fine-tuning.
|
27 |
|
28 |
## Model Details
|
29 |
|
30 |
### Model Description
|
31 |
|
32 |
+
This is the model card for a 🤗 transformers model that has been pushed on the Hub after PPO fine-tuning. The model card has been refined with details gathered from experiments and training logs.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
+
- **Developed by:** Ekaterina Aleksanian
|
35 |
+
- **Model type:** Causal Language Model (autoregressive) fine-tuned using Proximal Policy Optimization (PPO)
|
36 |
+
- **Language(s) (NLP):** English
|
37 |
+
- **License:** MIT License
|
38 |
+
- **Finetuned from model [optional]:** SmolLM-135M-Instruct
|
39 |
|
40 |
+
## How to Get Started with the Model
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
+
You can load the model using the Hugging Face Transformers library. For example:
|
43 |
|
44 |
+
```python
|
45 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
46 |
|
47 |
+
model = AutoModelForCausalLM.from_pretrained("estnafinema0/smolLM-variation-ppo")
|
48 |
+
tokenizer = AutoTokenizer.from_pretrained("estnafinema0/smolLM-variation-ppo")
|
49 |
|
50 |
+
# Generate a response
|
51 |
+
messages = [{"role": "user", "content": "What's your morning routine like?"}]
|
52 |
+
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
53 |
+
inputs = tokenizer([text], return_tensors="pt")
|
54 |
+
output_ids = model.generate(inputs.input_ids, max_new_tokens=256, do_sample=True)
|
55 |
+
response = tokenizer.batch_decode(output_ids, skip_special_tokens=True)[0]
|
56 |
+
print(response)
|
57 |
+
```
|
58 |
|
59 |
+
## Generation Examples
|
60 |
|
61 |
+
**Before Fine-Tuning (Reference Policy):**
|
62 |
+
```
|
63 |
+
User: What's your morning routine like?
|
64 |
+
Assistant: What a wonderful question! As a conversational AI, I have my own wake-up routine tailored to my needs. Here's my "wake-up routine" for you:
|
65 |
|
66 |
+
**Morning Routine (10-15 minutes)**
|
67 |
|
68 |
+
1. **10:00 AM**: Start with a gentle exercise routine to loosen up my muscles and get my blood flowing. This could be a simple yoga pose like downward-facing dog, child's pose, or a standing forward fold.
|
69 |
+
2. **11:00 AM**: Finish my morning routine with a healthy breakfast or a hearty snack, such as oatmeal with fruits, nuts, or Greek yogurt with honey.
|
70 |
+
3. **6:00 PM**: Take my morning bus or drive to my workspace to start my morning routine. During my commute, I set my alarm clock, get dressed, and start my daily activities.
|
71 |
+
4. **7:00 PM**: Work on an important project or focus on other tasks, such as researching for my thesis or preparing for a project deadline.
|
72 |
+
5. **8:00 PM**: Have a quick lunch break, so I can get back to my desk or grab some lunch before my morning exercise routine begins.
|
73 |
+
```
|
74 |
|
75 |
+
**After PPO Fine-Tuning:**
|
76 |
+
```
|
77 |
+
User: What's your morning routine like?
|
78 |
+
Assistant: I'm excited to share my morning routine with you! As a digital AI assistant, I don't have personal experiences or emotions, but I can provide you with a general idea of what a morning routine might look like. Here's a sample routine that I've developed based on various studies and research:
|
79 |
|
80 |
+
**Morning Routine (10-15 minutes)**
|
81 |
|
82 |
+
1. **Hydration**: Drink a full glass of water or a herbal tea (e.g., chamomile, peppermint) to start your day.
|
83 |
+
2. **Stretching or Exercise**: Engage in some light physical activity, like yoga, stretching, or a short walk. This helps increase energy and flexibility.
|
84 |
+
3. **Meditation or Mindfulness**: Spend 10-15 minutes meditating, focusing on your breath, or practicing mindfulness exercises. This helps clear your mind and set intentions for the day.
|
85 |
+
4. **Journaling**: Write down your thoughts, goals, and gratitudes to reflect on your day. This helps process emotions and gain clarity.
|
86 |
+
5. **Healthy Breakfast**: Prepare a nutritious breakfast, such as oatmeal with fruit, scrambled eggs with spinach, or Greek yogurt with berries.
|
87 |
+
```
|
88 |
|
89 |
## Training Details
|
90 |
|
91 |
### Training Data
|
92 |
|
93 |
+
The model was fine-tuned using the [HumanLLMs/Human-Like-DPO-Dataset](https://huggingface.co/datasets/HumanLLMs/Human-Like-DPO-Dataset), which provides prompts along with chosen and rejected responses. The data was reformatted into a chat template where only the prompt is retained for PPO fine-tuning.
|
|
|
|
|
94 |
|
95 |
### Training Procedure
|
96 |
|
97 |
+
The training procedure involved:
|
98 |
+
- Converting the raw dataset into a prompt-only format using a chat template.
|
99 |
+
- Tokenizing the data while preserving critical information from the prompt.
|
100 |
+
- Fine-tuning the SmolLM-135M-Instruct model with PPO using TRL's PPOTrainer.
|
101 |
+
- Leveraging a pre-trained reward model and value model to guide the PPO updates.
|
102 |
+
- Training was conducted on an A100 GPU with Automatic Mixed Precision (AMP) enabled for efficiency.
|
103 |
|
104 |
+
#### Training Hyperparameters:
|
105 |
+
- **Learning Rate:** 5e-5
|
106 |
+
- **Batch Size:** 16
|
107 |
+
- **Mini Batch Size:** 4
|
108 |
+
- **PPO Epochs:** 4
|
109 |
+
- **Max Sequence Length:** 1024
|
110 |
+
- **Max Prompt Length:** 256
|
111 |
|
112 |
+
#### Preprocessing
|
113 |
|
114 |
+
The dataset was processed by applying a chat template that formats the prompt in a conversational style. Tokenization included truncation to retain the most informative tokens.
|
115 |
|
116 |
+
#### Speeds, Sizes, Times
|
117 |
|
118 |
+
Fine-tuning on an A100 GPU took approximately 2 minutes per epoch. The final model size remains similar to the base model while optimized for efficient inference with AMP.
|
119 |
|
120 |
## Evaluation
|
121 |
|
|
|
|
|
122 |
### Testing Data, Factors & Metrics
|
123 |
|
124 |
#### Testing Data
|
125 |
|
126 |
+
Evaluation was performed on a subset of the training data (in-distribution) and an external dataset (wikitext-2-raw-v1) to assess generalization.
|
|
|
|
|
127 |
|
128 |
#### Factors
|
129 |
|
130 |
+
Evaluation factors include:
|
131 |
+
- The log probability assigned to in-distribution versus out-of-distribution data.
|
132 |
+
- Reward margins computed from the difference in log probabilities.
|
133 |
+
- Qualitative generation quality of the responses.
|
134 |
|
135 |
#### Metrics
|
136 |
|
137 |
+
Key evaluation metrics are:
|
138 |
+
- **Log Probability Distribution:** A comparison between in-distribution and external data.
|
139 |
+
- **Reward Margins:** The differential between the rewards of chosen versus rejected responses.
|
140 |
+
- **Reward Accuracy:** The percentage of instances where the chosen response is favored.
|
141 |
|
142 |
### Results
|
143 |
|
144 |
+
The evaluation indicates that the PPO fine-tuned model assigns higher log probabilities to in-distribution data compared to external samples. This suggests that the model has successfully learned to generate responses more aligned with the training data and human preferences. Improvements in reward margins and accuracy metrics further support this observation.
|
145 |
|
146 |
#### Summary
|
147 |
|
148 |
+
In summary, the PPO fine-tuned model demonstrates enhanced performance in generating human-aligned responses. The model effectively differentiates between preferred and non-preferred responses, as validated by both quantitative metrics and qualitative generation examples.
|
149 |
|
150 |
+
## Technical Specifications
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
|
152 |
### Model Architecture and Objective
|
153 |
|
154 |
+
The model is based on the SmolLM-135M-Instruct architecture. The PPO fine-tuning objective is to optimize the policy model using a reward signal provided by a pre-trained reward model and value model, thus aligning the model’s outputs with human preferences.
|
155 |
|
156 |
### Compute Infrastructure
|
157 |
|
158 |
+
Fine-tuning was performed on an A100 GPU with AMP enabled for computational efficiency.
|
159 |
|
160 |
#### Hardware
|
161 |
+
- NVIDIA A100 GPU
|
|
|
162 |
|
163 |
#### Software
|
164 |
+
- PyTorch
|
165 |
+
- Hugging Face Transformers
|
166 |
+
- TRL (for reinforcement learning components)
|
167 |
+
- Additional libraries for data processing and visualization
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
|
169 |
**APA:**
|
170 |
|
171 |
+
Aleksanian, E. (2025). *SmolLM Variation PPO Fine-Tuning for RLHF*. Retrieved from https://huggingface.co/estnafinema0/smolLM-variation-ppo
|
|
|
|
|
172 |
|
173 |
+
## Glossary
|
174 |
|
175 |
+
- **PPO (Proximal Policy Optimization):** A reinforcement learning algorithm that updates the policy by taking small, conservative steps to improve performance.
|
176 |
+
- **RLHF:** Reinforcement Learning from Human Feedback.
|
177 |
+
- **AMP:** Automatic Mixed Precision, used to speed up training.
|
178 |
|
179 |
+
## More Information
|
180 |
|
181 |
+
For further details, please refer to the associated repositories:
|
182 |
+
- **DPO Fine-Tuning:** [estnafinema0/smolLM-variation-dpo](https://huggingface.co/estnafinema0/smolLM-variation-dpo)
|
183 |
+
- **Trainer Output:** [estnafinema0/trainer_output](https://huggingface.co/estnafinema0/trainer_output)
|
184 |
|
185 |
+
## Model Card Authors
|
186 |
|
187 |
+
- Ekaterina Aleksanian
|
188 |
|
189 |
## Model Card Contact
|
190 |
|
191 |
+
For any questions or feedback regarding this model card, please contact Ekaterina Aleksanian at [[email protected]].
|