mav23 commited on
Commit
acb07a8
·
verified ·
1 Parent(s): a633261

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. .gitattributes +1 -0
  2. README.md +154 -0
  3. gemma-2-baku-2b-it.Q4_0.gguf +3 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ gemma-2-baku-2b-it.Q4_0.gguf filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ thumbnail: https://github.com/rinnakk/japanese-pretrained-models/blob/master/rinna.png
3
+ license: gemma
4
+ language:
5
+ - ja
6
+ - en
7
+ tags:
8
+ - gemma2
9
+ - conversational
10
+ base_model:
11
+ - google/gemma-2-2b
12
+ - google/gemma-2-2b-it
13
+ - rinna/gemma-2-baku-2b
14
+ base_model_relation: merge
15
+ pipeline_tag: text-generation
16
+ library_name: transformers
17
+ ---
18
+
19
+
20
+ # `Gemma 2 Baku 2B Instruct (rinna/gemma-2-baku-2b-it)`
21
+
22
+ ![rinna-icon](./rinna.png)
23
+
24
+ # Overview
25
+
26
+ 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.
27
+
28
+ | Size | Continual Pre-Training | Instruction-Tuning |
29
+ | :- | :- | :- |
30
+ | 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) |
31
+
32
+ * **Model architecture**
33
+
34
+ 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.
35
+
36
+ * **Training**
37
+
38
+ **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.
39
+
40
+ ~~~~text
41
+ rinna/gemma-2-baku-2b + 1.0 * (google/gemma-2-2b-it - google/gemma-2-2b)
42
+ ~~~~
43
+
44
+ During this process, the embedding layer was excluded during the subtraction and addition of parameter vectors.
45
+
46
+ **OPRO** was applied using a subset of the following dataset to further refine the performance of the merged model.
47
+
48
+ - rinna's internal dataset
49
+
50
+ * **Contributors**
51
+
52
+ - [Xinqi Chen](https://huggingface.co/Keely0419)
53
+ - [Toshiaki Wakatsuki](https://huggingface.co/t-w)
54
+ - [Kei Sawada](https://huggingface.co/keisawada)
55
+
56
+ ---
57
+
58
+ # Benchmarking
59
+
60
+ Please refer to [rinna's LM benchmark page](https://rinnakk.github.io/research/benchmarks/lm/index.html).
61
+
62
+ ---
63
+
64
+ # How to use the model
65
+
66
+ ~~~~python
67
+ from transformers import AutoTokenizer, AutoModelForCausalLM
68
+ import torch
69
+
70
+ model_id = "rinna/gemma-2-baku-2b-it"
71
+ dtype = torch.bfloat16
72
+
73
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
74
+ model = AutoModelForCausalLM.from_pretrained(
75
+ model_id,
76
+ device_map="cuda",
77
+ torch_dtype=dtype,
78
+ attn_implementation="eager",
79
+ )
80
+
81
+ chat = [
82
+ { "role": "user", "content": "西田幾多郎とはどんな人物ですか?" },
83
+ ]
84
+ prompt = tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)
85
+
86
+ input_ids = tokenizer.encode(prompt, add_special_tokens=False, return_tensors="pt").to(model.device)
87
+ outputs = model.generate(
88
+ input_ids,
89
+ max_new_tokens=512,
90
+ )
91
+
92
+ response = tokenizer.decode(outputs[0][input_ids.shape[-1]:], skip_special_tokens=True)
93
+ print(response)
94
+ ~~~~
95
+
96
+ It is recommended to use eager attention when conducting batch inference under bfloat16 precision.
97
+ 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.
98
+
99
+ ---
100
+
101
+ # Tokenization
102
+ The model uses the original [google/gemma-2-2b-it](https://huggingface.co/google/gemma-2-2b-it) tokenizer.
103
+
104
+ ---
105
+
106
+ # How to cite
107
+ ```bibtex
108
+ @misc{rinna-gemma-2-baku-2b-it,
109
+ title = {rinna/gemma-2-baku-2b-it},
110
+ author = {Chen, Xinqi and Wakatsuki, Toshiaki and Sawada, Kei},
111
+ url = {https://huggingface.co/rinna/gemma-2-baku-2b-it}
112
+ }
113
+
114
+ @inproceedings{sawada2024release,
115
+ title = {Release of Pre-Trained Models for the {J}apanese Language},
116
+ author = {Sawada, Kei and Zhao, Tianyu and Shing, Makoto and Mitsui, Kentaro and Kaga, Akio and Hono, Yukiya and Wakatsuki, Toshiaki and Mitsuda, Koh},
117
+ booktitle = {Proceedings of the 2024 Joint International Conference on Computational Linguistics, Language Resources and Evaluation (LREC-COLING 2024)},
118
+ month = {5},
119
+ year = {2024},
120
+ pages = {13898--13905},
121
+ url = {https://aclanthology.org/2024.lrec-main.1213},
122
+ note = {\url{https://arxiv.org/abs/2404.01657}}
123
+ }
124
+ ```
125
+ ---
126
+
127
+ # References
128
+ ```bibtex
129
+ @article{gemma-2-2024,
130
+ title = {Gemma 2},
131
+ url = {https://www.kaggle.com/models/google/gemma-2},
132
+ publisher = {Kaggle},
133
+ author = {Gemma Team},
134
+ year = {2024}
135
+ }
136
+
137
+ @article{huang2023chat,
138
+ title = {Chat Vector: A Simple Approach to Equip LLMs with Instruction Following and Model Alignment in New Languages},
139
+ 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},
140
+ year = {2023},
141
+ url = {https://arxiv.org/abs/2310.04799}
142
+ }
143
+
144
+ @article{hong2024orpo,
145
+ title = {ORPO: Monolithic Preference Optimization without Reference Model},
146
+ author = {Hong, Jiwoo and Lee, Noah and Thorne, James},
147
+ year = {2024},
148
+ url = {https://arxiv.org/abs/2403.07691}
149
+ }
150
+ ```
151
+ ---
152
+
153
+ # License
154
+ [Gemma Terms of Use](https://ai.google.dev/gemma/terms)
gemma-2-baku-2b-it.Q4_0.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9032d4e326d54c073e5302be4baf228474824060d2cbfd22e372ac7845267a20
3
+ size 1629509952