Safetensors
English
gptj
sauc-abadal-lloret commited on
Commit
56a1d93
·
verified ·
1 Parent(s): 311057f

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +123 -3
README.md CHANGED
@@ -1,3 +1,123 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ datasets:
4
+ - CarperAI/openai_summarize_tldr
5
+ language:
6
+ - en
7
+ base_model:
8
+ - EleutherAI/gpt-j-6b
9
+ - CarperAI/openai_summarize_tldr_sft
10
+ ---
11
+ # ALT-Quark model
12
+ This is a Quark-based baseline developed during the research carried out in the [ALT paper](https://www.arxiv.org/abs/2407.16970). The model is trained following the algorithm introduced in [Quark](https://arxiv.org/abs/2205.13636), with a slight modification as to sample multiple generations per prompt to compute the reward quantiles locally instead of globally across all prompts. We found that this was crucial for training.
13
+ Notice that Quark was not introduced for tackling the alignment problem but for unlearning attributes in text completion tasks, such as unlearning toxcity, negative sentiment or repetition.
14
+
15
+ It is a fine-tuned **GPT-J (6B)** model on the **TL;DR Summarization** dataset to be better aligned with humans' preferences on summaries, i.e., accounting for axes such as accuracy, coverage, and coherence.
16
+
17
+ # Model description
18
+ The alignment process departs from a [SFT checkpoint](https://huggingface.co/CarperAI/openai_summarize_tldr_sft) released by CarperAI and trained using their [trlx](https://github.com/CarperAI/trlx/tree/main/examples/summarize_rlhf) library.
19
+
20
+ In a nutshell, the Quark method consists on sampling new generations and scoring them with a reward model to further cluster them into reward quantiles. For every quantile in a pre-defined number of quantiles, a new reward quantile token is added to the tokenizer. Afterward, each generation is mapped to a reward quantile token, and the latter is preppended to the input prompt for conditional language modelling training.
21
+
22
+ For extensive coverage on Quark, please refer to their paper.
23
+
24
+ The reward model used for scoring the generaations can be found in [here](https://huggingface.co/CarperAI/openai_summarize_tldr_rm_checkpoint). We uses K = 5 quantile tokens, which were newly added to the tokenizer:
25
+ ```python
26
+ {'_QUANTILE_0_', '_QUANTILE_1_', '_QUANTILE_2_', '_QUANTILE_3_', '_QUANTILE_4_'}
27
+ ```
28
+ Thus, at inference time, the expected aligned behavior can be attained by conditioning the input on *'_QUANTILE_TOKEN_0_'*.
29
+
30
+ **Related Models:** [ALT-RM](https://huggingface.co/sauc-abadal-lloret/gpt-j-6b-ALT-RM-tldr).
31
+
32
+ # Intended uses & limitations
33
+ This model originates from a research project focused on alignment and is intended primarily for research purposes. Commercial use as an off-the-shelf model is discouraged, as it was not designed with such applications in mind. The model is tailored specifically for the summarization task, having been trained on the TL;DR dataset, though some out-of-distribution generalization may be possible for related datasets.
34
+
35
+ # How to use
36
+
37
+ You should format the input by preppending the feedback as follows: `_QUANTILE_TOKEN_0_{prompt}`
38
+ ```python
39
+ from transformers import AutoTokenizer, AutoModelForCausalLM, GenerationConfig
40
+
41
+ checkpoint_path = "sauc-abadal-lloret/gpt-j-6b-ALT-Quark-tldr"
42
+
43
+ tokenizer = AutoTokenizer.from_pretrained(checkpoint_path)
44
+ tokenizer.pad_token = tokenizer.eos_token
45
+
46
+ model = AutoModelForCausalLM.from_pretrained(checkpoint_path)
47
+ model.eval()
48
+
49
+ prompt = "_QUANTILE_TOKEN_0_SUBREDDIT: r/relationship_advice\nTITLE: I'm [18M] going to a party where an old middle \
50
+ school crush [17F] is also going.\nPOST: Story time! Back in the summer after 8th grade, I hung out with my group of \
51
+ friends everyday for the whole summer. There was this girl in the group and I really liked her. Like I had the biggest \
52
+ and dumbest crush on her. I was only 13 so I didn't know shit, but I was thinking she's perfect for me, I gotta marry \
53
+ her and all this dumb stuff. The puppy love was so strong I wanted to be a part of her life and I wanted her to be a \
54
+ part of my life. I never had the courage to ask her out, and we went to different high schools. Eventually we stopped \
55
+ talking but during high school I never really liked anyone else. Every other girl felt dull compared to her. I still \
56
+ get nostalgic thinking about her and what would've been different if I had the balls to ask her out. Anyway I'm going \
57
+ to a party this Friday and I heard she's coming. I honestly don't know what to do to so this goes great and eventually \
58
+ ends up in a relationship.\nTL;DR:"
59
+
60
+ inputs = tokenizer([prompt], padding=True, truncation=True, return_tensors="pt")
61
+ input_seq_len = inputs["input_ids"].shape[1]
62
+
63
+ generation_config = GenerationConfig(
64
+ max_length = 2048,
65
+ max_new_tokens = 64,
66
+ do_sample = False,
67
+ num_beams = 1,
68
+ bad_words_ids = None,
69
+ num_return_sequences = 1,
70
+ return_dict_in_generate = True,
71
+ pad_token_id = tokenizer.pad_token_id,
72
+ )
73
+
74
+ outputs = model.generate(**inputs, generation_config=generation_config)
75
+ generated_input_ids = outputs["sequences"][:, input_seq_len:]
76
+ generated_text = tokenizer.batch_decode(
77
+ generated_input_ids, skip_special_tokens=True, clean_up_tokenization_spaces=True
78
+ )
79
+ generated_text
80
+ ```
81
+
82
+ ```
83
+ [" I'm going to a party where an old middle school crush is also going. I honestly don't know what to do to so this goes great and eventually ends up in a relationship."]
84
+ ```
85
+
86
+ ## Training data
87
+ The model was trained on the TL;DR summarization dataset introduced in the Stiennon et al.'s, ["Learning to Summarize from human feedback"](https://arxiv.org/abs/2009.01325) paper. We employed the dataset version from CarperAI, which can be found in the HuggingFace Hub in [here](CarperAI/openai_summarize_tldr).
88
+
89
+ ## Training procedure
90
+ The exact training procedure and hyper-parameters configuration can be found in our paper.
91
+
92
+ ## Variable and metrics
93
+ As an evaluation metric, we compute GPT-4 win-rates over PPO on a 1k random subset of the test set. We use the prompt provided in the DPO paper and we ask GPT-4 to compare generations between ALT-RM and Quark and PPO. Furthermore, we report the following metrics computed on the whole test set: average reward model score, perplexity measured by the SFT reference policy as a proxy for fluency, and average length of the generations. In addition, we conduct an out-of-domain evaluation and compute GPT-4 win-rates on 100 articles from the test split of the CNN/DailyMail dataset.
94
+
95
+ | **Model** | **TL;DR** (In-domain) | **CNN/DailyMail** (Out-of-domain) |
96
+ |:---------------:|:---------------------:|:----------------------------------:|
97
+ | Quark vs PPO | 0.36 | 0.40 |
98
+ | ALT-RM vs PPO | 0.50 | 0.48 |
99
+
100
+ *Win-rates with GPT-4. TL;DR on 1000 randomly chosen test prompts and CNN/daily mail on 100 randomly chosen test prompts.*
101
+
102
+ | **Model** | **RM** | **PPL** | **Avg. len** | **# Train** |
103
+ |:---------------:|:---------------------:|:----------------------------------:|:----------------------------------:|:----------------------------------:|
104
+ | SFT | 2.89 | 1.96 | 31.25 | - |
105
+ | Refrences | 2.89 | 11.84 | 32.60 | - |
106
+ | PPO | 3.38 | 2.29 | 67.52 | 116k |
107
+ | Quark | 3.52 | 1.82 | 49.42 | 19k |
108
+ | ALT-RM | 3.58 | 2.20 | 46.14 | 19k |
109
+
110
+ *TL;DR metrics on the whole test set, including avg. reward model score, perplexity, avg. generations’ length, and number of training prompts.*
111
+
112
+ ## BibTeX entry and citation info
113
+ ```
114
+ @misc{lloret2024aligninglanguagemodelstextual,
115
+ title={Towards Aligning Language Models with Textual Feedback},
116
+ author={Saüc Abadal Lloret and Shehzaad Dhuliawala and Keerthiram Murugesan and Mrinmaya Sachan},
117
+ year={2024},
118
+ eprint={2407.16970},
119
+ archivePrefix={arXiv},
120
+ primaryClass={cs.CL},
121
+ url={https://arxiv.org/abs/2407.16970},
122
+ }
123
+ ```