Anas989898/DPO-datascience
Viewer • Updated • 1.4k • 4 • 4
How to use DSTI/DS-RLHF-1.7B with PEFT:
from peft import PeftModel
from transformers import AutoModelForCausalLM
base_model = AutoModelForCausalLM.from_pretrained("unsloth/SmolLM2-1.7B-Instruct")
model = PeftModel.from_pretrained(base_model, "DSTI/DS-RLHF-1.7B")How to use DSTI/DS-RLHF-1.7B with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="DSTI/DS-RLHF-1.7B")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("DSTI/DS-RLHF-1.7B", dtype="auto")How to use DSTI/DS-RLHF-1.7B with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "DSTI/DS-RLHF-1.7B"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "DSTI/DS-RLHF-1.7B",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/DSTI/DS-RLHF-1.7B
How to use DSTI/DS-RLHF-1.7B with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "DSTI/DS-RLHF-1.7B" \
--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": "DSTI/DS-RLHF-1.7B",
"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 "DSTI/DS-RLHF-1.7B" \
--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": "DSTI/DS-RLHF-1.7B",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use DSTI/DS-RLHF-1.7B with Unsloth Studio:
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for DSTI/DS-RLHF-1.7B to start chatting
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for DSTI/DS-RLHF-1.7B to start chatting
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for DSTI/DS-RLHF-1.7B to start chatting
pip install unsloth
from unsloth import FastModel
model, tokenizer = FastModel.from_pretrained(
model_name="DSTI/DS-RLHF-1.7B",
max_seq_length=2048,
)How to use DSTI/DS-RLHF-1.7B with Docker Model Runner:
docker model run hf.co/DSTI/DS-RLHF-1.7B
# Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("DSTI/DS-RLHF-1.7B", dtype="auto")This model is a fine-tuned version of SmolLM2-1.7B-Instruct using ORPO (Odds Ratio Preference Optimization), a reinforcement learning from human feedback (RLHF) method.
Use the code below to get started with the model.
from huggingface_hub import login
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
tokenizer = AutoTokenizer.from_pretrained("unsloth/SmolLM2-1.7B-Instruct",)
base_model = AutoModelForCausalLM.from_pretrained(
"unsloth/SmolLM2-1.7B-Instruct",
device_map={"": 0}
)
model = PeftModel.from_pretrained(base_model,"DSTI/DS-RLHF-1.7B")
prompt = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
### Instruction:
{}
### Input:
{}
### Response:
{}"""
inputs = tokenizer(
[
prompt.format(
"You are an AI assistant that helps people find information",
"What is the k-Means Clustering algorithm and what is it's purpose?",
"",
)
],
return_tensors="pt",
).to("cuda")
from transformers import TextStreamer
text_streamer = TextStreamer(tokenizer)
_ = model.generate(**inputs, streamer=text_streamer, max_new_tokens=1800)
If you use this model, please cite:
The source dataset: Anas989898/DPO-datascience
@misc{DS-RLHF-1.7B,
title = {ORPO (Odds Ratio Preference Optimization) on data science–related samples},
author = {Rustam Shiriyev},
year = {2025}
}
Base model
HuggingFaceTB/SmolLM2-1.7B
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="DSTI/DS-RLHF-1.7B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)