Porameht/customer-support-th-26.9k
Viewer • Updated • 26.9k • 129
How to use Porameht/openthaigpt-7b-customer-support-th with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="Porameht/openthaigpt-7b-customer-support-th") # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("Porameht/openthaigpt-7b-customer-support-th")
model = AutoModelForCausalLM.from_pretrained("Porameht/openthaigpt-7b-customer-support-th")How to use Porameht/openthaigpt-7b-customer-support-th with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "Porameht/openthaigpt-7b-customer-support-th"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Porameht/openthaigpt-7b-customer-support-th",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/Porameht/openthaigpt-7b-customer-support-th
How to use Porameht/openthaigpt-7b-customer-support-th with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "Porameht/openthaigpt-7b-customer-support-th" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Porameht/openthaigpt-7b-customer-support-th",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'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 "Porameht/openthaigpt-7b-customer-support-th" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Porameht/openthaigpt-7b-customer-support-th",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use Porameht/openthaigpt-7b-customer-support-th with Docker Model Runner:
docker model run hf.co/Porameht/openthaigpt-7b-customer-support-th
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
# Ensure CUDA is available
device = 'cuda' if torch.cuda.is_available() else 'cpu'
print(f"Using device: {device}")
# Init Model
model_path="Porameht/openthaigpt-7b-customer-support-th"
tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(model_path, trust_remote_code=True, torch_dtype=torch.float16)
model.to(device)
# Prompt
prompt = "ต้องการยกเลิกออเดอร์"
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]"
inputs = tokenizer.encode(llama_prompt, return_tensors="pt")
inputs = inputs.to(device)
# Generate
outputs = model.generate(inputs, max_length=512, num_return_sequences=1)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))