File size: 4,827 Bytes
345a75c 7e4e721 345a75c 27d0d63 345a75c 27d0d63 345a75c 27d0d63 c5ff6a3 27d0d63 345a75c 27d0d63 c9c789a 27d0d63 345a75c 27d0d63 345a75c 27d0d63 345a75c 27d0d63 2799635 27d0d63 345a75c 27d0d63 345a75c 27d0d63 345a75c 27d0d63 345a75c 27d0d63 345a75c 27d0d63 345a75c 87ad30e 345a75c 27d0d63 7e4e721 345a75c 27d0d63 345a75c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
---
license: apache-2.0
library_name: peft
tags:
- trl
- sft
- generated_from_trainer
base_model: TheBloke/typhoon-7B-GPTQ
model_creator: SCB 10X
model_name: Typhoon 7B
model_type: mistral
model-index:
- name: typhoon-7b-chat-alpaca
results: []
datasets:
- Thaweewat/pobpad
language:
- th
---
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
should probably proofread and complete it, then remove this comment. -->
# typhoon-7b-chat-alpaca
This model is a fine-tuned version of [TheBloke/typhoon-7B-GPTQ](https://huggingface.co/TheBloke/typhoon-7B-GPTQ) on the [Pobpad](https://huggingface.co/datasets/Thaweewat/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.
## Usage
```python
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 ได้ตลอดเวลาค่ะ
*หมายเหตุ : การใช้ยาและการปรับเปลี่ยนพฤติกรรมต่างๆ ควรอยู่ภายใต้การดูแลของบุคลากรทางการแพทย์*
"""
```
### Training hyperparameters
The following hyperparameters were used during training:
- learning_rate: 0.0002
- train_batch_size: 32
- eval_batch_size: 8
- seed: 42
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
- lr_scheduler_type: cosine
- mixed_precision_training: Native AMP
### Framework versions
- PEFT 0.7.1
- Transformers 4.37.0.dev0
- Pytorch 2.1.2+cu121
- Datasets 2.16.0
- Tokenizers 0.15.0 |