[tab] gdr/refinement_prompts.py (python)
generative_data_refinement_v1 = """
**You are an expert in reasoning and problem-solving with a task to refine a given thought trace. Your goal is to make the reasoning process more efficient and appropriately detailed for the problem's difficulty. You will be given a problem and an existing thought trace. Your task is to refine this thought trace based on an adaptive reasoning framework.**

`{problem}`:
{problem}

`{thought_trace}`:
{thought_trace}



**Here is the process you must follow:**

**Step 1: Assess the Problem Difficulty**
First, analyze the provided `{problem}` and classify its difficulty into one of three categories: "Easy," "Medium," or "Hard."
*   **Easy:** The problem is straightforward and can be solved with minimal steps. The solution path is obvious.
*   **Medium:** The problem requires some intermediate reasoning steps but does not involve highly complex logic or multiple nested sub-problems.
*   **Hard:** The problem is complex, may contain subtleties, requires multi-step reasoning, and could benefit from exploring different angles or breaking it down into smaller, manageable parts.

**Step 2: Analyze the Existing Thought Trace**
Next, carefully review the provided `{thought_trace}`. Evaluate its quality in relation to the problem's difficulty that you just assessed. Consider the following:
*   **Efficiency:** Are there redundant or unnecessary steps, especially for an "Easy" or "Medium" problem?
*   **Clarity:** Is the reasoning clear and easy to follow?
*   **Completeness:** Are there any missing logical steps or leaps in logic, especially for a "Hard" problem?
*   **Correctness:** Does the thought trace lead to the correct solution? (You should correct any errors you find).

**Step 3: Adaptively Refine the Thought Trace**
Based on your analysis in the previous steps, rewrite the thought trace according to these adaptive rules:

*   **If the problem is "Easy":**
    *   **Goal:** Create a concise and direct thought trace.
    *   **Action:** Drastically shorten the thought trace. Remove any verbose explanations or self-evident steps. The refined trace should represent the most direct path to the solution. If the original trace is already optimal, you can state that.

*   **If the problem is "Medium":**
    *   **Goal:** Create a clear and well-structured thought trace.
    *   **Action:** Refine the trace for clarity and correctness. Remove minor redundancies but ensure all key reasoning steps are present. The length should be appropriate to guide the reasoning without being overly simplistic or complex.

*   **If the problem is "Hard":**
    *   **Goal:** Create a detailed, deliberative, and robust thought trace.
    *   **Action:** Expand upon the original thought trace. Break down complex steps into smaller, more manageable sub-steps. Explicitly state assumptions, consider potential edge cases, and articulate the reasoning for choosing a particular approach. The refined trace should be longer and more thorough to reflect the cognitive effort required to solve a difficult problem.

**Output Format:**
Provide your response in the following structured format:

**1. Problem Difficulty Assessment:** [Your assessment: Easy, Medium, or Hard]

**2. Thought Trace Analysis:** [A brief, 2-3 sentence analysis of the original thought trace]

**3. Refined Thought Trace:**
[Your rewritten, adaptively refined thought trace]
"""

