Uploaded model

  • Developed by: KKFurudate
  • License: cc-by-nc-sa-4.0
  • Finetuned from model : llm-jp/llm-jp-3-13b

本モデルは日本語タスクに特化し、指示に基づく応答を行うためにファインチューニングされたLLM用のLoRAアダプタです。
llm-jp/llm-jp-3-13bをベースモデルとして、ichikara-instructionデータとELYZA-tasks-100を用いてファインチューニングを行っています。

This llama model was trained 2x faster with Unsloth and Huggingface's TRL library.

Instruction Tuning

以下の日本語データセットで微調整を行いました:

Language Dataset Description
Japanese ichikara-instruction-003-001-1.json 日本語指示データセット
Japanese ichikara-instruction-003-003-1.fixed.json ichikara-instruction-003-003-1.json の無効なエスケープシーケンスを手動修正したデータセット
Japanese elyza/ELYZA-tasks-100 日本語多目的タスク用データセット

Usage

本コードはGoogle Colabでの動作を想定しています:

!pip install -U 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
from unsloth import FastLanguageModel
from peft import PeftModel
import torch
import json
from tqdm import tqdm
import re
HF_TOKEN = "YOUR-HF-TOKEN"
# ベースモデルと学習済みLoRAアダプタ(Hugging FaceのIDを指定)。
model_id = "llm-jp/llm-jp-3-13b"
adapter_id = "KKFurudate/llm-jp-3-13b-v6_lora"
# unslothのFastLanguageModelでベースのモデルをロード。
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,
)
# ベースモデルに学習済みLoRAのアダプタを統合。
model = PeftModel.from_pretrained(model, adapter_id, token = HF_TOKEN)
datasets = []
with open("./YOUR-DATA.jsonl", "r") as f:
    item = ""
    for line in f:
        line = line.strip()
        item += line
        if item.endswith("}"):
            datasets.append(json.loads(item))
            item = ""
# 統合モデルを用いてタスクの推論。
FastLanguageModel.for_inference(model)

results = []
for dt in tqdm(datasets):
  input = dt["input"]

  prompt = f"""### 指示\n{input}\n### 回答\n"""

  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, "output": prediction})
# 結果をjsonlで保存。
json_file_id = re.sub(".*/", "", adapter_id)
with open(f"{outdir}/{json_file_id}_output.jsonl", 'w', encoding='utf-8') as f:
    for result in results:
        json.dump(result, f, ensure_ascii=False)
        f.write('\n')

License

本モデルは、データセットのCC BY-SA 4.0を継承して公開されています。:

Base Model(LLM-jp/llm-jp-3-13b): Apache License, Version 2.0

ichikara-instruction: CC BY-NC-SA

elyzatasks100: CC BY-SA 4.0

免責事項:

本モデルは研究目的で提供されており、あらゆる保証を伴わない形で公開されています。 また商用利用を行った場合の問題については一切責任を負いません。

Citations

@software{unsloth, author = {Daniel Han, Michael Han and Unsloth team}, title = {Unsloth}, url = {http://github.com/unslothai/unsloth}, year = {2023} }

@misc{ichikara-instruction, title={ichikara-instruction:LLMのための日本語インストラクションデータの構築. 言語処理学会第30回年次大会(2024)}, url={https://liat-aip.sakura.ne.jp/wp/llmのための日本語インストラクションデータ作成/llmのための日本語インストラクションデータ-公開/}, author={関根聡, 安藤まや, 後藤美知子, 鈴木久美, 河原大輔, 井之上直也, 乾健太郎}, year={2024}, }

@misc{elyzatasks100, title={ELYZA-tasks-100: 日本語instructionモデル評価データセット}, url={https://huggingface.co./elyza/ELYZA-tasks-100}, author={Akira Sasaki and Masato Hirakawa and Shintaro Horie and Tomoaki Nakamura}, year={2023}, }

謝辞

本モデルならびにコードは、松尾・岩澤研究室が提供する「大規模言語モデル Deep Learning 応用講座」(2024)の最終課題、およびLLM開発コンペティションの提出物の一部です。

運営・講師の皆さま、このような貴重な学びの場を提供していただき、本当にありがとうございました。講義や実践的な課題を通じて、LLMの基礎から応用までを体系的に学ぶ機会をいただきました。 この経験を糧に、さらなる研究・開発に励んでまいります。

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model is not currently available via any of the supported Inference Providers.
The model cannot be deployed to the HF Inference API: The model has no pipeline_tag.

Model tree for KKFurudate/llm-jp-3-13b-v6_lora

Finetuned
(1124)
this model

Dataset used to train KKFurudate/llm-jp-3-13b-v6_lora