update
Browse files- README.md +143 -0
- config.json +27 -0
- pytorch_model.bin +3 -0
- rinna.png +0 -0
- spiece.model +3 -0
- spiece.vocab +0 -0
- tokenizer_config.json +1 -0
README.md
CHANGED
@@ -1,3 +1,146 @@
|
|
1 |
---
|
|
|
2 |
license: mit
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
thumbnail: https://github.com/rinnakk/japanese-pretrained-models/blob/master/rinna.png
|
3 |
license: mit
|
4 |
+
datasets:
|
5 |
+
- Anthropic/hh-rlhf
|
6 |
+
language:
|
7 |
+
- ja
|
8 |
+
- en
|
9 |
+
inference: false
|
10 |
---
|
11 |
+
|
12 |
+
# bilingual-gpt-neox-4b-instruction-ppo
|
13 |
+
|
14 |
+
![rinna-icon](./rinna.png)
|
15 |
+
|
16 |
+
---
|
17 |
+
|
18 |
+
# Overview
|
19 |
+
This repository provides an English-Japanese bilingual GPT-NeoX model of 3.8 billion parameters.
|
20 |
+
|
21 |
+
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.
|
22 |
+
|
23 |
+
* **Model architecture**
|
24 |
+
|
25 |
+
A 36-layer, 2816-hidden-size transformer-based language model.
|
26 |
+
|
27 |
+
* **RLHF**
|
28 |
+
|
29 |
+
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).
|
30 |
+
* The first SFT stage produces [`rinna/bilingual-gpt-neox-4b-instruction-sft`](https://huggingface.co/rinna/bilingual-gpt-neox-4b-instruction-sft).
|
31 |
+
* The second RL stage produces this model.
|
32 |
+
|
33 |
+
* **Model Series**
|
34 |
+
|
35 |
+
| Variant | Link |
|
36 |
+
| :-- | :--|
|
37 |
+
| Bilingual 4B MiniGPT4 | https://huggingface.co/rinna/bilingual-gpt-neox-4b-minigpt4 |
|
38 |
+
| Bilingual 4B PPO | https://huggingface.co/rinna/bilingual-gpt-neox-4b-instruction-ppo |
|
39 |
+
| Bilingual 4B SFT | https://huggingface.co/rinna/bilingual-gpt-neox-4b-instruction-sft |
|
40 |
+
| Bilingual 4B 8K | https://huggingface.co/rinna/bilingual-gpt-neox-4b-8k |
|
41 |
+
| Bilingual 4B | https://huggingface.co/rinna/bilingual-gpt-neox-4b |
|
42 |
+
| Japanese 3.6B PPO | https://huggingface.co/rinna/japanese-gpt-neox-3.6b-instruction-ppo |
|
43 |
+
| Japanese 3.6B SFT-v2 | https://huggingface.co/rinna/japanese-gpt-neox-3.6b-instruction-sft-v2 |
|
44 |
+
| Japanese 3.6B SFT | https://huggingface.co/rinna/japanese-gpt-neox-3.6b-instruction-sft |
|
45 |
+
| Japanese 3.6B | https://huggingface.co/rinna/japanese-gpt-neox-3.6b |
|
46 |
+
|
47 |
+
* **Authors**
|
48 |
+
|
49 |
+
[Tianyu Zhao](https://huggingface.co/tianyuz) and [Kei Sawada](https://huggingface.co/keisawada)
|
50 |
+
|
51 |
+
---
|
52 |
+
|
53 |
+
# I/O Format
|
54 |
+
A special format has been adopted to construct inputs.
|
55 |
+
* An input prompt is formatted as a conversation between `ユーザー` and `システム`.
|
56 |
+
* Each input utterance consists of (1) its speaker (`"ユーザー"` or `"システム"`), (2) a colon (`":"`), (3) a whitespace (`" "`), and (4) utterance text (e.g. `"世界で一番高い山は?"`).
|
57 |
+
* The input prompt should be ended with `"システム: "` to acknowledge the model to generate a response.
|
58 |
+
* All the utterances in the input prompt should be separated by a newline `\n`.
|
59 |
+
|
60 |
+
Following is an example to construct input from a conversation.
|
61 |
+
~~~python
|
62 |
+
prompt = [
|
63 |
+
{
|
64 |
+
"speaker": "ユーザー",
|
65 |
+
"text": "Hello, you are an assistant that helps me learn Japanese."
|
66 |
+
},
|
67 |
+
{
|
68 |
+
"speaker": "システム",
|
69 |
+
"text": "Sure, what can I do for you?"
|
70 |
+
},
|
71 |
+
{
|
72 |
+
"speaker": "ユーザー",
|
73 |
+
"text": "VRはなんですか。"
|
74 |
+
}
|
75 |
+
]
|
76 |
+
prompt = [
|
77 |
+
f"{uttr['speaker']}: {uttr['text']}"
|
78 |
+
for uttr in prompt
|
79 |
+
]
|
80 |
+
prompt = "\n".join(prompt)
|
81 |
+
prompt = (
|
82 |
+
prompt
|
83 |
+
+ "\n"
|
84 |
+
+ "システム: "
|
85 |
+
)
|
86 |
+
print(prompt)
|
87 |
+
"""
|
88 |
+
ユーザー: Hello, you are an assistant that helps me learn Japanese.
|
89 |
+
システム: Sure, what can I do for you?
|
90 |
+
ユーザー: VRはなんですか。
|
91 |
+
システム:
|
92 |
+
"""
|
93 |
+
~~~
|
94 |
+
|
95 |
+
---
|
96 |
+
|
97 |
+
# How to use the model
|
98 |
+
|
99 |
+
**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.
|
100 |
+
|
101 |
+
~~~~python
|
102 |
+
import torch
|
103 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
104 |
+
|
105 |
+
tokenizer = AutoTokenizer.from_pretrained("rinna/bilingual-gpt-neox-4b-instruction-ppo", use_fast=False)
|
106 |
+
model = AutoModelForCausalLM.from_pretrained("rinna/bilingual-gpt-neox-4b-instruction-ppo")
|
107 |
+
|
108 |
+
if torch.cuda.is_available():
|
109 |
+
model = model.to("cuda")
|
110 |
+
|
111 |
+
token_ids = tokenizer.encode(prompt, add_special_tokens=False, return_tensors="pt")
|
112 |
+
|
113 |
+
with torch.no_grad():
|
114 |
+
output_ids = model.generate(
|
115 |
+
token_ids.to(model.device),
|
116 |
+
max_new_tokens=512,
|
117 |
+
do_sample=True,
|
118 |
+
temperature=1.0,
|
119 |
+
top_p=0.85,
|
120 |
+
pad_token_id=tokenizer.pad_token_id,
|
121 |
+
bos_token_id=tokenizer.bos_token_id,
|
122 |
+
eos_token_id=tokenizer.eos_token_id
|
123 |
+
)
|
124 |
+
|
125 |
+
output = tokenizer.decode(output_ids.tolist()[0][token_ids.size(1):])
|
126 |
+
print(output)
|
127 |
+
"""VRとはVirtual Realityの略で、仮想現実とも呼ばれます。これは、コンピューターを使用して仮想世界を作り出し、仮想世界上でコンピューターのゲームや仮想世界を体験するための技術です。この技術は、コンピューターやモバイ ルデバイスの進歩に���って、2015年以降、ますます普及しています。VRは、ゲームや仮想世界、その他のアプリケー ションなどのさまざまな分野で、コンピューターと人間の相互作用の新しい方法を提供しています。</s>"""
|
128 |
+
~~~~
|
129 |
+
|
130 |
+
---
|
131 |
+
|
132 |
+
# Tokenization
|
133 |
+
The model uses a [sentencepiece](https://github.com/google/sentencepiece)-based tokenizer.
|
134 |
+
* The tokenizer has a vocabulary size of 65,536.
|
135 |
+
* It uses *byte fallback* to decompose unknown text pieces into UTF-8 byte pieces to avoid producing `<UNK>` tokens.
|
136 |
+
* It can recognize *consecutive whitespaces*, *newlines*, and *tabs* to handle structured texts better.
|
137 |
+
* We turned off the default behaviour of prepending leading whitespace because it is not beneficial for processing Japanese.
|
138 |
+
* 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`).
|
139 |
+
* This decision trades the English processing efficiency for a unified way to treat whitespaces.
|
140 |
+
* It leads to a significantly lower loss of next token prediction on English data because whitespaces are easy to predict.
|
141 |
+
* **Don't forget to set `use_fast=False` to make the above features function correctly.**
|
142 |
+
|
143 |
+
---
|
144 |
+
|
145 |
+
# Licenese
|
146 |
+
[The MIT license](https://opensource.org/licenses/MIT)
|
config.json
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"architectures": [
|
3 |
+
"GPTNeoXForCausalLM"
|
4 |
+
],
|
5 |
+
"attention_dropout": 0.1,
|
6 |
+
"bos_token_id": 2,
|
7 |
+
"classifier_dropout": 0.1,
|
8 |
+
"eos_token_id": 3,
|
9 |
+
"hidden_act": "gelu",
|
10 |
+
"hidden_dropout": 0.1,
|
11 |
+
"hidden_size": 2816,
|
12 |
+
"initializer_range": 0.02,
|
13 |
+
"intermediate_size": 11264,
|
14 |
+
"layer_norm_eps": 1e-05,
|
15 |
+
"max_position_embeddings": 2048,
|
16 |
+
"model_type": "gpt_neox",
|
17 |
+
"num_attention_heads": 22,
|
18 |
+
"num_hidden_layers": 36,
|
19 |
+
"rope_scaling": null,
|
20 |
+
"rotary_emb_base": 10000,
|
21 |
+
"rotary_pct": 1.0,
|
22 |
+
"tie_word_embeddings": false,
|
23 |
+
"torch_dtype": "float16",
|
24 |
+
"use_cache": true,
|
25 |
+
"use_parallel_residual": false,
|
26 |
+
"vocab_size": 65536
|
27 |
+
}
|
pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:445c7189f5a6451285e1711b05c8c65778f98d19450b93e1d3c4306086c3faa7
|
3 |
+
size 7775149229
|
rinna.png
ADDED
spiece.model
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:85a0205d37a98bb3b97cf4ca3f507c78873cf8f6cefa3b51d8d6a15006dc889d
|
3 |
+
size 1341798
|
spiece.vocab
ADDED
The diff for this file is too large to render.
See raw diff
|
|
tokenizer_config.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"eos_token": "</s>", "unk_token": "[UNK]", "pad_token": "[PAD]", "extra_ids": 0, "additional_special_tokens": [], "sp_model_kwargs": {}, "bos_token": "<s>", "cls_token": "[CLS]", "sep_token": "[SEP]", "mask_token": "[MASK]", "do_lower_case": false, "tokenizer_class": "T5Tokenizer"}
|