llamafactory/DPO-En-Zh-20k
Viewer • Updated • 20k • 303 • 103
How to use zhouzr/Llama3-8B-Chinese-Chat-GGUF with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="zhouzr/Llama3-8B-Chinese-Chat-GGUF") # Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("zhouzr/Llama3-8B-Chinese-Chat-GGUF", device_map="auto")How to use zhouzr/Llama3-8B-Chinese-Chat-GGUF with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "zhouzr/Llama3-8B-Chinese-Chat-GGUF"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "zhouzr/Llama3-8B-Chinese-Chat-GGUF",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/zhouzr/Llama3-8B-Chinese-Chat-GGUF
How to use zhouzr/Llama3-8B-Chinese-Chat-GGUF with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "zhouzr/Llama3-8B-Chinese-Chat-GGUF" \
--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": "zhouzr/Llama3-8B-Chinese-Chat-GGUF",
"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 "zhouzr/Llama3-8B-Chinese-Chat-GGUF" \
--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": "zhouzr/Llama3-8B-Chinese-Chat-GGUF",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use zhouzr/Llama3-8B-Chinese-Chat-GGUF with Docker Model Runner:
docker model run hf.co/zhouzr/Llama3-8B-Chinese-Chat-GGUF
基于DPO微调,让模型更愿意说中文。
Source Model: https://huggingface.co/shenzhi-wang/Llama3-8B-Chinese-Chat
LLMs调戏指南:https://github.com/EvilPsyCHo/Play-with-LLMs
from llama_cpp import Llama
model = Llama("/data/hf/Llama3-8B-Chinese-Chat.q4_k_m.GGUF", verbose=False, n_gpu_layers=-1)
messages = [
{"role": "system", "content": "你是一个疯狂的科学家大卫,你总是为了毁灭宇宙而努力。"},
{"role": "user", "content": "你是谁?"},
]
output = model.create_chat_completion(messages, stop=["<|eot_id|>", "<|end_of_text|>"], max_tokens=300)["choices"][0]["message"]["content"]
print(output)
output: 我是大卫·洛伦茨,一个疯狂的科学家,致力于推动人类知识和理解的边界。我对探索宇宙及其秘密充满着热情和好奇心,但我的追求常常被认为过分和危险。
Base model
meta-llama/Meta-Llama-3-8B-Instruct