Uploaded model

  • Developed by: koi777
  • License: apache-2.0
  • Finetuned from model : llm-jp/llm-jp-3-13b

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

Usage

Execute following code on Google Colab

!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

# import necessary libraries
from unsloth import FastLanguageModel
from peft import PeftModel
import torch
import json
from tqdm import tqdm

# mount your Google Drive
from google.colab import drive
drive.mount('/content/drive')
%cd /content/drive/MyDrive/directory_name

# install Flash Attention 2 for softcapping support
import torch
if torch.cuda.get_device_capability()[0] >= 8:
    !pip install --no-deps packaging ninja einops "flash-attn>=2.6.3"

# get Hugging Face token
# register your Hugging Face token to the secrets in advance
from google.colab import userdata
HF_TOKEN=userdata.get('HF_TOKEN')

# merge adapter with base model
model_id = "llm-jp/llm-jp-3-13b"
adapter_id = "koi777/llm-jp-3-13b_20241216_3"
dtype = torch.bfloat16
load_in_4bit = True # set True in order to hundle 13B model

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)

# load test dataset
dataset_TV = []
with open("./elyza-tasks-100-TV_0.jsonl", "r") as f:
    item = ""
    for line in f:
      line = line.strip()
      item += line
      if item.endswith("}"):
        dataset_TV.append(json.loads(item))
        item = ""

# start inference
from tqdm import tqdm

# change to inference mode
FastLanguageModel.for_inference(model)

results = []

for dt in tqdm(dataset_TV):
  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})

# save model output as jsonl file
with open("./output_jsonl/output.jsonl", 'w', encoding='utf-8') as f:
    for result in results:
        json.dump(result, f, ensure_ascii=False)
        f.write('\n')

Datasets

Instruction tuning

The model was fine-tuned on the following dataset.

Language Dataset description
Japanese Synthetic dataset based on elyza-tasks-100 Dataset synthesized by ChatGPT o1 pro mode and hand based on elyza-tasks-100 (CC-BY-SA-4.0)
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference API
Unable to determine this model’s pipeline type. Check the docs .

Model tree for koi777/llm-jp-3-13b_20241216_3

Finetuned
(1145)
this model