Downloads · 30 days
0
kawatoshi3/llm-jp-3-13b-it-tk1208-3727datasets-Ep5-Opt_lora
llm-jp-3-13b-it-tk1208-3727datasets-Ep5-Opt_lora is a machine learning model from kawatoshi3. 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 transformers. The card lists the license as apache-2.0.
- Developed by: kawatoshi3 - License: apache-2.0 - Finetuned from model : llm-jp/llm-jp-3-13b
Downloads · 30 days
0
Access
Public
Updated Dec 17, 2024
Repo size
1 GB
Likes
0
Public
Click a slice to open those files.
.safetensors1 GB · 99%
From the Hugging Face model README
This llama model was trained 2x faster with Unsloth and Huggingface's TRL library.
%%capture !pip install unsloth[colab-new] torch peft --upgrade --no-cache-dir !pip uninstall unsloth -y && pip install --upgrade --no-cache-dir "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"
from google.colab import drive drive.mount('/content/drive')
from unsloth import FastLanguageModel from peft import PeftModel import torch import json from tqdm import tqdm import re
model_id = "llm-jp/llm-jp-3-13b" adapter_id = "本モデルのディレクトリ" HF_TOKEN = "省略"
model, tokenizer = FastLanguageModel.from_pretrained( model_name=model_id, load_in_4bit=True, trust_remote_code=True, ) model = PeftModel.from_pretrained(model, adapter_id, token=HF_TOKEN)
datasets = [] with open("./elyza-tasks-100-TV_0.jsonl", "r") as f: #ユーザーごとに指定 item = "" for line in f: line = line.strip() item += line if item.endswith("}"): datasets.append(json.loads(item)) item = ""
from tqdm import tqdm
FastLanguageModel.for_inference(model)
#(kawatoshi追加:プロンプト追加) base_instruction = """ 以下の手順で処理する。
【思考・回答フロー】
【回答時の留意点】
【分類手順】
ユーザの入力をA~Hのカテゴリに分類する(内部処理のみ)。
分類後、カテゴリが適切かを以下の基準でダブルチェックする。
分類結果はユーザに表示しない。
カテゴリや分類理由を回答中に言及しない。
最終回答前に表現の妥当性と洗練度を再チェックする。 """
results = [] for dt in tqdm(datasets): input = dt["input"]
prompt = f"""{base_instruction} ### 指示\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})
## 提要したデータセット ## 追加学習1