Text Generation
Transformers
PyTorch
Safetensors
Japanese
English
llama
Eval Results
text-generation-inference
tianyuz commited on
Commit
96d1690
1 Parent(s): 52929e1
README.md ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ thumbnail: https://github.com/rinnakk/japanese-pretrained-models/blob/master/rinna.png
3
+ license: llama2
4
+ language:
5
+ - ja
6
+ - en
7
+ inference: false
8
+ datasets:
9
+ - databricks/databricks-dolly-15k
10
+ - kunishou/databricks-dolly-15k-ja
11
+ - izumi-lab/llm-japanese-dataset
12
+ ---
13
+
14
+ # `rinna/youri-7b-chat`
15
+
16
+ ![rinna-icon](./rinna.png)
17
+
18
+ # Overview
19
+ The model is the instruction-tuned version of [`rinna/youri-7b`](https://huggingface.co/rinna/youri-7b). It adopts a chat-style input format.
20
+
21
+ * **Model architecture**
22
+
23
+ A 32-layer, 4096-hidden-size transformer-based language model. Refer to the [llama2 paper](https://arxiv.org/abs/2307.09288) for architecture details.
24
+
25
+ * **Fine-tuning**
26
+
27
+ The fine-tuning data is the subset of the following datasets.
28
+ * [Databricks Dolly data](https://huggingface.co/datasets/databricks/databricks-dolly-15k)
29
+ * [Japanese Databricks Dolly data](https://huggingface.co/datasets/kunishou/databricks-dolly-15k-ja)
30
+ * [Anthropic HH RLHF data](https://huggingface.co/datasets/Anthropic/hh-rlhf) and its Japanese translation
31
+ * [FLAN Instruction Tuning data](https://github.com/google-research/FLAN) and its Japanese translation
32
+ * [Izumi lab LLM Japanese dataset](https://github.com/masanorihirano/llm-japanese-dataset/tree/main)
33
+ * The following sections are used
34
+ * alt
35
+ * aozora-txt
36
+ * CourseraParallel
37
+ * ParaNatCom
38
+ * Tab-delimited_Bilingual_Sentence_Pairs
39
+ * tanaka-corpus
40
+ * wikinews
41
+ * wordnet
42
+ * yasashi-japanese
43
+ * The [remaining sections](https://github.com/masanorihirano/llm-japanese-dataset/tree/main/datasets-cc-by-sa) contain commonly used evaluation corpora so they are skipped to prevent data leak.
44
+
45
+ * **Authors**
46
+
47
+ - [Tianyu Zhao](https://huggingface.co/tianyuz)
48
+ - [Kei Sawada](https://huggingface.co/keisawada)
49
+
50
+ ---
51
+
52
+ # Benchmarking
53
+
54
+ Evaluation experiments suggest that rinna's `youri-7b` series outperforms other open-source Japanese LLMs on Japanese tasks according to our runs.
55
+
56
+ | Model | Model type | 4-task score | 6-task score | 8-task score |
57
+ | :-- | :-- | :-- | :-- | :-- |
58
+ | rinna/youri-7b-instruction | SFT | 83.88 | 80.93 | 63.63 |
59
+ | **rinna/youri-7b-chat** | **SFT** | **78.29** | **78.47** | **62.18** |
60
+ | matsuo-lab/weblab-10b-instruction-sft | SFT | 78.75 | 75.05 | 59.11 |
61
+ | rinna/youri-7b | pre-trained | 73.32 | 74.58 | 58.87 |
62
+ | stabilityai/japanese-stablelm-instruct-alpha-7b | SFT | 70.10 | 71.32 | 54.71 |
63
+ | elyza/ELYZA-japanese-Llama-2-7b | pre-trained | 71.72 | 69.28 | 53.17 |
64
+ | elyza/ELYZA-japanese-Llama-2-7b-instruct | SFT | 70.57 | 68.12 | 53.14 |
65
+ | stabilityai/japanese-stablelm-base-alpha-7b | pre-trained | 61.03 | 65.83 | 51.05 |
66
+ | matsuo-lab/weblab-10b | pre-trained | 66.33 | 65.58 | 50.74 |
67
+ | meta/llama2-7b | pre-trained | 56.33 | 54.80 | 42.97 |
68
+ | rinna/japanese-gpt-neox-3.6b | pre-trained | 47.20 | 54.68 | 41.80 |
69
+ | rinna/bilingual-gpt-neox-4b | pre-trained | 46.60 | 52.04 | 40.03 |
70
+
71
+ ---
72
+
73
+ # How to use the model
74
+
75
+ ~~~~python
76
+ import torch
77
+ from transformers import AutoTokenizer, AutoModelForCausalLM
78
+
79
+ tokenizer = AutoTokenizer.from_pretrained("rinna/youri-7b-chat")
80
+ model = AutoModelForCausalLM.from_pretrained("rinna/youri-7b-chat")
81
+
82
+ if torch.cuda.is_available():
83
+ model = model.to("cuda")
84
+
85
+ instruction = "次の日本語を英語に翻訳してください。"
86
+ input = "自然言語による指示に基づきタスクが解けるよう学習させることを Instruction tuning と呼びます。"
87
+
88
+ context = [
89
+ {
90
+ "speaker": "設定",
91
+ "text": instruction
92
+ },
93
+ {
94
+ "speaker": "ユーザー",
95
+ "text": input
96
+ }
97
+ ]
98
+ prompt = [
99
+ f"{uttr['speaker']}: {uttr['text']}"
100
+ for uttr in context
101
+ ]
102
+ prompt = "\n".join(prompt)
103
+ prompt = (
104
+ prompt
105
+ + "\n"
106
+ + "システム: "
107
+ )
108
+ token_ids = tokenizer.encode(prompt, add_special_tokens=False, return_tensors="pt")
109
+
110
+ with torch.no_grad():
111
+ output_ids = model.generate(
112
+ token_ids.to(model.device),
113
+ max_new_tokens=200,
114
+ do_sample=True,
115
+ temperature=0.5,
116
+ pad_token_id=tokenizer.pad_token_id,
117
+ bos_token_id=tokenizer.bos_token_id,
118
+ eos_token_id=tokenizer.eos_token_id
119
+ )
120
+
121
+ output = tokenizer.decode(output_ids.tolist()[0])
122
+ print(output)
123
+ """
124
+ 設定: 次の日本語を英語に翻訳してください。
125
+ ユーザー: 自然言語による指示に基づきタスクが解けるよう学習させることを Instruction tuning と呼びます。
126
+ システム: Learning to solve tasks based on natural language instructions is called instruction tuning.</s>
127
+ """
128
+
129
+ output = output[len(prompt):-len("</s>")].strip()
130
+ input = "大規模言語モデル(だいきぼげんごモデル、英: large language model、LLM)は、多数のパラメータ(数千万から数十億)を持つ人工ニューラルネットワークで構成されるコンピュータ言語モデルで、膨大なラベルなしテキストを使用して自己教師あり学習または半教師あり学習によって訓練が行われる。"
131
+
132
+ context.extend([
133
+ {
134
+ "speaker": "システム",
135
+ "text": output
136
+ },
137
+ {
138
+ "speaker": "ユーザー",
139
+ "text": input
140
+ }
141
+ ])
142
+ prompt = [
143
+ f"{uttr['speaker']}: {uttr['text']}"
144
+ for uttr in context
145
+ ]
146
+ prompt = "\n".join(prompt)
147
+ prompt = (
148
+ prompt
149
+ + "\n"
150
+ + "システム: "
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=200,
158
+ do_sample=True,
159
+ temperature=0.5,
160
+ pad_token_id=tokenizer.pad_token_id,
161
+ bos_token_id=tokenizer.bos_token_id,
162
+ eos_token_id=tokenizer.eos_token_id
163
+ )
164
+
165
+ output = tokenizer.decode(output_ids.tolist()[0])
166
+ print(output)
167
+ """
168
+ 設定: 次の日本語を英語に翻訳してください。
169
+ ユーザー: 自然言語による指示に基づきタスクが解けるよう学習させることを Instruction tuning と呼びます。
170
+ システム: Learning to solve tasks based on natural language instructions is called instruction tuning.
171
+ ユーザー: 大規模言語モデル(だいきぼげんごモデル、英: large language model、LLM)は、多数のパラメータ(数千万から数十億)を持つ人工ニューラルネットワークで構成されるコンピュータ言語モデルで、膨大なラベルなしテ キストを使用して自己教師あり学習または半教師あり学習によって訓練が行われる。
172
+ システム: Large language models (LLMs) are computer language models consisting of a deep artificial neural network with millions to billions of parameters that are trained by self-supervised learning or semi-supervised learning using vast unlabeled text corpora.</s>
173
+ """
174
+ ~~~~
175
+
176
+ ---
177
+
178
+ # Tokenization
179
+ The model uses the original llama-2 tokenizer.
180
+
181
+ ---
182
+
183
+ # How to cite
184
+ ~~~
185
+ @misc{RinnaYouri7bChat,
186
+ url={https://huggingface.co/rinna/youri-7b-chat},
187
+ title={rinna/youri-7b-chat},
188
+ author={Zhao, Tianyu and Sawada, Kei}
189
+ }
190
+ ~~~
191
+ ---
192
+
193
+ # License
194
+ [The llama2 license](https://ai.meta.com/llama/license/)
config.json ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "LlamaForCausalLM"
4
+ ],
5
+ "attention_bias": false,
6
+ "bos_token_id": 1,
7
+ "eos_token_id": 2,
8
+ "hidden_act": "silu",
9
+ "hidden_size": 4096,
10
+ "initializer_range": 0.02,
11
+ "intermediate_size": 11008,
12
+ "max_position_embeddings": 4096,
13
+ "model_type": "llama",
14
+ "num_attention_heads": 32,
15
+ "num_hidden_layers": 32,
16
+ "num_key_value_heads": 32,
17
+ "pad_token_id": 0,
18
+ "pretraining_tp": 1,
19
+ "rms_norm_eps": 1e-05,
20
+ "rope_scaling": null,
21
+ "rope_theta": 10000.0,
22
+ "tie_word_embeddings": false,
23
+ "torch_dtype": "bfloat16",
24
+ "transformers_version": "4.34.0",
25
+ "use_cache": true,
26
+ "vocab_size": 32000
27
+ }
generation_config.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 1,
4
+ "eos_token_id": 2,
5
+ "pad_token_id": 0,
6
+ "transformers_version": "4.34.0"
7
+ }
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bcf5f583fcd1b32a9a471a77942cc947107719120c13a5300d2380a9407e782d
3
+ size 13476871854
rinna.png ADDED
special_tokens_map.json ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<s>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "</s>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "unk_token": {
17
+ "content": "<unk>",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ }
23
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9e556afd44213b6bd1be2b850ebbbd98f5481437a8021afaf58ee7fb1818d347
3
+ size 499723
tokenizer_checklist.chk ADDED
@@ -0,0 +1 @@
 
 
1
+ eeec4125e9c7560836b4873b6f8e3025 tokenizer.model
tokenizer_config.json ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": true,
3
+ "add_eos_token": false,
4
+ "bos_token": {
5
+ "__type": "AddedToken",
6
+ "content": "<s>",
7
+ "lstrip": false,
8
+ "normalized": false,
9
+ "rstrip": false,
10
+ "single_word": false
11
+ },
12
+ "clean_up_tokenization_spaces": false,
13
+ "eos_token": {
14
+ "__type": "AddedToken",
15
+ "content": "</s>",
16
+ "lstrip": false,
17
+ "normalized": false,
18
+ "rstrip": false,
19
+ "single_word": false
20
+ },
21
+ "legacy": false,
22
+ "model_max_length": 1000000000000000019884624838656,
23
+ "pad_token": null,
24
+ "padding_side": "right",
25
+ "sp_model_kwargs": {},
26
+ "tokenizer_class": "LlamaTokenizer",
27
+ "unk_token": {
28
+ "__type": "AddedToken",
29
+ "content": "<unk>",
30
+ "lstrip": false,
31
+ "normalized": false,
32
+ "rstrip": false,
33
+ "single_word": false
34
+ }
35
+ }