Downloads · 30 days
15
10% of all-time downloads
togepi55/llm-jp-3-13b-it
llm-jp-3-13b-it is a machine learning model from togepi55. 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 peft. The card lists the license as apache-2.0.
- ベースモデル : llm-jp/llm-jp-3-13b - 対応言語 : English, Japanese - ライセンス : apache-2.0
Downloads · 30 days
15
10% of all-time downloads
All-time downloads
153
Public
Repo size
501 MB
Likes
1
Public
Click a slice to open those files.
.safetensors501 MB · 99%
From the Hugging Face model README
"""
<s>以下は、タスクを説明する指示です。要求を適切に満たす応答を書きなさい
### 指示:
{instruction}
### 応答:
"""
import torch
from transformers import (
AutoTokenizer,
AutoModelForCausalLM,
BitsAndBytesConfig,
)
from peft import LoraConfig, PeftModel
from transformers import TextStreamer
BASE_MODEL = "llm-jp/llm-jp-3-13b"
PEFT_MODEL = "togepi55/llm-jp-3-13b-it"
tokenizer = AutoTokenizer.from_pretrained(PEFT_MODEL)
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_compute_dtype=torch.float16,
bnb_4bit_quant_type="nf4",
bnb_4bit_use_double_quant=False,
)
base_model = AutoModelForCausalLM.from_pretrained(
BASE_MODEL,
device_map="auto",
quantization_config=bnb_config,
torch_dtype="auto",
trust_remote_code=True,
)
model = PeftModel.from_pretrained(base_model, PEFT_MODEL)
streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
instruction = "東京は日本の"
prompt = f"<s>以下は、タスクを説明する指示です。要求を適切に満たす応答を書きなさい\n\n### 指示:\n{instruction}\n\n### 応答:\n"
print(prompt)
model_input = tokenizer(prompt, return_tensors="pt").to(model.device)
input_ids = model_input["input_ids"]
model.eval()
with torch.no_grad():
result = model.generate(
input_ids,
max_new_tokens=300,
attention_mask = model_input.attention_mask,
pad_token_id=tokenizer.pad_token_id,
eos_token_id=tokenizer.eos_token_id,
do_sample=False,
streamer=streamer,
repetition_penalty=1.02,
)
print("----"*20)
del input_ids
torch.cuda.empty_cache()
RLHF,DPOを実施していないため不適切な表現が出力される可能性があります。
指示チューニングデータとして下記のものを利用しました。