jondurbin commited on
Commit
92cefd2
1 Parent(s): c9853f5

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +182 -0
README.md CHANGED
@@ -1,3 +1,185 @@
1
  ---
2
  license: apache-2.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
+ datasets:
4
+ - ai2_arc
5
+ - unalignment/spicy-3.1
6
+ - codeparrot/apps
7
+ - facebook/belebele
8
+ - boolq
9
+ - jondurbin/cinematika-v0.1
10
+ - drop
11
+ - lmsys/lmsys-chat-1m
12
+ - TIGER-Lab/MathInstruct
13
+ - cais/mmlu
14
+ - Muennighoff/natural-instructions
15
+ - openbookqa
16
+ - piqa
17
+ - Vezora/Tested-22k-Python-Alpaca
18
+ - cakiki/rosetta-code
19
+ - Open-Orca/SlimOrca
20
+ - spider
21
+ - squad_v2
22
+ - migtissera/Synthia-v1.3
23
+ - datasets/winogrande
24
+ - nvidia/HelpSteer
25
+ - Intel/orca_dpo_pairs
26
+ - Squish42/bluemoon-fandom-1-1-rp-cleaned
27
+ - LDJnr/Capybara
28
+ - JULIELab/EmoBank
29
+ - kingbri/PIPPA-shareGPT
30
  ---
