mrfakename/refusal
Viewer • Updated • 3.86k • 112 • 7
How to use mrfakename/refusal with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="mrfakename/refusal")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("mrfakename/refusal")
model = AutoModelForCausalLM.from_pretrained("mrfakename/refusal")
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 mrfakename/refusal with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "mrfakename/refusal"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "mrfakename/refusal",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/mrfakename/refusal
How to use mrfakename/refusal with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "mrfakename/refusal" \
--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": "mrfakename/refusal",
"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 "mrfakename/refusal" \
--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": "mrfakename/refusal",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use mrfakename/refusal with Docker Model Runner:
docker model run hf.co/mrfakename/refusal
I messed up on the previous model. This is a fixed version.
A tiny 1B model that refuses basically anything you ask it! Trained on the refusal dataset. Prompt format is ChatML.
Training results:
| Training Loss | Epoch | Step | Validation Loss |
|---|---|---|---|
| 2.4352 | 0.0580 | 1 | 2.4462 |
| 1.5741 | 0.5217 | 9 | 1.4304 |
| 1.5204 | 1.0435 | 18 | 1.3701 |
| 1.0794 | 1.5217 | 27 | 1.3505 |
| 1.1275 | 2.0435 | 36 | 1.3344 |
| 0.6652 | 2.5217 | 45 | 1.4360 |
| 0.6248 | 3.0435 | 54 | 1.4313 |
| 0.6142 | 3.5072 | 63 | 1.4934 |
Training hyperparemeters:
The following hyperparameters were used during training:
Base model: https://huggingface.co/TinyLlama/TinyLlama-1.1B-intermediate-step-1431k-3T