RichardErkhov commited on
Commit
0cd9fce
·
verified ·
1 Parent(s): 2b9c639

uploaded readme

Browse files
Files changed (1) hide show
  1. README.md +198 -0
README.md ADDED
@@ -0,0 +1,198 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ gemma-2-baku-2b-it - GGUF
11
+ - Model creator: https://huggingface.co/rinna/
12
+ - Original model: https://huggingface.co/rinna/gemma-2-baku-2b-it/
13
+
14
+
15
+ | Name | Quant method | Size |
16
+ | ---- | ---- | ---- |
17
+ | [gemma-2-baku-2b-it.Q2_K.gguf](https://huggingface.co/RichardErkhov/rinna_-_gemma-2-baku-2b-it-gguf/blob/main/gemma-2-baku-2b-it.Q2_K.gguf) | Q2_K | 1.15GB |
18
+ | [gemma-2-baku-2b-it.IQ3_XS.gguf](https://huggingface.co/RichardErkhov/rinna_-_gemma-2-baku-2b-it-gguf/blob/main/gemma-2-baku-2b-it.IQ3_XS.gguf) | IQ3_XS | 1.22GB |
19
+ | [gemma-2-baku-2b-it.IQ3_S.gguf](https://huggingface.co/RichardErkhov/rinna_-_gemma-2-baku-2b-it-gguf/blob/main/gemma-2-baku-2b-it.IQ3_S.gguf) | IQ3_S | 1.27GB |
20
+ | [gemma-2-baku-2b-it.Q3_K_S.gguf](https://huggingface.co/RichardErkhov/rinna_-_gemma-2-baku-2b-it-gguf/blob/main/gemma-2-baku-2b-it.Q3_K_S.gguf) | Q3_K_S | 1.27GB |
21
+ | [gemma-2-baku-2b-it.IQ3_M.gguf](https://huggingface.co/RichardErkhov/rinna_-_gemma-2-baku-2b-it-gguf/blob/main/gemma-2-baku-2b-it.IQ3_M.gguf) | IQ3_M | 1.3GB |
22
+ | [gemma-2-baku-2b-it.Q3_K.gguf](https://huggingface.co/RichardErkhov/rinna_-_gemma-2-baku-2b-it-gguf/blob/main/gemma-2-baku-2b-it.Q3_K.gguf) | Q3_K | 1.36GB |
23
+ | [gemma-2-baku-2b-it.Q3_K_M.gguf](https://huggingface.co/RichardErkhov/rinna_-_gemma-2-baku-2b-it-gguf/blob/main/gemma-2-baku-2b-it.Q3_K_M.gguf) | Q3_K_M | 1.36GB |
24
+ | [gemma-2-baku-2b-it.Q3_K_L.gguf](https://huggingface.co/RichardErkhov/rinna_-_gemma-2-baku-2b-it-gguf/blob/main/gemma-2-baku-2b-it.Q3_K_L.gguf) | Q3_K_L | 1.44GB |
25
+ | [gemma-2-baku-2b-it.IQ4_XS.gguf](https://huggingface.co/RichardErkhov/rinna_-_gemma-2-baku-2b-it-gguf/blob/main/gemma-2-baku-2b-it.IQ4_XS.gguf) | IQ4_XS | 1.47GB |
26
+ | [gemma-2-baku-2b-it.Q4_0.gguf](https://huggingface.co/RichardErkhov/rinna_-_gemma-2-baku-2b-it-gguf/blob/main/gemma-2-baku-2b-it.Q4_0.gguf) | Q4_0 | 1.52GB |
27
+ | [gemma-2-baku-2b-it.IQ4_NL.gguf](https://huggingface.co/RichardErkhov/rinna_-_gemma-2-baku-2b-it-gguf/blob/main/gemma-2-baku-2b-it.IQ4_NL.gguf) | IQ4_NL | 1.53GB |
28
+ | [gemma-2-baku-2b-it.Q4_K_S.gguf](https://huggingface.co/RichardErkhov/rinna_-_gemma-2-baku-2b-it-gguf/blob/main/gemma-2-baku-2b-it.Q4_K_S.gguf) | Q4_K_S | 1.53GB |
29
+ | [gemma-2-baku-2b-it.Q4_K.gguf](https://huggingface.co/RichardErkhov/rinna_-_gemma-2-baku-2b-it-gguf/blob/main/gemma-2-baku-2b-it.Q4_K.gguf) | Q4_K | 1.59GB |
30
+ | [gemma-2-baku-2b-it.Q4_K_M.gguf](https://huggingface.co/RichardErkhov/rinna_-_gemma-2-baku-2b-it-gguf/blob/main/gemma-2-baku-2b-it.Q4_K_M.gguf) | Q4_K_M | 1.59GB |
31
+ | [gemma-2-baku-2b-it.Q4_1.gguf](https://huggingface.co/RichardErkhov/rinna_-_gemma-2-baku-2b-it-gguf/blob/main/gemma-2-baku-2b-it.Q4_1.gguf) | Q4_1 | 1.64GB |
32
+ | [gemma-2-baku-2b-it.Q5_0.gguf](https://huggingface.co/RichardErkhov/rinna_-_gemma-2-baku-2b-it-gguf/blob/main/gemma-2-baku-2b-it.Q5_0.gguf) | Q5_0 | 1.75GB |
33
+ | [gemma-2-baku-2b-it.Q5_K_S.gguf](https://huggingface.co/RichardErkhov/rinna_-_gemma-2-baku-2b-it-gguf/blob/main/gemma-2-baku-2b-it.Q5_K_S.gguf) | Q5_K_S | 1.75GB |
34
+ | [gemma-2-baku-2b-it.Q5_K.gguf](https://huggingface.co/RichardErkhov/rinna_-_gemma-2-baku-2b-it-gguf/blob/main/gemma-2-baku-2b-it.Q5_K.gguf) | Q5_K | 1.79GB |
35
+ | [gemma-2-baku-2b-it.Q5_K_M.gguf](https://huggingface.co/RichardErkhov/rinna_-_gemma-2-baku-2b-it-gguf/blob/main/gemma-2-baku-2b-it.Q5_K_M.gguf) | Q5_K_M | 1.79GB |
36
+ | [gemma-2-baku-2b-it.Q5_1.gguf](https://huggingface.co/RichardErkhov/rinna_-_gemma-2-baku-2b-it-gguf/blob/main/gemma-2-baku-2b-it.Q5_1.gguf) | Q5_1 | 1.87GB |
37
+ | [gemma-2-baku-2b-it.Q6_K.gguf](https://huggingface.co/RichardErkhov/rinna_-_gemma-2-baku-2b-it-gguf/blob/main/gemma-2-baku-2b-it.Q6_K.gguf) | Q6_K | 2.0GB |
38
+ | [gemma-2-baku-2b-it.Q8_0.gguf](https://huggingface.co/RichardErkhov/rinna_-_gemma-2-baku-2b-it-gguf/blob/main/gemma-2-baku-2b-it.Q8_0.gguf) | Q8_0 | 2.59GB |
39
+
40
+
41
+
42
+
43
+ Original model description:
44
+ ---
45
+ thumbnail: https://github.com/rinnakk/japanese-pretrained-models/blob/master/rinna.png
46
+ license: gemma
47
+ language:
48
+ - ja
49
+ - en
50
+ tags:
51
+ - gemma2
52
+ - conversational
53
+ base_model:
54
+ - google/gemma-2-2b
55
+ - google/gemma-2-2b-it
56
+ - rinna/gemma-2-baku-2b
57
+ base_model_relation: merge
58
+ pipeline_tag: text-generation
59
+ library_name: transformers
60
+ ---
61
+
62
+
63
+ # `Gemma 2 Baku 2B Instruct (rinna/gemma-2-baku-2b-it)`
64
+
65
+ ![rinna-icon](./rinna.png)
66
+
67
+ # Overview
68
+
69
+ The model is an instruction-tuned variant of [rinna/gemma-2-baku-2b](https://huggingface.co/rinna/gemma-2-baku-2b), utilizing Chat Vector and Odds Ratio Preference Optimization (ORPO) for fine-tuning. It adheres to the gemma-2 chat format.
70
+
71
+ | Size | Continual Pre-Training | Instruction-Tuning |
72
+ | :- | :- | :- |
73
+ | 2B | Gemma 2 Baku 2B [[HF]](https://huggingface.co/rinna/gemma-2-baku-2b) | Gemma 2 Baku 2B Instruct [[HF]](https://huggingface.co/rinna/gemma-2-baku-2b-it) |
74
+
75
+ * **Model architecture**
76
+
77
+ A 26-layer, 2304-hidden-size transformer-based language model. Please refer to the [Gemma 2 Model Card](https://www.kaggle.com/models/google/gemma-2/) for detailed information on the model's architecture.
78
+
79
+ * **Training**
80
+
81
+ **Model merging.** The base model was endowed with instruction-following capabilities through a chat vector addition process. The chat vector was derived by subtracting the parameter vectors of [google/gemma-2-2b](https://huggingface.co/google/gemma-2-2b) from [google/gemma-2-2b-it](https://huggingface.co/google/gemma-2-2b-it), as follows.
82
+
83
+ ~~~~text
84
+ rinna/gemma-2-baku-2b + 1.0 * (google/gemma-2-2b-it - google/gemma-2-2b)
85
+ ~~~~
86
+
87
+ During this process, the embedding layer was excluded during the subtraction and addition of parameter vectors.
88
+
89
+ **OPRO** was applied using a subset of the following dataset to further refine the performance of the merged model.
90
+
91
+ - rinna's internal dataset
92
+
93
+ * **Contributors**
94
+
95
+ - [Xinqi Chen](https://huggingface.co/Keely0419)
96
+ - [Toshiaki Wakatsuki](https://huggingface.co/t-w)
97
+ - [Kei Sawada](https://huggingface.co/keisawada)
98
+
99
+ ---
100
+
101
+ # Benchmarking
102
+
103
+ Please refer to [rinna's LM benchmark page](https://rinnakk.github.io/research/benchmarks/lm/index.html).
104
+
105
+ ---
106
+
107
+ # How to use the model
108
+
109
+ ~~~~python
110
+ from transformers import AutoTokenizer, AutoModelForCausalLM
111
+ import torch
112
+
113
+ model_id = "rinna/gemma-2-baku-2b-it"
114
+ dtype = torch.bfloat16
115
+
116
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
117
+ model = AutoModelForCausalLM.from_pretrained(
118
+ model_id,
119
+ device_map="cuda",
120
+ torch_dtype=dtype,
121
+ attn_implementation="eager",
122
+ )
123
+
124
+ chat = [
125
+ { "role": "user", "content": "西田幾多郎とはどんな人物ですか?" },
126
+ ]
127
+ prompt = tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)
128
+
129
+ input_ids = tokenizer.encode(prompt, add_special_tokens=False, return_tensors="pt").to(model.device)
130
+ outputs = model.generate(
131
+ input_ids,
132
+ max_new_tokens=512,
133
+ )
134
+
135
+ response = tokenizer.decode(outputs[0][input_ids.shape[-1]:], skip_special_tokens=True)
136
+ print(response)
137
+ ~~~~
138
+
139
+ It is recommended to use eager attention when conducting batch inference under bfloat16 precision.
140
+ Currently, Gemma 2 yields NaN values for input sequences with padding when the default attention mechanism (torch.scaled_dot_product_attention) is employed in conjunction with bfloat16.
141
+
142
+ ---
143
+
144
+ # Tokenization
145
+ The model uses the original [google/gemma-2-2b-it](https://huggingface.co/google/gemma-2-2b-it) tokenizer.
146
+
147
+ ---
148
+
149
+ # How to cite
150
+ ```bibtex
151
+ @misc{rinna-gemma-2-baku-2b-it,
152
+ title = {rinna/gemma-2-baku-2b-it},
153
+ author = {Chen, Xinqi and Wakatsuki, Toshiaki and Sawada, Kei},
154
+ url = {https://huggingface.co/rinna/gemma-2-baku-2b-it}
155
+ }
156
+
157
+ @inproceedings{sawada2024release,
158
+ title = {Release of Pre-Trained Models for the {J}apanese Language},
159
+ author = {Sawada, Kei and Zhao, Tianyu and Shing, Makoto and Mitsui, Kentaro and Kaga, Akio and Hono, Yukiya and Wakatsuki, Toshiaki and Mitsuda, Koh},
160
+ booktitle = {Proceedings of the 2024 Joint International Conference on Computational Linguistics, Language Resources and Evaluation (LREC-COLING 2024)},
161
+ month = {5},
162
+ year = {2024},
163
+ pages = {13898--13905},
164
+ url = {https://aclanthology.org/2024.lrec-main.1213},
165
+ note = {\url{https://arxiv.org/abs/2404.01657}}
166
+ }
167
+ ```
168
+ ---
169
+
170
+ # References
171
+ ```bibtex
172
+ @article{gemma-2-2024,
173
+ title = {Gemma 2},
174
+ url = {https://www.kaggle.com/models/google/gemma-2},
175
+ publisher = {Kaggle},
176
+ author = {Gemma Team},
177
+ year = {2024}
178
+ }
179
+
180
+ @article{huang2023chat,
181
+ title = {Chat Vector: A Simple Approach to Equip LLMs with Instruction Following and Model Alignment in New Languages},
182
+ author = {Huang, Shih-Cheng and Li, Pin-Zu and Hsu, Yu-Chi and Chen, Kuang-Ming and Lin, Yu Tung and Hsiao, Shih-Kai and Tzong-Han Tsai, Richard and Lee, Hung-yi},
183
+ year = {2023},
184
+ url = {https://arxiv.org/abs/2310.04799}
185
+ }
186
+
187
+ @article{hong2024orpo,
188
+ title = {Orpo: Monolithic preference optimization without reference model},
189
+ author = {Hong, Jiwoo and Lee, Noah and Thorne, James},
190
+ year = {2024},
191
+ url = {https://arxiv.org/abs/2403.07691}
192
+ }
193
+ ```
194
+ ---
195
+
196
+ # License
197
+ [Gemma Terms of Use](https://ai.google.dev/gemma/terms)
198
+