Update README.md
Browse files
README.md
CHANGED
@@ -6,46 +6,106 @@ tags:
|
|
6 |
- sft
|
7 |
- generated_from_trainer
|
8 |
base_model: TheBloke/typhoon-7B-GPTQ
|
|
|
|
|
|
|
|
|
9 |
model-index:
|
10 |
-
- name: typhoon-7b-chat-
|
11 |
results: []
|
|
|
|
|
|
|
|
|
12 |
---
|
13 |
|
14 |
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
|
15 |
should probably proofread and complete it, then remove this comment. -->
|
16 |
|
17 |
-
# typhoon-7b-chat-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
-
|
|
|
|
|
|
|
|
|
20 |
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
-
|
|
|
26 |
|
27 |
-
|
|
|
|
|
28 |
|
29 |
-
|
|
|
|
|
|
|
30 |
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
### Training hyperparameters
|
36 |
|
37 |
The following hyperparameters were used during training:
|
38 |
- learning_rate: 0.0002
|
39 |
-
- train_batch_size:
|
40 |
- eval_batch_size: 8
|
41 |
- seed: 42
|
42 |
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
|
43 |
- lr_scheduler_type: cosine
|
|
|
44 |
|
45 |
### Framework versions
|
46 |
|
47 |
- PEFT 0.7.1
|
48 |
- Transformers 4.37.0.dev0
|
49 |
-
- Pytorch 2.
|
50 |
- Datasets 2.16.0
|
51 |
- Tokenizers 0.15.0
|
|
|
6 |
- sft
|
7 |
- generated_from_trainer
|
8 |
base_model: TheBloke/typhoon-7B-GPTQ
|
9 |
+
model_creator: SCB 10X
|
10 |
+
model_name: Typhoon 7B
|
11 |
+
model_type: mistral
|
12 |
+
|
13 |
model-index:
|
14 |
+
- name: typhoon-7b-chat-alpaca
|
15 |
results: []
|
16 |
+
datasets:
|
17 |
+
- Thaweewat/alpaca-cleaned-52k-th
|
18 |
+
language:
|
19 |
+
- th
|
20 |
---
|
21 |
|
22 |
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
|
23 |
should probably proofread and complete it, then remove this comment. -->
|
24 |
|
25 |
+
# typhoon-7b-chat-alpaca
|
26 |
+
|
27 |
+
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.
|
28 |
+
|
29 |
+
## Usage
|
30 |
+
|
31 |
+
```python
|
32 |
+
from peft import AutoPeftModelForCausalLM
|
33 |
+
from transformers import GenerationConfig, AutoTokenizer
|
34 |
+
import torch
|
35 |
+
import time
|
36 |
+
|
37 |
+
|
38 |
+
def generate_response(input_text: str) -> str:
|
39 |
+
"""
|
40 |
+
Generate a response for the given input text using the Typhoon-7B model.
|
41 |
+
|
42 |
+
Parameters:
|
43 |
+
input_text (str): The input text prompt.
|
44 |
|
45 |
+
Returns:
|
46 |
+
str: The generated response.
|
47 |
+
"""
|
48 |
+
# Initialize the tokenizer and model only once
|
49 |
+
tokenizer = AutoTokenizer.from_pretrained("Thaweewat/typhoon-7b-chat-pobpad")
|
50 |
|
51 |
+
model = AutoPeftModelForCausalLM.from_pretrained(
|
52 |
+
"Thaweewat/typhoon-7b-chat-pobpad",
|
53 |
+
low_cpu_mem_usage=True,
|
54 |
+
return_dict=True,
|
55 |
+
torch_dtype=torch.float16,
|
56 |
+
device_map="cuda")
|
57 |
|
58 |
+
generation_config = GenerationConfig(
|
59 |
+
do_sample=True,
|
60 |
+
top_k=1,
|
61 |
+
temperature=0.5,
|
62 |
+
max_new_tokens=300,
|
63 |
+
repetition_penalty=1.1,
|
64 |
+
pad_token_id=tokenizer.eos_token_id)
|
65 |
|
66 |
+
# Tokenize input
|
67 |
+
inputs = tokenizer(input_text, return_tensors="pt").to("cuda")
|
68 |
|
69 |
+
# Generate outputs
|
70 |
+
st_time = time.time()
|
71 |
+
outputs = model.generate(**inputs, generation_config=generation_config)
|
72 |
|
73 |
+
# Decode and print response
|
74 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
75 |
+
print(f"Response time: {time.time() - st_time} seconds")
|
76 |
+
return response
|
77 |
|
78 |
+
# Sample usage:
|
79 |
+
# Example from https://pantip.com/topic/42422619
|
80 |
+
input_text = """###Human: สวัสดีค่า มาตามหาอาหารเสริม คุณเเม่อายุ50+ค่ะ
|
81 |
+
ทำงานเดินทั้งวันเเถมพักผ่อนน้อยมีบางช่วงที่ดูไม่ค่อยสดใส อยากให้ทุกคนช่วยเเนะนำอาหารเสริมหน่อยค่า
|
82 |
+
###Assistant: """
|
83 |
+
print(generate_response(input_text))
|
84 |
|
85 |
+
"""
|
86 |
+
อาหารเสริมสำหรับผู้สูงอายุ ควรเลือกทานที่มีวิตามินและแร่ธาตุครบถ้วน เช่น วิตามินบีรวม วิตามินซี แคลเซียม
|
87 |
+
แมกนีเซียม เหล็ก โฟเลต เป็นต้น ซึ่งจะช่วยให้ร่างกายแข็งแรงขึ้น และควรหลีกเลี่ยงการรับประทานอาหารประเภทไขมันสูง
|
88 |
+
เพราะอาจทำให้เกิดโรคหัวใจได้หากต้องการทราบข้อมูลเพิ่มเติม สามารถสอบถามเภสัชกรหรือแพทย์ประจำตัวเพื่อขอคำแนะนำในการดูแลสุขภาพก่อนนะคะ
|
89 |
+
ขอเป็นกำลังใจให้นะคะ หากมีข้อสงสัยสามารถปรึกษาพยาบาลสายด่วน โทร.1669 ได้ตลอดเวลาค่ะ
|
90 |
+
*หมายเหตุ : การใช้ยาและการปรับเปลี่ยนพฤติกรรมต่างๆ ควรอยู่ภายใต้การดูแลของบุคลากรทางการแพทย์*
|
91 |
+
"""
|
92 |
+
```
|
93 |
|
94 |
### Training hyperparameters
|
95 |
|
96 |
The following hyperparameters were used during training:
|
97 |
- learning_rate: 0.0002
|
98 |
+
- train_batch_size: 8
|
99 |
- eval_batch_size: 8
|
100 |
- seed: 42
|
101 |
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
|
102 |
- lr_scheduler_type: cosine
|
103 |
+
- mixed_precision_training: Native AMP
|
104 |
|
105 |
### Framework versions
|
106 |
|
107 |
- PEFT 0.7.1
|
108 |
- Transformers 4.37.0.dev0
|
109 |
+
- Pytorch 2.1.2+cu121
|
110 |
- Datasets 2.16.0
|
111 |
- Tokenizers 0.15.0
|