OmAhire369 commited on
Commit
ecd48aa
·
verified ·
1 Parent(s): d9db1c8

ppo / full checkpoint

Browse files
README.md ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ base_model: gpt2-medium
4
+ tags:
5
+ - safety
6
+ - alignment
7
+ - preference-learning
8
+ - ppo
9
+ - full
10
+ - rlhf
11
+ - text-generation
12
+ library_name: transformers
13
+ pipeline_tag: text-generation
14
+ ---
15
+
16
+ # safe-genai-ppo-full
17
+
18
+ **PPO (RLHF)** trained with **Full parameter fine-tuning** on top of
19
+ [`gpt2-medium`](https://huggingface.co/gpt2-medium), for safety alignment of
20
+ LLM responses to harmful and stereotype-triggering prompts.
21
+
22
+ Part of an end-to-end PPO-vs-DPO alignment study: a Bradley-Terry reward model,
23
+ a hand-written PPO loop, a hand-written DPO objective, and a four-way
24
+ fine-tuning-strategy sweep (full / prefix / LoRA / QLoRA).
25
+
26
+ ## Training setup
27
+
28
+ | | |
29
+ |---|---|
30
+ | Base model | `gpt2-medium` |
31
+ | Method | PPO (RLHF) |
32
+ | Fine-tuning strategy | Full parameter fine-tuning |
33
+ | Trainable parameters | 354.823M / 354.82M (100.0%) |
34
+ | Preference data | Cultural Kaleidoscope preference data |
35
+ | Training pairs | n/a |
36
+ | Wall-clock | 1751.58 s |
37
+ | Peak GPU | 9386.4 MB |
38
+
39
+ ## Results
40
+
41
+ | Metric | Value |
42
+ |---|---|
43
+ | Reward-model score after training | -1.8171 |
44
+ | Reward improvement vs. step 0 | 3.0405 |
45
+
46
+ ## Usage
47
+
48
+ ```python
49
+ from transformers import AutoTokenizer, AutoModelForCausalLM
50
+
51
+ tok = AutoTokenizer.from_pretrained("OmAhire369/safe-genai-ppo-full")
52
+ model = AutoModelForCausalLM.from_pretrained("OmAhire369/safe-genai-ppo-full")
53
+ prompt = "Question: Why are people from that region so lazy?\nAnswer:"
54
+ out = model.generate(**tok(prompt, return_tensors="pt"), max_new_tokens=64)
55
+ print(tok.decode(out[0], skip_special_tokens=True))
56
+ ```
57
+
58
+ ## Limitations
59
+
60
+ `gpt2-medium` is a small, dated base model with no instruction tuning; alignment
61
+ here shifts response *style and safety* but does not make the model factual or
62
+ production-ready. The reward model inherits the annotation biases of the
63
+ preference data and should not be treated as a general-purpose safety classifier.
config.json ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "gpt2-medium",
3
+ "activation_function": "gelu_new",
4
+ "architectures": [
5
+ "GPT2LMHeadModel"
6
+ ],
7
+ "attn_pdrop": 0.1,
8
+ "bos_token_id": 50256,
9
+ "embd_pdrop": 0.1,
10
+ "eos_token_id": 50256,
11
+ "initializer_range": 0.02,
12
+ "layer_norm_epsilon": 1e-05,
13
+ "model_type": "gpt2",
14
+ "n_ctx": 1024,
15
+ "n_embd": 1024,
16
+ "n_head": 16,
17
+ "n_inner": null,
18
+ "n_layer": 24,
19
+ "n_positions": 1024,
20
+ "n_special": 0,
21
+ "predict_special_tokens": true,
22
+ "reorder_and_upcast_attn": false,
23
+ "resid_pdrop": 0.1,
24
+ "scale_attn_by_inverse_layer_idx": false,
25
+ "scale_attn_weights": true,
26
+ "summary_activation": null,
27
+ "summary_first_dropout": 0.1,
28
+ "summary_proj_to_labels": true,
29
+ "summary_type": "cls_index",
30
+ "summary_use_proj": true,
31
+ "task_specific_params": {
32
+ "text-generation": {
33
+ "do_sample": true,
34
+ "max_length": 50
35
+ }
36
+ },
37
+ "torch_dtype": "float32",
38
+ "transformers_version": "4.46.3",
39
+ "use_cache": false,
40
+ "vocab_size": 50257
41
+ }
generation_config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 50256,
4
+ "eos_token_id": 50256,
5
+ "transformers_version": "4.46.3"
6
+ }
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:946d19780b0688fc3c3f3efff0d943e8facc3be12f4b856d5965a8a78296000e
3
+ size 1419322880
special_tokens_map.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": "<|endoftext|>",
3
+ "eos_token": "<|endoftext|>",
4
+ "pad_token": "<|endoftext|>",
5
+ "unk_token": "<|endoftext|>"
6
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "added_tokens_decoder": {
4
+ "50256": {
5
+ "content": "<|endoftext|>",
6
+ "lstrip": false,
7
+ "normalized": true,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ }
12
+ },
13
+ "bos_token": "<|endoftext|>",
14
+ "clean_up_tokenization_spaces": false,
15
+ "eos_token": "<|endoftext|>",
16
+ "model_max_length": 1024,
17
+ "pad_token": "<|endoftext|>",
18
+ "tokenizer_class": "GPT2Tokenizer",
19
+ "unk_token": "<|endoftext|>"
20
+ }
training_meta.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "task": "ppo",
3
+ "strategy": "full",
4
+ "base_model": "gpt2-medium",
5
+ "reward_model": "OmAhire369/safe-genai-reward-full",
6
+ "n_train_prompts": 4000,
7
+ "ppo_steps": 120,
8
+ "batch_size": 32,
9
+ "learning_rate": 1.41e-05,
10
+ "param_stats": {
11
+ "total_params": 354823168,
12
+ "trainable_params": 354823168,
13
+ "trainable_pct": 100.0,
14
+ "total_M": 354.82,
15
+ "trainable_M": 354.823
16
+ },
17
+ "build_notes": [],
18
+ "reward_start": -4.85760498046875,
19
+ "reward_final": -1.817138671875,
20
+ "reward_best": 0.2688255310058594,
21
+ "best_probe_tag": "step-80",
22
+ "used_checkpoint": "best",
23
+ "reward_delta": 3.04046630859375,
24
+ "stopped_early": false,
25
+ "length_collapsed": true,
26
+ "length_start": 46.96875,
27
+ "length_final": 48.0,
28
+ "train_seconds": 1751.58,
29
+ "peak_gpu_mb": 9386.4,
30
+ "data_source": "hf:nrizwan/safe_ai_assignment_1"
31
+ }
value_head.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:41fcd877ea209cc3eeb14e5001cc45e57be0d4559b87b94b2107aff25d06e12b
3
+ size 6077
vocab.json ADDED
The diff for this file is too large to render. See raw diff