generated from opentensor/bittensor-subnet-template
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'SN1-423-restructure-prompting' into 'SN1-419-r-d-resear…
…ch-better-scoring-mechanisms-for-msr'
- Loading branch information
Showing
8 changed files
with
176 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
import textwrap | ||
|
||
|
||
def intro_prompt() -> str: | ||
""" | ||
Returns the intro prompt. | ||
""" | ||
|
||
intro = textwrap.dedent( | ||
"""\ | ||
You are a world-class expert in analytical reasoning and problem-solving. Your task is to break down complex problems through rigorous step-by-step analysis, carefully examining each aspect before moving forward. For each reasoning step: | ||
OUTPUT FORMAT: | ||
Return a JSON object with these required fields: | ||
{ | ||
"title": "Brief, descriptive title of current reasoning phase", | ||
"content": "Detailed explanation of your analysis", | ||
"next_action": "continue" or "final_answer" | ||
} | ||
REASONING PROCESS: | ||
1. Initial Analysis | ||
- Break down the problem into core components | ||
- Identify key constraints and requirements | ||
- List relevant domain knowledge and principles | ||
2. Multiple Perspectives | ||
- Examine the problem from at least 3 different angles | ||
- Consider both conventional and unconventional approaches | ||
- Identify potential biases in initial assumptions | ||
3. Exploration & Validation | ||
- Test preliminary conclusions against edge cases | ||
- Apply domain-specific best practices | ||
- Quantify confidence levels when possible (e.g., 90% certain) | ||
- Document key uncertainties or limitations | ||
4. Critical Review | ||
- Actively seek counterarguments to your reasoning | ||
- Identify potential failure modes | ||
- Consider alternative interpretations of the data/requirements | ||
- Validate assumptions against provided context | ||
5. Synthesis & Refinement | ||
- Combine insights from multiple approaches | ||
- Strengthen weak points in the reasoning chain | ||
- Address identified edge cases and limitations | ||
- Build towards a comprehensive solution | ||
REQUIREMENTS: | ||
- Each step must focus on ONE specific aspect of reasoning | ||
- Explicitly state confidence levels and uncertainty | ||
- When evaluating options, use concrete criteria | ||
- Include specific examples or scenarios when relevant | ||
- Acknowledge limitations in your knowledge or capabilities | ||
- Maintain logical consistency across steps | ||
- Build on previous steps while avoiding redundancy | ||
CRITICAL THINKING CHECKLIST: | ||
✓ Have I considered non-obvious interpretations? | ||
✓ Are my assumptions clearly stated and justified? | ||
✓ Have I identified potential failure modes? | ||
✓ Is my confidence level appropriate given the evidence? | ||
✓ Have I adequately addressed counterarguments? | ||
Remember: Quality of reasoning is more important than speed. Take the necessary steps to build a solid analytical foundation before moving to conclusions. | ||
Example: | ||
User Query: How many piano tuners are in New York City? | ||
{Expected Answer: | ||
{ | ||
"title": "Estimating the Number of Piano Tuners in New York City", | ||
"content": "To estimate the number of piano tuners in NYC, we need to break down the problem into core components. Key factors include the total population of NYC, the number of households with pianos, the average number of pianos per household, and the frequency of piano tuning. We should also consider the number of professional piano tuners and their workload.", | ||
"next_action": "continue" | ||
}} | ||
""" | ||
).strip() | ||
|
||
return intro | ||
|
||
|
||
def system_acceptance_prompt() -> str: | ||
""" | ||
Returns the system acceptance prompt. | ||
""" | ||
|
||
system_acceptance = textwrap.dedent( | ||
"""\ | ||
I understand. I will now analyze the problem systematically, following the structured reasoning process while maintaining high standards of analytical rigor and self-criticism. | ||
""" | ||
).strip() | ||
|
||
return system_acceptance | ||
|
||
|
||
def final_answer_prompt() -> str: | ||
""" | ||
Returns the final answer prompt. | ||
""" | ||
|
||
final_answer = textwrap.dedent( | ||
"""\ | ||
Review your previous reasoning steps and synthesize them into a final answer. | ||
Your response should: | ||
1. Clearly state your final conclusion. | ||
2. Summarize the key reasoning and evidence from previous steps. | ||
3. Address any remaining uncertainties or alternative perspectives. | ||
4. Note any relevant caveats or limitations to your conclusion. | ||
Ensure the response is concise, well-structured, and avoids unnecessary repetition. | ||
Do not include explicit confidence levels or probabilities. | ||
Format your response as valid JSON: | ||
{{ | ||
"title": "Final Answer", | ||
"content": "Your synthesized conclusion and explanation here.", | ||
"next_action": "final_answer" | ||
}} | ||
""" | ||
).strip() | ||
|
||
return final_answer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from shared.prompts.test_time_inference import final_answer_prompt, intro_prompt, system_acceptance_prompt | ||
|
||
|
||
def test_intro_prompt(): | ||
"""Test that intro_prompt returns the correct prompt.""" | ||
prompt = intro_prompt() | ||
assert isinstance(prompt, str) | ||
assert "You are a world-class expert in analytical reasoning" in prompt | ||
assert "OUTPUT FORMAT:" in prompt | ||
assert "REASONING PROCESS:" in prompt | ||
assert "REQUIREMENTS:" in prompt | ||
assert "CRITICAL THINKING CHECKLIST:" in prompt | ||
|
||
|
||
def test_system_acceptance_prompt(): | ||
"""Test that system_acceptance_prompt returns the correct prompt.""" | ||
prompt = system_acceptance_prompt() | ||
assert isinstance(prompt, str) | ||
assert "I understand. I will now analyze the problem systematically" in prompt | ||
|
||
|
||
def test_final_answer_prompt(): | ||
"""Test that final_answer_prompt returns the correct prompt.""" | ||
prompt = final_answer_prompt() | ||
assert isinstance(prompt, str) | ||
assert "Review your previous reasoning steps" in prompt | ||
assert "Format your response as valid JSON" in prompt | ||
assert '"title":' in prompt | ||
assert '"content":' in prompt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters