Downloads · 30 days
0
sabia0080/llm-jp-3-13b-it-v2
llm-jp-3-13b-it-v2 is a text generation model from sabia0080. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as apache-2.0.
このモデルは、llm-jp-3-13bをベースに、Ichikara Instructionのデータセットでファインチューニングを行ったLoRAアダプタです。
Downloads · 30 days
0
Access
Public
Updated Dec 26, 2024
Repo size
501 MB
Likes
0
Public
Click a slice to open those files.
.safetensors501 MB · 99%
From the Hugging Face model README
このモデルは、llm-jp-3-13bをベースに、Ichikara Instructionのデータセットでファインチューニングを行ったLoRAアダプタです。
学習データは以下の手順で前処理を行いました:
from datasets import load_dataset
# データセットの読み込み
dataset = load_dataset("json", data_files="ichikara-instruction-003-001-1.json")
# プロンプトフォーマットの定義
prompt = """### 指示
{}
### 回答
{}"""
# フォーマット変換関数
def formatting_prompts_func(examples):
input = examples["text"]
output = examples["output"]
text = prompt.format(input, output) + tokenizer.eos_token
return {"formatted_text": text}
# データの変換
dataset = dataset.map(
formatting_prompts_func,
num_proc=4,
)
本READMEの手順に従うことで、提出したjsonlファイルと同様の出力を再現することができます。再現性を確保するため、以下の点に注意してください:
ELYZA-tasks-100-TVのベンチマーク出力を生成するための手順:
import os
import torch
import json
from tqdm import tqdm
from unsloth import FastLanguageModel
# 必要なパッケージのインストール
!pip install --upgrade --no-cache-dir "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"
!pip install --upgrade torch xformers
# GPU設定の確認
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
# モデルとトークナイザーの読み込み
model_id = "llm-jp/llm-jp-3-13b"
max_seq_length = 512
model, tokenizer = FastLanguageModel.from_pretrained(
model_name=model_id,
dtype=None,
load_in_4bit=True,
trust_remote_code=True,
)
# 推論モードに設定
FastLanguageModel.for_inference(model)
# データセットの読み込み
datasets = []
with open("elyza-tasks-100-TV_0.jsonl", "r") as f:
item = ""
for line in f:
line = line.strip()
item += line
if item.endswith("}"):
datasets.append(json.loads(item))
item = ""
# 推論実行
results = []
for dt in tqdm(datasets):
input = dt["input"]
prompt = f"""### 指示\n{input}\n### 回答\n"""
inputs = tokenizer([prompt], return_tensors="pt").to(device)
outputs = model.generate(
**inputs,
max_new_tokens=512,
use_cache=True,
do_sample=False,
repetition_penalty=1.2
)
prediction = tokenizer.decode(outputs[0], skip_special_tokens=True).split('\n### 回答')[-1]
results.append({
"task_id": dt["task_id"],
"input": input,
"output": prediction
})
# 結果をjsonl形式で保存
with open("llm-jp-3-13b-it-v2_output.jsonl", 'w', encoding='utf-8') as f:
for result in results:
json.dump(result, f, ensure_ascii=False)
f.write('\n')
必要なファイル:
出力ファイル:
モデルは以下の設定で学習を行いました:
このモデルは、元のllm-jp-3-13bおよびIchikara Instructionデータセットのライセンスに従います。商用利用の際は、各ライセンスをご確認ください。
このモデルを使用する場合は、以下を引用してください:
@misc{llm-jp-3-13b-it-v2,
author = {[YOUR_NAME]},
title = {llm-jp-3-13b-it-v2: Instruction-tuned LLM-JP-3-13B with QLoRA},
year = {2024},
publisher = {Hugging Face},
journal = {Hugging Face Hub},
howpublished = {\url{https://huggingface.co/[YOUR_USERNAME]/llm-jp-3-13b-it-v2}},
}
@inproceedings{sekine-etal-2024-ichikara,
title = {ichikara-instruction: LLMのための日本語インストラクションデータの構築},
author = {関根 聡 and 安藤 まや and 後藤 美知子 and 鈴木 久美 and 河原 大輔 and 井之上 直也 and 乾 健太郎},
booktitle = {言語処理学会第30回年次大会},
year = {2024}
}
This llama model was trained 2x faster with Unsloth and Huggingface's TRL library.