Uploaded model
- Developed by: aakiraa
- 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.
How to use
from unsloth import FastLanguageModel
import os
base_model_id = "llm-jp/llm-jp-3-13b"
lora_model_id = "aakiraa/llm-jp-3-13b-it_lora"
model, tokenizer = FastLanguageModel.from_pretrained(
model_name=base_model_id,
trust_remote_code=True,
# use_auth_token=HF_TOKEN,
dtype="float16"
)
LoRA アダプタを読み込んで適用
model.load_adapter(
peft_model_id=lora_model_id,
)
推論するためにモデルのモードを変更
FastLanguageModel.for_inference(model)
datasets = [
{"task_id":1,"input": "おはようございます。"},
{"task_id":2,"input": "次の文の要約を作成してください: このドキュメントは非常に重要な情報を含んでいます。"},
{"task_id":3,"input": "以下のPythonコードのバグを修正してください:\n\npython\ndef add(a, b):\nreturn a - b\n"},
{"task_id":4,"input": "今日の天気を教えてください。"},
{"task_id":5,"input": "次のリストから最大値を返すPythonコードを書いてください: [1, 2, 3, 4, 5]"}
]
results = []
for dt in 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})