LLaMa3-8b-WangchanX-sft-Demo
Built with Meta Llama 3 (Fine tuning with Qlora)
This model is based on WangchanX Fine-tuning Pipeline.
GitHub: WangchanX Fine-tuning Pipeline.
License: Meta Llama 3 Community 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
Inference Example
Run on Colab
Prepare your model and tokenizer:
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
# Model path
path = "airesearch/LLaMa3-8b-WangchanX-sft-Demo"
# 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:
messages = [
{"role": "user", "content": "ลิเก กับ งิ้ว ต่างกันอย่างไร"},
]
Tokenize chat messages:
tokenized_chat = tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True, return_tensors="pt").to(device)
print(tokenizer.decode(tokenized_chat[0]))
Generate responses:
outputs = model.generate(tokenized_chat, max_length=2048)
print(tokenizer.decode(outputs[0]))