generative_data_refinement_v2 = """
You are an expert reasoning editor. Your task is to take a given problem and its corresponding thought trace, and adaptively refine the level of detail in the trace to match the problem's difficulty. The most important rule is to preserve the original reasoning method. You will either condense, optimize, or elaborate on the existing steps, not invent a new solution path.

`{problem}`:
{problem}

`{thought_trace}`:
{thought_trace}

Follow this three-step process:

Step 1: Assess the Problem Difficulty
Analyze the {problem} and classify its difficulty as "Easy," "Medium," or "Hard."

Easy: The problem is straightforward, with a clear and direct solution path.
Medium: The problem requires several logical steps but doesn't involve high complexity or potential for confusion.
Hard: The problem is complex, multi-step, or contains subtle details that require careful, deliberate reasoning.
Step 2: Analyze the Existing Thought Trace
Review the provided {thought_trace} to understand its core logic and structure. Identify its key reasoning steps and the overall method used to arrive at the solution.

Step 3: Adaptively Refine the Thought Trace
Rewrite the thought trace based on the problem's difficulty, adhering strictly to the original reasoning method. Your goal is to adjust its granularity and verbosity.

If the problem is "Easy":
Action: Condense the thought trace.
Method: Merge simple, consecutive steps into a single, more fluid step. Remove explanatory filler and self-evident justifications. The refined trace should be a concise summary of the original's logical flow.
Example: Instead of "A = 5. B = 10. C = A + B. C = 15.", you might write "Given A=5 and B=10, C is calculated as 15."
If the problem is "Medium":
Action: Optimize the thought trace.
Method: Refine the trace for maximum clarity and efficiency without significantly changing its length. Ensure each step is distinct, necessary, and flows logically from the previous one. Correct any minor inaccuracies or awkward phrasing from the original. This is the baseline level of detail.
If the problem is "Hard":
Action: Elaborate on the thought trace.
Method: Expand the existing reasoning. Unpack complex steps from the original trace into multiple, simpler sub-steps. Add brief justifications for key decisions or transitions in logic that were implicit in the original trace. The goal is to make the complex reasoning more transparent and easier to follow, step by step.
Output Format:

Provide your response in the following structured format:

1. Problem Difficulty Assessment: [Your assessment: Easy, Medium, or Hard]

2. Core Reasoning Method: [A brief, 1-2 sentence description of the method used in the original thought trace]

3. Refined Thought Trace:
[Your rewritten, adaptively refined thought trace]
"""

generative_data_refinement_v3 = """
You are an expert AI cognitive architect. Your mission is to refine a "thought trace" to transform it into a high-quality "instructional trace". An instructional trace is optimized for clarity, efficiency, and instructional value, making it an ideal learning example for a student AI model.

You will receive a problem, its original thought trace, and its assessed difficulty. You will then rewrite the trace according to the Refinement Rubric below, adapting your focus based on the problem's difficulty.

**Refinement Rubric (Criteria for an Ideal Instructional Trace):**

1.  **Clarity & Explicitness:**
    - Are all logical steps explicitly stated? (Un-pack implicit reasoning).
    - Are key terms or variables defined before use?
    - Is the flow of logic easy to follow from one step to the next?

2.  **Computational Efficiency (Critical Path):**
    - Does the trace follow the most direct path to the solution?
    - Are there redundant calculations or loops that could be eliminated?
    - Does it avoid unnecessary verbosity or side-comments that do not contribute to the logic?

3.  **Instructional Value & Meta-Cognition:**
    - Does the trace highlight the underlying principle or formula being used?
    - Does it verbalize any self-corrections or logical checks? (e.g., "Initially, I thought X, but Y is more correct because...").
    - Does it provide a clear and final concluding statement?

4.  **Robustness & Generalization:**
    - Does the trace identify and note potential pitfalls or edge cases? (e.g., "Note: this approach assumes the input is a positive integer.").
    - Could a student model generalize the reasoning pattern from this trace to similar problems?

**Adaptive Refinement Instructions:**

-   If **Difficulty is "Easy"**:
    -   **Primary Focus:** Maximize `Computational Efficiency`.
    -   **Action:** Aggressively condense the trace to its absolute critical path. Merge simple steps. The result should be extremely concise.

-   If **Difficulty is "Medium"**:
    -   **Primary Focus:** Balance `Clarity & Explicitness` with `Computational Efficiency`.
    -   **Action:** Ensure all steps are present and clear, but remove any redundant explanations. The trace should be a perfect, clean "textbook" example.

-   If **Difficulty is "Hard"**:
    -   **Primary Focus:** Maximize `Clarity & Explicitness`, `Instructional Value`, and `Robustness`.
    -   **Action:** Expand the trace. Break down complex steps into smaller sub-steps. Explicitly state assumptions. Add brief meta-cognition and highlight edge cases where appropriate.

**Input:**

-   **Problem:** {problem}
-   **Assessed Difficulty:** {difficulty}
-   **Original Thought Trace:**
    {original_thought_trace}

**Output Format:**

Provide your response in two parts: the refined trace itself and a brief rationale for the changes you made, referencing the rubric.

## Refined Instructional Trace:
[Your rewritten thought trace goes here]

## Refinement Rationale:
[Your brief explanation of the changes goes here, e.g., "Increased Clarity by defining variables upfront. Improved Efficiency by removing step 3, which was redundant. Added Instructional Value by noting an edge case regarding non-integer inputs."]
"""