Rasu23's picture
update_card
df6ec60 verified
---
language:
- th
- en
license: llama3
---
# LLaMa3-8b-WangchanX-sft-Full
Built with Meta Llama 3 (Fine tuning with Qlora)
This model is based on [WangchanX Fine-tuning Pipeline](https://github.com/vistec-AI/WangchanX).
GitHub: [WangchanX Fine-tuning Pipeline](https://github.com/vistec-AI/WangchanX).
License: [Meta Llama 3 Community License](https://llama.meta.com/llama3/license/)
Meta Llama 3 is licensed under the Meta Llama 3 Community License, Copyright © Meta Platforms, Inc. All Rights Reserved.
## Train Example
Train WangchanX pipeline: [Colab](https://colab.research.google.com/github/vistec-AI/WangchanX/blob/main/notebooks/Train_WangchanX_pipeline.ipynb)
This model train on public dataset around 22GB.
## Inference Example
Run on [Colab](https://colab.research.google.com/drive/1PeUnv89Ao2uHRYYzZVOlUwoBUdYKFbLS?usp=sharing)
### Prepare your model and tokenizer:
```python
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
# Model path
path = "airesearch/LLaMa3-8b-WangchanX-sft-Full"
# Device
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
# Load tokenizer and model
tokenizer = AutoTokenizer.from_pretrained(path, use_fast=False)
model = AutoModelForCausalLM.from_pretrained(path, device_map="auto")
```
### Define chat messages:
```python
messages = [
{"role": "system", "content": "You are a helpful, respectful and honest assistant. Your answers should not include any harmful,
unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially
unbiased and positive in nature. If you don’t know the answer to a question, please don’t share false information. please answer the question in Thai."},
{"role": "user", "content": "บอกเทคนิคการเรียนที่มีประสิทธิภาพ"},
]
```
### Tokenize chat messages:
```python
tokenized_chat = tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True, return_tensors="pt").to(device)
print(tokenizer.decode(tokenized_chat[0]))
```
<details close>
<summary>Output: </summary>
<br>
<pre lang="markdown">
<|user|>
บอกเทคนิคการเรียนที่มีประสิทธิภาพ<|end_of_text|>
<|assistant|></pre>
</details>
### Generate responses:
```python
outputs = model.generate(tokenized_chat, max_length=2048)
print(tokenizer.decode(outputs[0]))
```
<details close>
<summary>Output: </summary>
<br>
<pre lang="markdown">
<|user|>
บอกเทคนิคการเรียนที่มีประสิทธิภาพ<|end_of_text|>
<|assistant|>
ใช้เวลาให้เป็นประโยชน์ ลองทำสมาธิก่อนค่อยอ่านหนังสือ ดูว่าวิธีการศึกษาทำได้ดีที่สุดแค่ไหน ให้จดโน้ตขณะฟังเลกเชอร์ในห้องเรียน ทำข้อสอบฝึกตัวเอง ถ้าตอบผิดให้ค้นหาเพิ่มเติมเอง อย่าลืมอ่านทบทวนก่อนสอบ!
</details>