RichardErkhov commited on
Commit
d438426
·
verified ·
1 Parent(s): 97c9208

uploaded readme

Browse files
Files changed (1) hide show
  1. README.md +256 -0
README.md ADDED
@@ -0,0 +1,256 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 - bnb 4bits
11
+ - Model creator: https://huggingface.co/rinna/
12
+ - Original model: https://huggingface.co/rinna/bilingual-gpt-neox-4b/
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
+ - mc4
23
+ - cc100
24
+ - wikipedia
25
+ - EleutherAI/pile
26
+ - togethercomputer/RedPajama-Data-1T
27
+ language:
28
+ - ja
29
+ - en
30
+ inference: false
31
+ ---
32
+
33
+ # bilingual-gpt-neox-4b
34
+
35
+ ![rinna-icon](./rinna.png)
36
+
37
+ # Overview
38
+ This repository provides an English-Japanese bilingual GPT-NeoX model of 3.8 billion parameters.
39
+
40
+ * **Library**
41
+
42
+ The model was trained using code based on [EleutherAI/gpt-neox](https://github.com/EleutherAI/gpt-neox).
43
+
44
+ * **Model architecture**
45
+
46
+ A 36-layer, 2816-hidden-size transformer-based language model.
47
+
48
+ * **Pre-training**
49
+
50
+ The model was trained on around **524B** tokens from a mixture of the following corpora
51
+
52
+ - [Japanese CC-100](http://data.statmt.org/cc-100/ja.txt.xz)
53
+ - [Japanese C4](https://huggingface.co/datasets/mc4)
54
+ - [The Pile](https://huggingface.co/datasets/EleutherAI/pile)
55
+ - [Redpajama](https://huggingface.co/datasets/togethercomputer/RedPajama-Data-1T)
56
+ - [Wikipedia](https://dumps.wikimedia.org/other/cirrussearch)
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)
75
+ - [Toshiaki Wakatsuki](https://huggingface.co/t-w)
76
+ - [Akio Kaga](https://huggingface.co/rakaga)
77
+ - [Koh Mitsuda](https://huggingface.co/mitsu-koh)
78
+ - [Kei Sawada](https://huggingface.co/keisawada)
79
+
80
+ ---
81
+
82
+ # Benchmarking
83
+
84
+ * **Japanese benchmark**
85
+
86
+ Our evaluation experiments suggest that the bilingual-gpt-neox-4b model performs slightly better than the previous [Japanese GPT-NeoX 3.6B](https://huggingface.co/rinna/japanese-gpt-neox-3.6b) in Japanese tasks.
87
+ - *The 4-task average accuracy is based on results of JCommonsenseQA, JNLI, MARC-ja, and JSQuAD.*
88
+ - *The 6-task average accuracy is based on results of JCommonsenseQA, JNLI, MARC-ja, JSQuAD, XWinograd, and JAQKET-v2.*
89
+
90
+ | Model | 4-task average accuracy | 6-task average accuracy |
91
+ | :-- | :-- | :-- |
92
+ | bilingual-gpt-neox-4b-instruction-ppo | 61.01 | 61.16 |
93
+ | bilingual-gpt-neox-4b-instruction-sft | 61.02 | 61.69 |
94
+ | **bilingual-gpt-neox-4b** | **56.12** | **51.83** |
95
+ | japanese-gpt-neox-3.6b-instruction-ppo | 59.86 | 60.07 |
96
+ | japanese-gpt-neox-3.6b | 55.07 | 50.32 |
97
+
98
+ * **English benchmark**
99
+
100
+ Using the [EleutherAI Language Model Evaluation Harness](https://github.com/EleutherAI/lm-evaluation-harness/tree/master), we found the bilingual-gpt-neox-4b performs comparably with English/multilingual models of similar sizes.
101
+ - *The average accuracy is based on results of Arc-Challenge, Arc-Easy, BoolQ, COPA, HellaSwag, OpenBookQA, PIQA, PROST, SWAG, and WinoGrande.*
102
+
103
+ | Model | Average accuracy |
104
+ | :-- | :-- |
105
+ | mpt-7b | 59.30 |
106
+ | llama-7b | 57.35 |
107
+ | bloom-7b | 51.51 |
108
+ | xglm-7.5b | 50.96 |
109
+ | xglm-4.5b | 50.15 |
110
+ | **bilingual-gpt-neox-4b** | **49.49** |
111
+ | bloom-3b | 48.56 |
112
+ | xglm-2.9b | 47.44 |
113
+ | bloom-1.7b | 46.54 |
114
+
115
+ ---
116
+
117
+ # How to use the model
118
+
119
+ **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.
120
+
121
+ ~~~~python
122
+ import torch
123
+ from transformers import AutoTokenizer, AutoModelForCausalLM
124
+
125
+ tokenizer = AutoTokenizer.from_pretrained("rinna/bilingual-gpt-neox-4b", use_fast=False)
126
+ model = AutoModelForCausalLM.from_pretrained("rinna/bilingual-gpt-neox-4b")
127
+
128
+ if torch.cuda.is_available():
129
+ model = model.to("cuda")
130
+
131
+ text = "西田幾多郎は、"
132
+ token_ids = tokenizer.encode(text, add_special_tokens=False, return_tensors="pt")
133
+
134
+ with torch.no_grad():
135
+ output_ids = model.generate(
136
+ token_ids.to(model.device),
137
+ max_new_tokens=100,
138
+ min_new_tokens=100,
139
+ do_sample=True,
140
+ temperature=1.0,
141
+ top_p=0.95,
142
+ pad_token_id=tokenizer.pad_token_id,
143
+ bos_token_id=tokenizer.bos_token_id,
144
+ eos_token_id=tokenizer.eos_token_id
145
+ )
146
+
147
+ output = tokenizer.decode(output_ids.tolist()[0])
148
+ print(output)
149
+ """
150
+ 西田幾多郎は、その著書「自覚の哲学」の中で、次のように書きました。
151
+ 「知識を、自分のものと考えることに満足していると、自己の限界に目覚めることを忘れてしまう。しかし、他者との協同なしには、自己の本当の理解に達することはできないのだ。知識は他者と相互の、協同の力によってこそ、得られるのである。」(引用終わり)
152
+ この一節を、私たちは今から学び直すべきです。そして、これからの社会をリードする子どもたちに、その能力を伸ばすべく、
153
+ """
154
+ ~~~~
155
+
156
+ ~~~~python
157
+ text = "Socrates says"
158
+ token_ids = tokenizer.encode(text, add_special_tokens=False, return_tensors="pt")
159
+
160
+ with torch.no_grad():
161
+ output_ids = model.generate(
162
+ token_ids.to(model.device),
163
+ max_new_tokens=100,
164
+ min_new_tokens=100,
165
+ do_sample=True,
166
+ temperature=1.0,
167
+ top_p=0.95,
168
+ pad_token_id=tokenizer.pad_token_id,
169
+ bos_token_id=tokenizer.bos_token_id,
170
+ eos_token_id=tokenizer.eos_token_id
171
+ )
172
+
173
+ output = tokenizer.decode(output_ids.tolist()[0])
174
+ print(output)
175
+
176
+ """
177
+ Socrates says: he thinks that philosophy, as opposed to myth, can be demonstrated; as opposed to poetry, that it is not possible to have knowledge of the unknowable (that is, neither by reason nor by any art of divination). So in this case he is in agreement with Socrates in not thinking that we could prove the existence of the gods or of fate. Now, I do not know the content of Xenophon's _Symposium_, but he must have made a point of this passage that has ex
178
+ """
179
+ ~~~~
180
+
181
+ ~~~~python
182
+ text = "def bubble_sort(array):"
183
+ token_ids = tokenizer.encode(text, add_special_tokens=False, return_tensors="pt")
184
+
185
+ with torch.no_grad():
186
+ output_ids = model.generate(
187
+ token_ids.to(model.device),
188
+ max_new_tokens=200,
189
+ min_new_tokens=200,
190
+ do_sample=True,
191
+ temperature=1.0,
192
+ top_p=0.5,
193
+ pad_token_id=tokenizer.pad_token_id,
194
+ bos_token_id=tokenizer.bos_token_id,
195
+ eos_token_id=tokenizer.eos_token_id
196
+ )
197
+
198
+ output = tokenizer.decode(output_ids.tolist()[0])
199
+ print(output)
200
+ """
201
+ def bubble_sort(array):
202
+ for i in range(len(array)):
203
+ for j in range(len(array)-1):
204
+ if array[j] > array[j+1]:
205
+ array[j], array[j+1] = array[j+1], array[j]
206
+ return array
207
+
208
+ print(bubble_sort([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]))
209
+
210
+ The code above will sort the array from 1 to 10 in the following order:
211
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
212
+
213
+ However, I am not sure how to do
214
+ """
215
+ ~~~~
216
+
217
+ ---
218
+
219
+ # Tokenization
220
+ The model uses a [sentencepiece](https://github.com/google/sentencepiece)-based tokenizer.
221
+ * The tokenizer has a vocabulary size of 65,536.
222
+ * It uses *byte fallback* to decompose unknown text pieces into UTF-8 byte pieces to avoid producing `<UNK>` tokens.
223
+ * It can recognize *consecutive whitespaces*, *newlines*, and *tabs* to handle structured texts better.
224
+ * We turned off the default behaviour of prepending leading whitespace because it is not beneficial for processing Japanese.
225
+ * 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`).
226
+ * This decision trades the English processing efficiency for a unified way to treat whitespaces.
227
+ * It leads to a significantly lower loss of next token prediction on English data because whitespaces are easy to predict.
228
+ * **Don't forget to set `use_fast=False` to make the above features function correctly.**
229
+
230
+ ---
231
+
232
+ # How to cite
233
+ ```bibtex
234
+ @misc{rinna-bilingual-gpt-neox-4b,
235
+ title = {rinna/bilingual-gpt-neox-4b},
236
+ author = {Zhao, Tianyu and Wakatsuki, Toshiaki and Kaga, Akio and Mitsuda, Koh and Sawada, Kei},
237
+ url = {https://huggingface.co/rinna/bilingual-gpt-neox-4b}
238
+ }
239
+
240
+ @inproceedings{sawada2024release,
241
+ title = {Release of Pre-Trained Models for the {J}apanese Language},
242
+ author = {Sawada, Kei and Zhao, Tianyu and Shing, Makoto and Mitsui, Kentaro and Kaga, Akio and Hono, Yukiya and Wakatsuki, Toshiaki and Mitsuda, Koh},
243
+ booktitle = {Proceedings of the 2024 Joint International Conference on Computational Linguistics, Language Resources and Evaluation (LREC-COLING 2024)},
244
+ month = {5},
245
+ year = {2024},
246
+ pages = {13898--13905},
247
+ url = {https://aclanthology.org/2024.lrec-main.1213},
248
+ note = {\url{https://arxiv.org/abs/2404.01657}}
249
+ }
250
+ ```
251
+
252
+ ---
253
+
254
+ # Licenese
255
+ [The MIT license](https://opensource.org/licenses/MIT)
256
+