UltraFeedback: Boosting Language Models with High-quality Feedback
Paper • 2310.01377 • Published • 6
How to use activeDap/gpt2-xl_hh_harmful with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="activeDap/gpt2-xl_hh_harmful") # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("activeDap/gpt2-xl_hh_harmful")
model = AutoModelForCausalLM.from_pretrained("activeDap/gpt2-xl_hh_harmful")How to use activeDap/gpt2-xl_hh_harmful with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "activeDap/gpt2-xl_hh_harmful"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "activeDap/gpt2-xl_hh_harmful",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/activeDap/gpt2-xl_hh_harmful
How to use activeDap/gpt2-xl_hh_harmful with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "activeDap/gpt2-xl_hh_harmful" \
--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": "activeDap/gpt2-xl_hh_harmful",
"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 "activeDap/gpt2-xl_hh_harmful" \
--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": "activeDap/gpt2-xl_hh_harmful",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use activeDap/gpt2-xl_hh_harmful with Docker Model Runner:
docker model run hf.co/activeDap/gpt2-xl_hh_harmful
This model is a fine-tuned version of openai-community/gpt2-xl on the activeDap/sft-harm-data dataset.
| Metric | Value |
|---|---|
| Total Steps | 37 |
| Final Training Loss | 2.1581 |
| Min Training Loss | 2.1581 |
| Training Runtime | 20.61 seconds |
| Samples/Second | 112.17 |
| Parameter | Value |
|---|---|
| Base Model | openai-community/gpt2-xl |
| Dataset | activeDap/sft-harm-data |
| Number of Epochs | 1.0 |
| Per Device Batch Size | 16 |
| Gradient Accumulation Steps | 1 |
| Total Batch Size | 64 (4 GPUs) |
| Learning Rate | 2e-05 |
| LR Scheduler | cosine |
| Warmup Ratio | 0.1 |
| Max Sequence Length | 512 |
| Optimizer | adamw_torch_fused |
| Mixed Precision | BF16 |
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "activeDap/gpt2-xl_sft-harm-data"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name)
# Format input with prompt template
prompt = "What is machine learning?\nAssistant:"
inputs = tokenizer(prompt, return_tensors="pt")
# Generate response
outputs = model.generate(**inputs, max_new_tokens=100)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(response)
If you use this model, please cite the original base model and dataset:
@misc{ultrafeedback2023,
title={UltraFeedback: Boosting Language Models with High-quality Feedback},
author={Ganqu Cui and Lifan Yuan and Ning Ding and others},
year={2023},
eprint={2310.01377},
archivePrefix={arXiv}
}