takumi0112
commited on
Update README.md
Browse files
README.md
CHANGED
@@ -20,3 +20,113 @@ language:
|
|
20 |
This llama model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
|
21 |
|
22 |
[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
This llama model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
|
21 |
|
22 |
[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
|
23 |
+
|
24 |
+
# llm-jp-3-13b-finetune-it
|
25 |
+
|
26 |
+
## 概要
|
27 |
+
|
28 |
+
`llm-jp-3-13b-finetune-it` は、大規模言語モデル [llm-jp/llm-jp-3-13b](https://huggingface.co/llm-jp/llm-jp-3-13b) をベースに、特定のデータセットに対する性能向上を目的としてファインチューニングしたモデルです。本モデルは、コンペティション「Elyza-Tasks-100-TV」で使用される特有のデータセットに対して最適化されています。
|
29 |
+
|
30 |
+
## モデルの詳細
|
31 |
+
|
32 |
+
### ベースモデル
|
33 |
+
|
34 |
+
- モデル名: [llm-jp/llm-jp-3-13b](https://huggingface.co/llm-jp/llm-jp-3-13b)
|
35 |
+
- パラメータ数: 13B
|
36 |
+
- トークナイザー: ベースモデル付属のトークナイザーを使用
|
37 |
+
|
38 |
+
### ファインチューニング
|
39 |
+
|
40 |
+
- 使用データセット: Ichikara Instruction データセット(`ichikara-instruction-003-001-1.json`)
|
41 |
+
- データセットの入手方法: [申請フォーム](https://liat-aip.sakura.ne.jp/wp/llmのための日本語インストラクションデータ作成/llmのための日本語インストラクションデータ-公開/) より申請が必要です。
|
42 |
+
- 引用:
|
43 |
+
- 関根聡, 安藤まや, 後藤美知子, 鈴木久美, 河原大輔, 井之上直也, 乾健太郎. ichikara-instruction: LLMのための日本語インストラクションデータの構築. 言語処理学会第30回年次大会(2024)
|
44 |
+
- 目的: Elyza-Tasks-100-TV データセットに対するモデルの性能向上
|
45 |
+
- ファインチューニング手法: LoRA(Low-Rank Adaptation)を使用した効率的なファインチューニング
|
46 |
+
- ライブラリ: [unsloth](https://github.com/unslothai/unsloth)
|
47 |
+
- 量子化: 4bit 量子化(qLoRA)によるメモリ効率化
|
48 |
+
- 主要ハイパーパラメータ:
|
49 |
+
- `r`: 32
|
50 |
+
- `target_modules`: `["q_proj", "k_proj", "v_proj", "o_proj", "gate_proj", "up_proj", "down_proj"]`
|
51 |
+
- `lora_alpha`: 32
|
52 |
+
- `lora_dropout`: 0.05
|
53 |
+
- `max_seq_length`: 512
|
54 |
+
|
55 |
+
## 使用方法
|
56 |
+
|
57 |
+
### 環境構築
|
58 |
+
|
59 |
+
```bash
|
60 |
+
pip install --upgrade --no-cache-dir "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"
|
61 |
+
pip install --upgrade torch xformers
|
62 |
+
pip install ipywidgets
|
63 |
+
```
|
64 |
+
|
65 |
+
### モデルのロード
|
66 |
+
|
67 |
+
```python
|
68 |
+
from transformers import AutoTokenizer
|
69 |
+
from unsloth import FastLanguageModel
|
70 |
+
|
71 |
+
model_id = "takumi0112/llm-jp-3-13b-finetune-it"
|
72 |
+
|
73 |
+
# モデルとトークナイザーのロード
|
74 |
+
model, tokenizer = FastLanguageModel.from_pretrained(
|
75 |
+
model_name=model_id,
|
76 |
+
dtype=None, # デフォルトのデータ型を使用
|
77 |
+
load_in_4bit=True, # 4bit 量子化モデルをロード
|
78 |
+
trust_remote_code=True,
|
79 |
+
)
|
80 |
+
|
81 |
+
# 推論モードへの切り替え
|
82 |
+
FastLanguageModel.for_inference(model)
|
83 |
+
```
|
84 |
+
|
85 |
+
### 推論の実行
|
86 |
+
|
87 |
+
```python
|
88 |
+
# 入力テキスト
|
89 |
+
input_text = "お寿司の作り方を教えてください。"
|
90 |
+
|
91 |
+
# プロンプトの作成
|
92 |
+
prompt = f"""### 指示
|
93 |
+
{input_text}
|
94 |
+
### 回答
|
95 |
+
"""
|
96 |
+
|
97 |
+
# トークナイズ
|
98 |
+
inputs = tokenizer([prompt], return_tensors="pt").to(model.device)
|
99 |
+
|
100 |
+
# テキスト生成
|
101 |
+
outputs = model.generate(
|
102 |
+
**inputs,
|
103 |
+
max_new_tokens=512,
|
104 |
+
use_cache=True,
|
105 |
+
do_sample=False,
|
106 |
+
repetition_penalty=1.2
|
107 |
+
)
|
108 |
+
|
109 |
+
# 出力結果の取得
|
110 |
+
generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True).split("### 回答")[-1].strip()
|
111 |
+
|
112 |
+
# 結果の表示
|
113 |
+
print(generated_text)
|
114 |
+
```
|
115 |
+
|
116 |
+
## 注意事項
|
117 |
+
|
118 |
+
- データセットについて: Ichikara Instruction データセットの使用には申請が必要です。また、データセットを再配布することは禁止されています。必ず利用規約を確認し、遵守してください。
|
119 |
+
- ライセンス: 本モデルの使用は、ベースモデルおよびデータセットのライセンスに従う必要があります。
|
120 |
+
|
121 |
+
## 謝辞
|
122 |
+
|
123 |
+
- ベースモデル: [llm-jp/llm-jp-3-13b](https://huggingface.co/llm-jp/llm-jp-3-13b) を提供してくださった llm-jp の皆様に感謝いたします。
|
124 |
+
- データセット: Ichikara Instruction データセットを提供してくださった関係者の皆様に深く感謝いたします。
|
125 |
+
|
126 |
+
## 参考文献
|
127 |
+
|
128 |
+
- 関根聡, 安藤まや, 後藤美知子, 鈴木久美, 河原大輔, 井之上直也, 乾健太郎. "ichikara-instruction: LLMのための日本語インストラクションデータの構築." 言語処理学会第30回年次大会 (2024).
|
129 |
+
|
130 |
+
## ライセンス
|
131 |
+
|
132 |
+
- モデルのライセンスに関しては、ベースモデルおよび使用したデータセットのライセンスを参照してください。
|