HuggingFaceH4/ultrachat_200k
Viewer • Updated • 515k • 68.4k • 705
How to use Neural-Hacker/Qwen3.5-2B-chat with PEFT:
from peft import PeftModel
from transformers import AutoModelForCausalLM
base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3.5-2B")
model = PeftModel.from_pretrained(base_model, "Neural-Hacker/Qwen3.5-2B-chat")How to use Neural-Hacker/Qwen3.5-2B-chat with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="Neural-Hacker/Qwen3.5-2B-chat")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("Neural-Hacker/Qwen3.5-2B-chat", dtype="auto")How to use Neural-Hacker/Qwen3.5-2B-chat with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "Neural-Hacker/Qwen3.5-2B-chat"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Neural-Hacker/Qwen3.5-2B-chat",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/Neural-Hacker/Qwen3.5-2B-chat
How to use Neural-Hacker/Qwen3.5-2B-chat with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "Neural-Hacker/Qwen3.5-2B-chat" \
--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": "Neural-Hacker/Qwen3.5-2B-chat",
"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 "Neural-Hacker/Qwen3.5-2B-chat" \
--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": "Neural-Hacker/Qwen3.5-2B-chat",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use Neural-Hacker/Qwen3.5-2B-chat with Docker Model Runner:
docker model run hf.co/Neural-Hacker/Qwen3.5-2B-chat
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
base_model = "Qwen/Qwen3.5-2B"
adapter = "your-username/your-repo-name"
tokenizer = AutoTokenizer.from_pretrained(base_model, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
base_model,
torch_dtype=torch.float16,
device_map="auto",
trust_remote_code=True
)
model = PeftModel.from_pretrained(model, adapter)
model.eval()
messages = [
{"role": "user", "content": "Explain gravity briefly"}
]
text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True
)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
outputs = model.generate(
**inputs,
max_new_tokens=400,
do_sample=True,
temperature=0.7,
top_p=0.9,
eos_token_id=tokenizer.eos_token_id
)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
if "</think>" in response:
response = response.split("</think>")[-1]
response = response.replace(text, "").strip()
print(response)
This model is released under the CC BY-NC 4.0 license.