0Pricing
AI Prompt Engineering · Lesson

Self-Critique and Revision Patterns

Prompting models to evaluate and rewrite their own outputs against a constitution.

Self-Critique as a Prompting Technique

Even without a formal CAI training process, you can prompt any capable LLM to critique and improve its own outputs. This self-critique pattern dramatically improves quality for tasks where accuracy, completeness, or safety matters.

The key insight: models have more knowledge than they show in a first pass. A critique prompt surfaces that knowledge.

Basic Accuracy Critique Pattern

The simplest self-critique: ask the model to review its response for factual accuracy and fix any errors.

import anthropic

client = anthropic.Anthropic(api_key='sk-ant-...')

def generate_and_self_critique(question):
    # Step 1: Generate
    r1 = client.messages.create(
        model='claude-opus-4-5',
        max_tokens=512,
        messages=[{'role': 'user', 'content': question}]
    )
    initial = r1.content[0].text

    # Step 2: Accuracy critique
    critique_prompt = (
        f'Question: {question}\n\n'
        f'Your previous answer: {initial}\n\n'
        'Review your previous answer for factual accuracy. '
        'Identify any errors, unsupported claims, or missing important nuances. '
        'Then provide a corrected, improved answer.'
    )
    r2 = client.messages.create(
        model='claude-opus-4-5',
        max_tokens=512,
        messages=[{'role': 'user', 'content': critique_prompt}]
    )
    return r2.content[0].text

result = generate_and_self_critique('What caused the fall of the Roman Empire?')
print(result[:300])

All lessons in this course

  1. CAI Principles and Critique Prompts
  2. Self-Critique and Revision Patterns
  3. Harmlessness vs Helpfulness Tension
  4. Implementing CAI in Applications
← Back to AI Prompt Engineering