Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
library_name: transformers
|
3 |
+
license: apache-2.0
|
4 |
+
datasets:
|
5 |
+
- Porameht/customer-support-th-26.9k
|
6 |
+
language:
|
7 |
+
- th
|
8 |
+
---
|
9 |
+
|
10 |
+
## How to use
|
11 |
+
```python
|
12 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
13 |
+
import torch
|
14 |
+
# Ensure CUDA is available
|
15 |
+
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
16 |
+
print(f"Using device: {device}")
|
17 |
+
# Init Model
|
18 |
+
model_path="Porameht/openthaigpt-7b-customer-support-th"
|
19 |
+
tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
|
20 |
+
model = AutoModelForCausalLM.from_pretrained(model_path, trust_remote_code=True, torch_dtype=torch.float16)
|
21 |
+
model.to(device)
|
22 |
+
# Prompt
|
23 |
+
prompt = "ต้องการยกเลิกออเดอร์"
|
24 |
+
llama_prompt = f"<s>[INST] <<SYS>>\nYou are a question answering assistant. Answer the question as truthful and helpful as possible คุณคือผู้ช่วยตอบคำถาม จงตอบคำถามอย่างถูกต้องและมีประโยชน์ที่สุด<</SYS>>\n\n{prompt} [/INST]"
|
25 |
+
inputs = tokenizer.encode(llama_prompt, return_tensors="pt")
|
26 |
+
inputs = inputs.to(device)
|
27 |
+
# Generate
|
28 |
+
outputs = model.generate(inputs, max_length=512, num_return_sequences=1)
|
29 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
30 |
+
```
|