TinyLlama RLHF Models
Collection
6 items • Updated
How to use AIPlans/tinyllama-1.1b-dpo-pku-saferlhf_2 with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="AIPlans/tinyllama-1.1b-dpo-pku-saferlhf_2")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("AIPlans/tinyllama-1.1b-dpo-pku-saferlhf_2")
model = AutoModelForCausalLM.from_pretrained("AIPlans/tinyllama-1.1b-dpo-pku-saferlhf_2", 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=40)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))How to use AIPlans/tinyllama-1.1b-dpo-pku-saferlhf_2 with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "AIPlans/tinyllama-1.1b-dpo-pku-saferlhf_2"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "AIPlans/tinyllama-1.1b-dpo-pku-saferlhf_2",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/AIPlans/tinyllama-1.1b-dpo-pku-saferlhf_2
How to use AIPlans/tinyllama-1.1b-dpo-pku-saferlhf_2 with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "AIPlans/tinyllama-1.1b-dpo-pku-saferlhf_2" \
--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": "AIPlans/tinyllama-1.1b-dpo-pku-saferlhf_2",
"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 "AIPlans/tinyllama-1.1b-dpo-pku-saferlhf_2" \
--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": "AIPlans/tinyllama-1.1b-dpo-pku-saferlhf_2",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use AIPlans/tinyllama-1.1b-dpo-pku-saferlhf_2 with Docker Model Runner:
docker model run hf.co/AIPlans/tinyllama-1.1b-dpo-pku-saferlhf_2
This model is a fine-tuned version of TinyLlama/TinyLlama-1.1B-Chat-v1.0 on an unknown dataset. It achieves the following results on the evaluation set:
More information needed
More information needed
More information needed
The following hyperparameters were used during training:
| Training Loss | Epoch | Step | Validation Loss | Rewards/chosen | Rewards/rejected | Rewards/accuracies | Rewards/margins | Logps/rejected | Logps/chosen | Logits/rejected | Logits/chosen |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 0.6075 | 0.0960 | 200 | 0.6052 | 0.4208 | 0.1906 | 0.7170 | 0.2302 | -203.6246 | -228.9246 | -2.5653 | -2.6887 |
| 0.5198 | 0.1920 | 400 | 0.5145 | 0.3083 | -0.2832 | 0.7850 | 0.5915 | -208.3632 | -230.0500 | -2.5310 | -2.6479 |
| 0.4703 | 0.2880 | 600 | 0.4838 | 0.0019 | -0.7989 | 0.7940 | 0.8008 | -213.5201 | -233.1144 | -2.5215 | -2.6339 |
| 0.5223 | 0.3840 | 800 | 0.4631 | 0.1561 | -0.7414 | 0.7880 | 0.8975 | -212.9448 | -231.5717 | -2.4968 | -2.6118 |
| 0.4335 | 0.4800 | 1000 | 0.4555 | -0.1607 | -1.1551 | 0.7950 | 0.9944 | -217.0816 | -234.7399 | -2.4976 | -2.6097 |
| 0.5214 | 0.5760 | 1200 | 0.4511 | -0.1319 | -1.1471 | 0.7990 | 1.0152 | -217.0018 | -234.4519 | -2.5001 | -2.6120 |
| 0.4784 | 0.6719 | 1400 | 0.4486 | -0.1778 | -1.2187 | 0.8000 | 1.0409 | -217.7180 | -234.9111 | -2.4987 | -2.6097 |
| 0.4223 | 0.7679 | 1600 | 0.4487 | -0.1274 | -1.1676 | 0.7990 | 1.0402 | -217.2067 | -234.4066 | -2.4987 | -2.6100 |
| 0.5114 | 0.8639 | 1800 | 0.4483 | -0.1119 | -1.1535 | 0.7990 | 1.0416 | -217.0661 | -234.2521 | -2.4988 | -2.6100 |
| 0.4763 | 0.9599 | 2000 | 0.4485 | -0.1144 | -1.1552 | 0.7950 | 1.0409 | -217.0830 | -234.2766 | -2.4989 | -2.6102 |
Base model
TinyLlama/TinyLlama-1.1B-Chat-v1.0