botways commited on
Commit
34b0cbc
·
verified ·
1 Parent(s): 366a809

botways/llama_cpo_finetune

Browse files
README.md ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers
3
+ model_name: llama-CPO
4
+ tags:
5
+ - generated_from_trainer
6
+ - trl
7
+ - cpo
8
+ licence: license
9
+ ---
10
+
11
+ # Model Card for llama-CPO
12
+
13
+ This model is a fine-tuned version of [None](https://huggingface.co/None).
14
+ It has been trained using [TRL](https://github.com/huggingface/trl).
15
+
16
+ ## Quick start
17
+
18
+ ```python
19
+ from transformers import pipeline
20
+
21
+ question = "If you had a time machine, but could only go to the past or the future once and never return, which would you choose and why?"
22
+ generator = pipeline("text-generation", model="botways/llama-CPO", device="cuda")
23
+ output = generator([{"role": "user", "content": question}], max_new_tokens=128, return_full_text=False)[0]
24
+ print(output["generated_text"])
25
+ ```
26
+
27
+ ## Training procedure
28
+
29
+
30
+
31
+ This model was trained with CPO, a method introduced in [Contrastive Preference Optimization: Pushing the Boundaries of LLM Performance in Machine Translation](https://huggingface.co/papers/2401.08417).
32
+
33
+ ### Framework versions
34
+
35
+ - TRL: 0.12.1
36
+ - Transformers: 4.46.3
37
+ - Pytorch: 2.5.1
38
+ - Datasets: 3.1.0
39
+ - Tokenizers: 0.20.3
40
+
41
+ ## Citations
42
+
43
+ Cite CPO as:
44
+
45
+ ```bibtex
46
+ @inproceedings{xu2024contrastive,
47
+ title = {{Contrastive Preference Optimization: Pushing the Boundaries of LLM Performance in Machine Translation}},
48
+ author = {Haoran Xu and Amr Sharaf and Yunmo Chen and Weiting Tan and Lingfeng Shen and Benjamin Van Durme and Kenton Murray and Young Jin Kim},
49
+ year = 2024,
50
+ booktitle = {Forty-first International Conference on Machine Learning, {ICML} 2024, Vienna, Austria, July 21-27, 2024},
51
+ publisher = {OpenReview.net},
52
+ url = {https://openreview.net/forum?id=51iwkioZpn}
53
+ }
54
+ ```
55
+
56
+ Cite TRL as:
57
+
58
+ ```bibtex
59
+ @misc{vonwerra2022trl,
60
+ title = {{TRL: Transformer Reinforcement Learning}},
61
+ author = {Leandro von Werra and Younes Belkada and Lewis Tunstall and Edward Beeching and Tristan Thrush and Nathan Lambert and Shengyi Huang and Kashif Rasul and Quentin Gallouédec},
62
+ year = 2020,
63
+ journal = {GitHub repository},
64
+ publisher = {GitHub},
65
+ howpublished = {\url{https://github.com/huggingface/trl}}
66
+ }
67
+ ```
adapter_config.json ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alpha_pattern": {},
3
+ "auto_mapping": null,
4
+ "base_model_name_or_path": "model",
5
+ "bias": "none",
6
+ "fan_in_fan_out": false,
7
+ "inference_mode": true,
8
+ "init_lora_weights": true,
9
+ "layer_replication": null,
10
+ "layers_pattern": null,
11
+ "layers_to_transform": null,
12
+ "loftq_config": {},
13
+ "lora_alpha": 16,
14
+ "lora_dropout": 0.1,
15
+ "megatron_config": null,
16
+ "megatron_core": "megatron.core",
17
+ "modules_to_save": null,
18
+ "peft_type": "LORA",
19
+ "r": 64,
20
+ "rank_pattern": {},
21
+ "revision": null,
22
+ "target_modules": [
23
+ "v_proj",
24
+ "up_proj",
25
+ "k_proj",
26
+ "gate_proj",
27
+ "down_proj",
28
+ "q_proj"
29
+ ],
30
+ "task_type": "CAUSAL_LM",
31
+ "use_dora": false,
32
+ "use_rslora": false
33
+ }
adapter_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:582281102245dc527b595361d724185f2149e40472dc5f25be7b1f3e03a31ccb
3
+ size 572574272
special_tokens_map.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<s>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "</s>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": "</s>",
17
+ "unk_token": {
18
+ "content": "<unk>",
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,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": true,
3
+ "add_eos_token": false,
4
+ "add_prefix_space": null,
5
+ "added_tokens_decoder": {
6
+ "0": {
7
+ "content": "<unk>",
8
+ "lstrip": false,
9
+ "normalized": false,
10
+ "rstrip": false,
11
+ "single_word": false,
12
+ "special": true
13
+ },
14
+ "1": {
15
+ "content": "<s>",
16
+ "lstrip": false,
17
+ "normalized": false,
18
+ "rstrip": false,
19
+ "single_word": false,
20
+ "special": true
21
+ },
22
+ "2": {
23
+ "content": "</s>",
24
+ "lstrip": false,
25
+ "normalized": false,
26
+ "rstrip": false,
27
+ "single_word": false,
28
+ "special": true
29
+ }
30
+ },
31
+ "bos_token": "<s>",
32
+ "chat_template": "{% if messages[0]['role'] == 'system' %}{% set loop_messages = messages[1:] %}{% set system_message = messages[0]['content'] %}{% else %}{% set loop_messages = messages %}{% set system_message = false %}{% endif %}{% for message in loop_messages %}{% if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}{{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}{% endif %}{% if loop.index0 == 0 and system_message != false %}{% set content = '<<SYS>>\\n' + system_message + '\\n<</SYS>>\\n\\n' + message['content'] %}{% else %}{% set content = message['content'] %}{% endif %}{% if message['role'] == 'user' %}{{ bos_token + '[INST] ' + content.strip() + ' [/INST]' }}{% elif message['role'] == 'assistant' %}{{ ' ' + content.strip() + ' ' + eos_token }}{% endif %}{% endfor %}",
33
+ "clean_up_tokenization_spaces": false,
34
+ "eos_token": "</s>",
35
+ "legacy": false,
36
+ "model_max_length": 1000000000000000019884624838656,
37
+ "pad_token": "</s>",
38
+ "padding_side": "right",
39
+ "sp_model_kwargs": {},
40
+ "tokenizer_class": "LlamaTokenizer",
41
+ "unk_token": "<unk>",
42
+ "use_default_system_prompt": false
43
+ }
trainer_state.json ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "best_metric": null,
3
+ "best_model_checkpoint": null,
4
+ "epoch": 3.0,
5
+ "eval_steps": 500,
6
+ "global_step": 39,
7
+ "is_hyper_param_search": false,
8
+ "is_local_process_zero": true,
9
+ "is_world_process_zero": true,
10
+ "log_history": [
11
+ {
12
+ "epoch": 0.7692307692307693,
13
+ "grad_norm": 1.8173785209655762,
14
+ "learning_rate": 7.435897435897435e-07,
15
+ "logits/chosen": 0.13414913415908813,
16
+ "logits/rejected": 0.12645891308784485,
17
+ "logps/chosen": -298.76983642578125,
18
+ "logps/rejected": -261.02435302734375,
19
+ "loss": 9.7803,
20
+ "nll_loss": 1.0939728021621704,
21
+ "rewards/accuracies": 0.44999998807907104,
22
+ "rewards/chosen": -29.87698745727539,
23
+ "rewards/margins": -3.774548292160034,
24
+ "rewards/rejected": -26.102436065673828,
25
+ "step": 10
26
+ },
27
+ {
28
+ "epoch": 1.5384615384615383,
29
+ "grad_norm": 1.8889318704605103,
30
+ "learning_rate": 4.871794871794871e-07,
31
+ "logits/chosen": 0.077309250831604,
32
+ "logits/rejected": 0.12109130620956421,
33
+ "logps/chosen": -277.27899169921875,
34
+ "logps/rejected": -260.14141845703125,
35
+ "loss": 8.6446,
36
+ "nll_loss": 1.0915288925170898,
37
+ "rewards/accuracies": 0.4749999940395355,
38
+ "rewards/chosen": -27.7278995513916,
39
+ "rewards/margins": -1.7137558460235596,
40
+ "rewards/rejected": -26.014141082763672,
41
+ "step": 20
42
+ },
43
+ {
44
+ "epoch": 2.3076923076923075,
45
+ "grad_norm": 1.609092354774475,
46
+ "learning_rate": 2.3076923076923078e-07,
47
+ "logits/chosen": 0.09378460794687271,
48
+ "logits/rejected": 0.0867479220032692,
49
+ "logps/chosen": -280.64697265625,
50
+ "logps/rejected": -273.1399841308594,
51
+ "loss": 7.8556,
52
+ "nll_loss": 1.1089527606964111,
53
+ "rewards/accuracies": 0.5,
54
+ "rewards/chosen": -28.064701080322266,
55
+ "rewards/margins": -0.7507012486457825,
56
+ "rewards/rejected": -27.31399917602539,
57
+ "step": 30
58
+ },
59
+ {
60
+ "epoch": 3.0,
61
+ "step": 39,
62
+ "total_flos": 0.0,
63
+ "train_loss": 8.851261627979767,
64
+ "train_runtime": 435.0584,
65
+ "train_samples_per_second": 0.69,
66
+ "train_steps_per_second": 0.09
67
+ }
68
+ ],
69
+ "logging_steps": 10,
70
+ "max_steps": 39,
71
+ "num_input_tokens_seen": 0,
72
+ "num_train_epochs": 3,
73
+ "save_steps": 500,
74
+ "stateful_callbacks": {
75
+ "TrainerControl": {
76
+ "args": {
77
+ "should_epoch_stop": false,
78
+ "should_evaluate": false,
79
+ "should_log": false,
80
+ "should_save": true,
81
+ "should_training_stop": true
82
+ },
83
+ "attributes": {}
84
+ }
85
+ },
86
+ "total_flos": 0.0,
87
+ "train_batch_size": 8,
88
+ "trial_name": null,
89
+ "trial_params": null
90
+ }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8b5786356a82264536514208a1f3b3612cb7f48f7f87a70601536c758e745411
3
+ size 5624