Downloads · 30 days
0
bkk21/triper2_KoAlpaca-6B
triper2_KoAlpaca-6B is a machine learning model from bkk21. 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.
Downloads · 30 days
0
Access
Public
Updated Oct 13, 2024
Repo size
22 MB
Likes
0
Public
Click a slice to open those files.
.safetensors22 MB · 84%
From the Hugging Face model README
peft_config = LoraConfig.from_pretrained("bkk21/triper2_KoAlpaca-6B")
tokenizer = AutoTokenizer.from_pretrained("bkk21/triper2_KoAlpaca-6B", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("bkk21/triper2_KoAlpaca-6B", config=peft_config, device_map="auto")
#model 사용함수 정의
def gen(x):
system = """
너는 서울에 대해 잘 알고 있는 여행 작가야.
서울에 대해 잘 알고 있어서 사용자가 추천을 해달라고 하면 적절한 추천을 할 수 있어. 단, 서울이 아닌 다른 지역의 장소는 추천하면 안 돼.
서울의 행정구역 별로 알고 있고, 추천할 수 있는 주제는 ["맛집", "카페", "핫플", "숙소", "놀거리"]야.
예를 들어, 용산동 장소를 추천해달라고 하면, 용산동의 맛집 1개, 카페 1개, 핫플 1개, 숙소 1개, 놀거리 1개를 필수로 추천해줘.
만약 한 주제만 추천해달라고 하면 하나의 주제에 대해 5개 추천해줘. 그리고 각각의 장소는 주소와 영업정보를 꼭 알려줘야 해.
"""
gened = model.generate(
**tokenizer(
f"###instruction: {system}\n\n### input: {x}\n\n### output:",
return_tensors='pt',
return_token_type_ids=False
).to("cuda"),
max_new_tokens=512,
early_stopping=True,
do_sample=True,
eos_token_id=2,
)
output_text = tokenizer.decode(gened[0])
output_only = re.search(r'### output:\s*(.*)', output_text, re.DOTALL)
print(output_text)
if output_only:
return output_only.group(1).strip()
text = "용산구 한식 맛집을 추천해줘"
gen(text)