ArjunShukla commited on
Commit
217b5f3
·
verified ·
1 Parent(s): fa33598

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +222 -222
README.md CHANGED
@@ -1,222 +1,222 @@
1
- ---
2
- base_model: Qwen/Qwen2.5-1.5B-Instruct
3
- library_name: peft
4
- license: mit
5
- language:
6
- - en
7
- pipeline_tag: text-generation
8
- tags:
9
- - promptforge
10
- - prompt-optimization
11
- - prompt-engineering
12
- - lora
13
- - peft
14
- - qwen2.5
15
- - text-generation
16
- - base_model:adapter:Qwen/Qwen2.5-1.5B-Instruct
17
- - transformers
18
- ---
19
-
20
- # PromptForge-Optimizer
21
-
22
- LoRA adapter that rewrites **weak / vague prompts** into **clear, specific, actionable LLM prompts** while preserving the original intent and topic.
23
-
24
- Part of [PromptForge](https://github.com/YOUR_USER/promptModel) — local-first prompt quality scoring + optimization.
25
-
26
- ## Model Details
27
-
28
- ### Model Description
29
-
30
- 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.
31
-
32
- - **Developed by:** PromptForge contributors
33
- - **Model type:** Causal LM adapter (LoRA / PEFT)
34
- - **Language(s):** English
35
- - **License:** MIT
36
- - **Finetuned from:** [`Qwen/Qwen2.5-1.5B-Instruct`](https://huggingface.co/Qwen/Qwen2.5-1.5B-Instruct)
37
-
38
- ### Model Sources
39
-
40
- - **Repository:** https://github.com/YOUR_USER/promptModel
41
- - **Companion model:** PromptForge-Quality (ModernBERT multi-dimension prompt scorer)
42
- - **Demo:** Gradio app in the PromptForge repo (`demo/app.py`)
43
-
44
- ## Uses
45
-
46
- ### Direct Use
47
-
48
- - Rewrite vague prompts into production-ready LLM instructions
49
- - Pair with **PromptForge-Quality** for score → optimize → re-score workflows
50
- - Local / offline prompt tooling (CLI, Python API, Gradio)
51
-
52
- Example weak → strong:
53
-
54
- | Weak | Optimized (intent preserved) |
55
- |------|------------------------------|
56
- | `Make an app about social media like facebook and stuff` | Social media / Facebook-like app prompt with profiles, feed, likes, constraints, output format |
57
-
58
- ### Downstream Use
59
-
60
- - Prompt engineering assistants
61
- - IDE / agent tooling that improves user instructions before calling an LLM
62
- - Synthetic data pipelines that need higher-quality prompts
63
-
64
- ### Out-of-Scope Use
65
-
66
- - Not a general chat assistant
67
- - Not a substitute for domain experts (legal, medical, safety-critical advice)
68
- - Not guaranteed to preserve intent on topics far outside the curated training set
69
- - Do not use to generate harmful, deceptive, or disallowed content
70
-
71
- ## Bias, Risks, and Limitations
72
-
73
- - Trained on **curated synthetic** weak→strong pairs; coverage is strongest on coding apps, writing, data, research, and planning prompts
74
- - May invent plausible audience / stack details (e.g. “product managers”, “Flask”) when the weak prompt is underspecified
75
- - Small base model (**1.5B**) — quality is good for local use, not frontier-LLM rewrite quality
76
- - Inference includes validation + fallback in the PromptForge package; raw adapter output alone may still drift
77
-
78
- ### Recommendations
79
-
80
- - Prefer the **PromptForge Python package / CLI** (chat template + stop tokens + validation) over raw `generate`
81
- - For new domains, add your own weak→strong pairs and retrain the LoRA
82
- - Always review optimized prompts before sending them to production LLMs
83
-
84
- ## How to Get Started with the Model
85
-
86
- ### With PromptForge (recommended)
87
-
88
- ```bash
89
- pip install promptforge
90
- # or from source: pip install -e ".[demo]"
91
-
92
- python -m promptforge download \
93
- --quality-repo YOUR_HF_USERNAME/PromptForge-Quality \
94
- --optimizer-repo YOUR_HF_USERNAME/PromptForge-Optimizer
95
-
96
- python -m promptforge run "Make an app about social media like facebook and stuff"
97
- ```
98
-
99
- ```python
100
- from promptforge import PromptForge
101
-
102
- pf = PromptForge(
103
- quality_model_path="YOUR_HF_USERNAME/PromptForge-Quality",
104
- optimizer_model_path="YOUR_HF_USERNAME/PromptForge-Optimizer",
105
- )
106
- print(pf.run("Build me a website for a startup")["optimized_prompt"])
107
- ```
108
-
109
- ### Load the adapter directly (PEFT)
110
-
111
- ```python
112
- from peft import PeftModel
113
- from transformers import AutoModelForCausalLM, AutoTokenizer
114
-
115
- base = "Qwen/Qwen2.5-1.5B-Instruct"
116
- adapter = "YOUR_HF_USERNAME/PromptForge-Optimizer"
117
-
118
- tokenizer = AutoTokenizer.from_pretrained(adapter, trust_remote_code=True)
119
- model = AutoModelForCausalLM.from_pretrained(base, trust_remote_code=True, device_map="auto")
120
- model = PeftModel.from_pretrained(model, adapter)
121
- ```
122
-
123
- Use Qwen’s chat template (`tokenizer.apply_chat_template`) — do not hand-roll `<|system|>` tags.
124
-
125
- ## Training Details
126
-
127
- ### Training Data
128
-
129
- - **~800** curated high-quality **weak → strong** prompt pairs
130
- - **~140** unique topic-preserving seeds (coding, writing, data, research, general)
131
- - Intent rule: optimized prompt must keep the same topic as the weak prompt
132
- - Assistant-only loss masking (system/user tokens not trained)
133
-
134
- ### Training Procedure
135
-
136
- #### Training Hyperparameters
137
-
138
- | Setting | Value |
139
- |---------|-------|
140
- | Base model | `Qwen/Qwen2.5-1.5B-Instruct` |
141
- | Method | LoRA (PEFT) |
142
- | LoRA rank / alpha | 16 / 32 |
143
- | Target modules | q/k/v/o + MLP projections |
144
- | Max sequence length | 512 |
145
- | Epochs | 6 |
146
- | Effective batch size | 8 (batch 1 × grad accum 8) |
147
- | Learning rate | 1e-4 |
148
- | Precision | fp16 |
149
- | Gradient checkpointing | enabled |
150
- | Config | `configs/optimizer_fast_8gb.yaml` |
151
-
152
- #### Speeds, Sizes, Times
153
-
154
- - **Hardware:** NVIDIA GeForce RTX 5060 Laptop GPU (8 GB)
155
- - **Wall time:** ~87 minutes (6 epochs)
156
- - **Adapter size on disk:** ~82 MB
157
- - **Train loss:** ~0.47
158
- - **Validation loss:** ~0.121
159
-
160
- ## Evaluation
161
-
162
- ### Metrics
163
-
164
- | Signal | Result |
165
- |--------|--------|
166
- | Validation loss | **0.121** |
167
- | Example quality lift (scorer) | e.g. **41.5 → 94.0** on a social-media app prompt |
168
- | Intent preservation | Topic keywords retained (social / Facebook) |
169
- | Validation gate | Rejects empty / repetitive / low-intent outputs |
170
-
171
- Evaluation is primarily: held-out SFT loss + pipeline checks (score delta, instruction preservation, repetition detection). Not a public leaderboard benchmark.
172
-
173
- ### Summary
174
-
175
- 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.
176
-
177
- ## Environmental Impact
178
-
179
- - **Hardware Type:** NVIDIA RTX 5060 Laptop (8 GB)
180
- - **Hours used:** ~1.5 h for this adapter run
181
- - **Cloud Provider:** N/A (local)
182
- - **Compute Region:** N/A
183
- - **Carbon Emitted:** Not measured
184
-
185
- ## Technical Specifications
186
-
187
- ### Model Architecture and Objective
188
-
189
- - Causal language model (Qwen2.5 Instruct) + LoRA
190
- - Objective: SFT to map weak prompt (+ analysis) → optimized prompt text only
191
-
192
- ### Compute Infrastructure
193
-
194
- #### Hardware
195
-
196
- - RTX 5060 Laptop GPU, 8 GB VRAM
197
-
198
- #### Software
199
-
200
- - PyTorch (CUDA)
201
- - Transformers
202
- - PEFT / LoRA
203
- - PromptForge training scripts
204
-
205
- ### Framework versions
206
-
207
- - PEFT 0.20.0
208
-
209
- ## Citation
210
-
211
- ```bibtex
212
- @software{promptforge_optimizer,
213
- title = {PromptForge-Optimizer},
214
- author = {PromptForge Contributors},
215
- year = {2026},
216
- url = {https://huggingface.co/YOUR_HF_USERNAME/PromptForge-Optimizer}
217
- }
218
- ```
219
-
220
- ## Model Card Contact
221
-
222
- Open an issue on the PromptForge GitHub repository.
 
1
+ ---
2
+ base_model: Qwen/Qwen2.5-1.5B-Instruct
3
+ library_name: peft
4
+ license: mit
5
+ language:
6
+ - en
7
+ pipeline_tag: text-generation
8
+ tags:
9
+ - promptforge
10
+ - prompt-optimization
11
+ - prompt-engineering
12
+ - lora
13
+ - peft
14
+ - qwen2.5
15
+ - text-generation
16
+ - base_model:adapter:Qwen/Qwen2.5-1.5B-Instruct
17
+ - transformers
18
+ ---
19
+
20
+ # PromptForge-Optimizer
21
+
22
+ LoRA adapter that rewrites **weak / vague prompts** into **clear, specific, actionable LLM prompts** while preserving the original intent and topic.
23
+
24
+ Part of [PromptForge](https://github.com/arjun988/promptModel) — local-first prompt quality scoring + optimization.
25
+
26
+ ## Model Details
27
+
28
+ ### Model Description
29
+
30
+ 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.
31
+
32
+ - **Developed by:** PromptForge contributors
33
+ - **Model type:** Causal LM adapter (LoRA / PEFT)
34
+ - **Language(s):** English
35
+ - **License:** MIT
36
+ - **Finetuned from:** [`Qwen/Qwen2.5-1.5B-Instruct`](https://huggingface.co/Qwen/Qwen2.5-1.5B-Instruct)
37
+
38
+ ### Model Sources
39
+
40
+ - **Repository:** https://github.com/arjun988/promptModel
41
+ - **Companion model:** PromptForge-Quality (ModernBERT multi-dimension prompt scorer)
42
+ - **Demo:** Gradio app in the PromptForge repo (`demo/app.py`)
43
+
44
+ ## Uses
45
+
46
+ ### Direct Use
47
+
48
+ - Rewrite vague prompts into production-ready LLM instructions
49
+ - Pair with **PromptForge-Quality** for score → optimize → re-score workflows
50
+ - Local / offline prompt tooling (CLI, Python API, Gradio)
51
+
52
+ Example weak → strong:
53
+
54
+ | Weak | Optimized (intent preserved) |
55
+ |------|------------------------------|
56
+ | `Make an app about social media like facebook and stuff` | Social media / Facebook-like app prompt with profiles, feed, likes, constraints, output format |
57
+
58
+ ### Downstream Use
59
+
60
+ - Prompt engineering assistants
61
+ - IDE / agent tooling that improves user instructions before calling an LLM
62
+ - Synthetic data pipelines that need higher-quality prompts
63
+
64
+ ### Out-of-Scope Use
65
+
66
+ - Not a general chat assistant
67
+ - Not a substitute for domain experts (legal, medical, safety-critical advice)
68
+ - Not guaranteed to preserve intent on topics far outside the curated training set
69
+ - Do not use to generate harmful, deceptive, or disallowed content
70
+
71
+ ## Bias, Risks, and Limitations
72
+
73
+ - Trained on **curated synthetic** weak→strong pairs; coverage is strongest on coding apps, writing, data, research, and planning prompts
74
+ - May invent plausible audience / stack details (e.g. “product managers”, “Flask”) when the weak prompt is underspecified
75
+ - Small base model (**1.5B**) — quality is good for local use, not frontier-LLM rewrite quality
76
+ - Inference includes validation + fallback in the PromptForge package; raw adapter output alone may still drift
77
+
78
+ ### Recommendations
79
+
80
+ - Prefer the **PromptForge Python package / CLI** (chat template + stop tokens + validation) over raw `generate`
81
+ - For new domains, add your own weak→strong pairs and retrain the LoRA
82
+ - Always review optimized prompts before sending them to production LLMs
83
+
84
+ ## How to Get Started with the Model
85
+
86
+ ### With PromptForge (recommended)
87
+
88
+ ```bash
89
+ pip install promptforge
90
+ # or from source: pip install -e ".[demo]"
91
+
92
+ python -m promptforge download \
93
+ --quality-repo ArjunShukla/PromptForge-Quality \
94
+ --optimizer-repo ArjunShukla/PromptForge-Optimizer
95
+
96
+ python -m promptforge run "Make an app about social media like facebook and stuff"
97
+ ```
98
+
99
+ ```python
100
+ from promptforge import PromptForge
101
+
102
+ pf = PromptForge(
103
+ quality_model_path="ArjunShukla/PromptForge-Quality",
104
+ optimizer_model_path="ArjunShukla/PromptForge-Optimizer",
105
+ )
106
+ print(pf.run("Build me a website for a startup")["optimized_prompt"])
107
+ ```
108
+
109
+ ### Load the adapter directly (PEFT)
110
+
111
+ ```python
112
+ from peft import PeftModel
113
+ from transformers import AutoModelForCausalLM, AutoTokenizer
114
+
115
+ base = "Qwen/Qwen2.5-1.5B-Instruct"
116
+ adapter = "ArjunShukla/PromptForge-Optimizer"
117
+
118
+ tokenizer = AutoTokenizer.from_pretrained(adapter, trust_remote_code=True)
119
+ model = AutoModelForCausalLM.from_pretrained(base, trust_remote_code=True, device_map="auto")
120
+ model = PeftModel.from_pretrained(model, adapter)
121
+ ```
122
+
123
+ Use Qwen’s chat template (`tokenizer.apply_chat_template`) — do not hand-roll `<|system|>` tags.
124
+
125
+ ## Training Details
126
+
127
+ ### Training Data
128
+
129
+ - **~800** curated high-quality **weak → strong** prompt pairs
130
+ - **~140** unique topic-preserving seeds (coding, writing, data, research, general)
131
+ - Intent rule: optimized prompt must keep the same topic as the weak prompt
132
+ - Assistant-only loss masking (system/user tokens not trained)
133
+
134
+ ### Training Procedure
135
+
136
+ #### Training Hyperparameters
137
+
138
+ | Setting | Value |
139
+ |---------|-------|
140
+ | Base model | `Qwen/Qwen2.5-1.5B-Instruct` |
141
+ | Method | LoRA (PEFT) |
142
+ | LoRA rank / alpha | 16 / 32 |
143
+ | Target modules | q/k/v/o + MLP projections |
144
+ | Max sequence length | 512 |
145
+ | Epochs | 6 |
146
+ | Effective batch size | 8 (batch 1 × grad accum 8) |
147
+ | Learning rate | 1e-4 |
148
+ | Precision | fp16 |
149
+ | Gradient checkpointing | enabled |
150
+ | Config | `configs/optimizer_fast_8gb.yaml` |
151
+
152
+ #### Speeds, Sizes, Times
153
+
154
+ - **Hardware:** NVIDIA GeForce RTX 5060 Laptop GPU (8 GB)
155
+ - **Wall time:** ~87 minutes (6 epochs)
156
+ - **Adapter size on disk:** ~82 MB
157
+ - **Train loss:** ~0.47
158
+ - **Validation loss:** ~0.121
159
+
160
+ ## Evaluation
161
+
162
+ ### Metrics
163
+
164
+ | Signal | Result |
165
+ |--------|--------|
166
+ | Validation loss | **0.121** |
167
+ | Example quality lift (scorer) | e.g. **41.5 → 94.0** on a social-media app prompt |
168
+ | Intent preservation | Topic keywords retained (social / Facebook) |
169
+ | Validation gate | Rejects empty / repetitive / low-intent outputs |
170
+
171
+ Evaluation is primarily: held-out SFT loss + pipeline checks (score delta, instruction preservation, repetition detection). Not a public leaderboard benchmark.
172
+
173
+ ### Summary
174
+
175
+ 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.
176
+
177
+ ## Environmental Impact
178
+
179
+ - **Hardware Type:** NVIDIA RTX 5060 Laptop (8 GB)
180
+ - **Hours used:** ~1.5 h for this adapter run
181
+ - **Cloud Provider:** N/A (local)
182
+ - **Compute Region:** N/A
183
+ - **Carbon Emitted:** Not measured
184
+
185
+ ## Technical Specifications
186
+
187
+ ### Model Architecture and Objective
188
+
189
+ - Causal language model (Qwen2.5 Instruct) + LoRA
190
+ - Objective: SFT to map weak prompt (+ analysis) → optimized prompt text only
191
+
192
+ ### Compute Infrastructure
193
+
194
+ #### Hardware
195
+
196
+ - RTX 5060 Laptop GPU, 8 GB VRAM
197
+
198
+ #### Software
199
+
200
+ - PyTorch (CUDA)
201
+ - Transformers
202
+ - PEFT / LoRA
203
+ - PromptForge training scripts
204
+
205
+ ### Framework versions
206
+
207
+ - PEFT 0.20.0
208
+
209
+ ## Citation
210
+
211
+ ```bibtex
212
+ @software{promptforge_optimizer,
213
+ title = {PromptForge-Optimizer},
214
+ author = {PromptForge Contributors},
215
+ year = {2026},
216
+ url = {https://huggingface.co/ArjunShukla/PromptForge-Optimizer}
217
+ }
218
+ ```
219
+
220
+ ## Model Card Contact
221
+
222
+ Open an issue on the PromptForge GitHub repository.