|
--- |
|
language: |
|
- ja |
|
- en |
|
license: other |
|
library_name: transformers |
|
license_name: gemma-terms-of-use |
|
license_link: https://www.kaggle.com/models/google/gemma/license/consent |
|
--- |
|
|
|
# Usage |
|
|
|
```python |
|
from transformers import AutoTokenizer, AutoModelForCausalLM |
|
import torch |
|
|
|
# トークナイザーとモデルの準備 |
|
tokenizer = AutoTokenizer.from_pretrained( |
|
"alfredplpl/gemma-2b-it-ja-poc" |
|
) |
|
model = AutoModelForCausalLM.from_pretrained( |
|
"alfredplpl/gemma-2b-it-ja-poc", |
|
device_map="cuda:0", |
|
torch_dtype=torch.float16 |
|
) |
|
|
|
# プロンプトの準備 |
|
prompt=""" |
|
あなたは親切なアシスタントです。英語は喋らず、日本語だけ喋ってください。 |
|
<start_of_turn>user |
|
人生で大切なことはなんですか?<end_of_turn> |
|
<start_of_turn>model""" |
|
|
|
# 推論の実行 |
|
input_ids = tokenizer(prompt, return_tensors="pt").to(model.device) |
|
outputs = model.generate( |
|
**input_ids, |
|
max_new_tokens=128, |
|
do_sample=True, |
|
top_p=0.95, |
|
temperature=0.2, |
|
repetition_penalty=1.1, |
|
) |
|
print(tokenizer.decode(outputs[0])) |
|
|
|
``` |
|
|
|
## Result |
|
|
|
```bash |
|
<bos> |
|
あなたは親切なアシスタントです。英語は喋らず、日本語だけ喋ってください。 |
|
<start_of_turn>user |
|
人生で大切なことはなんですか?<end_of_turn> |
|
<start_of_turn>model |
|
人生で大切なのは、家族と友人との愛です。<end_of_turn> |
|
<eos> |
|
``` |
|
|
|
# Chat Templete |
|
|
|
```bash |
|
<bos> |
|
{{system prompt}} |
|
<start_of_turn>user |
|
{{prompt}}<end_of_turn> |
|
<start_of_turn>model |
|
{{response}}<end_of_turn> |
|
<eos> |
|
``` |
|
|
|
# Base model |
|
- free-ai-ltd/ja-aozora-wikipedia-gamma-2b-chat |
|
|
|
# Dataset for Instruct tuning |
|
- llm-jp/databricks-dolly-15k-ja |
|
- llm-jp/oasst1-21k-ja |
|
- kunishou/oasst1-chat-44k-ja |
|
- kunishou/oasst2-chat-68k-ja |
|
- kunishou/cnn-dailymail-27k-ja |
|
- kunishou/databricks-dolly-69k-ja-en-translation |
|
- kunishou/databricks-dolly-15k-ja |
|
|
|
# How to make this model |
|
- [LoRA](https://gist.github.com/alfredplpl/e20cad036c151f38645a1abc87f56a2f) |