Update README.md
Browse files
README.md
CHANGED
@@ -1,204 +1,129 @@
|
|
1 |
---
|
2 |
library_name: peft
|
3 |
base_model: unsloth/gemma-7b-bnb-4bit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
---
|
5 |
|
6 |
-
# Model Card for Model ID
|
7 |
|
8 |
-
|
|
|
9 |
|
|
|
10 |
|
|
|
|
|
11 |
|
12 |
-
|
|
|
13 |
|
14 |
-
|
|
|
15 |
|
16 |
-
|
17 |
|
|
|
|
|
18 |
|
|
|
|
|
|
|
|
|
19 |
|
20 |
-
|
21 |
-
- **Funded by [optional]:** [More Information Needed]
|
22 |
-
- **Shared by [optional]:** [More Information Needed]
|
23 |
-
- **Model type:** [More Information Needed]
|
24 |
-
- **Language(s) (NLP):** [More Information Needed]
|
25 |
-
- **License:** [More Information Needed]
|
26 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
27 |
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
-
|
|
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
|
36 |
-
|
|
|
|
|
37 |
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
-
|
|
|
|
|
|
|
|
|
41 |
|
42 |
-
|
|
|
43 |
|
44 |
-
|
45 |
|
46 |
-
### Downstream Use [optional]
|
47 |
|
48 |
-
|
|
|
|
|
49 |
|
50 |
-
|
|
|
51 |
|
52 |
-
|
|
|
53 |
|
54 |
-
|
|
|
55 |
|
56 |
-
|
|
|
57 |
|
58 |
-
|
|
|
59 |
|
60 |
-
|
|
|
|
|
|
|
61 |
|
62 |
-
|
|
|
|
|
63 |
|
64 |
-
|
|
|
|
|
65 |
|
66 |
-
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
67 |
|
68 |
-
|
|
|
69 |
|
70 |
-
|
|
|
71 |
|
72 |
-
|
73 |
-
|
74 |
-
[More Information Needed]
|
75 |
-
|
76 |
-
## Training Details
|
77 |
-
|
78 |
-
### Training Data
|
79 |
-
|
80 |
-
<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
81 |
-
|
82 |
-
[More Information Needed]
|
83 |
-
|
84 |
-
### Training Procedure
|
85 |
-
|
86 |
-
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
87 |
-
|
88 |
-
#### Preprocessing [optional]
|
89 |
-
|
90 |
-
[More Information Needed]
|
91 |
-
|
92 |
-
|
93 |
-
#### Training Hyperparameters
|
94 |
-
|
95 |
-
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
96 |
-
|
97 |
-
#### Speeds, Sizes, Times [optional]
|
98 |
-
|
99 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
100 |
-
|
101 |
-
[More Information Needed]
|
102 |
-
|
103 |
-
## Evaluation
|
104 |
-
|
105 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
106 |
-
|
107 |
-
### Testing Data, Factors & Metrics
|
108 |
-
|
109 |
-
#### Testing Data
|
110 |
-
|
111 |
-
<!-- This should link to a Dataset Card if possible. -->
|
112 |
-
|
113 |
-
[More Information Needed]
|
114 |
-
|
115 |
-
#### Factors
|
116 |
-
|
117 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
118 |
-
|
119 |
-
[More Information Needed]
|
120 |
-
|
121 |
-
#### Metrics
|
122 |
-
|
123 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
124 |
-
|
125 |
-
[More Information Needed]
|
126 |
-
|
127 |
-
### Results
|
128 |
-
|
129 |
-
[More Information Needed]
|
130 |
-
|
131 |
-
#### Summary
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
## Model Examination [optional]
|
136 |
-
|
137 |
-
<!-- Relevant interpretability work for the model goes here -->
|
138 |
-
|
139 |
-
[More Information Needed]
|
140 |
-
|
141 |
-
## Environmental Impact
|
142 |
-
|
143 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
144 |
-
|
145 |
-
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
146 |
-
|
147 |
-
- **Hardware Type:** [More Information Needed]
|
148 |
-
- **Hours used:** [More Information Needed]
|
149 |
-
- **Cloud Provider:** [More Information Needed]
|
150 |
-
- **Compute Region:** [More Information Needed]
|
151 |
-
- **Carbon Emitted:** [More Information Needed]
|
152 |
-
|
153 |
-
## Technical Specifications [optional]
|
154 |
-
|
155 |
-
### Model Architecture and Objective
|
156 |
-
|
157 |
-
[More Information Needed]
|
158 |
-
|
159 |
-
### Compute Infrastructure
|
160 |
-
|
161 |
-
[More Information Needed]
|
162 |
-
|
163 |
-
#### Hardware
|
164 |
-
|
165 |
-
[More Information Needed]
|
166 |
-
|
167 |
-
#### Software
|
168 |
-
|
169 |
-
[More Information Needed]
|
170 |
-
|
171 |
-
## Citation [optional]
|
172 |
-
|
173 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
174 |
-
|
175 |
-
**BibTeX:**
|
176 |
-
|
177 |
-
[More Information Needed]
|
178 |
-
|
179 |
-
**APA:**
|
180 |
-
|
181 |
-
[More Information Needed]
|
182 |
-
|
183 |
-
## Glossary [optional]
|
184 |
-
|
185 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
186 |
-
|
187 |
-
[More Information Needed]
|
188 |
-
|
189 |
-
## More Information [optional]
|
190 |
-
|
191 |
-
[More Information Needed]
|
192 |
-
|
193 |
-
## Model Card Authors [optional]
|
194 |
-
|
195 |
-
[More Information Needed]
|
196 |
-
|
197 |
-
## Model Card Contact
|
198 |
-
|
199 |
-
[More Information Needed]
|
200 |
-
|
201 |
-
|
202 |
-
### Framework versions
|
203 |
-
|
204 |
-
- PEFT 0.8.2
|
|
|
1 |
---
|
2 |
library_name: peft
|
3 |
base_model: unsloth/gemma-7b-bnb-4bit
|
4 |
+
language:
|
5 |
+
- ja
|
6 |
+
- en
|
7 |
+
tags:
|
8 |
+
- translation
|
9 |
+
- qlora
|
10 |
+
- gemma
|
11 |
+
- text-generation-inference
|
12 |
+
- nlp
|
13 |
---
|
14 |
|
15 |
+
# モデルカード(Model Card for Model ID)
|
16 |
|
17 |
+
C3TR-AdapterはGoogleが発表したLLMであるgemma-7bの日英・英日翻訳性能を向上させるQLoRAです。
|
18 |
+
C3TR-Adapter is a QLoRA that improves the Japanese-English and English-Japanese translation performance of gemma-7b released by Google.
|
19 |
|
20 |
+
## モデル詳細(Model Details)
|
21 |
|
22 |
+
C3TR-Adapterは翻訳ベンチマークで多言語翻訳モデルであるGoogleのMadlad400やmetaのSeamless m4t v2 large、[ALMA-Ja-V2](https://huggingface.co/webbigdata/ALMA-7B-Ja-V2) (私達の以前のモデル)よりも大幅に優れた日英・日英翻訳性能を持っています。
|
23 |
+
Benchmarks show significantly better English-Japanese and Japanese-English translation performance than Google's Madlad400, META's Seamless m4t v2 large, and [ALMA-Ja-V2](https://huggingface.co/webbigdata/ALMA-7B-Ja-V2) (our previous model).
|
24 |
|
25 |
+
GoogleのウェブサービスColabを使うと無料でC3TR-Adapterを試す事が出来ます。
|
26 |
+
You can try C3TR-Adapter for free using Google's web service Colab.
|
27 |
|
28 |
+
- [動作確認用の簡単なサンプル(A simple sample to check the operation)](https://colab.research.google.com/drive/1RrUZ3Yq_XDtU33hs5Stru2o-6rXmFikm#scrollTo=8QeXdYv3enkl)
|
29 |
+
- [テキストファイルを一括で日英・英日翻訳するサンプル(Sample of batch translation of text files)](https://colab.research.google.com/drive/1eHtKxDCs4qxu-C7bzBsDppFQvZYt-v5y#scrollTo=9tCLTsfT_qgA)
|
30 |
|
31 |
+
### モデルの動かし方(How to use Model)
|
32 |
|
33 |
+
自分のパソコンで動かす場合は、約8.3GB以上のGPU RAMが必要です。
|
34 |
+
If you want to run it on your own local computer, you will need approximately 8.3 GB or more of GPU RAM.
|
35 |
|
36 |
+
必要なライブラリのインストール
|
37 |
+
Installation of required libraries
|
38 |
+
```
|
39 |
+
pip install transformers==0.38.1 peft==0.9.0 bitsandbytes==0.42.0
|
40 |
|
41 |
+
```
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
+
サンプルスクリプト
|
44 |
+
```
|
45 |
+
import torch
|
46 |
+
import os
|
47 |
+
import json
|
48 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
49 |
+
from peft import PeftModel
|
50 |
|
51 |
+
model_id = "unsloth/gemma-7b-bnb-4bit"
|
52 |
+
peft_model_id = "webbigdata/C3TR-Adapter"
|
53 |
|
54 |
+
model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto")
|
55 |
+
model = PeftModel.from_pretrained(model = model, model_id = peft_model_id)
|
56 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
57 |
|
58 |
+
def trans(my_str):
|
59 |
+
input_ids = tokenizer(my_str, return_tensors="pt",
|
60 |
+
padding=True, max_length=1600, truncation=True).input_ids.cuda()
|
61 |
|
62 |
+
# Translation
|
63 |
+
generated_ids = model.generate(input_ids=input_ids,
|
64 |
+
num_beams=3, max_new_tokens=800,
|
65 |
+
use_cache=True,
|
66 |
+
prompt_lookup_num_tokens=10
|
67 |
+
)
|
68 |
+
full_outputs = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)
|
69 |
+
return full_outputs[0].split("### Answer:\n")[-1].strip()
|
70 |
+
|
71 |
+
|
72 |
+
ret = trans("""
|
73 |
+
### Instructions:
|
74 |
+
Translate Japanese to English.
|
75 |
+
### Input:
|
76 |
+
現地時間2月22日午後8時05分(日本時間2月23日午前8時05分)から約1時間半、G20外相会合出席のためリオデジャネイロを訪問中の上川陽子外務大臣は、「WPS+イノベ-ション in リオ」と題する意見交換会を主催したところ、概要は以下のとおりです。
|
77 |
|
78 |
+
続いて、エリカ・タキモト・リオデジャネイロ州議会議員、ジョイス・トリンダ-ジ・リオ市女性活躍推進局長、スザンナ・カ-ン・リオデジャネイロ連邦大学工学部長、柔道家>のシルヴァナ・ナガイ氏から、それぞれブラジルにおける現場での経験を踏まえつつ、貧困や環境問題、女性の社会進出等の社会課題について、女性の視点を共有しつつ、発言しました。
|
79 |
+
### Answer:
|
80 |
+
""")
|
81 |
+
print(ret)
|
82 |
+
```
|
83 |
|
84 |
+
## 留意事項 Attention
|
85 |
+
**Do not save this adapter merged with the base model**, as there exists a bug that reduces performance when saving this adapter merged with the model.
|
86 |
|
87 |
+
このアダプターをモデルとマージして保存すると性能が下がってしまう不具合が存在するため、**ベースモデルとマージして保存しないでください**
|
88 |
|
|
|
89 |
|
90 |
+
### Terms of Use
|
91 |
+
基本的にはgemmaと同じライセンスです
|
92 |
+
Basically the same license as gemma.
|
93 |
|
94 |
+
加えて貴方に以下のお願いがあります。
|
95 |
+
Additionally, We have the following request to you.
|
96 |
|
97 |
+
私たちの以前のモデルであるALMA-7B-Ja-V2のダウンロード件数は15万件を超えているのですが、どんな人がどのような場面で使っているのか全く把握できていません。
|
98 |
+
Our previous model, ALMA-7B-Ja-V2, has over 150K downloads, but we have no idea who is using it and in what situations.
|
99 |
|
100 |
+
そのため、使用した後は[Googleフォームに感想や今後期待する方向性、気が付いた誤訳の例などを記入](https://forms.gle/Ycr9nWumvGamiNma9)してください。
|
101 |
+
So, after you use it, please [fill out the Google form below with your impressions, future directions you expect us to take, and examples of mistranslations you have noticed](https://forms.gle/Ycr9nWumvGamiNma9).
|
102 |
|
103 |
+
個人情報は収集しないので、気軽にご記入をお願いします
|
104 |
+
We do not collect personal information, so please feel free to fill out the form!
|
105 |
|
106 |
+
どんなご意見でも結構です!
|
107 |
+
Any feedback would be appreciated!
|
108 |
|
109 |
+
### 謝辞 Acknowledgment
|
110 |
+
Original Base Model
|
111 |
+
google/gemma-7b
|
112 |
+
https://huggingface.co/google/gemma-7b
|
113 |
|
114 |
+
Base Model
|
115 |
+
unsloth/gemma-7b-bnb-4bit
|
116 |
+
https://huggingface.co/unsloth/gemma-7b-bnb-4bit
|
117 |
|
118 |
+
QLoRA Adapter
|
119 |
+
webbigdata/C3TR-Adapter
|
120 |
+
https://huggingface.co/webbigdata/C3TR-Adapter
|
121 |
|
|
|
122 |
|
123 |
+
This adapter was trained with Unsloth.
|
124 |
+
https://github.com/unslothai/unsloth
|
125 |
|
126 |
+
その他、[ALMA](https://arxiv.org/abs/2309.11674)をはじめ、コミュニティの皆さんからヒントを貰っています。ありがとう
|
127 |
+
Other tips I have received from [ALMA](https://arxiv.org/abs/2309.11674) and others in the community. Thank you.
|
128 |
|
129 |
+
- **Developed by:** [webbigdata](https://webbigdata.jp/)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|