tuneprompt 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tuneprompt-1.0.0/LICENSE +21 -0
- tuneprompt-1.0.0/PKG-INFO +316 -0
- tuneprompt-1.0.0/README.md +276 -0
- tuneprompt-1.0.0/pyproject.toml +68 -0
- tuneprompt-1.0.0/setup.cfg +4 -0
- tuneprompt-1.0.0/src/promptforge/__init__.py +15 -0
- tuneprompt-1.0.0/src/promptforge/__main__.py +6 -0
- tuneprompt-1.0.0/src/promptforge/analyzer.py +27 -0
- tuneprompt-1.0.0/src/promptforge/cli.py +461 -0
- tuneprompt-1.0.0/src/promptforge/comparison.py +101 -0
- tuneprompt-1.0.0/src/promptforge/config.py +173 -0
- tuneprompt-1.0.0/src/promptforge/data/__init__.py +33 -0
- tuneprompt-1.0.0/src/promptforge/data/generate.py +198 -0
- tuneprompt-1.0.0/src/promptforge/data/optimizer_generate.py +1683 -0
- tuneprompt-1.0.0/src/promptforge/data/prepare.py +109 -0
- tuneprompt-1.0.0/src/promptforge/evaluation.py +227 -0
- tuneprompt-1.0.0/src/promptforge/hub.py +118 -0
- tuneprompt-1.0.0/src/promptforge/local_paths.py +138 -0
- tuneprompt-1.0.0/src/promptforge/models/__init__.py +3 -0
- tuneprompt-1.0.0/src/promptforge/models/quality.py +180 -0
- tuneprompt-1.0.0/src/promptforge/optimizer.py +113 -0
- tuneprompt-1.0.0/src/promptforge/optimizer_chat.py +139 -0
- tuneprompt-1.0.0/src/promptforge/optimizer_validation.py +106 -0
- tuneprompt-1.0.0/src/promptforge/pipeline.py +202 -0
- tuneprompt-1.0.0/src/promptforge/py.typed +0 -0
- tuneprompt-1.0.0/src/promptforge/scorer.py +124 -0
- tuneprompt-1.0.0/src/promptforge/training/__init__.py +20 -0
- tuneprompt-1.0.0/src/promptforge/training/metrics.py +77 -0
- tuneprompt-1.0.0/src/promptforge/training/train_optimizer.py +355 -0
- tuneprompt-1.0.0/src/promptforge/training/train_quality.py +196 -0
- tuneprompt-1.0.0/src/promptforge/training/trainer.py +36 -0
- tuneprompt-1.0.0/src/promptforge/utils/__init__.py +17 -0
- tuneprompt-1.0.0/src/promptforge/utils/device.py +72 -0
- tuneprompt-1.0.0/src/tuneprompt.egg-info/PKG-INFO +316 -0
- tuneprompt-1.0.0/src/tuneprompt.egg-info/SOURCES.txt +38 -0
- tuneprompt-1.0.0/src/tuneprompt.egg-info/dependency_links.txt +1 -0
- tuneprompt-1.0.0/src/tuneprompt.egg-info/entry_points.txt +3 -0
- tuneprompt-1.0.0/src/tuneprompt.egg-info/requires.txt +20 -0
- tuneprompt-1.0.0/src/tuneprompt.egg-info/top_level.txt +1 -0
- tuneprompt-1.0.0/tests/test_smoke.py +111 -0
tuneprompt-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 PromptForge Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tuneprompt
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Open-source prompt quality scoring and optimization for LLMs
|
|
5
|
+
Author: PromptForge Contributors
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/arjun988/promptModel
|
|
8
|
+
Project-URL: Issues, https://github.com/arjun988/promptModel/issues
|
|
9
|
+
Project-URL: Documentation, https://github.com/arjun988/promptModel#readme
|
|
10
|
+
Project-URL: Hugging Face (Quality), https://huggingface.co/ArjunShukla/PromptForge-Quality
|
|
11
|
+
Project-URL: Hugging Face (Optimizer), https://huggingface.co/ArjunShukla/PromptForge-Optimizer
|
|
12
|
+
Keywords: prompt-engineering,llm,modernbert,huggingface,prompt-quality,promptforge
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
18
|
+
Requires-Python: >=3.10
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
Requires-Dist: torch>=2.1.0
|
|
22
|
+
Requires-Dist: transformers>=4.48.0
|
|
23
|
+
Requires-Dist: datasets>=2.19.0
|
|
24
|
+
Requires-Dist: accelerate>=0.30.0
|
|
25
|
+
Requires-Dist: peft>=0.11.0
|
|
26
|
+
Requires-Dist: scikit-learn>=1.4.0
|
|
27
|
+
Requires-Dist: pandas>=2.1.0
|
|
28
|
+
Requires-Dist: numpy>=1.26.0
|
|
29
|
+
Requires-Dist: scipy>=1.11.0
|
|
30
|
+
Requires-Dist: evaluate>=0.4.0
|
|
31
|
+
Requires-Dist: huggingface_hub>=0.23.0
|
|
32
|
+
Requires-Dist: pyyaml>=6.0
|
|
33
|
+
Requires-Dist: tqdm>=4.66.0
|
|
34
|
+
Provides-Extra: dev
|
|
35
|
+
Requires-Dist: pytest>=8.0.0; extra == "dev"
|
|
36
|
+
Requires-Dist: ruff>=0.4.0; extra == "dev"
|
|
37
|
+
Provides-Extra: demo
|
|
38
|
+
Requires-Dist: gradio>=4.0.0; extra == "demo"
|
|
39
|
+
Dynamic: license-file
|
|
40
|
+
|
|
41
|
+
# PromptForge
|
|
42
|
+
|
|
43
|
+
**Local-first prompt quality scoring and optimization.**
|
|
44
|
+
|
|
45
|
+
PromptForge scores LLM prompts across seven quality dimensions, then rewrites weak prompts into clear, intent-preserving instructions — runnable on your machine via Python API, CLI, or Gradio.
|
|
46
|
+
|
|
47
|
+
```text
|
|
48
|
+
"Make an app about social media like facebook"
|
|
49
|
+
│
|
|
50
|
+
▼
|
|
51
|
+
┌─────────────────────┐
|
|
52
|
+
│ Quality Scorer │ ModernBERT · ~150M
|
|
53
|
+
│ 41.5 → issues… │
|
|
54
|
+
└──────────┬──────────┘
|
|
55
|
+
▼
|
|
56
|
+
┌─────────────────────┐
|
|
57
|
+
│ Prompt Optimizer │ Qwen2.5-1.5B + LoRA
|
|
58
|
+
└──────────┬──────────┘
|
|
59
|
+
▼
|
|
60
|
+
Build a social media app similar to Facebook…
|
|
61
|
+
profiles · feed · likes · constraints · output format
|
|
62
|
+
│
|
|
63
|
+
▼
|
|
64
|
+
41.5 → 94.0
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
[Docs](docs/LOCAL.md) · [Product plan](docs/PRD.md) · [Contributing](CONTRIBUTING.md) · [License](LICENSE)
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Why PromptForge
|
|
72
|
+
|
|
73
|
+
Most prompt tools either **judge** quality or **rewrite** text. PromptForge does both in one local pipeline:
|
|
74
|
+
|
|
75
|
+
| Capability | What you get |
|
|
76
|
+
|------------|--------------|
|
|
77
|
+
| **Multi-dimension scoring** | Clarity, specificity, context, goals, constraints, completeness, actionability |
|
|
78
|
+
| **Intent-preserving rewrite** | Optimizes the *same* topic — not a generic template |
|
|
79
|
+
| **Validation & fallback** | Rejects repetitive / off-topic generations |
|
|
80
|
+
| **Runs locally** | ~1.65B total params; trains on 8 GB GPUs |
|
|
81
|
+
| **Dev-ready surface** | `pip` package, CLI, Gradio demo, Colab notebooks |
|
|
82
|
+
|
|
83
|
+
No API key required for inference once models are on disk.
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## Example
|
|
88
|
+
|
|
89
|
+
**Input**
|
|
90
|
+
|
|
91
|
+
```text
|
|
92
|
+
Make an app about social media like facebook and stuff
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
**Output (optimizer)**
|
|
96
|
+
|
|
97
|
+
```text
|
|
98
|
+
Build a social media app similar to Facebook for product managers.
|
|
99
|
+
This is for a portfolio demo.
|
|
100
|
+
|
|
101
|
+
Core features:
|
|
102
|
+
- User profiles and friend connections
|
|
103
|
+
- News feed with posts, likes, and comments
|
|
104
|
+
- Basic notifications
|
|
105
|
+
|
|
106
|
+
Requirements:
|
|
107
|
+
- Use Python and Flask.
|
|
108
|
+
- Keep the first version simple and usable
|
|
109
|
+
- Include error handling and clear project structure
|
|
110
|
+
|
|
111
|
+
Include short examples.
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**Quality:** `41.5 → 94.0` (Δ +52.5) · topic preserved · no fallback
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## Models
|
|
119
|
+
|
|
120
|
+
| Component | Base | Size | Training |
|
|
121
|
+
|-----------|------|------|----------|
|
|
122
|
+
| **Scorer** | [`ModernBERT-base`](https://huggingface.co/answerdotai/ModernBERT-base) | ~150M | Full fine-tune |
|
|
123
|
+
| **Optimizer** | [`Qwen2.5-1.5B-Instruct`](https://huggingface.co/Qwen/Qwen2.5-1.5B-Instruct) | 1.5B | LoRA (base frozen) |
|
|
124
|
+
|
|
125
|
+
Weights are **not** stored in git. Train locally or download from Hugging Face:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
python -m promptforge download \
|
|
129
|
+
--quality-repo ArjunShukla/PromptForge-Quality \
|
|
130
|
+
--optimizer-repo ArjunShukla/PromptForge-Optimizer
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
- Quality: https://huggingface.co/ArjunShukla/PromptForge-Quality
|
|
134
|
+
- Optimizer: https://huggingface.co/ArjunShukla/PromptForge-Optimizer
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## Results
|
|
139
|
+
|
|
140
|
+
Benchmarks from local training on **RTX 5060 Laptop (8 GB)** · Windows · `torch+cu128`.
|
|
141
|
+
|
|
142
|
+
### Quality scorer
|
|
143
|
+
|
|
144
|
+
| Split | MAE | Pearson |
|
|
145
|
+
|-------|----:|--------:|
|
|
146
|
+
| Validation | **2.73** | **0.993** |
|
|
147
|
+
| Test (overall) | **0.96** | **0.999** |
|
|
148
|
+
|
|
149
|
+
25k synthetic examples · 3 epochs · ~33 min
|
|
150
|
+
|
|
151
|
+
### Prompt optimizer
|
|
152
|
+
|
|
153
|
+
| Metric | Value |
|
|
154
|
+
|--------|------:|
|
|
155
|
+
| Validation loss | **0.121** |
|
|
156
|
+
| Train loss | 0.466 |
|
|
157
|
+
| Data | **800** curated weak→strong pairs |
|
|
158
|
+
| Epochs | 6 |
|
|
159
|
+
| Wall time | ~87 min |
|
|
160
|
+
|
|
161
|
+
Config: `configs/optimizer_fast_8gb.yaml` (seq 512, grad checkpointing, batch 1 × accum 8)
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## Quickstart
|
|
166
|
+
|
|
167
|
+
### Install from PyPI
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
pip install tuneprompt
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
> **Note:** The PyPI package is **`tuneprompt`** (`promptforge` is already taken).
|
|
174
|
+
> Import and CLI stay the same: `from promptforge import PromptForge` · `promptforge` / `tuneprompt`.
|
|
175
|
+
|
|
176
|
+
### Install from source
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
git clone https://github.com/arjun988/promptModel.git
|
|
180
|
+
cd promptModel
|
|
181
|
+
|
|
182
|
+
python -m venv .venv
|
|
183
|
+
# Windows: .venv\Scripts\activate
|
|
184
|
+
# Unix: source .venv/bin/activate
|
|
185
|
+
|
|
186
|
+
pip install -U pip
|
|
187
|
+
pip install -e ".[demo,dev]"
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
**GPU tip:** default `pip install torch` is often CPU-only. For NVIDIA (incl. RTX 50-series):
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
pip uninstall -y torch torchvision torchaudio
|
|
194
|
+
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu128
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Full local guide: [docs/LOCAL.md](docs/LOCAL.md)
|
|
198
|
+
|
|
199
|
+
### Configure & run
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
# Point at your trained checkpoints
|
|
203
|
+
python -m promptforge init \
|
|
204
|
+
--quality-model outputs/promptforge-quality-model \
|
|
205
|
+
--optimizer-model outputs/promptforge-optimizer-model
|
|
206
|
+
|
|
207
|
+
python -m promptforge doctor
|
|
208
|
+
python -m promptforge run "Build me a website for a startup"
|
|
209
|
+
python -m promptforge analyze "Make an app." --json
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
> On some Windows setups, Application Control blocks `.venv\Scripts\promptforge.exe`. Prefer `python -m promptforge …`.
|
|
213
|
+
|
|
214
|
+
### Python API
|
|
215
|
+
|
|
216
|
+
```python
|
|
217
|
+
from promptforge import PromptForge
|
|
218
|
+
|
|
219
|
+
pf = PromptForge.from_config()
|
|
220
|
+
|
|
221
|
+
print(pf.analyze("Make an app."))
|
|
222
|
+
result = pf.run("Make an app about social media like facebook and stuff")
|
|
223
|
+
print(result["optimized_prompt"])
|
|
224
|
+
print(result["delta"]["quality_score"])
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## Train your own
|
|
230
|
+
|
|
231
|
+
```bash
|
|
232
|
+
# Phase 1 — quality scorer
|
|
233
|
+
python scripts/train_quality.py --require-gpu --regenerate
|
|
234
|
+
|
|
235
|
+
# Phase 2 — optimizer (recommended on 8GB GPUs)
|
|
236
|
+
python scripts/train_optimizer.py --require-gpu --fast --regenerate
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
| Flag / config | Purpose |
|
|
240
|
+
|---------------|---------|
|
|
241
|
+
| `--fast` | Loads `configs/optimizer_fast_8gb.yaml` |
|
|
242
|
+
| `--regenerate` | Rebuild curated optimizer dataset |
|
|
243
|
+
| `load_in_4bit: true` | Use if 1.5B LoRA OOMs |
|
|
244
|
+
|
|
245
|
+
Publish checkpoints:
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
huggingface-cli login
|
|
249
|
+
python scripts/export_to_hub.py --repo-id ArjunShukla/PromptForge-Quality
|
|
250
|
+
python scripts/export_to_hub.py --repo-id ArjunShukla/PromptForge-Optimizer --optimizer
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
## CLI
|
|
256
|
+
|
|
257
|
+
| Command | Description |
|
|
258
|
+
|---------|-------------|
|
|
259
|
+
| `init` | Create `~/.promptforge` and register model paths |
|
|
260
|
+
| `doctor` | GPU / config / model health check |
|
|
261
|
+
| `download` | Pull models from Hugging Face |
|
|
262
|
+
| `analyze` | Score a prompt |
|
|
263
|
+
| `optimize` | Rewrite a prompt |
|
|
264
|
+
| `run` | Score → optimize → compare |
|
|
265
|
+
| `eval` | Pipeline evaluation reports |
|
|
266
|
+
| `space` | Launch Gradio demo |
|
|
267
|
+
| `train-quality` / `train-optimizer` | Training entrypoints |
|
|
268
|
+
|
|
269
|
+
---
|
|
270
|
+
|
|
271
|
+
## Project layout
|
|
272
|
+
|
|
273
|
+
```text
|
|
274
|
+
promptModel/
|
|
275
|
+
├── src/promptforge/ # Package: scorer, optimizer, pipeline, CLI
|
|
276
|
+
├── configs/ # Training + local defaults
|
|
277
|
+
├── scripts/ # Train / eval / Hub export
|
|
278
|
+
├── demo/ # Gradio app
|
|
279
|
+
├── notebooks/
|
|
280
|
+
│ ├── colab/ # Self-contained experiments
|
|
281
|
+
│ └── package/ # Thin package drivers
|
|
282
|
+
├── docs/ # PRD + local setup
|
|
283
|
+
├── tests/
|
|
284
|
+
└── pyproject.toml
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
Notebooks: [notebooks/README.md](notebooks/README.md)
|
|
288
|
+
|
|
289
|
+
---
|
|
290
|
+
|
|
291
|
+
## Roadmap
|
|
292
|
+
|
|
293
|
+
| Phase | Deliverable | Status |
|
|
294
|
+
|------:|-------------|--------|
|
|
295
|
+
| 1 | Multi-dimension quality scorer | Done |
|
|
296
|
+
| 2 | Intent-preserving prompt optimizer (LoRA) | Done |
|
|
297
|
+
| 3 | Combined pipeline + eval + Gradio | Done |
|
|
298
|
+
| 4 | Local package + CLI | Done |
|
|
299
|
+
| 5 | VS Code / Cursor extension | Planned |
|
|
300
|
+
|
|
301
|
+
---
|
|
302
|
+
|
|
303
|
+
## Contributing
|
|
304
|
+
|
|
305
|
+
Issues and PRs welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) for setup, style, and PR expectations.
|
|
306
|
+
|
|
307
|
+
```bash
|
|
308
|
+
pip install -e ".[dev]"
|
|
309
|
+
pytest -q
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
## License
|
|
315
|
+
|
|
316
|
+
[MIT](LICENSE) © PromptForge contributors
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
# PromptForge
|
|
2
|
+
|
|
3
|
+
**Local-first prompt quality scoring and optimization.**
|
|
4
|
+
|
|
5
|
+
PromptForge scores LLM prompts across seven quality dimensions, then rewrites weak prompts into clear, intent-preserving instructions — runnable on your machine via Python API, CLI, or Gradio.
|
|
6
|
+
|
|
7
|
+
```text
|
|
8
|
+
"Make an app about social media like facebook"
|
|
9
|
+
│
|
|
10
|
+
▼
|
|
11
|
+
┌─────────────────────┐
|
|
12
|
+
│ Quality Scorer │ ModernBERT · ~150M
|
|
13
|
+
│ 41.5 → issues… │
|
|
14
|
+
└──────────┬──────────┘
|
|
15
|
+
▼
|
|
16
|
+
┌─────────────────────┐
|
|
17
|
+
│ Prompt Optimizer │ Qwen2.5-1.5B + LoRA
|
|
18
|
+
└──────────┬──────────┘
|
|
19
|
+
▼
|
|
20
|
+
Build a social media app similar to Facebook…
|
|
21
|
+
profiles · feed · likes · constraints · output format
|
|
22
|
+
│
|
|
23
|
+
▼
|
|
24
|
+
41.5 → 94.0
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
[Docs](docs/LOCAL.md) · [Product plan](docs/PRD.md) · [Contributing](CONTRIBUTING.md) · [License](LICENSE)
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Why PromptForge
|
|
32
|
+
|
|
33
|
+
Most prompt tools either **judge** quality or **rewrite** text. PromptForge does both in one local pipeline:
|
|
34
|
+
|
|
35
|
+
| Capability | What you get |
|
|
36
|
+
|------------|--------------|
|
|
37
|
+
| **Multi-dimension scoring** | Clarity, specificity, context, goals, constraints, completeness, actionability |
|
|
38
|
+
| **Intent-preserving rewrite** | Optimizes the *same* topic — not a generic template |
|
|
39
|
+
| **Validation & fallback** | Rejects repetitive / off-topic generations |
|
|
40
|
+
| **Runs locally** | ~1.65B total params; trains on 8 GB GPUs |
|
|
41
|
+
| **Dev-ready surface** | `pip` package, CLI, Gradio demo, Colab notebooks |
|
|
42
|
+
|
|
43
|
+
No API key required for inference once models are on disk.
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Example
|
|
48
|
+
|
|
49
|
+
**Input**
|
|
50
|
+
|
|
51
|
+
```text
|
|
52
|
+
Make an app about social media like facebook and stuff
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
**Output (optimizer)**
|
|
56
|
+
|
|
57
|
+
```text
|
|
58
|
+
Build a social media app similar to Facebook for product managers.
|
|
59
|
+
This is for a portfolio demo.
|
|
60
|
+
|
|
61
|
+
Core features:
|
|
62
|
+
- User profiles and friend connections
|
|
63
|
+
- News feed with posts, likes, and comments
|
|
64
|
+
- Basic notifications
|
|
65
|
+
|
|
66
|
+
Requirements:
|
|
67
|
+
- Use Python and Flask.
|
|
68
|
+
- Keep the first version simple and usable
|
|
69
|
+
- Include error handling and clear project structure
|
|
70
|
+
|
|
71
|
+
Include short examples.
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**Quality:** `41.5 → 94.0` (Δ +52.5) · topic preserved · no fallback
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Models
|
|
79
|
+
|
|
80
|
+
| Component | Base | Size | Training |
|
|
81
|
+
|-----------|------|------|----------|
|
|
82
|
+
| **Scorer** | [`ModernBERT-base`](https://huggingface.co/answerdotai/ModernBERT-base) | ~150M | Full fine-tune |
|
|
83
|
+
| **Optimizer** | [`Qwen2.5-1.5B-Instruct`](https://huggingface.co/Qwen/Qwen2.5-1.5B-Instruct) | 1.5B | LoRA (base frozen) |
|
|
84
|
+
|
|
85
|
+
Weights are **not** stored in git. Train locally or download from Hugging Face:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
python -m promptforge download \
|
|
89
|
+
--quality-repo ArjunShukla/PromptForge-Quality \
|
|
90
|
+
--optimizer-repo ArjunShukla/PromptForge-Optimizer
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
- Quality: https://huggingface.co/ArjunShukla/PromptForge-Quality
|
|
94
|
+
- Optimizer: https://huggingface.co/ArjunShukla/PromptForge-Optimizer
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## Results
|
|
99
|
+
|
|
100
|
+
Benchmarks from local training on **RTX 5060 Laptop (8 GB)** · Windows · `torch+cu128`.
|
|
101
|
+
|
|
102
|
+
### Quality scorer
|
|
103
|
+
|
|
104
|
+
| Split | MAE | Pearson |
|
|
105
|
+
|-------|----:|--------:|
|
|
106
|
+
| Validation | **2.73** | **0.993** |
|
|
107
|
+
| Test (overall) | **0.96** | **0.999** |
|
|
108
|
+
|
|
109
|
+
25k synthetic examples · 3 epochs · ~33 min
|
|
110
|
+
|
|
111
|
+
### Prompt optimizer
|
|
112
|
+
|
|
113
|
+
| Metric | Value |
|
|
114
|
+
|--------|------:|
|
|
115
|
+
| Validation loss | **0.121** |
|
|
116
|
+
| Train loss | 0.466 |
|
|
117
|
+
| Data | **800** curated weak→strong pairs |
|
|
118
|
+
| Epochs | 6 |
|
|
119
|
+
| Wall time | ~87 min |
|
|
120
|
+
|
|
121
|
+
Config: `configs/optimizer_fast_8gb.yaml` (seq 512, grad checkpointing, batch 1 × accum 8)
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## Quickstart
|
|
126
|
+
|
|
127
|
+
### Install from PyPI
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
pip install tuneprompt
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
> **Note:** The PyPI package is **`tuneprompt`** (`promptforge` is already taken).
|
|
134
|
+
> Import and CLI stay the same: `from promptforge import PromptForge` · `promptforge` / `tuneprompt`.
|
|
135
|
+
|
|
136
|
+
### Install from source
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
git clone https://github.com/arjun988/promptModel.git
|
|
140
|
+
cd promptModel
|
|
141
|
+
|
|
142
|
+
python -m venv .venv
|
|
143
|
+
# Windows: .venv\Scripts\activate
|
|
144
|
+
# Unix: source .venv/bin/activate
|
|
145
|
+
|
|
146
|
+
pip install -U pip
|
|
147
|
+
pip install -e ".[demo,dev]"
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
**GPU tip:** default `pip install torch` is often CPU-only. For NVIDIA (incl. RTX 50-series):
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
pip uninstall -y torch torchvision torchaudio
|
|
154
|
+
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu128
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Full local guide: [docs/LOCAL.md](docs/LOCAL.md)
|
|
158
|
+
|
|
159
|
+
### Configure & run
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
# Point at your trained checkpoints
|
|
163
|
+
python -m promptforge init \
|
|
164
|
+
--quality-model outputs/promptforge-quality-model \
|
|
165
|
+
--optimizer-model outputs/promptforge-optimizer-model
|
|
166
|
+
|
|
167
|
+
python -m promptforge doctor
|
|
168
|
+
python -m promptforge run "Build me a website for a startup"
|
|
169
|
+
python -m promptforge analyze "Make an app." --json
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
> On some Windows setups, Application Control blocks `.venv\Scripts\promptforge.exe`. Prefer `python -m promptforge …`.
|
|
173
|
+
|
|
174
|
+
### Python API
|
|
175
|
+
|
|
176
|
+
```python
|
|
177
|
+
from promptforge import PromptForge
|
|
178
|
+
|
|
179
|
+
pf = PromptForge.from_config()
|
|
180
|
+
|
|
181
|
+
print(pf.analyze("Make an app."))
|
|
182
|
+
result = pf.run("Make an app about social media like facebook and stuff")
|
|
183
|
+
print(result["optimized_prompt"])
|
|
184
|
+
print(result["delta"]["quality_score"])
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## Train your own
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
# Phase 1 — quality scorer
|
|
193
|
+
python scripts/train_quality.py --require-gpu --regenerate
|
|
194
|
+
|
|
195
|
+
# Phase 2 — optimizer (recommended on 8GB GPUs)
|
|
196
|
+
python scripts/train_optimizer.py --require-gpu --fast --regenerate
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
| Flag / config | Purpose |
|
|
200
|
+
|---------------|---------|
|
|
201
|
+
| `--fast` | Loads `configs/optimizer_fast_8gb.yaml` |
|
|
202
|
+
| `--regenerate` | Rebuild curated optimizer dataset |
|
|
203
|
+
| `load_in_4bit: true` | Use if 1.5B LoRA OOMs |
|
|
204
|
+
|
|
205
|
+
Publish checkpoints:
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
huggingface-cli login
|
|
209
|
+
python scripts/export_to_hub.py --repo-id ArjunShukla/PromptForge-Quality
|
|
210
|
+
python scripts/export_to_hub.py --repo-id ArjunShukla/PromptForge-Optimizer --optimizer
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## CLI
|
|
216
|
+
|
|
217
|
+
| Command | Description |
|
|
218
|
+
|---------|-------------|
|
|
219
|
+
| `init` | Create `~/.promptforge` and register model paths |
|
|
220
|
+
| `doctor` | GPU / config / model health check |
|
|
221
|
+
| `download` | Pull models from Hugging Face |
|
|
222
|
+
| `analyze` | Score a prompt |
|
|
223
|
+
| `optimize` | Rewrite a prompt |
|
|
224
|
+
| `run` | Score → optimize → compare |
|
|
225
|
+
| `eval` | Pipeline evaluation reports |
|
|
226
|
+
| `space` | Launch Gradio demo |
|
|
227
|
+
| `train-quality` / `train-optimizer` | Training entrypoints |
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
## Project layout
|
|
232
|
+
|
|
233
|
+
```text
|
|
234
|
+
promptModel/
|
|
235
|
+
├── src/promptforge/ # Package: scorer, optimizer, pipeline, CLI
|
|
236
|
+
├── configs/ # Training + local defaults
|
|
237
|
+
├── scripts/ # Train / eval / Hub export
|
|
238
|
+
├── demo/ # Gradio app
|
|
239
|
+
├── notebooks/
|
|
240
|
+
│ ├── colab/ # Self-contained experiments
|
|
241
|
+
│ └── package/ # Thin package drivers
|
|
242
|
+
├── docs/ # PRD + local setup
|
|
243
|
+
├── tests/
|
|
244
|
+
└── pyproject.toml
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
Notebooks: [notebooks/README.md](notebooks/README.md)
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
## Roadmap
|
|
252
|
+
|
|
253
|
+
| Phase | Deliverable | Status |
|
|
254
|
+
|------:|-------------|--------|
|
|
255
|
+
| 1 | Multi-dimension quality scorer | Done |
|
|
256
|
+
| 2 | Intent-preserving prompt optimizer (LoRA) | Done |
|
|
257
|
+
| 3 | Combined pipeline + eval + Gradio | Done |
|
|
258
|
+
| 4 | Local package + CLI | Done |
|
|
259
|
+
| 5 | VS Code / Cursor extension | Planned |
|
|
260
|
+
|
|
261
|
+
---
|
|
262
|
+
|
|
263
|
+
## Contributing
|
|
264
|
+
|
|
265
|
+
Issues and PRs welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) for setup, style, and PR expectations.
|
|
266
|
+
|
|
267
|
+
```bash
|
|
268
|
+
pip install -e ".[dev]"
|
|
269
|
+
pytest -q
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
## License
|
|
275
|
+
|
|
276
|
+
[MIT](LICENSE) © PromptForge contributors
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "tuneprompt"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Open-source prompt quality scoring and optimization for LLMs"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
authors = [{ name = "PromptForge Contributors" }]
|
|
13
|
+
keywords = [
|
|
14
|
+
"prompt-engineering",
|
|
15
|
+
"llm",
|
|
16
|
+
"modernbert",
|
|
17
|
+
"huggingface",
|
|
18
|
+
"prompt-quality",
|
|
19
|
+
"promptforge",
|
|
20
|
+
]
|
|
21
|
+
classifiers = [
|
|
22
|
+
"Development Status :: 4 - Beta",
|
|
23
|
+
"Intended Audience :: Developers",
|
|
24
|
+
"License :: OSI Approved :: MIT License",
|
|
25
|
+
"Programming Language :: Python :: 3",
|
|
26
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
27
|
+
]
|
|
28
|
+
dependencies = [
|
|
29
|
+
"torch>=2.1.0",
|
|
30
|
+
"transformers>=4.48.0",
|
|
31
|
+
"datasets>=2.19.0",
|
|
32
|
+
"accelerate>=0.30.0",
|
|
33
|
+
"peft>=0.11.0",
|
|
34
|
+
"scikit-learn>=1.4.0",
|
|
35
|
+
"pandas>=2.1.0",
|
|
36
|
+
"numpy>=1.26.0",
|
|
37
|
+
"scipy>=1.11.0",
|
|
38
|
+
"evaluate>=0.4.0",
|
|
39
|
+
"huggingface_hub>=0.23.0",
|
|
40
|
+
"pyyaml>=6.0",
|
|
41
|
+
"tqdm>=4.66.0",
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
[project.optional-dependencies]
|
|
45
|
+
dev = [
|
|
46
|
+
"pytest>=8.0.0",
|
|
47
|
+
"ruff>=0.4.0",
|
|
48
|
+
]
|
|
49
|
+
demo = [
|
|
50
|
+
"gradio>=4.0.0",
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
[project.scripts]
|
|
54
|
+
tuneprompt = "promptforge.cli:main"
|
|
55
|
+
promptforge = "promptforge.cli:main"
|
|
56
|
+
|
|
57
|
+
[project.urls]
|
|
58
|
+
Homepage = "https://github.com/arjun988/promptModel"
|
|
59
|
+
Issues = "https://github.com/arjun988/promptModel/issues"
|
|
60
|
+
Documentation = "https://github.com/arjun988/promptModel#readme"
|
|
61
|
+
"Hugging Face (Quality)" = "https://huggingface.co/ArjunShukla/PromptForge-Quality"
|
|
62
|
+
"Hugging Face (Optimizer)" = "https://huggingface.co/ArjunShukla/PromptForge-Optimizer"
|
|
63
|
+
|
|
64
|
+
[tool.setuptools.packages.find]
|
|
65
|
+
where = ["src"]
|
|
66
|
+
|
|
67
|
+
[tool.setuptools.package-data]
|
|
68
|
+
promptforge = ["py.typed"]
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"""PromptForge — local prompt quality scoring and optimization."""
|
|
2
|
+
|
|
3
|
+
from promptforge.analyzer import PromptAnalyzer
|
|
4
|
+
from promptforge.optimizer import PromptOptimizer
|
|
5
|
+
from promptforge.pipeline import PromptForge
|
|
6
|
+
from promptforge.scorer import PromptQualityScorer
|
|
7
|
+
|
|
8
|
+
__version__ = "1.0.0"
|
|
9
|
+
__all__ = [
|
|
10
|
+
"PromptAnalyzer",
|
|
11
|
+
"PromptForge",
|
|
12
|
+
"PromptOptimizer",
|
|
13
|
+
"PromptQualityScorer",
|
|
14
|
+
"__version__",
|
|
15
|
+
]
|