alfredplpl
commited on
Update README.md
Browse files
README.md
CHANGED
@@ -2,4 +2,79 @@
|
|
2 |
license: other
|
3 |
license_name: gemma-terms-of-use
|
4 |
license_link: https://www.kaggle.com/models/google/gemma/license/consent
|
|
|
|
|
|
|
|
|
5 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
license: other
|
3 |
license_name: gemma-terms-of-use
|
4 |
license_link: https://www.kaggle.com/models/google/gemma/license/consent
|
5 |
+
language:
|
6 |
+
- ja
|
7 |
+
- en
|
8 |
+
library_name: transformers
|
9 |
---
|
10 |
+
|
11 |
+
# Usage
|
12 |
+
|
13 |
+
```python
|
14 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
15 |
+
import torch
|
16 |
+
|
17 |
+
# トークナイザーとモデルの準備
|
18 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
19 |
+
"alfredplpl/gemma-2b-it-ja-poc"
|
20 |
+
)
|
21 |
+
model = AutoModelForCausalLM.from_pretrained(
|
22 |
+
"alfredplpl/gemma-2b-it-ja-poc",
|
23 |
+
device_map="cuda:0",
|
24 |
+
torch_dtype=torch.float16
|
25 |
+
)
|
26 |
+
|
27 |
+
# プロンプトの準備
|
28 |
+
prompt="""
|
29 |
+
あなたは親切なアシスタントです。英語は喋らず、日本語だけ喋ってください。
|
30 |
+
<start_of_turn>user
|
31 |
+
人生で大切なことはなんですか?<end_of_turn>
|
32 |
+
<start_of_turn>model"""
|
33 |
+
|
34 |
+
# 推論の実行
|
35 |
+
input_ids = tokenizer(prompt, return_tensors="pt").to(model.device)
|
36 |
+
outputs = model.generate(
|
37 |
+
**input_ids,
|
38 |
+
max_new_tokens=128,
|
39 |
+
do_sample=True,
|
40 |
+
top_p=0.95,
|
41 |
+
temperature=0.2,
|
42 |
+
repetition_penalty=1.1,
|
43 |
+
)
|
44 |
+
print(tokenizer.decode(outputs[0]))
|
45 |
+
|
46 |
+
```
|
47 |
+
|
48 |
+
```bash
|
49 |
+
<bos>
|
50 |
+
あなたは親切なアシスタントです。英語は喋らず、日本語だけ喋ってください。
|
51 |
+
<start_of_turn>user
|
52 |
+
人生で大切なことはなんですか?<end_of_turn>
|
53 |
+
<start_of_turn>model
|
54 |
+
人生で大切なのは、家族と友人との愛です。<end_of_turn>
|
55 |
+
<eos>
|
56 |
+
```
|
57 |
+
|
58 |
+
# Chat Templete
|
59 |
+
|
60 |
+
```bash
|
61 |
+
<bos>
|
62 |
+
{{system prompt}}
|
63 |
+
<start_of_turn>user
|
64 |
+
{{prompt}}<end_of_turn>
|
65 |
+
<start_of_turn>model
|
66 |
+
{{response}}<end_of_turn>
|
67 |
+
<eos>
|
68 |
+
```
|
69 |
+
|
70 |
+
# Base model
|
71 |
+
- free-ai-ltd/ja-aozora-wikipedia-gamma-2b-chat
|
72 |
+
|
73 |
+
# Dataset for Instruct tuning
|
74 |
+
- llm-jp/databricks-dolly-15k-ja
|
75 |
+
- llm-jp/oasst1-21k-ja
|
76 |
+
- kunishou/oasst1-chat-44k-ja
|
77 |
+
- kunishou/oasst2-chat-68k-ja
|
78 |
+
- kunishou/cnn-dailymail-27k-ja
|
79 |
+
- kunishou/databricks-dolly-69k-ja-en-translation
|
80 |
+
- kunishou/databricks-dolly-15k-ja
|