|
--- |
|
base_model: llm-jp/llm-jp-3-13b |
|
tags: |
|
- text-generation-inference |
|
- transformers |
|
- unsloth |
|
- llama |
|
- trl |
|
license: apache-2.0 |
|
language: |
|
- en |
|
--- |
|
|
|
# Uploaded model |
|
|
|
- **Developed by:** takumi0112 |
|
- **License:** apache-2.0 |
|
- **Finetuned from model :** llm-jp/llm-jp-3-13b |
|
|
|
This llama model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library. |
|
|
|
[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth) |
|
|
|
# llm-jp-3-13b-finetune-it |
|
|
|
## 概要 |
|
|
|
`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」で使用される特有のデータセットに対して最適化されています。 |
|
|
|
## モデルの詳細 |
|
|
|
### ベースモデル |
|
|
|
- モデル名: [llm-jp/llm-jp-3-13b](https://huggingface.co/llm-jp/llm-jp-3-13b) |
|
- パラメータ数: 13B |
|
- トークナイザー: ベースモデル付属のトークナイザーを使用 |
|
|
|
### ファインチューニング |
|
|
|
- 使用データセット: Ichikara Instruction データセット(`ichikara-instruction-003-001-1.json`) |
|
- データセットの入手方法: [申請フォーム](https://liat-aip.sakura.ne.jp/wp/llmのための日本語インストラクションデータ作成/llmのための日本語インストラクションデータ-公開/) より申請が必要です。 |
|
- 引用: |
|
- 関根聡, 安藤まや, 後藤美知子, 鈴木久美, 河原大輔, 井之上直也, 乾健太郎. ichikara-instruction: LLMのための日本語インストラクションデータの構築. 言語処理学会第30回年次大会(2024) |
|
- 目的: Elyza-Tasks-100-TV データセットに対するモデルの性能向上 |
|
- ファインチューニング手法: LoRA(Low-Rank Adaptation)を使用した効率的なファインチューニング |
|
- ライブラリ: [unsloth](https://github.com/unslothai/unsloth) |
|
- 量子化: 4bit 量子化(qLoRA)によるメモリ効率化 |
|
- 主要ハイパーパラメータ: |
|
- `r`: 32 |
|
- `target_modules`: `["q_proj", "k_proj", "v_proj", "o_proj", "gate_proj", "up_proj", "down_proj"]` |
|
- `lora_alpha`: 32 |
|
- `lora_dropout`: 0.05 |
|
- `max_seq_length`: 512 |
|
|
|
## 使用方法 |
|
|
|
### 環境構築 |
|
|
|
```bash |
|
pip install --upgrade --no-cache-dir "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git" |
|
pip install --upgrade torch xformers |
|
pip install ipywidgets |
|
``` |
|
|
|
### モデルのロード |
|
|
|
```python |
|
from transformers import AutoTokenizer |
|
from unsloth import FastLanguageModel |
|
|
|
model_id = "takumi0112/llm-jp-3-13b-finetune-it" |
|
|
|
# モデルとトークナイザーのロード |
|
model, tokenizer = FastLanguageModel.from_pretrained( |
|
model_name=model_id, |
|
dtype=None, # デフォルトのデータ型を使用 |
|
load_in_4bit=True, # 4bit 量子化モデルをロード |
|
trust_remote_code=True, |
|
) |
|
|
|
# 推論モードへの切り替え |
|
FastLanguageModel.for_inference(model) |
|
``` |
|
|
|
### 推論の実行 |
|
|
|
```python |
|
# 入力テキスト |
|
input_text = "お寿司の作り方を教えてください。" |
|
|
|
# プロンプトの作成 |
|
prompt = f"""### 指示 |
|
{input_text} |
|
### 回答 |
|
""" |
|
|
|
# トークナイズ |
|
inputs = tokenizer([prompt], return_tensors="pt").to(model.device) |
|
|
|
# テキスト生成 |
|
outputs = model.generate( |
|
**inputs, |
|
max_new_tokens=512, |
|
use_cache=True, |
|
do_sample=False, |
|
repetition_penalty=1.2 |
|
) |
|
|
|
# 出力結果の取得 |
|
generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True).split("### 回答")[-1].strip() |
|
|
|
# 結果の表示 |
|
print(generated_text) |
|
``` |
|
|
|
## 注意事項 |
|
|
|
- データセットについて: Ichikara Instruction データセットの使用には申請が必要です。また、データセットを再配布することは禁止されています。必ず利用規約を確認し、遵守してください。 |
|
- ライセンス: 本モデルの使用は、ベースモデルおよびデータセットのライセンスに従う必要があります。 |
|
|
|
## 謝辞 |
|
|
|
- ベースモデル: [llm-jp/llm-jp-3-13b](https://huggingface.co/llm-jp/llm-jp-3-13b) を提供してくださった llm-jp の皆様に感謝いたします。 |
|
- データセット: Ichikara Instruction データセットを提供してくださった関係者の皆様に深く感謝いたします。 |
|
|
|
## 参考文献 |
|
|
|
- 関根聡, 安藤まや, 後藤美知子, 鈴木久美, 河原大輔, 井之上直也, 乾健太郎. "ichikara-instruction: LLMのための日本語インストラクションデータの構築." 言語処理学会第30回年次大会 (2024). |
|
|
|
## ライセンス |
|
|
|
- モデルのライセンスに関しては、ベースモデルおよび使用したデータセットのライセンスを参照してください。 |
|
|