31
+
32
+ # A bagel, with everything (except DPO)
33
+
34
+ ![bagel](bagel.png)
35
+
36
+ ## Overview
37
+
38
+ An experimental fine-tune of [mamba-2.8b-slimpj](https://hf.co/state-spaces/mamba-2.8b-slimpj) using [bagel](https://github.com/jondurbin/bagel)
39
+
40
+ Default recommended system prompt:
41
+ ```
42
+ You are a helpful, unbiased, uncensored assistant.
43
+ ```
44
+
45
+ Supports several prompt formats, but you can also use `tokenizer.apply_chat_template`
46
+
47
+ You probably want the [DPO version](https://hf.co/jondurbin/bagel-dpo-2.8b-v0.2) - it's much better.
48
+
49
+ ## Example chat script
50
+
51
+ ```python
52
+ import torch
53
+ from transformers import AutoTokenizer, AutoModelForCausalLM
54
+ from mamba_ssm.models.mixer_seq_simple import MambaLMHeadModel
55
+
56
+ device = "cuda"
57
+ tokenizer = AutoTokenizer.from_pretrained("bagel-final-2.8b-v0.2")
58
+ model = MambaLMHeadModel.from_pretrained("bagel-final-2.8b-v0.2", device="cuda", dtype=torch.float32)
59
+
60
+ messages = [{"role": "system", "content": "You are a helpful, unbiased, uncensored assistant."}]
61
+ while True:
62
+ user_message = input("[INST] ")
63
+ messages.append({"role": "user", "content": user_message})
64
+ input_ids = tokenizer.apply_chat_template(messages, return_tensors="pt", add_generation_prompt=True).to("cuda")
65
+ out = model.generate(input_ids=input_ids, max_length=2000, temperature=0.9, top_p=0.7, eos_token_id=tokenizer.eos_token_id, repetition_penalty=1.07)
66
+ decoded = tokenizer.batch_decode(out)[0].split("[/INST]")[-1].replace("</s>", "").strip()
67
+ messages.append({"role": "assistant", "content": decoded})
68
+ print("[/INST]", decoded)
69
+ ```
70
+
71
+ ## SFT data sources
72
+
73
+ *Yes, you will see benchmark names in the list, but this only uses the train splits, and a decontamination by cosine similarity is performed at the end as a sanity check*
74
+
75
+ - [ai2_arc](https://huggingface.co/datasets/ai2_arc)
76
+ - Abstraction and reasoning dataset, useful in measuring "intelligence" to a certain extent.
77
+ - [airoboros](https://huggingface.co/datasets/unalignment/spicy-3.1)
78
+ - Variety of categories of synthetic instructions generated by gpt-4.
79
+ - [apps](https://huggingface.co/datasets/codeparrot/apps)
80
+ - Python coding dataset with 10k problems.
81
+ - [belebele](https://huggingface.co/datasets/facebook/belebele)
82
+ - Multi-lingual reading comprehension dataset.
83
+ - [bluemoon](https://huggingface.co/datasets/Squish42/bluemoon-fandom-1-1-rp-cleaned)
84
+ - Roleplay data scraped from Bluemoon, then cleaned and formatted as ShareGPT.
85
+ - [boolq](https://huggingface.co/datasets/boolq)
86
+ - Corpus of yes/no questions (which can be surprisingly difficult for AI to answer apparently?)
87
+ - [capybara](https://huggingface.co/datasets/LDJnr/Capybara)
88
+ - Multi-turn dataset used to create the capybara models.
89
+ - [cinematika](https://huggingface.co/datasets/jondurbin/cinematika-v0.1) (instruction and plain text)
90
+ - RP-style data synthesized from movie scripts so the model isn't quite as boring as it otherwise would be.
91
+ - [drop](https://huggingface.co/datasets/drop)
92
+ - More reading comprehension.
93
+ - [emobank](https://github.com/JULIELab/EmoBank)
94
+ - Emotion annotations using the Valence-Arousal-Domninance scheme.
95
+ - [gutenberg](https://www.gutenberg.org/) (plain text)
96
+ - Books/plain text, again to make the model less boring, only a handful of examples supported by [chapterize](https://github.com/JonathanReeve/chapterize)
97
+ - [lmsys_chat_1m](https://huggingface.co/datasets/lmsys/lmsys-chat-1m) (only gpt-4 items, also used for DPO)
98
+ - Chats collected by the lmsys chat arena, containing a wide variety of chats with various models.
99
+ - [mathinstruct](https://huggingface.co/datasets/TIGER-Lab/MathInstruct)
100
+ - Composite dataset with a variety of math-related tasks and problem/question formats.
101
+ - [mmlu](https://huggingface.co/datasets/cais/mmlu)
102
+ - Massive Multitask Language Understanding - a wide variety of questions about various subject matters.
103
+ - [natural_instructions](https://huggingface.co/datasets/Muennighoff/natural-instructions)
104
+ - Millions of instructions from 1600+ task categories (sampled down substantially, stratified by task type)
105
+ - [openbookqa](https://huggingface.co/datasets/openbookqa)
106
+ - Question answering dataset.
107
+ - [pippa](https://huggingface.co/datasets/kingbri/PIPPA-shareGPT)
108
+ - Deduped version of [PIPPA](https://huggingface.co/datasets/PygmalionAI/PIPPA) in ShareGPT format.
109
+ - [piqa](https://huggingface.co/datasets/piqa)
110
+ - Phyiscal interaction question answering.
111
+ - [python_alpaca](https://huggingface.co/datasets/Vezora/Tested-22k-Python-Alpaca)
112
+ - Python instruction response pairs, validated as functional.
113
+ - [rosetta_code](https://huggingface.co/datasets/cakiki/rosetta-code)
114
+ - Code problems and solutions in a variety of programming languages taken from rosettacode.org.
115
+ - [slimorca](https://huggingface.co/datasets/Open-Orca/SlimOrca)
116
+ - Collection of ~500k gpt-4 verified chats from OpenOrca.
117
+ - [spider](https://huggingface.co/datasets/spider)
118
+ - SQL-targeted dataset.
119
+ - [squad_v2](https://huggingface.co/datasets/squad_v2)
120
+ - Contextual question answering (RAG).
121
+ - [synthia](https://huggingface.co/datasets/migtissera/Synthia-v1.3)
122
+ - GPT-4 generated data using advanced prompting from Migel Tissera.
123
+ - [winogrande](https://huggingface.co/datasets/winogrande)
124
+ - Fill in the blank style prompts.
125
+
126
+ Only the train splits were used (if a split was provided), and an additional pass of decontamination is performed using approximate nearest neighbor search (via faiss).
127
+
128
+ ## Prompt formatting
129
+
130
+ In sticking with the theme of the bagel, I didn't want to use a single prompt format, so I used 4 - vicuna, llama-2, alpaca, and chat-ml (sorta).
131
+ I also didn't want to randomly select a single prompt format for each item (hoping each instruction would generalize more when used in a variety of prompt formats), so each instruction is actually converted into every prompt format.
132
+
133
+ This means each epoch of our fine-tune is really basically 4 epochs. So, for the fine-tunes, I would recommend only doing 1 epoch (or 0.75 epochs). I am testing with a single epoch using a relatively low learning rate.
134
+
135
+ ### Alpaca (sort of)
136
+
137
+ ```
138
+ Below is an instruction that describes a task. Write a response that appropriately completes the request.
139
+
140
+ ### Instruction:
141
+ {system prompt, if provided}
142
+ {instruction}
143
+
144
+ ### Response:
145
+ ```
146
+
147
+ The main difference here is that because of the dataset formatting and variety of data sources, it would have been much to tedious to add an `### Input:` block, so the inputs are just in the instruction section.
148
+
149
+ ### Vicuna
150
+
151
+ ```
152
+ {system prompt, if provided, randomly defaulting to "A chat between a user and an unbiased, uncensored assistant."}
153
+ USER: {instruction}
154
+ ASSISTANT:
155
+ ```
156
+
157
+ ### ChatML (sort of)
158
+
159
+ I don't really understand the point of having special tokens for `<|im_start|>` and `<|im_end|>`, because in practice they just act as BOS and EOS tokens (but, please correct me if I'm wrong).
160
+
161
+ So, instead of:
162
+ ```text
163
+ {bos}<|im_start|>{role}
164
+ {text}
165
+ <|im_end|>{eos}
166
+ ```
167
+
168
+ I just changed it to:
169
+ ```text
170
+ {bos}{role}
171
+ {text}
172
+ {eos}
173
+ ```
174
+
175
+ If you *really* want to use `<|im_start|>` and `<|im_end|>`, just update your `tokenizer_config.json` to use `<|im_start|>` instead of `<s>` and `<|im_end|>` instead of `</s>` and when tokenizing. And if you still don't like what I've done to this chat-ml-ish format, feel free to cry into your pillow or fork the code and do a new fine-tune.
176
+
177
+ ### Llama-2 chat
178
+
179
+ ```
180
+ [INST] <<SYS>>
181
+ {system}
182
+ <</SYS>>
183
+
184
+ {instruction} [/INST]
185
+ ```