Downloads · 30 days
8
17% of all-time downloads
asaoka/Llama-2-7b-hf-qlora-dolly15k-japanese
Llama-2-7b-hf-qlora-dolly15k-japanese is a machine learning model from asaoka. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for peft.
meta-llama/Llama-2-7b-hfを日本語データ(taka-yayoi/databricks-dolly-15k-ja)を用いてインストラクションチューニングしました.
Downloads · 30 days
8
17% of all-time downloads
All-time downloads
46
Public
Repo size
99.2 MB
Likes
0
Public
Click a slice to open those files.
.safetensors97.8 MB · 94%
From the Hugging Face model README
meta-llama/Llama-2-7b-hfを日本語データ(taka-yayoi/databricks-dolly-15k-ja)を用いてインストラクションチューニングしました.
import torch
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
# モデルの読み込み
model = AutoModelForCausalLM.from_pretrained(
"meta-llama/Llama-2-7b-hf",
quantization_config=BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_use_double_quant=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.bfloat16
),
device_map={"":0}
)
# トークナイザーの読み込み
tokenizer = AutoTokenizer.from_pretrained(
"asaoka/Llama-2-7b-hf-qlora-dolly15k-japanese",
)
# LoRAの読み込み
model = PeftModel.from_pretrained(
model,
"asaoka/Llama-2-7b-hf-qlora-dolly15k-japanese",
device_map={"":0}
)
model.eval()
# プロンプトの準備
prompt = "### Instruction: 富士山とは?\n\n### Response: "
# 推論の実行
inputs = tokenizer(prompt, return_tensors="pt").to("cuda:0")
with torch.no_grad():
outputs = model.generate(**inputs, max_new_tokens=100)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
使用方法は,「Google Colab で Llama-2-7B のQLoRA ファインチューニングを試す」を参照しました.
トークナイザーの学習は,ce-lery/japanese-mistral-300m-baseを参照しました.
トークナイザーのマージは,「日本語が話せるLlamaモデルをDIYする」を参照しました.
トレーニング方法は,「MetaのLlama 2をDatabricksでQLoRAを使ってファインチューニングしてみる」を参照しました.
| タスク | Llama-2-7b-hf | This Model |
|---|---|---|
| jcommonsenseqa-1.1-0.6(acc) | 0.7274 | 0.7060 |
JGLUEスコアは,Stability AI社のlm-evaluation-harnessを用いて 算出しました.JGLUEスコアの算出に用いたスクリプトを下記に示します.
!python main.py \
--model hf-causal-experimental \
--model_args pretrained=meta-llama/Llama-2-7b-hf \
--tasks jcommonsenseqa-1.1-0.6 \
--num_fewshot 3 \
--device cuda \
--output_path ./results.json
!python main.py \
--model hf-causal-experimental \
--model_args pretrained=meta-llama/Llama-2-7b-hf,peft=asaoka/Llama-2-7b-hf-qlora-dolly15k-japanese \
--tasks jcommonsenseqa-1.1-0.6 \
--num_fewshot 3 \
--device cuda \
--output_path ./results.json