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}
}
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for Kamran-56/Qwen2.5-3B-PromptRefiner

Adapter
(1024)
this model

Dataset used to train Kamran-56/Qwen2.5-3B-PromptRefiner