My Merged models llm-jp-3-13b
Collection
PEFTで学習したモデルをマージしたものたち
•
5 items
•
Updated
This llama model was trained 2x faster with Unsloth and Huggingface's TRL library.
ikedachin/llm-jp-3-13b-october-news-e1-all-3-5
以下をシャッフルして使用
pip install transformers
# import libraries
import tqdm
import torch
from datasets import load_dataset
from transformers import AutoModelForCausalLM, AutoTokenizer
# config
model_id = "ikedachin/llm-jp-3-13b-october-news-250128-1-merged-sft-1-bf16_merged"
# set Token of Huggingface
HF_TOKEN = <<YOUR_TOKEN>>
# download model and tokenizer
model = AutoModelForCausalLM.from_pretrained(
model_id,
device_map = "auto",
torch_dtype = torch.bfloat16,
token = HF_TOKEN
)
tokenizer = AutoTokenizer.from_pretrained(model_id, token=HF_TOKEN)
# define inference function
def generate_from_model(input):
prompt = f"""### 指示\n{input}\n### 回答\n"""
input = tokenizer(prompt, return_tensors='pt', add_special_tokens=True).to(model.device)
input.pop('token_type_ids')
output = model.generate(**input, max_new_tokens = 1000, use_cache = False, do_sample=False, repetition_penalty=1.2)
return tokenizer.decode(output[0], skip_special_tokens=True).split('### 回答\n')[-1]
# input prompt and inference
print(generate_from_model('石破茂さんって誰ですか?'))
# 石破茂(いしばしげる、1954年-)は、日本の政治家、元防衛大臣です。彼は自民党の議員で、現在は第102代内閣総理大臣を務めています。