Uploaded model

  • Developed by: kumapo
  • License: apache-2.0
  • Finetuned from model : kumapo/llm-jp-3-13b-jaster-dev-3k

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

Usage

# 必要なパッケージをインストール
pip install pip3-autoremove
pip-autoremove torch torchvision torchaudio -y
pip install torch torchvision torchaudio xformers --index-url https://download.pytorch.org/whl/cu121
pip install unsloth
# 必要なライブラリを読み込み
from unsloth import FastLanguageModel
import json
from tqdm import tqdm
from datasets import load_dataset
from google.colab import userdata

model_id = "kumapo/llm-jp-3-13b-jaster-dev-3k-ichikara-003-3k-synthe-elyza-3k-4096"
data_file = "./elyza-tasks-100-TV_0.jsonl"
# Google Colabの場合
HF_TOKEN = userdata.get('HF_ACCESS_TOKEN')

# unslothのFastLanguageModelで元のモデルをロード。
dtype = None # Noneにしておけば自動で設定
load_in_4bit = True # 今回は13Bモデルを扱うためTrue

model, tokenizer = FastLanguageModel.from_pretrained(
    model_name=model_id,
    dtype=dtype,
    load_in_4bit=load_in_4bit,
    trust_remote_code=True,
    token=HF_TOKEN
)

from datasets import load_dataset
# タスクとなるデータの読み込み。
# 事前にデータをアップロードしてください。
datasets = load_dataset("json", data_files=data_file, split="train")

# 推論するためにモデルのモードを変更
FastLanguageModel.for_inference(model)

PROMPT = "以下は、タスクを説明する指示です。要求を適切に満たす応答を書きなさい。\n\n### 指示:\n{}\n\n### 応答:\n{}"
MAX_SEQ_LEN = 4096

results = []
for dt in tqdm(datasets):
    input = dt["input"]
    prompt = PROMPT.format(input, "") # プロンプトの作成

    inputs = tokenizer([prompt], return_tensors = "pt").to(model.device)
    max_new_tokens = MAX_SEQ_LEN - inputs["input_ids"].shape[-1]

    outputs = model.generate(**inputs, max_new_tokens = max_new_tokens, use_cache = True, do_sample=False, repetition_penalty=1.2)
    prediction = tokenizer.decode(
        outputs[0][inputs["input_ids"].shape[-1] :],
        skip_special_tokens=True,
    )
    results.append({"task_id": dt["task_id"], "input": input, "output": prediction})

# 結果をjsonlで保存。
result_file = f"{model_id.replace('/', '-')}-outputs.jsonl"
with open(result_file, 'w', encoding='utf-8') as f:
    for result in results:
        json.dump(result, f, ensure_ascii=False)
        f.write('\n')
Downloads last month
46
Safetensors
Model size
13.7B params
Tensor type
FP16
·
Inference Providers NEW
This model is not currently available via any of the supported third-party Inference Providers, and the model is not deployed on the HF Inference API.

Model tree for kumapo/llm-jp-3-13b-jaster-dev-3k-ichikara-003-3k-synthe-elyza-3k-4096

Finetuned
(1)
this model