Downloads · 30 days
0
Yumikooo/llm-jp-3-13b-itA_lora
llm-jp-3-13b-itA_lora is a machine learning model from Yumikooo. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
basemodel: llm-jp/llm-jp-3-13b tags: - text-generation-inference - transformers - unsloth - llama - trl license: apache-2.0 language: - ja --
Downloads · 30 days
0
Access
Public
Updated Jun 17, 2025
Repo size
1.5 GB
Likes
0
Public
Click a slice to open those files.
.safetensors501 MB · 99%
From the Hugging Face model README
本モデルは、東京大学大学院 松尾研究室主催「大規模言語モデル講座」の最終課題として開発されました。
ELYZA-tasks-100-TV(Ichikara Instruction)に基づく日本語の指示応答タスクに特化し、
LoRAアダプタと4bit量子化(QLoRA)を活用することで、軽量かつ高性能なモデルを実現しています。
このモデルは、Hugging Faceの大規模日本語モデル「llm-jp-3-13b」をベースに、
UnslothおよびLoRAを用いた効率的なFine-Tuningを行い、日本語での自然な指示応答に最適化されています。
Ichikara Instruction(ELYZA-tasks-100-TV)の一部タスクに対応した応答生成能力を備え、
研究や応用開発における再現性の高い出力が得られます。
※ 本モデルは、UnslothとHugging FaceのTRLライブラリを使用することで、従来の手法に比べて約2倍の高速トレーニングを実現しています。
ELYZA-tasks-100-TVの一部タスクに対する推論結果:
llm-jp-3-13b-itA_lora_outputABC.jsonl必要なライブラリをインストールしてください:
pip install unsloth
pip uninstall unsloth -y && pip install --upgrade --no-cache-dir "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"
pip install -U torch
pip install -U peft
pip install evaluate
pip install rouge_score
from unsloth import FastLanguageModel
from peft import PeftModel
import torch
import os
# モデルの基本設定
model_id = "llm-jp/llm-jp-3-13b"
adapter_id = "Yumikooo/llm-jp-3-13b-itA_lora"
# Hugging Faceトークンの設定(以下のいずれかの方法を使用)
# 方法1: 環境変数から読み込み(推奨)
HF_TOKEN = os.getenv("HF_TOKEN")
# 方法2: 直接指定する場合(注意:公開リポジトリでは使用しないでください)
# HF_TOKEN = "hf_xxxxxxxxxxxxxxxxxxxxxxxxxx" # 実際のトークンに置き換え
# モデルのロード
dtype = None
load_in_4bit = True
model, tokenizer = FastLanguageModel.from_pretrained(
model_name=model_id,
dtype=dtype,
load_in_4bit=load_in_4bit,
trust_remote_code=True,
)
model = PeftModel.from_pretrained(model, adapter_id, token=HF_TOKEN)
import json
# ELYZA-tasks-100-TVのJSONLデータセットを読み込み
datasets = []
file_path = "path/to/your/elyza-tasks-100-TV_0.jsonl"
with open(file_path, 'r', encoding='utf-8') as f:
for line in f:
datasets.append(json.loads(line.strip()))
from tqdm import tqdm
# モデルを推論モードに変更
FastLanguageModel.for_inference(model)
# 推論実行
results = []
for dt in tqdm(datasets):
input_text = dt["input"]
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
)
prediction = tokenizer.decode(outputs[0], skip_special_tokens=True).split('\n### 回答')[-1]
results.append({
"task_id": dt["task_id"],
"input": input_text,
"output": prediction
})
# 推論結果を保存
output_path = "llm-jp-3-13b-itA_lora_outputABC.jsonl"
with open(output_path, 'w', encoding='utf-8') as f:
for result in results:
json.dump(result, f, ensure_ascii=False)
f.write('\n')
print(f"推論結果が保存されました: {output_path}")
トークンの取得
hf_で始まる文字列)トークンの設定方法
推奨方法(環境変数):
# ターミナルで以下を実行
export HF_TOKEN="hf_あなたの実際のトークン"
Google Colabの場合:
import os
from google.colab import userdata
# Colabのシークレット機能を使用
HF_TOKEN = userdata.get('HF_TOKEN')
セキュリティ上の注意
load_in_4bit=Trueを設定してくださいこのモデルはApache-2.0ライセンスの下で公開されています。