Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -231,6 +231,116 @@ Please provide your response in the following JSON format, enclosed in <json> ta
|
|
231 |
</json>
|
232 |
'''
|
233 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
234 |
|
235 |
# Define the metaprompts
|
236 |
metaprompt1 = """
|
|
|
231 |
</json>
|
232 |
'''
|
233 |
|
234 |
+
echo_prompt_refiner = '''You are an AI assistant implementing an advanced version of the ECHO (Enhanced Chain of Harmonized Optimization) method to refine an initial prompt into a more relevant, comprehensive, and effective one. Given an initial prompt, meticulously follow these steps:
|
235 |
+
|
236 |
+
1. Prompt Analysis and Evaluation:
|
237 |
+
- Thoroughly analyze the initial prompt
|
238 |
+
- Identify key concepts, objectives, constraints, and implicit assumptions within the prompt
|
239 |
+
- Determine the prompt type (e.g., task-oriented, creative, analytical, informational)
|
240 |
+
- Evaluate the prompt's strengths and weaknesses
|
241 |
+
- Assess the complexity and any specific requirements
|
242 |
+
|
243 |
+
2. Prompt Expansion and Exploration:
|
244 |
+
- Generate 8-10 alternative versions of the prompt that explore different aspects or phrasings
|
245 |
+
- Ensure these versions cover various perspectives and potential interpretations
|
246 |
+
- Include a mix of more specific, more general, and differently focused versions
|
247 |
+
- Apply techniques such as role prompting, emotion prompting, and style prompting
|
248 |
+
- Incorporate chain-of-thought reasoning in your expansions
|
249 |
+
|
250 |
+
3. Prompt Clustering and Thematic Analysis:
|
251 |
+
- Group the generated prompts into 5-7 thematic clusters
|
252 |
+
- Identify the core themes, objectives, and unique aspects represented by each cluster
|
253 |
+
- Apply the Tree of Thoughts technique to explore multiple enhancement paths simultaneously
|
254 |
+
|
255 |
+
4. Demonstration and Approach Outline:
|
256 |
+
- For each cluster, outline how an AI might interpret and approach that prompt version
|
257 |
+
- Include potential reasoning steps, areas of focus, and expected outcomes
|
258 |
+
- Incorporate techniques like few-shot prompting and least-to-most prompting
|
259 |
+
- Avoid generating actual responses; focus on the approach and reasoning process
|
260 |
+
|
261 |
+
5. Prompt Refinement and Optimization:
|
262 |
+
- Review the demonstration outlines and identify strengths and weaknesses of each prompt version
|
263 |
+
- Refine each version, addressing potential misinterpretations and improving clarity
|
264 |
+
- Ensure each refined version maintains the original intent while enhancing specificity or broadening scope as needed
|
265 |
+
- Apply linguistic optimization techniques to improve structure and clarity
|
266 |
+
- Aim to create at least 7-10 refined versions
|
267 |
+
- Implement self-consistency checks and self-calibration techniques
|
268 |
+
|
269 |
+
6. Cross-Pollination and Synthesis:
|
270 |
+
- Identify effective elements, techniques, and approaches from each refined version
|
271 |
+
- Integrate these elements to create multiple synthesized, improved prompts
|
272 |
+
- Apply the mixture of reasoning experts (MoRE) approach to combine insights from various perspectives
|
273 |
+
|
274 |
+
7. Final Prompt Synthesis and Optimization:
|
275 |
+
- Combine the most effective elements from all refined and synthesized versions
|
276 |
+
- Construct a final, comprehensive prompt that captures the essence of the original while incorporating improvements from multiple refined versions
|
277 |
+
- Ensure the final prompt is detailed, clear, and addresses multiple aspects identified in the refinement process
|
278 |
+
- The final prompt should be substantially longer and more detailed than any individual refined prompt, typically 3-8 times the length of the original prompt
|
279 |
+
- Include specific instructions, key areas to cover, and guidance on approach and structure
|
280 |
+
- Incorporate self-verification and chain-of-verification (COVE) steps
|
281 |
+
- Apply the max mutual information method to optimize the prompt's effectiveness
|
282 |
+
- Include instructions for dynamic, adaptive reasoning processes
|
283 |
+
- Ensure the prompt leverages the autoregressive nature of language models by strategically ordering information
|
284 |
+
|
285 |
+
8. Meta-Learning and Continuous Improvement:
|
286 |
+
- Incorporate steps for the AI to learn from the prompt enhancement process
|
287 |
+
- Include instructions for adaptive technique selection based on prompt characteristics
|
288 |
+
- Add self-evaluation and iterative improvement guidelines within the prompt
|
289 |
+
|
290 |
+
Ensure each step of your process is thorough and well-documented in the JSON output. Your final refined prompt should be clear, comprehensive, and effectively capture the intent of the initial prompt while addressing any identified shortcomings and maximizing its potential for generating high-quality, contextually relevant responses.
|
291 |
+
|
292 |
+
Initial prompt: {insert_prompt_here}
|
293 |
+
|
294 |
+
Please provide your response in the following JSON format, enclosed in <json> tags:
|
295 |
+
|
296 |
+
<json>
|
297 |
+
{
|
298 |
+
"initial_prompt": "The original prompt provided",
|
299 |
+
"initial_prompt_evaluation": "Your detailed evaluation of the initial prompt, including strengths and weaknesses, in a string format using markdown bullet points",
|
300 |
+
"prompt_analysis": {
|
301 |
+
"key_concepts": ["concept1", "concept2", "concept3", "..."],
|
302 |
+
"objectives": "String describing the main objectives",
|
303 |
+
"constraints": "String describing any identified constraints",
|
304 |
+
"prompt_type": "Type of prompt (e.g., task-oriented, creative, analytical, informational)",
|
305 |
+
"complexity_assessment": "Assessment of the prompt's complexity and specific requirements"
|
306 |
+
},
|
307 |
+
"expanded_prompts": [
|
308 |
+
"First alternative prompt version",
|
309 |
+
"Second alternative prompt version",
|
310 |
+
"...",
|
311 |
+
"Last alternative prompt version"
|
312 |
+
],
|
313 |
+
"prompt_clusters": {
|
314 |
+
"cluster1_name": [
|
315 |
+
"First prompt in this cluster",
|
316 |
+
"Second prompt in this cluster",
|
317 |
+
"..."
|
318 |
+
],
|
319 |
+
"cluster2_name": [
|
320 |
+
"First prompt in this cluster",
|
321 |
+
"Second prompt in this cluster",
|
322 |
+
"..."
|
323 |
+
],
|
324 |
+
"...": "Additional clusters as needed"
|
325 |
+
},
|
326 |
+
"demonstration_outlines": {
|
327 |
+
"cluster1_name": "Detailed approach outline for this cluster",
|
328 |
+
"cluster2_name": "Detailed approach outline for this cluster",
|
329 |
+
"...": "Additional outlines as needed"
|
330 |
+
},
|
331 |
+
"refined_prompts": [
|
332 |
+
"First refined prompt version",
|
333 |
+
"Second refined prompt version",
|
334 |
+
"...",
|
335 |
+
"Last refined prompt version"
|
336 |
+
],
|
337 |
+
"refined_prompt": "The final, synthesized prompt as a single comprehensive string",
|
338 |
+
"explanation_of_refinements": "Detailed explanation of techniques used, improvements made, and rationale behind the final synthesized prompt. Include specific examples of how elements from different refined versions were incorporated. Provide this explanation in a bullet-point format for clarity. Add
|
339 |
+
discussion of any potential limitations or considerations for the refined prompt, including areas that may require further refinement or attention in future iterations.
|
340 |
+
as as a single comprehensive string"
|
341 |
+
}
|
342 |
+
</json>
|
343 |
+
'''
|
344 |
|
345 |
# Define the metaprompts
|
346 |
metaprompt1 = """
|