sh0416/ag_news
Viewer • Updated • 128k • 2.5k • 13
How to use kingabzpro/qwen35-small-news-class with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="kingabzpro/qwen35-small-news-class")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("kingabzpro/qwen35-small-news-class", dtype="auto")How to use kingabzpro/qwen35-small-news-class with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "kingabzpro/qwen35-small-news-class"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "kingabzpro/qwen35-small-news-class",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/kingabzpro/qwen35-small-news-class
How to use kingabzpro/qwen35-small-news-class with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "kingabzpro/qwen35-small-news-class" \
--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": "kingabzpro/qwen35-small-news-class",
"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 "kingabzpro/qwen35-small-news-class" \
--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": "kingabzpro/qwen35-small-news-class",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use kingabzpro/qwen35-small-news-class with Docker Model Runner:
docker model run hf.co/kingabzpro/qwen35-small-news-class
This model is a LoRA fine-tuned version of Qwen3.5-0.8B trained to classify news articles into four categories using the AG News dataset.
Classes:
| Label | Category |
|---|---|
| 0 | World |
| 1 | Sports |
| 2 | Business |
| 3 | Sci/Tech |
The model was evaluated on 200 samples from the AG News test set using prompt-based classification.
| Model | Accuracy | Weighted F1 |
|---|---|---|
| Base Model | 0.52 | 0.4589 |
| Fine-Tuned Model | 0.865 | 0.8661 |
Fine-tuning improved performance significantly, increasing accuracy from 52% → 86.5%.
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
model_id = "kingabzpro/qwen35-small-news-class"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id)
text = "Apple announced a new AI chip designed for machine learning workloads."
prompt = f"""
Classify the news article.
Article:
{text}
Return ONLY the number.
0 = World
1 = Sports
2 = Business
3 = Sci/Tech
Answer:
"""
inputs = tokenizer(prompt, return_tensors="pt")
with torch.inference_mode():
outputs = model.generate(**inputs, max_new_tokens=5)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
This version is clean, concise, and follows the style used by many popular Hugging Face models.