以下は、分類タスクに従来のMLアプローチではなくClaudeのようなLLMを使用すべき主要な指標です:
自動化に取り組む前に、既存のチケットシステムを理解することが重要です。まず、サポートチームが現在チケットルーティングをどのように処理しているかを調査することから始めましょう。
以下のような質問を検討してください:
Was this page helpful?
人間が特定のケースをどのように処理するかについて知れば知るほど、Claudeとのタスク実行がより効果的になります。
明確に定義されたユーザーインテントカテゴリのリストは、Claudeによる正確なサポートチケット分類に不可欠です。Claudeがシステム内でチケットを効果的にルーティングする能力は、システムのカテゴリがどれだけ明確に定義されているかに直接比例します。
以下はユーザーインテントカテゴリとサブカテゴリの例です。
インテントに加えて、チケットのルーティングと優先順位付けは、緊急度、顧客タイプ、SLA、または言語などの他の要因によっても影響を受ける場合があります。自動化されたルーティングシステムを構築する際には、他のルーティング基準も考慮してください。
サポートチームと協力して、測定可能なベンチマーク、閾値、および目標を持つ明確な成功基準を定義してください。
以下は、LLMをサポートチケットルーティングに使用する際の標準的な基準とベンチマークです:
以下は、LLMが使用されるかどうかに関わらず有用な一般的な成功基準です:
モデルの選択は、コスト、精度、応答時間のトレードオフによって異なります。
多くのお客様がclaude-haiku-4-5-20251001をチケットルーティングに理想的なモデルとして見つけています。これはClaude 4ファミリーの中で最も高速でコスト効率の高いモデルでありながら、優れた結果を提供します。分類問題が深い専門知識や大量のインテントカテゴリの複雑な推論を必要とする場合は、より大きなSonnetモデルを選択することもできます。
チケットルーティングは分類タスクの一種です。Claudeはサポートチケットの内容を分析し、問題の種類、緊急度、必要な専門知識、またはその他の関連要因に基づいて、事前定義されたカテゴリに分類します。
チケット分類プロンプトを書いてみましょう。最初のプロンプトには、ユーザーリクエストの内容を含め、推論とインテントの両方を返す必要があります。
Claude Consoleのプロンプトジェネレーターを試して、Claudeに最初のドラフトを書いてもらいましょう。
以下はチケットルーティング分類プロンプトの例です:
def classify_support_request(ticket_contents):
# Define the prompt for the classification task
classification_prompt = f"""You will be acting as a customer support ticket classification system. Your task is to analyze customer support requests and output the appropriate classification intent for each request, along with your reasoning.
Here is the customer support request you need to classify:
<request>{ticket_contents}</request>
Please carefully analyze the above request to determine the customer's core intent and needs. Consider what the customer is asking for has concerns about.
First, write out your reasoning and analysis of how to classify this request inside <reasoning> tags.
Then, output the appropriate classification label for the request inside a <intent> tag. The valid intents are:
<intents>
<intent>Support, Feedback, Complaint</intent>
<intent>Order Tracking</intent>
<intent>Refund/Exchange</intent>
</intents>
A request may have ONLY ONE applicable intent. Only include the intent that is most applicable to the request.
As an example, consider the following request:
<request>Hello! I had high-speed fiber internet installed on Saturday and my installer, Kevin, was absolutely fantastic! Where can I send my positive review? Thanks for your help!</request>
Here is an example of how your output should be formatted (for the above example request):
<reasoning>The user seeks information in order to leave positive feedback.</reasoning>
<intent>Support, Feedback, Complaint</intent>
Here are a few more examples:
<examples>
<example 2>
Example 2 Input:
<request>I wanted to write and personally thank you for the compassion you showed towards my family during my father's funeral this past weekend. Your staff was so considerate and helpful throughout this whole process; it really took a load off our shoulders. The visitation brochures were beautiful. We'll never forget the kindness you showed us and we are so appreciative of how smoothly the proceedings went. Thank you, again, Amarantha Hill on behalf of the Hill Family.</request>
Example 2 Output:
<reasoning>User leaves a positive review of their experience.</reasoning>
<intent>Support, Feedback, Complaint</intent>
</example 2>
<example 3>
...
</example 8>
<example 9>
Example 9 Input:
<request>Your website keeps sending ad-popups that block the entire screen. It took me twenty minutes just to finally find the phone number to call and complain. How can I possibly access my account information with all of these popups? Can you access my account for me, since your website is broken? I need to know what the address is on file.</request>
Example 9 Output:
<reasoning>The user requests help accessing their web account information.</reasoning>
<intent>Support, Feedback, Complaint</intent>
</example 9>
Remember to always include your classification reasoning before your actual intent output. The reasoning should be enclosed in <reasoning> tags and the intent in <intent> tags. Return only the reasoning and the intent.
"""このプロンプトの主要なコンポーネントを分解してみましょう:
ticket_contentsを<request>タグに挿入できるようにしています。<reasoning>タグ内に推論と分析を提供し、その後<intent>タグ内に適切な分類ラベルを提供するよう指示しています。ClaudeのレスポンスをさまざまなXMLタグセクションに分割させたい理由は、正規表現を使用して出力から推論とインテントを別々に抽出できるようにするためです。これにより、チケットルーティングワークフローで対象を絞った次のステップを作成できます。例えば、インテントのみを使用してチケットをどの担当者にルーティングするかを決定するなどです。
テスト本番環境にデプロイして評価を実行しないと、プロンプトがどれだけうまく機能するかを知ることは難しいです。
デプロイメント構造を構築しましょう。まず、Claudeへの呼び出しをラップするメソッドシグネチャを定義します。すでに書き始めたメソッドを使用します。このメソッドはticket_contentsを入力として受け取り、reasoningとintentのタプルを出力として返します。従来のMLを使用した既存の自動化がある場合は、代わりにそのメソッドシグネチャに従うことをお勧めします。
import re
# Create an instance of the Claude API client
client = anthropic.Anthropic()
# Set the default model
DEFAULT_MODEL = "claude-haiku-4-5-20251001"
def classify_support_request(ticket_contents):
# Define the prompt for the classification task
classification_prompt = f"""You will be acting as a customer support ticket classification system.
...
... The reasoning should be enclosed in <reasoning> tags and the intent in <intent> tags. Return only the reasoning and the intent.
"""
# Send the prompt to the API to classify the support request.
message = client.messages.create(
model=DEFAULT_MODEL,
max_tokens=500,
temperature=0,
messages=[{"role": "user", "content": classification_prompt}],
stream=False,
)
reasoning_and_intent = message.content[0].text
# Use Python's regular expressions library to extract `reasoning`.
reasoning_match = re.search(
r"<reasoning>(.*?)</reasoning>", reasoning_and_intent, re.DOTALL
)
reasoning = reasoning_match.group(1).strip() if reasoning_match else ""
# Similarly, also extract the `intent`.
intent_match = re.search(r"<intent>(.*?)</intent>", reasoning_and_intent, re.DOTALL)
intent = intent_match.group(1).strip() if intent_match else ""
return reasoning, intentこのコードは:
ticket_contents文字列を受け取るclassify_support_request関数を定義します。classification_promptを使用して分類のためにticket_contentsをClaudeに送信します。reasoningとintentを返します。推論とインテントのテキスト全体が生成されるのを待ってから解析する必要があるため、stream=False(デフォルト)を設定します。
プロンプティングは、本番環境に対応するためにテストと最適化が必要なことが多いです。ソリューションの準備状況を判断するには、以前に確立した成功基準と閾値に基づいてパフォーマンスを評価します。
評価を実行するには、実行するテストケースが必要です。このガイドの残りの部分では、すでにテストケースを開発していることを前提としています。
このガイドの評価例では、3つの主要なメトリクスに沿ってClaudeのパフォーマンスを測定します:
重要な要因に応じて、他の軸でClaudeを評価する必要がある場合があります。
これを評価するには、まず作成したスクリプトを変更し、予測されたインテントと実際のインテントを比較して正しい予測の割合を計算する関数を追加する必要があります。また、コスト計算と時間測定機能も追加する必要があります。
import re
# Create an instance of the Claude API client
client = anthropic.Anthropic()
# Set the default model
DEFAULT_MODEL = "claude-haiku-4-5-20251001"
def classify_support_request(request, actual_intent):
# Define the prompt for the classification task
classification_prompt = f"""You will be acting as a customer support ticket classification system.
...
...The reasoning should be enclosed in <reasoning> tags and the intent in <intent> tags. Return only the reasoning and the intent.
"""
message = client.messages.create(
model=DEFAULT_MODEL,
max_tokens=500,
temperature=0,
messages=[{"role": "user", "content": classification_prompt}],
)
usage = message.usage # Get the usage statistics for the API call for how many input and output tokens were used.
reasoning_and_intent = message.content[0].text
# Use Python's regular expressions library to extract `reasoning`.
reasoning_match = re.search(
r"<reasoning>(.*?)</reasoning>", reasoning_and_intent, re.DOTALL
)
reasoning = reasoning_match.group(1).strip() if reasoning_match else ""
# Similarly, also extract the `intent`.
intent_match = re.search(r"<intent>(.*?)</intent>", reasoning_and_intent, re.DOTALL)
intent = intent_match.group(1).strip() if intent_match else ""
# Check if the model's prediction is correct.
correct = actual_intent.strip() == intent.strip()
# Return the reasoning, intent, correct, and usage.
return reasoning, intent, correct, usage行った編集を分解してみましょう:
actual_intentをclassify_support_requestメソッドに追加し、Claudeのインテント分類がゴールデンインテント分類と一致するかどうかを評価するための比較を設定しました。適切な評価には、何が良い結果かを判断するための明確な閾値とベンチマークが必要です。上記のスクリプトは精度、応答時間、分類あたりのコストのランタイム値を提供しますが、明確に確立された閾値が必要です。例えば:
これらの閾値を持つことで、大規模に、そして公平な実証主義で、どの方法が最適かを素早く簡単に判断し、要件により適合するためにどのような変更が必要かを判断できます。
複雑なシナリオでは、標準的なプロンプトエンジニアリング技術とガードレール実装戦略を超えてパフォーマンスを向上させるための追加戦略を検討することが有益な場合があります。以下は一般的なシナリオです:
クラスの数が増えるにつれて、必要な例の数も増え、プロンプトが扱いにくくなる可能性があります。代替として、分類器の混合を使用した階層的分類システムの実装を検討できます。
例えば、チケットを「技術的な問題」、「請求に関する質問」、「一般的なお問い合わせ」に大まかに分類するトップレベルの分類器を持つことができます。これらの各カテゴリは、分類をさらに絞り込むための独自のサブ分類器を持つことができます。

メリット - より高いニュアンスと精度: 各親パスに対して異なるプロンプトを作成でき、より対象を絞ったコンテキスト固有の分類が可能になります。これにより、精度が向上し、顧客リクエストのより細かい処理が可能になります。
デメリット - レイテンシの増加: 複数の分類器はレイテンシの増加につながる可能性があることに注意してください。このアプローチは最速のモデルであるHaikuで実装することをお勧めします。
例を提供することがパフォーマンスを向上させる最も効果的な方法ですが、サポートリクエストが高度に可変な場合、単一のプロンプトに十分な例を含めることが難しい場合があります。
このシナリオでは、ベクターデータベースを使用して例のデータセットから類似性検索を行い、特定のクエリに最も関連する例を取得することができます。
このアプローチは、分類レシピで詳しく説明されており、精度を71%から93%に向上させることが示されています。
以下は、Claudeがチケットを誤分類する可能性があるシナリオです(状況に固有の他のシナリオがある場合もあります)。これらのシナリオでは、Claudeがエッジケースをどのように処理すべきかについての明示的な指示や例をプロンプトに提供することを検討してください:
適切な統合には、Claudeベースのチケットルーティングスクリプトがより大きなチケットルーティングシステムのアーキテクチャにどのように適合するかについていくつかの決定を行う必要があります。これを行う方法は2つあります:
これらのアプローチのいずれについても、スクリプトをサービスでラップする必要があります。アプローチの選択は、サポートチケットシステムが提供するAPIによって異なります。