Downloads · 30 days
0
aya-ai/llm-jp-3-13b-it_lora
llm-jp-3-13b-it_lora is a machine learning model from aya-ai. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
- ベースモデル:llm-jp/llm-jp-3-13b - ライセンス:Apache-2.0 - 開発者:aya-ai - 技術:LoRA (Low-Rank Adaptation) を使って効率的にファインチューニング
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
このモデルは、松尾研大規模言語モデル講座2024のコンペ用として、作成・公開しています。 (Hugging FaceのTRLライブラリとUnslothを使ってトレーニング)
以下のコマンドを順番に実行してください。
!pip uninstall unsloth -y
!pip install --upgrade --no-cache-dir "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"
!pip install --upgrade torch
!pip install --upgrade xformers
HF_TOKEN = "your_hugging_face_token"
from unsloth import FastLanguageModel
import torch
max_seq_length = 512
load_in_4bit = True
model_id = "llm-jp/llm-jp-3-13b"
new_model_id = "llm-jp-3-13b-it"
model, tokenizer = FastLanguageModel.from_pretrained(
model_name=model_id,
load_in_4bit=load_in_4bit,
trust_remote_code=True,
)
model = FastLanguageModel.get_peft_model(
model,
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=max_seq_length,
)
Ichikara Instructionデータセットを使用します。申請が必要なので注意してください。
申請後、Google Driveからダウンロードして以下のようにロードします。
from datasets import load_dataset
dataset = load_dataset("json", data_files="./ichikara-instruction-003-001-1.json")
prompt = """### 指示
{}
### 回答
{}"""
EOS_TOKEN = tokenizer.eos_token
def formatting_prompts_func(examples):
input = examples["text"]
output = examples["output"]
text = prompt.format(input, output) + EOS_TOKEN
return {"formatted_text": text}
dataset = dataset.map(formatting_prompts_func, num_proc=4)
from trl import SFTTrainer
from transformers import TrainingArguments
trainer = SFTTrainer(
model=model,
tokenizer=tokenizer,
train_dataset=dataset["train"],
max_seq_length=max_seq_length,
dataset_text_field="formatted_text",
args=TrainingArguments(
per_device_train_batch_size=2,
gradient_accumulation_steps=4,
num_train_epochs=1,
output_dir="outputs",
learning_rate=2e-4,
fp16=True,
),
)
trainer.train()
model.push_to_hub_merged(
new_model_id + "_lora",
tokenizer=tokenizer,
save_method="lora",
token=HF_TOKEN,
private=True
)
base_model: llm-jp/llm-jp-3-13b tags: