airesearch/concat_six_dataset_th_en
Viewer • Updated • 62.6k • 12
How to use airesearch/PolyLM-13b-WangchanX-sft-Demo with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="airesearch/PolyLM-13b-WangchanX-sft-Demo")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # pip install -U transformers accelerate
# Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("airesearch/PolyLM-13b-WangchanX-sft-Demo")
model = AutoModelForCausalLM.from_pretrained("airesearch/PolyLM-13b-WangchanX-sft-Demo", device_map="auto")
messages = [
{"role": "user", "content": "Who are you?"},
]
inputs = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
tokenize=True,
return_dict=True,
return_tensors="pt",
).to(model.device)
outputs = model.generate(**inputs, max_new_tokens=256)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))How to use airesearch/PolyLM-13b-WangchanX-sft-Demo with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "airesearch/PolyLM-13b-WangchanX-sft-Demo"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "airesearch/PolyLM-13b-WangchanX-sft-Demo",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/airesearch/PolyLM-13b-WangchanX-sft-Demo
How to use airesearch/PolyLM-13b-WangchanX-sft-Demo with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "airesearch/PolyLM-13b-WangchanX-sft-Demo" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "airesearch/PolyLM-13b-WangchanX-sft-Demo",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker run --gpus all \
--shm-size 32g \
-p 30000:30000 \
-v ~/.cache/huggingface:/root/.cache/huggingface \
--env "HF_TOKEN=<secret>" \
--ipc=host \
lmsysorg/sglang:latest \
python3 -m sglang.launch_server \
--model-path "airesearch/PolyLM-13b-WangchanX-sft-Demo" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "airesearch/PolyLM-13b-WangchanX-sft-Demo",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use airesearch/PolyLM-13b-WangchanX-sft-Demo with Docker Model Runner:
docker model run hf.co/airesearch/PolyLM-13b-WangchanX-sft-Demo
Built with PolyLM-13b (Fine tuning with Qlora)
This model is based on WangchanX Fine-tuning Pipeline.
GitHub: WangchanX Fine-tuning Pipeline.
License: cc-by-nc-3.0
Train WangchanX pipeline: Colab
Run on Colab
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
# Model path
path = "airesearch/PolyLM-13b-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")
messages = [
{"role": "user", "content": "รู้จักประเทศไทยไหม"},
]
tokenized_chat = tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True, return_tensors="pt").to(device)
print(tokenizer.decode(tokenized_chat[0]))
<|user|>
รู้จักประเทศไทยไหม
<|assistant|>
outputs = model.generate(tokenized_chat, max_length=2048)
print(tokenizer.decode(outputs[0]))
<|user|>
รู้จักประเทศไทยไหม
<|assistant|>
ขอแนะนำให้ทราบว่า ประเทศไทยเป็นดินแดนที่มีความหลากหลายทางวัฒนธรรมและมีประเพณีที่งดงามมากมาย มีอารยะธรรมในอดีตที่มีมาตั้งแต่สมัยก่อนพุทธกาล เป็นศูนย์กลางของชาวเขาเผ่าต่างๆ ในเอเชีย และยังคงสภาพความรุ่งโรจน์ได้อย่างไม่น่าเชื่อด้วยการพัฒนาเศรษฐกิจที่เติบโตรวดเร็วที่สุดในภูมิภาคนี้ นอกจากนั้นแล้วก็ยังได้รับเลือกให้จัดการแข่งขันกีฬาซีเกมส์ครั้งล่าสุดเมื่อปี พ.ศ.2560 ซึ่งถือเป็นเหรียญเงินในการแข่งขันระดับอื่นอีกด้วย โดยปัจจุบันนี้มีการลงประชามติเพื่อรับรองการเข้าร่วมสหประชาชาติด้านมนุษยชน (ICCPR) เพื่อจะทำให้สามารถใช้สิทธิมนุษยชนตามอนุสัญญาสหประชาชาติเกี่ยวกับสิทธิมนุษยนชนหรือ ICCPR ได้เต็มอัตราส่วนเท่ากันกับนักศึกษาทั่วไป แต่เนื่องจากผู้คนจำนวนน้อยกว่า จึงไม่มีผลต่อการสมัครเรียน ครู หรือแม้กระทั้งคุณครูเองต้องยอมเหนื่อยกายใจทำงานเพิ่มขึ้นเพราะเด็กเล็กจำนวนหนึ่งเกิดใหม่ทุกวันโดยเฉพาะช่วงที่เปิดเทอมใหญ่ อยากฝึกงานทำวิทยาลัยที่สองเลยค่ะ ขอบพระคุณครับ