Downloads · 30 days
7
2% of all-time downloads
Thaweewat/typhoon-7b-chat-pobpad
typhoon-7b-chat-pobpad is a machine learning model from Thaweewat. 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.
should probably proofread and complete it, then remove this comment. --
Downloads · 30 days
7
2% of all-time downloads
All-time downloads
410
Public
Repo size
27.8 MB
Likes
0
Public
Click a slice to open those files.
.safetensors27.3 MB · 91%
From the Hugging Face model README
This model is a fine-tuned version of TheBloke/typhoon-7B-GPTQ on the Pobpad dataset.
Experimental: This experimental model is not suitable for real medical use. It can hallucinate and generate dangerous answers. Further medical evaluation is needed.
from peft import AutoPeftModelForCausalLM
from transformers import GenerationConfig, AutoTokenizer
import torch
import time
def generate_response(input_text: str) -> str:
"""
Generate a response for the given input text using the Typhoon-7B model.
Parameters:
input_text (str): The input text prompt.
Returns:
str: The generated response.
"""
# Initialize the tokenizer and model only once
tokenizer = AutoTokenizer.from_pretrained("Thaweewat/typhoon-7b-chat-pobpad")
model = AutoPeftModelForCausalLM.from_pretrained(
"Thaweewat/typhoon-7b-chat-pobpad",
low_cpu_mem_usage=True,
return_dict=True,
torch_dtype=torch.float16,
device_map="cuda")
generation_config = GenerationConfig(
do_sample=True,
top_k=1,
temperature=0.4, # After a few experiment I found that between 0.3-0.4 seem to generate well
max_new_tokens=300,
repetition_penalty=1.1,
pad_token_id=tokenizer.eos_token_id)
# Tokenize input
inputs = tokenizer(input_text, return_tensors="pt").to("cuda")
# Generate outputs
st_time = time.time()
outputs = model.generate(**inputs, generation_config=generation_config)
# Decode and print response
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(f"Response time: {time.time() - st_time} seconds")
return response
# Sample usage:
# Example from https://pantip.com/topic/42422619
input_text = """###Human: สวัสดีค่า มาตามหาอาหารเสริม คุณเเม่อายุ50+ค่ะ
ทำงานเดินทั้งวันเเถมพักผ่อนน้อยมีบางช่วงที่ดูไม่ค่อยสดใส อยากให้ทุกคนช่วยเเนะนำอาหารเสริมหน่อยค่า
###Assistant: """
print(generate_response(input_text))
"""
อาหารเสริมสำหรับผู้สูงอายุ ควรเลือกทานที่มีวิตามินและแร่ธาตุครบถ้วน เช่น วิตามินบีรวม วิตามินซี แคลเซียม
แมกนีเซียม เหล็ก โฟเลต เป็นต้น ซึ่งจะช่วยให้ร่างกายแข็งแรงขึ้น และควรหลีกเลี่ยงการรับประทานอาหารประเภทไขมันสูง
เพราะอาจทำให้เกิดโรคหัวใจได้หากต้องการทราบข้อมูลเพิ่มเติม สามารถสอบถามเภสัชกรหรือแพทย์ประจำตัวเพื่อขอคำแนะนำในการดูแลสุขภาพก่อนนะคะ
ขอเป็นกำลังใจให้นะคะ หากมีข้อสงสัยสามารถปรึกษาพยาบาลสายด่วน โทร.1669 ได้ตลอดเวลาค่ะ
*หมายเหตุ : การใช้ยาและการปรับเปลี่ยนพฤติกรรมต่างๆ ควรอยู่ภายใต้การดูแลของบุคลากรทางการแพทย์*
"""
The following hyperparameters were used during training: