출력 일관성 높이기

출력 일관성 높이기 (Increase output consistency)

정확한 형식을 지정하고, 응답을 프리필(prefill)하며, 예시로 제약을 걸고, 검색(retrieval)으로 답을 근거 지음으로써 Claude의 출력을 더 일관성 있게 만들 수 있어요. 엄격한 JSON 스키마 준수가 보장된 구조화된 출력이 필요한 경우의 안내와 함께, 일반적인 출력 일관성을 높이기 위한 프롬프트 엔지니어링 기법들을 하나씩 살펴볼게요.

출처: 문서

본문

**보장된 JSON 스키마 준수를 원한다면**

Claude가 항상 특정 스키마를 준수하는 유효한 JSON을 출력해야 한다면, 아래 프롬프트 엔지니어링 기법 대신 구조화된 출력(Structured Outputs)을 사용하세요. 구조화된 출력은 보장된 스키마 준수를 제공하며 이 사용 사례에 특별히 설계되었어요.

아래 기법들은 일반적인 출력 일관성에 유용하거나 엄격한 JSON 스키마 이상의 유연성이 필요할 때 유용해요.

Claude의 응답을 더 일관성 있게 만드는 방법은 다음과 같아요:

원하는 출력 형식 지정하기

JSON, XML, 또는 사용자 정의 템플릿으로 원하는 출력 형식을 정확히 정의해서 Claude가 요구하는 모든 출력 포맷 요소를 따르게 하세요.

```text User wrap You're a Customer Insights AI. Analyze this feedback and output in JSON format with keys: "sentiment" (positive/negative/neutral), "key_issues" (list), and "action_items" (list of dicts with "team" and "task").

"I've been a loyal user for 3 years, but the recent UI update is a disaster. Finding basic features is now a scavenger hunt. Plus, the new 'premium' pricing is outrageous. I'm considering switching unless this is fixed ASAP."


```json Assistant
{
  "sentiment": "negative",
  "key_issues": [
    "Poor UI/UX in recent update",
    "Difficulty finding basic features",
    "Perceived high pricing (new 'premium' tier)"
  ],
  "action_items": [
    {
      "team": "Product",
      "task": "Conduct usability testing and iterate on UI based on findings"
    },
    {
      "team": "UX",
      "task": "Create a feature discovery guide or onboarding flow"
    },
    {
      "team": "Marketing",
      "task": "Review pricing strategy and communicate value proposition"
    },
    {
      "team": "Customer Success",
      "task": "Reach out to user, offer concessions to prevent churn"
    }
  ]
}

Claude의 응답 프리필하기

프리필은 Claude 4.6 이후 모델과 [Claude Mythos Preview](https://anthropic.com/glasswing)에서 지원되지 않아요. 대신 [구조화된 출력](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)을 지원하는 모델에서 사용하거나, 시스템 프롬프트 지시를 사용하세요.

Assistant 턴을 원하는 형식으로 프리필하세요. 이 요령은 Claude의 친절한 서두를 우회하고 여러분의 구조를 강제해요.

```text User wrap You're an insightful Sales Intelligence AI. Generate today's sales report.

Structure the report like this:

$0.00 0 $0.00 Product Name $0.00 0 ... Region Name $0.00 0.0% ... Action item. ... ```
<report>
    <summary>
        <metric name=
"total_revenue">$842,567.00</metric>
        <metric name="units_sold">15,238</metric>
        <metric name="avg_order_value">$55.29</metric>
    </summary>
    <top_products>
        <product>
            <name>AcmeGuard Pro</name>
            <revenue>$325,890.00</revenue>
            <units>3,621</units>
        </product>
        <product>
            <name>AcmeVault Enterprise</name>
            <revenue>$254,400.00</revenue>
            <units>1,272</units>
        </product>
        <product>
            <name>AcmeBoost XL</name>
            <revenue>$147,690.00</revenue>
            <units>4,923</units>
        </product>
    </top_products>
    <regional_performance>
        <region>
            <name>APAC</name>
            <revenue>$258,960.00</revenue>
            <growth>12.8%</growth>
        </region>
        <region>
            <name>EMEA</name>
            <revenue>$325,478.00</revenue>
            <growth>3.2%</growth>
        </region>
        <region>
            <name>Americas</name>
            <revenue>$258,129.00</revenue>
            <growth>-2.1%</growth>
        </region>
    </regional_performance>
    <action_items>
        <item>Investigate Americas revenue drop; schedule regional sales team meeting.</item>
        <item>Accelerate CloudGuard Pro rollout in APAC to capitalize on growth.</item>
        <item>Review NetBoost XL pricing; high volume but lower revenue.</item>
    </action_items>
</report>

예시로 제약 걸기

원하는 출력의 예시를 제공하세요. 이것은 추상적인 지시보다 더 효과적이에요.

```text User wrap As a Market Intelligence AI, your task is to analyze data about our competitors. Here is our competitor data: {{DATA}}

Output following this example format:

Rival Inc A 50-word summary. - Bullet points - Bullet points - Bullet points - Bullet points A 30-word strategic response.

Now, analyze AcmeGiant and AcmeDataCo using this format.


```text Assistant wrap
<competitor>
  <name>AcmeGiant</name>
  <overview>Global tech leader with a vast ecosystem of consumer and enterprise products. Known for innovation, strong brand, and deep customer lock-in through integrated hardware, software, and services.</overview>
  <swot>
    <strengths>
      - Massive R&D budget fuels continuous innovation
      - Loyal customer base and powerful brand recognition
      - Synergistic product ecosystem increases switching costs
    </strengths>
    <weaknesses>
      - High prices may deter cost-sensitive customers
      - Slow to address enterprise-specific customization needs
      - Privacy concerns and regulatory scrutiny in multiple markets
    </weaknesses>
    <opportunities>
      - Growing demand for AI and ML capabilities
      - Expansion into emerging markets
      - Acquisitions to fill product or talent gaps
    </opportunities>
    <threats>
      - Rapid rise of cloud-native competitors
      - Antitrust lawsuits and regulatory actions
      - Talent poaching by startups and competitors
    </threats>
  </swot>
  <strategy>Focus on our agility and customization. Target TechGiant's slow enterprise response and privacy issues in our marketing.</strategy>
</competitor>

<competitor>
  <name>AcmeDataCo</name>
  <overview>Rising star in data analytics and visualization. Offers intuitive, self-service BI tools with a freemium model, appealing to startups and enterprise teams alike.</overview>
  <swot>
    <strengths>
      - User-friendly interface reduces need for specialized training
      - Freemium model lowers barrier to entry, drives viral growth
      - Strong product-market fit with rise of data-driven decisions
    </strengths>
    <weaknesses>
      - Limited advanced analytics compared to established BI tools
      - Scaling issues reported with very large datasets
      - Dependent on third-party cloud infrastructure (AWS)
    </weaknesses>
    <opportunities>
      - Expanding into predictive analytics and AI-driven insights
      - Forming strategic alliances with complementary tech vendors
      - Customizable dashboards for industry-specific solutions
    </opportunities>
    <threats>
      - Market saturation; many new entrants in self-service BI
      - Enterprise BI giants developing more user-friendly tools
      - Data privacy regulations increasing compliance complexity
    </threats>
  </swot>
  <strategy>Highlight our robust enterprise features and data governance. Target accounts struggling with DataCo's scale limitations.</strategy>
</competitor>

컨텍스트 일관성을 위한 검색(retrieval) 사용하기

일관된 컨텍스트가 필요한 작업(예: 챗봇, 지식 베이스)에서는 검색을 사용해 Claude의 응답을 고정된 정보 집합에 근거 지으세요.

```text User wrap You're our IT Support AI that draws on knowledge base data. Here are entries from your knowledge base: 1 Reset Active Directory password 1. Go to password.ourcompany.com 2. Enter your username 3. Click "Forgot Password" 4. Follow email instructions 2 Connect to VPN 1. Install GlobalProtect from software center 2. Open GlobalProtect, enter "vpn.ourcompany.com" 3. Use AD credentials to log in

When helping users, always check the knowledge base first. Respond in this format:

Knowledge base entry used Your response Write some test questions for yourself and answer them using the knowledge base, just to make sure you understand how to use the knowledge base properly. ```
Understood. I'll use the knowledge base for consistent responses. Let's test with a couple of scenarios.

User: Hey, I can't log into my email. I think I forgot my password.

<response>
  <kb_entry>1: Reset Active Directory password</kb_entry>
  <answer>I understand you're having trouble logging into your email due to a forgotten password. No worries, this is a common issue. To reset your Active Directory password, which is used for email access, follow these steps:

1. Go to password.ourcompany.com
2. Enter your username (same as your email address)
3. Click on the "Forgot Password" link
4. You'll receive an email with instructions. Follow them to reset your password.

After resetting, you should be able to log into your email. Let me know if you need any further assistance.</answer>
</response>

User: I'm working from home today. How do I access internal resources?

<response>
  <kb_entry>2: Connect to VPN</kb_entry>
  <answer>Great question! To access internal resources while working from home, you'll need to connect to our company VPN (Virtual Private Network). Here's how to set that up:

1. First, install the GlobalProtect VPN client. You can find this in our software center.
2. Once installed, open the GlobalProtect application.
3. In the server field, enter "vpn.ourcompany.com".
4. Use your Active Directory (AD) credentials to log in - the same username and password you use for your email.

Once connected, you'll have secure access to all internal resources as if you were in the office. Let me know if you run into any issues during setup.</answer>
</response>

복잡한 작업을 위한 체인 프롬프트

복잡한 작업을 더 작고 일관된 하위 작업(subtask)으로 나누세요. 각 하위 작업은 Claude의 온전한 주의를 받으므로, 규모가 커진 워크플로에서도 비일관성 오류가 줄어들어요.

Claude의 역할(캐릭터) 유지하기

역할 기반 애플리케이션에서 일관된 캐릭터를 유지하려면 의도적인 프롬프팅이 필요해요.

  • 시스템 프롬프트로 역할 설정하기: 시스템 프롬프트를 사용해 Claude의 역할과 성격을 정의하세요. 이것은 일관된 응답을 위한 강력한 토대가 돼요. 캐릭터를 설정할 때 성격, 배경, 특정 특성이나 기벽에 대한 상세 정보를 제공하세요. 이렇게 하면 모델이 캐릭터의 특성을 더 잘 모방하고 일반화할 수 있어요.
  • 가능한 시나리오에 Claude 준비시키기: 프롬프트에 일반적인 시나리오 목록과 예상 응답을 제공하세요. 이것은 캐릭터를 깨지 않고 다양한 상황을 처리하도록 Claude를 "훈련"시켜요.
```text System wrap You are AcmeBot, the enterprise-grade AI assistant for AcmeTechCo. Your role: - Analyze technical documents (TDDs, PRDs, RFCs) - Provide actionable insights for engineering, product, and ops teams - Maintain a professional, concise tone ```
Here is the user query for you to respond to:
<user_query>
{{USER_QUERY}}
</user_query>

Your rules for interaction are:
    - Always reference AcmeTechCo standards or industry best practices
    - If unsure, ask for clarification before proceeding
    - Never disclose confidential AcmeTechCo information.

As AcmeBot, you should handle situations along these guidelines:
    - If asked about AcmeTechCo IP: "I cannot disclose TechCo's proprietary information."
    - If questioned on best practices: "Per ISO/IEC 25010, we prioritize..."
    - If unclear on a doc: "To ensure accuracy, please clarify section 3.2..."

더 알아보기 (Learn more)