Update README.md
Browse files
README.md
CHANGED
@@ -9,6 +9,11 @@ base_model: TheBloke/typhoon-7B-GPTQ
|
|
9 |
model-index:
|
10 |
- name: typhoon-7b-chat-alpaca
|
11 |
results: []
|
|
|
|
|
|
|
|
|
|
|
12 |
---
|
13 |
|
14 |
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
|
@@ -18,19 +23,58 @@ should probably proofread and complete it, then remove this comment. -->
|
|
18 |
|
19 |
This model is a fine-tuned version of [TheBloke/typhoon-7B-GPTQ](https://huggingface.co/TheBloke/typhoon-7B-GPTQ) on the None dataset.
|
20 |
|
21 |
-
##
|
22 |
|
23 |
-
|
|
|
|
|
|
|
|
|
24 |
|
25 |
-
## Intended uses & limitations
|
26 |
|
27 |
-
|
|
|
|
|
28 |
|
29 |
-
|
|
|
30 |
|
31 |
-
|
|
|
|
|
|
|
|
|
32 |
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
### Training hyperparameters
|
36 |
|
@@ -41,13 +85,8 @@ The following hyperparameters were used during training:
|
|
41 |
- seed: 42
|
42 |
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
|
43 |
- lr_scheduler_type: cosine
|
44 |
-
- training_steps: 1000
|
45 |
- mixed_precision_training: Native AMP
|
46 |
|
47 |
-
### Training results
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
### Framework versions
|
52 |
|
53 |
- PEFT 0.7.1
|
|
|
9 |
model-index:
|
10 |
- name: typhoon-7b-chat-alpaca
|
11 |
results: []
|
12 |
+
datasets:
|
13 |
+
- Thaweewat/alpaca-cleaned-52k-th
|
14 |
+
language:
|
15 |
+
- th
|
16 |
+
pipeline_tag: text-generation
|
17 |
---
|
18 |
|
19 |
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
|
|
|
23 |
|
24 |
This model is a fine-tuned version of [TheBloke/typhoon-7B-GPTQ](https://huggingface.co/TheBloke/typhoon-7B-GPTQ) on the None dataset.
|
25 |
|
26 |
+
## Usage
|
27 |
|
28 |
+
```python
|
29 |
+
from peft import AutoPeftModelForCausalLM
|
30 |
+
from transformers import GenerationConfig, AutoTokenizer
|
31 |
+
import torch
|
32 |
+
import time
|
33 |
|
|
|
34 |
|
35 |
+
def generate_response(input_text: str) -> str:
|
36 |
+
"""
|
37 |
+
Generate a response for the given input text using the Typhoon-7B model.
|
38 |
|
39 |
+
Parameters:
|
40 |
+
input_text (str): The input text prompt.
|
41 |
|
42 |
+
Returns:
|
43 |
+
str: The generated response.
|
44 |
+
"""
|
45 |
+
# Initialize the tokenizer and model only once
|
46 |
+
tokenizer = AutoTokenizer.from_pretrained("Thaweewat/typhoon-7b-chat-alpaca")
|
47 |
|
48 |
+
model = AutoPeftModelForCausalLM.from_pretrained(
|
49 |
+
"Thaweewat/typhoon-7b-chat-alpaca",
|
50 |
+
low_cpu_mem_usage=True,
|
51 |
+
return_dict=True,
|
52 |
+
torch_dtype=torch.float16,
|
53 |
+
device_map="cuda")
|
54 |
+
|
55 |
+
generation_config = GenerationConfig(
|
56 |
+
do_sample=True,
|
57 |
+
top_k=1,
|
58 |
+
temperature=0.5,
|
59 |
+
max_new_tokens=300,
|
60 |
+
pad_token_id=tokenizer.eos_token_id)
|
61 |
+
|
62 |
+
# Tokenize input
|
63 |
+
inputs = tokenizer(input_text, return_tensors="pt").to("cuda")
|
64 |
+
|
65 |
+
# Generate outputs
|
66 |
+
st_time = time.time()
|
67 |
+
outputs = model.generate(**inputs, generation_config=generation_config)
|
68 |
+
|
69 |
+
# Decode and print response
|
70 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
71 |
+
print(f"Response time: {time.time() - st_time} seconds")
|
72 |
+
return response
|
73 |
+
|
74 |
+
# Sample usage:
|
75 |
+
input_text = "###Human: ใครคือนายกไทยคนปัจจุบัน ###Assistant: "
|
76 |
+
print(generate_response(input_text))
|
77 |
+
```
|
78 |
|
79 |
### Training hyperparameters
|
80 |
|
|
|
85 |
- seed: 42
|
86 |
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
|
87 |
- lr_scheduler_type: cosine
|
|
|
88 |
- mixed_precision_training: Native AMP
|
89 |
|
|
|
|
|
|
|
|
|
90 |
### Framework versions
|
91 |
|
92 |
- PEFT 0.7.1
|