File size: 7,551 Bytes
217b5f3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0321642
217b5f3
 
1354f1c
217b5f3
 
 
 
 
 
0321642
217b5f3
 
 
 
 
 
 
 
 
 
 
 
0321642
 
217b5f3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
---

base_model: Qwen/Qwen2.5-1.5B-Instruct
library_name: peft
license: mit
language:
  - en
pipeline_tag: text-generation
tags:
  - promptforge
  - prompt-optimization
  - prompt-engineering
  - lora
  - peft
  - qwen2.5
  - text-generation
  - base_model:adapter:Qwen/Qwen2.5-1.5B-Instruct
  - transformers
---


# PromptForge-Optimizer

LoRA adapter that rewrites **weak / vague prompts** into **clear, specific, actionable LLM prompts** while preserving the original intent and topic.

Part of [PromptForge](https://github.com/arjun988/promptModel) — local-first prompt quality scoring + optimization.

## Model Details

### Model Description

PromptForge-Optimizer is a **PEFT/LoRA** fine-tune of [`Qwen/Qwen2.5-1.5B-Instruct`](https://huggingface.co/Qwen/Qwen2.5-1.5B-Instruct). Given a weak user prompt (plus optional quality analysis context), it generates an improved prompt with audience, constraints, structure, and output format — without changing the core topic.

- **Developed by:** PromptForge contributors
- **Model type:** Causal LM adapter (LoRA / PEFT)
- **Language(s):** English
- **License:** MIT
- **Finetuned from:** [`Qwen/Qwen2.5-1.5B-Instruct`](https://huggingface.co/Qwen/Qwen2.5-1.5B-Instruct)

### Model Sources

- **Repository:** https://github.com/arjun988/promptModel
- **Companion model:** PromptForge-Quality (ModernBERT multi-dimension prompt scorer)
- **Demo:** Gradio app in the PromptForge repo (`demo/app.py`)

## Uses

### Direct Use

- Rewrite vague prompts into production-ready LLM instructions
- Pair with **PromptForge-Quality** for score → optimize → re-score workflows
- Local / offline prompt tooling (CLI, Python API, Gradio)

Example weak → strong:

| Weak | Optimized (intent preserved) |
|------|------------------------------|
| `Make an app about social media like facebook and stuff` | Social media / Facebook-like app prompt with profiles, feed, likes, constraints, output format |

### Downstream Use

- Prompt engineering assistants
- IDE / agent tooling that improves user instructions before calling an LLM
- Synthetic data pipelines that need higher-quality prompts

### Out-of-Scope Use

- Not a general chat assistant
- Not a substitute for domain experts (legal, medical, safety-critical advice)
- Not guaranteed to preserve intent on topics far outside the curated training set
- Do not use to generate harmful, deceptive, or disallowed content

## Bias, Risks, and Limitations

- Trained on **curated synthetic** weak→strong pairs; coverage is strongest on coding apps, writing, data, research, and planning prompts
- May invent plausible audience / stack details (e.g. “product managers”, “Flask”) when the weak prompt is underspecified
- Small base model (**1.5B**) — quality is good for local use, not frontier-LLM rewrite quality
- Inference includes validation + fallback in the PromptForge package; raw adapter output alone may still drift

### Recommendations

- Prefer the **PromptForge Python package / CLI** (chat template + stop tokens + validation) over raw `generate`
- For new domains, add your own weak→strong pairs and retrain the LoRA
- Always review optimized prompts before sending them to production LLMs

## How to Get Started with the Model

### Install & use with [`tuneprompt`](https://pypi.org/project/tuneprompt/) (recommended)

```bash

pip install tuneprompt



python -m promptforge download \

  --quality-repo ArjunShukla/PromptForge-Quality \

  --optimizer-repo ArjunShukla/PromptForge-Optimizer



python -m promptforge run "Make an app about social media like facebook and stuff"

# or: tuneprompt run "Make an app about social media like facebook and stuff"

```

```python

from promptforge import PromptForge



pf = PromptForge(

    quality_model_path="ArjunShukla/PromptForge-Quality",

    optimizer_model_path="ArjunShukla/PromptForge-Optimizer",

)

print(pf.run("Build me a website for a startup")["optimized_prompt"])

```

> **Package:** [`tuneprompt`](https://pypi.org/project/tuneprompt/1.0.0/) on PyPI · **Import:** `promptforge` · **CLI:** `tuneprompt` / `promptforge` · **Code:** https://github.com/arjun988/promptModel

### Load the adapter directly (PEFT)

```python

from peft import PeftModel

from transformers import AutoModelForCausalLM, AutoTokenizer



base = "Qwen/Qwen2.5-1.5B-Instruct"

adapter = "ArjunShukla/PromptForge-Optimizer"



tokenizer = AutoTokenizer.from_pretrained(adapter, trust_remote_code=True)

model = AutoModelForCausalLM.from_pretrained(base, trust_remote_code=True, device_map="auto")

model = PeftModel.from_pretrained(model, adapter)

```

Use Qwen’s chat template (`tokenizer.apply_chat_template`) — do not hand-roll `<|system|>` tags.

## Training Details

### Training Data

- **~800** curated high-quality **weak → strong** prompt pairs
- **~140** unique topic-preserving seeds (coding, writing, data, research, general)
- Intent rule: optimized prompt must keep the same topic as the weak prompt
- Assistant-only loss masking (system/user tokens not trained)

### Training Procedure

#### Training Hyperparameters

| Setting | Value |
|---------|-------|
| Base model | `Qwen/Qwen2.5-1.5B-Instruct` |
| Method | LoRA (PEFT) |
| LoRA rank / alpha | 16 / 32 |
| Target modules | q/k/v/o + MLP projections |
| Max sequence length | 512 |
| Epochs | 6 |
| Effective batch size | 8 (batch 1 × grad accum 8) |
| Learning rate | 1e-4 |
| Precision | fp16 |
| Gradient checkpointing | enabled |
| Config | `configs/optimizer_fast_8gb.yaml` |

#### Speeds, Sizes, Times

- **Hardware:** NVIDIA GeForce RTX 5060 Laptop GPU (8 GB)
- **Wall time:** ~87 minutes (6 epochs)
- **Adapter size on disk:** ~82 MB
- **Train loss:** ~0.47
- **Validation loss:** ~0.121

## Evaluation

### Metrics

| Signal | Result |
|--------|--------|
| Validation loss | **0.121** |
| Example quality lift (scorer) | e.g. **41.5 → 94.0** on a social-media app prompt |
| Intent preservation | Topic keywords retained (social / Facebook) |
| Validation gate | Rejects empty / repetitive / low-intent outputs |

Evaluation is primarily: held-out SFT loss + pipeline checks (score delta, instruction preservation, repetition detection). Not a public leaderboard benchmark.

### Summary

The adapter reliably expands vague prompts into structured instructions on in-distribution topics. Off-distribution prompts may fall back to a safer template when used through PromptForge.

## Environmental Impact

- **Hardware Type:** NVIDIA RTX 5060 Laptop (8 GB)
- **Hours used:** ~1.5 h for this adapter run
- **Cloud Provider:** N/A (local)
- **Compute Region:** N/A
- **Carbon Emitted:** Not measured

## Technical Specifications

### Model Architecture and Objective

- Causal language model (Qwen2.5 Instruct) + LoRA
- Objective: SFT to map weak prompt (+ analysis) → optimized prompt text only

### Compute Infrastructure

#### Hardware

- RTX 5060 Laptop GPU, 8 GB VRAM

#### Software

- PyTorch (CUDA)
- Transformers
- PEFT / LoRA
- PromptForge training scripts

### Framework versions

- PEFT 0.20.0

## Citation

```bibtex

@software{promptforge_optimizer,

  title = {PromptForge-Optimizer},

  author = {PromptForge Contributors},

  year = {2026},

  url = {https://huggingface.co/ArjunShukla/PromptForge-Optimizer}

}

```

## Model Card Contact

Open an issue on the PromptForge GitHub repository.