RichardErkhov commited on
Commit
6ca63be
1 Parent(s): 7645a4e

uploaded readme

Browse files
Files changed (1) hide show
  1. README.md +210 -0
README.md ADDED
@@ -0,0 +1,210 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Quantization made by Richard Erkhov.
2
+
3
+ [Github](https://github.com/RichardErkhov)
4
+
5
+ [Discord](https://discord.gg/pvy7H8DZMG)
6
+
7
+ [Request more models](https://github.com/RichardErkhov/quant_request)
8
+
9
+
10
+ bilingual-gpt-neox-4b-instruction-ppo - bnb 4bits
11
+ - Model creator: https://huggingface.co/rinna/
12
+ - Original model: https://huggingface.co/rinna/bilingual-gpt-neox-4b-instruction-ppo/
13
+
14
+
15
+
16
+
17
+ Original model description:
18
+ ---
19
+ thumbnail: https://github.com/rinnakk/japanese-pretrained-models/blob/master/rinna.png
20
+ license: mit
21
+ datasets:
22
+ - Anthropic/hh-rlhf
23
+ language:
24
+ - ja
25
+ - en
26
+ inference: false
27
+ base_model: rinna/bilingual-gpt-neox-4b
28
+ ---
29
+
30
+ # bilingual-gpt-neox-4b-instruction-ppo
31
+
32
+ ![rinna-icon](./rinna.png)
33
+
34
+ ---
35
+
36
+ # Overview
37
+ This repository provides an English-Japanese bilingual GPT-NeoX model of 3.8 billion parameters.
38
+
39
+ The model is based on [`rinna/bilingual-gpt-neox-4b-instruction-sft`](https://huggingface.co/rinna/bilingual-gpt-neox-4b-instruction-sft) and has been aligned to serve as an instruction-following conversational agent.
40
+
41
+ * **Model architecture**
42
+
43
+ A 36-layer, 2816-hidden-size transformer-based language model.
44
+
45
+ * **RLHF**
46
+
47
+ Following the [OpenAI InstructGPT paper](https://arxiv.org/abs/2203.02155), **Reinforcement Learning from Human Feedback** (RLHF) has been applied to aligning the model's behaviour with input instructions. Particularly, the model has been trained in two stages, i.e. **Supervised Fine-Tuning** (SFT) and [PPO](https://arxiv.org/abs/1707.06347)-based **Reinforcement Learning** (RL).
48
+ * The first SFT stage produces [`rinna/bilingual-gpt-neox-4b-instruction-sft`](https://huggingface.co/rinna/bilingual-gpt-neox-4b-instruction-sft).
49
+ * The second RL stage produces this model.
50
+
51
+ * **Reinforcement learning**
52
+
53
+ We used [CarperAI/trlx](https://github.com/CarperAI/trlx) and its implementation of the PPO algorithm for the RL stage.
54
+
55
+ The RL data is the subset of the following dataset and has been translated into Japanese.
56
+ * [Anthropic HH RLHF data](https://huggingface.co/datasets/Anthropic/hh-rlhf)
57
+
58
+ * **Model Series**
59
+
60
+ | Variant | Link |
61
+ | :-- | :--|
62
+ | Bilingual 4B MiniGPT4 | https://huggingface.co/rinna/bilingual-gpt-neox-4b-minigpt4 |
63
+ | Bilingual 4B PPO | https://huggingface.co/rinna/bilingual-gpt-neox-4b-instruction-ppo |
64
+ | Bilingual 4B SFT | https://huggingface.co/rinna/bilingual-gpt-neox-4b-instruction-sft |
65
+ | Bilingual 4B 8K | https://huggingface.co/rinna/bilingual-gpt-neox-4b-8k |
66
+ | Bilingual 4B | https://huggingface.co/rinna/bilingual-gpt-neox-4b |
67
+ | Japanese 3.6B PPO | https://huggingface.co/rinna/japanese-gpt-neox-3.6b-instruction-ppo |
68
+ | Japanese 3.6B SFT-v2 | https://huggingface.co/rinna/japanese-gpt-neox-3.6b-instruction-sft-v2 |
69
+ | Japanese 3.6B SFT | https://huggingface.co/rinna/japanese-gpt-neox-3.6b-instruction-sft |
70
+ | Japanese 3.6B | https://huggingface.co/rinna/japanese-gpt-neox-3.6b |
71
+
72
+ * **Contributors**
73
+
74
+ [Tianyu Zhao](https://huggingface.co/tianyuz) and [Kei Sawada](https://huggingface.co/keisawada)
75
+
76
+ ---
77
+
78
+ # Benchmarking
79
+
80
+ Our evaluation experiments suggest that the PPO does not particularly improve the model's performance on the Japanese LLM benchmark in comparison with [Bilingual GPT-NeoX 4B SFT](https://huggingface.co/rinna/bilingual-gpt-neox-4b-instruction-sft), but we have seen **better conversation experience** on the PPO model than its SFT counterpart.
81
+ - *The 4-task average accuracy is based on results of JCommonsenseQA, JNLI, MARC-ja, and JSQuAD.*
82
+ - *The 6-task average accuracy is based on results of JCommonsenseQA, JNLI, MARC-ja, JSQuAD, XWinograd, and JAQKET-v2.*
83
+
84
+ | Model | 4-task average accuracy | 6-task average accuracy |
85
+ | :-- | :-- | :-- |
86
+ | **bilingual-gpt-neox-4b-instruction-ppo** | **61.01** | **61.16** |
87
+ | bilingual-gpt-neox-4b-instruction-sft | 61.02 | 61.69 |
88
+ | bilingual-gpt-neox-4b | 56.12 | 51.83 |
89
+ | japanese-gpt-neox-3.6b-instruction-ppo | 59.86 | 60.07 |
90
+ | japanese-gpt-neox-3.6b | 55.07 | 50.32 |
91
+
92
+ ---
93
+
94
+ # I/O Format
95
+ A special format has been adopted to construct inputs.
96
+ * An input prompt is formatted as a conversation between `ユーザー` and `システム`.
97
+ * Each input utterance consists of (1) its speaker (`"ユーザー"` or `"システム"`), (2) a colon (`":"`), (3) a whitespace (`" "`), and (4) utterance text (e.g. `"世界で一番高い山は?"`).
98
+ * The input prompt should be ended with `"システム: "` to acknowledge the model to generate a response.
99
+ * All the utterances in the input prompt should be separated by a newline `\n`.
100
+
101
+ Following is an example to construct input from a conversation.
102
+ ~~~python
103
+ prompt = [
104
+ {
105
+ "speaker": "ユーザー",
106
+ "text": "Hello, you are an assistant that helps me learn Japanese."
107
+ },
108
+ {
109
+ "speaker": "システム",
110
+ "text": "Sure, what can I do for you?"
111
+ },
112
+ {
113
+ "speaker": "ユーザー",
114
+ "text": "VRはなんですか。"
115
+ }
116
+ ]
117
+ prompt = [
118
+ f"{uttr['speaker']}: {uttr['text']}"
119
+ for uttr in prompt
120
+ ]
121
+ prompt = "\n".join(prompt)
122
+ prompt = (
123
+ prompt
124
+ + "\n"
125
+ + "システム: "
126
+ )
127
+ print(prompt)
128
+ """
129
+ ユーザー: Hello, you are an assistant that helps me learn Japanese.
130
+ システム: Sure, what can I do for you?
131
+ ユーザー: VRはなんですか。
132
+ システム:
133
+ """
134
+ ~~~
135
+
136
+ ---
137
+
138
+ # How to use the model
139
+
140
+ **Notice:** Since the model is **sensitive to decoding hyper-parameters** (e.g. `temperature`, `top_p`, `top_k`, `repetition_penalty`), it is suggested to explore the best setting for your task.
141
+
142
+ ~~~~python
143
+ import torch
144
+ from transformers import AutoTokenizer, AutoModelForCausalLM
145
+
146
+ tokenizer = AutoTokenizer.from_pretrained("rinna/bilingual-gpt-neox-4b-instruction-ppo", use_fast=False)
147
+ model = AutoModelForCausalLM.from_pretrained("rinna/bilingual-gpt-neox-4b-instruction-ppo")
148
+
149
+ if torch.cuda.is_available():
150
+ model = model.to("cuda")
151
+
152
+ token_ids = tokenizer.encode(prompt, add_special_tokens=False, return_tensors="pt")
153
+
154
+ with torch.no_grad():
155
+ output_ids = model.generate(
156
+ token_ids.to(model.device),
157
+ max_new_tokens=512,
158
+ do_sample=True,
159
+ temperature=1.0,
160
+ top_p=0.85,
161
+ pad_token_id=tokenizer.pad_token_id,
162
+ bos_token_id=tokenizer.bos_token_id,
163
+ eos_token_id=tokenizer.eos_token_id
164
+ )
165
+
166
+ output = tokenizer.decode(output_ids.tolist()[0][token_ids.size(1):])
167
+ print(output)
168
+ """VRとはVirtual Realityの略で、仮想現実とも呼ばれます。これは、コンピューターを使用して仮想世界を作り出し、仮想世界上でコンピューターのゲームや仮想世界を体験するための技術です。この技術は、コンピューターやモバイ ルデバイスの進歩によって、2015年以降、ますます普及しています。VRは、ゲームや仮想世界、その他のアプリケー ションなどのさまざまな分野で、コンピューターと人間の相互作用の新しい方法を提供しています。</s>"""
169
+ ~~~~
170
+
171
+ ---
172
+
173
+ # Tokenization
174
+ The model uses a [sentencepiece](https://github.com/google/sentencepiece)-based tokenizer.
175
+ * The tokenizer has a vocabulary size of 65,536.
176
+ * It uses *byte fallback* to decompose unknown text pieces into UTF-8 byte pieces to avoid producing `<UNK>` tokens.
177
+ * It can recognize *consecutive whitespaces*, *newlines*, and *tabs* to handle structured texts better.
178
+ * We turned off the default behaviour of prepending leading whitespace because it is not beneficial for processing Japanese.
179
+ * Specifically, single whitespace is always processed as one token so that any English word won't have a preceding whitespace like in many other tokenizers (e.g. `_Hello`).
180
+ * This decision trades the English processing efficiency for a unified way to treat whitespaces.
181
+ * It leads to a significantly lower loss of next token prediction on English data because whitespaces are easy to predict.
182
+ * **Don't forget to set `use_fast=False` to make the above features function correctly.**
183
+
184
+ ---
185
+
186
+ # How to cite
187
+ ```bibtex
188
+ @misc{rinna-bilingual-gpt-neox-4b-instruction-ppo,
189
+ title = {rinna/bilingual-gpt-neox-4b-instruction-ppo},
190
+ author = {Zhao, Tianyu and Sawada, Kei},
191
+ url = {https://huggingface.co/rinna/bilingual-gpt-neox-4b-instruction-ppo}
192
+ }
193
+
194
+ @inproceedings{sawada2024release,
195
+ title = {Release of Pre-Trained Models for the {J}apanese Language},
196
+ author = {Sawada, Kei and Zhao, Tianyu and Shing, Makoto and Mitsui, Kentaro and Kaga, Akio and Hono, Yukiya and Wakatsuki, Toshiaki and Mitsuda, Koh},
197
+ booktitle = {Proceedings of the 2024 Joint International Conference on Computational Linguistics, Language Resources and Evaluation (LREC-COLING 2024)},
198
+ month = {5},
199
+ year = {2024},
200
+ pages = {13898--13905},
201
+ url = {https://aclanthology.org/2024.lrec-main.1213},
202
+ note = {\url{https://arxiv.org/abs/2404.01657}}
203
+ }
204
+ ```
205
+
206
+ ---
207
+
208
+ # Licenese
209
+ [The MIT license](https://opensource.org/licenses/MIT)
210
+