Instructions to use Kamran-56/Qwen2.5-3B-PromptRefiner with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Kamran-56/Qwen2.5-3B-PromptRefiner with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Kamran-56/Qwen2.5-3B-PromptRefiner") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Kamran-56/Qwen2.5-3B-PromptRefiner", dtype="auto") - PEFT
How to use Kamran-56/Qwen2.5-3B-PromptRefiner with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Kamran-56/Qwen2.5-3B-PromptRefiner with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Kamran-56/Qwen2.5-3B-PromptRefiner" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Kamran-56/Qwen2.5-3B-PromptRefiner", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Kamran-56/Qwen2.5-3B-PromptRefiner
- SGLang
How to use Kamran-56/Qwen2.5-3B-PromptRefiner with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Kamran-56/Qwen2.5-3B-PromptRefiner" \ --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": "Kamran-56/Qwen2.5-3B-PromptRefiner", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
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 "Kamran-56/Qwen2.5-3B-PromptRefiner" \ --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": "Kamran-56/Qwen2.5-3B-PromptRefiner", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Kamran-56/Qwen2.5-3B-PromptRefiner with Docker Model Runner:
docker model run hf.co/Kamran-56/Qwen2.5-3B-PromptRefiner
Qwen2.5-3B-PromptRefiner
A fine-tuned version of Qwen2.5-1.5B-Instruct specifically trained to transform basic, vague user prompts into high-quality, structured, and effective prompts that get significantly better responses from AI systems.
Model Details
Model Description
- Developed by: Kamran (Kamran-56)
- Model type: Causal Language Model (fine-tuned with LoRA/PEFT)
- Language(s): English
- License: MIT
- Finetuned from: Qwen/Qwen2.5-1.5B-Instruct
- Dataset used: Kamran-56/prompt-refinement-dataset
Uses
Direct Use
This model takes a basic user-written prompt as input and returns an enhanced, detailed, and well-structured version of the same prompt. It is designed to be used as a middleware layer between the user and any AI chatbot.
Downstream Use
- Chrome extensions that auto-enhance prompts on AI platforms like ChatGPT, Claude, and Gemini
- API middleware that improves prompts before forwarding to LLMs
- Productivity tools that help non-technical users write better prompts
Out-of-Scope Use
- This model is not designed to answer questions or generate content
- Not suitable for tasks outside of prompt enhancement
- Not trained on non-English prompts
How to Get Started with the Model
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
BASE_MODEL = "Qwen/Qwen2.5-1.5B-Instruct"
LORA_MODEL = "Kamran-56/Qwen2.5-3B-PromptRefiner"
tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL, trust_remote_code=True)
base_model = AutoModelForCausalLM.from_pretrained(
BASE_MODEL,
torch_dtype=torch.bfloat16,
device_map="auto",
trust_remote_code=True
)
model = PeftModel.from_pretrained(base_model, LORA_MODEL)
model.eval()
def enhance_prompt(bad_prompt):
input_text = f"""<|im_start|>system
You are a world-class prompt engineer with deep expertise across all domains
including coding, writing, business, creativity, and research. Transform the
given basic prompt into a highly specific, structured, and effective prompt.
Every enhanced prompt MUST include a clear Role, Context, Task, Format, and
Constraints. Return ONLY the enhanced prompt, nothing else.<|im_end|>
<|im_start|>user
{bad_prompt}<|im_end|>
<|im_start|>assistant
"""
inputs = tokenizer(input_text, return_tensors="pt").to("cuda")
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=200,
do_sample=True,
temperature=0.7,
top_p=0.9,
repetition_penalty=1.2,
pad_token_id=tokenizer.eos_token_id
)
full_output = tokenizer.decode(outputs[0], skip_special_tokens=True)
return full_output.split("assistant")[-1].strip()
# Example
print(enhance_prompt("write a poem"))
Training Details
Training Data
Fine-tuned on Kamran-56/prompt-refinement-dataset which contains 1,561 input→output pairs of basic prompts mapped to high-quality enhanced prompts generated using Llama 3.1 via Groq API.
Training Procedure
Training Hyperparameters
- Training regime: bf16 mixed precision
- Fine-tuning method: LoRA (PEFT)
- LoRA rank (r): 8
- LoRA alpha: 16
- Target modules: q_proj, k_proj, v_proj, o_proj
- Learning rate: 5e-5
- Epochs: 3
- Batch size: 4
- Gradient accumulation steps: 4
- Effective batch size: 16
- LR scheduler: Cosine
- Warmup steps: 50
- Max sequence length: 512
Speeds, Sizes, Times
- Hardware: Kaggle P100 GPU (16GB VRAM)
- Training time: ~45 minutes
- Final training loss: 1.24
Evaluation
Testing Data
Evaluated manually on 12 diverse prompts spanning coding, writing, professional, creative, and general categories.
Results
| Input Prompt | Quality Before | Quality After |
|---|---|---|
| "write a poem" | Vague, no structure | Role + Context + Format + Constraints added |
| "fix my code" | No context | Step-by-step debugging structure with format |
| "write an email" | Generic | Professional tone, structure, constraints defined |
Average quality rating: 8.5/10 based on manual evaluation measuring specificity, structure, role clarity, and format instructions.
Citation
@model{qwen25_promptrefiner,
author = {Kamran},
title = {Qwen2.5-3B-PromptRefiner},
year = {2025},
publisher = {HuggingFace},
url = {https://huggingface.co/Kamran-56/Qwen2.5-3B-PromptRefiner}
}