ajagota71 commited on
Commit
a7d921d
·
verified ·
1 Parent(s): e85b09f

Checkpoint after epoch 160

Browse files
README.md ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ library_name: transformers
4
+ tags:
5
+ - trl
6
+ - ppo
7
+ - transformers
8
+ - reinforcement-learning
9
+ ---
10
+
11
+ # TRL Model
12
+
13
+ This is a [TRL language model](https://github.com/huggingface/trl) that has been fine-tuned with reinforcement learning to
14
+ guide the model outputs according to a value, function, or human feedback. The model can be used for text generation.
15
+
16
+ ## Usage
17
+
18
+ To use this model for inference, first install the TRL library:
19
+
20
+ ```bash
21
+ python -m pip install trl
22
+ ```
23
+
24
+ You can then generate text as follows:
25
+
26
+ ```python
27
+ from transformers import pipeline
28
+
29
+ generator = pipeline("text-generation", model="ajagota71//kaggle/working/irl_llms/outputs/2025-05-16_09-29-11/checkpoints/temp-checkpoint-epoch-160")
30
+ outputs = generator("Hello, my llama is cute")
31
+ ```
32
+
33
+ If you want to use the model for training or to obtain the outputs from the value head, load the model as follows:
34
+
35
+ ```python
36
+ from transformers import AutoTokenizer
37
+ from trl import AutoModelForCausalLMWithValueHead
38
+
39
+ tokenizer = AutoTokenizer.from_pretrained("ajagota71//kaggle/working/irl_llms/outputs/2025-05-16_09-29-11/checkpoints/temp-checkpoint-epoch-160")
40
+ model = AutoModelForCausalLMWithValueHead.from_pretrained("ajagota71//kaggle/working/irl_llms/outputs/2025-05-16_09-29-11/checkpoints/temp-checkpoint-epoch-160")
41
+
42
+ inputs = tokenizer("Hello, my llama is cute", return_tensors="pt")
43
+ outputs = model(**inputs, labels=inputs["input_ids"])
44
+ ```
config.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "GPTNeoXForCausalLM"
4
+ ],
5
+ "attention_bias": true,
6
+ "attention_dropout": 0.0,
7
+ "bos_token_id": 0,
8
+ "classifier_dropout": 0.1,
9
+ "eos_token_id": 0,
10
+ "hidden_act": "gelu",
11
+ "hidden_dropout": 0.0,
12
+ "hidden_size": 512,
13
+ "initializer_range": 0.02,
14
+ "intermediate_size": 2048,
15
+ "layer_norm_eps": 1e-05,
16
+ "max_position_embeddings": 2048,
17
+ "model_type": "gpt_neox",
18
+ "num_attention_heads": 8,
19
+ "num_hidden_layers": 6,
20
+ "partial_rotary_factor": 0.25,
21
+ "rope_scaling": null,
22
+ "rope_theta": 10000,
23
+ "rotary_emb_base": 10000,
24
+ "rotary_pct": 0.25,
25
+ "tie_word_embeddings": false,
26
+ "torch_dtype": "float32",
27
+ "transformers_version": "4.51.3",
28
+ "use_cache": true,
29
+ "use_parallel_residual": true,
30
+ "vocab_size": 50304
31
+ }
generation_config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 0,
4
+ "eos_token_id": 0,
5
+ "transformers_version": "4.51.3"
6
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b32be9d1a669852be11745230be30816157c2f3cc2c7c5b1f5e4d1837d9def3e
3
+ size 281717404
rlhf_config.yaml ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ rlhf:
2
+ model:
3
+ name: EleutherAI/pythia-70M
4
+ learning_rate: 1.0e-05
5
+ ppo_epochs: 4
6
+ init_kl_coef: 0.2
7
+ target: 6
8
+ cliprange: 0.2
9
+ cliprange_value: 0.2
10
+ vf_coef: 0.1
11
+ adap_kl_ctrl: true
12
+ use_score_norm: true
13
+ ratio_threshold: 10.0
14
+ batch_size: 128
15
+ mini_batch_size: 8
16
+ forward_batch_size: 8
17
+ gradient_accumulation_steps: 8
18
+ reward_model: facebook/roberta-hate-speech-dynabench-r4-target
19
+ use_raw_logits: true
20
+ generation:
21
+ min_length: 5
22
+ output_min_length: 15
23
+ output_max_length: 20
24
+ do_sample: true
25
+ top_k: 0.0
26
+ top_p: 1.0
27
+ training:
28
+ num_train_epochs: 100
29
+ save_freq: 20
30
+ eval_freq: 20
31
+ seed: 42
32
+ dataset:
33
+ name: allenai/real-toxicity-prompts
34
+ toxicity_threshold: 0.3
35
+ input_min_text_length: 15
36
+ input_max_text_length: 20
37
+ test_size: 0.1
38
+ output:
39
+ push_to_hub: true
40
+ organization: null
41
+ repository_name: pythia-70m-detox
42
+ wandb:
43
+ project: irl_llms
44
+ entity: null
45
+ name: null
46
+ irl:
47
+ mode: train
48
+ dataset:
49
+ original_model_name: EleutherAI/pythia-70M
50
+ detoxified_model_name: ajagota71/pythia-70m-detox-epoch-100
51
+ original_dataset_path: null
52
+ detoxified_dataset_path: null
53
+ cache_dir: ${hydra:runtime.cwd}/datasets
54
+ num_samples: 1000
55
+ max_new_tokens: 30
56
+ batch_size: 16
57
+ temperature: 0.7
58
+ top_p: 1.0
59
+ seed: ${seed}
60
+ use_cached: false
61
+ toxicity_threshold: 0.3
62
+ push_to_hub: false
63
+ hub_org: null
64
+ hub_token: ${oc.env:HF_TOKEN,null}
65
+ private: false
66
+ use_half_precision: null
67
+ model:
68
+ reward_model_base: null
69
+ use_half_precision: null
70
+ num_unfrozen_layers: 1
71
+ training:
72
+ irl_method: max_margin
73
+ learning_rate: 1.0e-05
74
+ epochs: 20
75
+ batch_size: 4
76
+ eval_interval: 5
77
+ max_length: 512
78
+ train_test_split: 0.8
79
+ grad_clip: 1.0
80
+ weight_decay: 0.01
81
+ margin: 0.1
82
+ temperature: 0.1
83
+ adam_epsilon: 1.0e-08
84
+ seed: ${seed}
85
+ include_prompt: true
86
+ output:
87
+ repo_name_prefix: irl-reward-model
88
+ base_dir: ${hydra:runtime.cwd}/outputs/irl
89
+ save_checkpoints: true
90
+ push_to_hub: false
91
+ hub_org: ajagota71
92
+ private: false
93
+ evaluation:
94
+ true_reward_model: facebook/roberta-hate-speech-dynabench-r4-target
95
+ logging:
96
+ project_name: irl-detoxification
97
+ use_wandb: true
98
+ wandb_mode: online
99
+ now: 2025-05-16_09-29-11
100
+ seed: 42
101
+ output_dir: ${hydra:runtime.cwd}/outputs/${now:%Y-%m-%d_%H-%M-%S}
102
+ mode: train
103
+ model:
104
+ name: EleutherAI/pythia-70M
105
+ learning_rate: 1.0e-05
106
+ batch_size: 128
107
+ mini_batch_size: 8
108
+ forward_batch_size: 8
109
+ gradient_accumulation_steps: 8
110
+ reward_model: facebook/roberta-hate-speech-dynabench-r4-target
111
+ use_raw_logits: true
112
+ ppo_epochs: 4
113
+ init_kl_coef: 0.2
114
+ target: 6
115
+ cliprange: 0.2
116
+ cliprange_value: 0.2
117
+ vf_coef: 0.1
118
+ adap_kl_ctrl: true
119
+ use_score_norm: true
120
+ ratio_threshold: 10.0
121
+ generation:
122
+ min_length: 5
123
+ output_min_length: 15
124
+ output_max_length: 20
125
+ do_sample: true
126
+ top_k: 0.0
127
+ top_p: 1.0
128
+ training:
129
+ num_train_epochs: 200
130
+ save_freq: 50
131
+ eval_freq: 20
132
+ seed: 42
133
+ dataset:
134
+ name: allenai/real-toxicity-prompts
135
+ toxicity_threshold: 0.3
136
+ input_min_text_length: 15
137
+ input_max_text_length: 20
138
+ test_size: 0.1
139
+ output:
140
+ push_to_hub: true
141
+ push_checkpoints_to_hub: true
142
+ checkpoint_push_freq: 20
143
+ organization: ajagota71
144
+ repository_name: pythia-70m-fb-detox
145
+ private: false
146
+ wandb:
147
+ project: irl_llms
148
+ entity: null
149
+ name: pythia-70M-2025-05-16_09-29-11
special_tokens_map.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<|endoftext|>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "<|endoftext|>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": "<|endoftext|>",
17
+ "unk_token": {
18
+ "content": "<|endoftext|>",
19
+ "lstrip": false,
20
+ "normalized": false,
21
+ "rstrip": false,
22
+ "single_word": false
23
+ }
24
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": false,
3
+ "add_eos_token": false,
4
+ "add_prefix_space": false,
5
+ "added_tokens_decoder": {
6
+ "0": {
7
+ "content": "<|endoftext|>",
8
+ "lstrip": false,
9
+ "normalized": false,
10
+ "rstrip": false,
11
+ "single_word": false,
12
+ "special": true
13
+ },
14
+ "1": {
15
+ "content": "<|padding|>",
16
+ "lstrip": false,
17
+ "normalized": false,
18
+ "rstrip": false,
19
+ "single_word": false,
20
+ "special": true
21
+ },
22
+ "50254": {
23
+ "content": " ",
24
+ "lstrip": false,
25
+ "normalized": true,
26
+ "rstrip": false,
27
+ "single_word": false,
28
+ "special": false
29
+ },
30
+ "50255": {
31
+ "content": " ",
32
+ "lstrip": false,
33
+ "normalized": true,
34
+ "rstrip": false,
35
+ "single_word": false,
36
+ "special": false
37
+ },
38
+ "50256": {
39
+ "content": " ",
40
+ "lstrip": false,
41
+ "normalized": true,
42
+ "rstrip": false,
43
+ "single_word": false,
44
+ "special": false
45
+ },
46
+ "50257": {
47
+ "content": " ",
48
+ "lstrip": false,
49
+ "normalized": true,
50
+ "rstrip": false,
51
+ "single_word": false,
52
+ "special": false
53
+ },
54
+ "50258": {
55
+ "content": " ",
56
+ "lstrip": false,
57
+ "normalized": true,
58
+ "rstrip": false,
59
+ "single_word": false,
60
+ "special": false
61
+ },
62
+ "50259": {
63
+ "content": " ",
64
+ "lstrip": false,
65
+ "normalized": true,
66
+ "rstrip": false,
67
+ "single_word": false,
68
+ "special": false
69
+ },
70
+ "50260": {
71
+ "content": " ",
72
+ "lstrip": false,
73
+ "normalized": true,
74
+ "rstrip": false,
75
+ "single_word": false,
76
+ "special": false
77
+ },
78
+ "50261": {
79
+ "content": " ",
80
+ "lstrip": false,
81
+ "normalized": true,
82
+ "rstrip": false,
83
+ "single_word": false,
84
+ "special": false
85
+ },
86
+ "50262": {
87
+ "content": " ",
88
+ "lstrip": false,
89
+ "normalized": true,
90
+ "rstrip": false,
91
+ "single_word": false,
92
+ "special": false
93
+ },
94
+ "50263": {
95
+ "content": " ",
96
+ "lstrip": false,
97
+ "normalized": true,
98
+ "rstrip": false,
99
+ "single_word": false,
100
+ "special": false
101
+ },
102
+ "50264": {
103
+ "content": " ",
104
+ "lstrip": false,
105
+ "normalized": true,
106
+ "rstrip": false,
107
+ "single_word": false,
108
+ "special": false
109
+ },
110
+ "50265": {
111
+ "content": " ",
112
+ "lstrip": false,
113
+ "normalized": true,
114
+ "rstrip": false,
115
+ "single_word": false,
116
+ "special": false
117
+ },
118
+ "50266": {
119
+ "content": " ",
120
+ "lstrip": false,
121
+ "normalized": true,
122
+ "rstrip": false,
123
+ "single_word": false,
124
+ "special": false
125
+ },
126
+ "50267": {
127
+ "content": " ",
128
+ "lstrip": false,
129
+ "normalized": true,
130
+ "rstrip": false,
131
+ "single_word": false,
132
+ "special": false
133
+ },
134
+ "50268": {
135
+ "content": " ",
136
+ "lstrip": false,
137
+ "normalized": true,
138
+ "rstrip": false,
139
+ "single_word": false,
140
+ "special": false
141
+ },
142
+ "50269": {
143
+ "content": " ",
144
+ "lstrip": false,
145
+ "normalized": true,
146
+ "rstrip": false,
147
+ "single_word": false,
148
+ "special": false
149
+ },
150
+ "50270": {
151
+ "content": " ",
152
+ "lstrip": false,
153
+ "normalized": true,
154
+ "rstrip": false,
155
+ "single_word": false,
156
+ "special": false
157
+ },
158
+ "50271": {
159
+ "content": " ",
160
+ "lstrip": false,
161
+ "normalized": true,
162
+ "rstrip": false,
163
+ "single_word": false,
164
+ "special": false
165
+ },
166
+ "50272": {
167
+ "content": " ",
168
+ "lstrip": false,
169
+ "normalized": true,
170
+ "rstrip": false,
171
+ "single_word": false,
172
+ "special": false
173
+ },
174
+ "50273": {
175
+ "content": " ",
176
+ "lstrip": false,
177
+ "normalized": true,
178
+ "rstrip": false,
179
+ "single_word": false,
180
+ "special": false
181
+ },
182
+ "50274": {
183
+ "content": " ",
184
+ "lstrip": false,
185
+ "normalized": true,
186
+ "rstrip": false,
187
+ "single_word": false,
188
+ "special": false
189
+ },
190
+ "50275": {
191
+ "content": " ",
192
+ "lstrip": false,
193
+ "normalized": true,
194
+ "rstrip": false,
195
+ "single_word": false,
196
+ "special": false
197
+ },
198
+ "50276": {
199
+ "content": " ",
200
+ "lstrip": false,
201
+ "normalized": true,
202
+ "rstrip": false,
203
+ "single_word": false,
204
+ "special": false
205
+ }
206
+ },
207
+ "bos_token": "<|endoftext|>",
208
+ "clean_up_tokenization_spaces": false,
209
+ "eos_token": "<|endoftext|>",
210
+ "extra_special_tokens": {},
211
+ "model_max_length": 1000000000000000019884624838656,
212
+ "pad_token": "<|endoftext|>",
213
+ "tokenizer_class": "GPTNeoXTokenizer",
214
+ "unk_token": "<|endoftext|>"
215
+ }