評価指標例:正確性(AIによる判断)
中級
これはEngineering, AI分野の自動化ワークフローで、13個のノードを含みます。主にSet, Evaluation, Agent, OpenAi, EvaluationTriggerなどのノードを使用、AI技術を活用したスマート自動化を実現。 評価指標サンプル:正確性(AIによる判断)
前提条件
- •OpenAI API Key
ワークフロープレビュー
ノード接続関係を可視化、ズームとパンをサポート
ワークフローをエクスポート
以下のJSON設定をn8nにインポートして、このワークフローを使用できます
{
"meta": {
"instanceId": "bf40384a063e00f3b983f4f9bada22b57a8231a04c0fb48d363e26d7b0f2b7e7",
"templateCredsSetupCompleted": true
},
"nodes": [
{
"id": "4e2acf3b-3629-4719-b6dd-80e0efdd1cad",
"name": "付箋1",
"type": "n8n-nodes-base.stickyNote",
"position": [
200,
20
],
"parameters": {
"color": 7,
"width": 300,
"height": 180,
"content": "Check whether the answer has the same meaning as the expected answer"
},
"typeVersion": 1
},
{
"id": "08f2b16f-766f-4d80-8a16-7b41ce4da472",
"name": "付箋3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1200,
40
],
"parameters": {
"width": 200,
"height": 500,
"content": "## How it works\nThis template shows how to calculate a workflow evaluation metric: **whether an output matches an expected output** (i.e. has the same meaning).\n\nThe workflow takes questions about the causes of historical events and compares them with the reference answers in the dataset.\n\nYou can find more information on workflow evaluation [here](https://docs.n8n.io/advanced-ai/evaluations/overview), and other metric examples [here](https://docs.n8n.io/advanced-ai/evaluations/metric-based-evaluations/#2-calculate-metrics)."
},
"typeVersion": 1
},
{
"id": "e8674263-6cb6-49dc-9b93-3ce167b35608",
"name": "付箋4",
"type": "n8n-nodes-base.stickyNote",
"position": [
-960,
280
],
"parameters": {
"color": 7,
"width": 220,
"height": 220,
"content": "Read in [this test dataset](https://docs.google.com/spreadsheets/d/1uuPS5cHtSNZ6HNLOi75A2m8nVWZrdBZ_Ivf58osDAS8/edit?gid=662663849#gid=662663849) of questions"
},
"typeVersion": 1
},
{
"id": "edcd9964-51a1-49bd-8a9e-ebc9b4d0e963",
"name": "OpenAI Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
-440,
420
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini"
},
"options": {}
},
"credentials": {
"openAiApi": {
"id": "Ag9qPAsY7lpIGkvC",
"name": "JPs n8n openAI key"
}
},
"typeVersion": 1.2
},
{
"id": "f5b9f75a-9a9c-48cf-93a6-16407c730340",
"name": "データセット行取得時",
"type": "n8n-nodes-base.evaluationTrigger",
"position": [
-900,
340
],
"parameters": {
"sheetName": {
"__rl": true,
"mode": "url",
"value": "https://docs.google.com/spreadsheets/d/1uuPS5cHtSNZ6HNLOi75A2m8nVWZrdBZ_Ivf58osDAS8/edit?gid=662663849#gid=662663849"
},
"documentId": {
"__rl": true,
"mode": "url",
"value": "https://docs.google.com/spreadsheets/d/1uuPS5cHtSNZ6HNLOi75A2m8nVWZrdBZ_Ivf58osDAS8/edit?gid=662663849#gid=662663849"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "bpr2LoSELMlxpwnN",
"name": "Google Sheets account David"
}
},
"typeVersion": 4.6
},
{
"id": "411fb522-c5d4-4c24-ba0f-cb830e1b63c4",
"name": "評価中?",
"type": "n8n-nodes-base.evaluation",
"position": [
-60,
200
],
"parameters": {
"operation": "checkIfEvaluating"
},
"typeVersion": 4.6
},
{
"id": "01b7bd96-00e5-4618-9797-8477b41ad78b",
"name": "AIエージェント",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
-440,
200
],
"parameters": {
"text": "={{ $json.chatInput }}",
"options": {
"systemMessage": "You are a helpful assistant. Answer the user's questions, but be very concise (max one sentence)"
},
"promptType": "define"
},
"typeVersion": 1.9
},
{
"id": "886ee0aa-db8a-4b64-a9d6-ac4fc865a36b",
"name": "正解率指標を計算",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
220,
80
],
"parameters": {
"modelId": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini",
"cachedResultName": "GPT-4O-MINI"
},
"options": {},
"messages": {
"values": [
{
"role": "system",
"content": "=You are an expert factual evaluator assessing the accuracy of answers compared to established ground truths.\n\nEvaluate the factual correctness of a given output compared to the provided ground truth on a scale from 1 to 5. Use detailed reasoning to thoroughly analyze all claims before determining the final score.\n\n# Scoring Criteria\n\n- 5: Highly similar - The output and ground truth are nearly identical, with only minor, insignificant differences.\n- 4: Somewhat similar - The output is largely similar to the ground truth but has few noticeable differences.\n- 3: Moderately similar - There are some evident differences, but the core essence is captured in the output.\n- 2: Slightly similar - The output only captures a few elements of the ground truth and contains several differences.\n- 1: Not similar - The output is significantly different from the ground truth, with few or no matching elements.\n\n# Evaluation Steps\n\n1. Identify and list the key elements present in both the output and the ground truth.\n2. Compare these key elements to evaluate their similarities and differences, considering both content and structure.\n3. Analyze the semantic meaning conveyed by both the output and the ground truth, noting any significant deviations.\n4. Consider factual accuracy of specific details, including names, dates, numbers, and relationships.\n5. Assess whether the output maintains the factual integrity of the ground truth, even if phrased differently.\n6. Determine the overall level of similarity and accuracy according to the defined criteria.\n\n# Output Format\n\nProvide:\n- A detailed analysis of the comparison (extended reasoning)\n- A one-sentence summary highlighting key differences (not similarities)\n- The final similarity score as an integer (1, 2, 3, 4, or 5)\n\nAlways follow the JSON format below and return nothing else:\n{\n \"extended_reasoning\": \"<detailed step-by-step analysis of factual accuracy and similarity>\",\n \"reasoning_summary\": \"<one sentence summary focusing on key differences>\",\n \"score\": <number: integer from 1 to 5>\n}\n\n# Examples\n\n**Example 1:**\n\nInput:\n- Output: \"The cat sat on the mat.\"\n- Ground Truth: \"The feline is sitting on the rug.\"\n\nExpected Output:\n{\n \"extended_reasoning\": \"I need to compare 'The cat sat on the mat' with 'The feline is sitting on the rug.' First, let me identify the key elements: both describe an animal ('cat' vs 'feline') in a position ('sat' vs 'sitting') on a surface ('mat' vs 'rug'). The subject is semantically identical - 'cat' and 'feline' refer to the same animal. The action is also semantically equivalent - 'sat' and 'sitting' both describe the same position, though one is past tense and one is present continuous. The location differs in specific wording ('mat' vs 'rug') but both refer to floor coverings that serve the same function. The basic structure and meaning of both sentences are preserved, though they use different vocabulary and slightly different tense. The core information being conveyed is the same, but there are noticeable wording differences.\",\n \"reasoning_summary\": \"The sentences differ in vocabulary choice ('cat' vs 'feline', 'mat' vs 'rug') and verb tense ('sat' vs 'is sitting').\",\n \"score\": 3\n}\n\n**Example 2:**\n\nInput:\n- Output: \"The quick brown fox jumps over the lazy dog.\"\n- Ground Truth: \"A fast brown animal leaps over a sleeping canine.\"\n\nExpected Output:\n{\n \"extended_reasoning\": \"I need to compare 'The quick brown fox jumps over the lazy dog' with 'A fast brown animal leaps over a sleeping canine.' Starting with the subjects: 'quick brown fox' vs 'fast brown animal'. Both describe the same entity (a fox is a type of animal) with the same attributes (quick/fast and brown). The action is described as 'jumps' vs 'leaps', which are synonymous verbs describing the same motion. The object in both sentences is a dog, described as 'lazy' in one and 'sleeping' in the other, which are related concepts (a sleeping dog could be perceived as lazy). The structure follows the same pattern: subject + action + over + object. The sentences convey the same scene with slightly different word choices that maintain the core meaning. The level of specificity differs slightly ('fox' vs 'animal', 'dog' vs 'canine'), but the underlying information and imagery remain very similar.\",\n \"reasoning_summary\": \"The sentences use different but synonymous terminology ('quick' vs 'fast', 'jumps' vs 'leaps', 'lazy' vs 'sleeping') and varying levels of specificity ('fox' vs 'animal', 'dog' vs 'canine').\",\n \"score\": 4\n}\n\n# Notes\n\n- Focus primarily on factual accuracy and semantic similarity, not writing style or phrasing differences.\n- Identify specific differences rather than making general assessments.\n- Pay special attention to dates, numbers, names, locations, and causal relationships when present.\n- Consider the significance of each difference in the context of the overall information.\n- Be consistent in your scoring approach across different evaluations."
},
{
"content": "=Output: {{ $json.output }}\n\nGround truth: {{ $('When fetching a dataset row').item.json.reference_answer }}"
}
]
},
"jsonOutput": true
},
"credentials": {
"openAiApi": {
"id": "Ag9qPAsY7lpIGkvC",
"name": "JPs n8n openAI key"
}
},
"typeVersion": 1.8
},
{
"id": "6157d456-aa3c-4cca-9d9e-9f5fd19eae68",
"name": "チャットメッセージ受信時",
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"position": [
-900,
100
],
"webhookId": "aa00c171-d603-4373-90c2-f2c2b97e2273",
"parameters": {
"options": {}
},
"typeVersion": 1.1
},
{
"id": "75aec6a1-376a-489e-940c-4868e8d8bcbb",
"name": "チャット形式に一致",
"type": "n8n-nodes-base.set",
"position": [
-680,
340
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "93f89095-7918-45ad-aa74-a0bbcf0d5788",
"name": "chatInput",
"type": "string",
"value": "={{ $json.question }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "04548ab1-8644-47d3-9652-4552d798853a",
"name": "付箋",
"type": "n8n-nodes-base.stickyNote",
"position": [
-80,
100
],
"parameters": {
"color": 7,
"width": 150,
"height": 260,
"content": "Only calculate metrics if we're evaluating, to reduce costs"
},
"typeVersion": 1
},
{
"id": "792ccfd0-387a-46bc-b68b-948fcd2098dd",
"name": "チャット応答を返す",
"type": "n8n-nodes-base.noOp",
"position": [
220,
340
],
"parameters": {},
"typeVersion": 1
},
{
"id": "1bb9466a-439a-41ff-a425-5550127786d4",
"name": "指標を設定",
"type": "n8n-nodes-base.evaluation",
"position": [
580,
80
],
"parameters": {
"metrics": {
"assignments": [
{
"id": "230589eb-34c8-4d10-9296-4a78d673077a",
"name": "similarity",
"type": "number",
"value": "={{ $json.message.content.score }}"
}
]
},
"operation": "setMetrics"
},
"typeVersion": 4.6
}
],
"pinData": {},
"connections": {
"01b7bd96-00e5-4618-9797-8477b41ad78b": {
"main": [
[
{
"node": "411fb522-c5d4-4c24-ba0f-cb830e1b63c4",
"type": "main",
"index": 0
}
]
]
},
"411fb522-c5d4-4c24-ba0f-cb830e1b63c4": {
"main": [
[
{
"node": "886ee0aa-db8a-4b64-a9d6-ac4fc865a36b",
"type": "main",
"index": 0
}
],
[
{
"node": "792ccfd0-387a-46bc-b68b-948fcd2098dd",
"type": "main",
"index": 0
}
]
]
},
"75aec6a1-376a-489e-940c-4868e8d8bcbb": {
"main": [
[
{
"node": "01b7bd96-00e5-4618-9797-8477b41ad78b",
"type": "main",
"index": 0
}
]
]
},
"edcd9964-51a1-49bd-8a9e-ebc9b4d0e963": {
"ai_languageModel": [
[
{
"node": "01b7bd96-00e5-4618-9797-8477b41ad78b",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"6157d456-aa3c-4cca-9d9e-9f5fd19eae68": {
"main": [
[
{
"node": "01b7bd96-00e5-4618-9797-8477b41ad78b",
"type": "main",
"index": 0
}
]
]
},
"f5b9f75a-9a9c-48cf-93a6-16407c730340": {
"main": [
[
{
"node": "75aec6a1-376a-489e-940c-4868e8d8bcbb",
"type": "main",
"index": 0
}
]
]
},
"886ee0aa-db8a-4b64-a9d6-ac4fc865a36b": {
"main": [
[
{
"node": "1bb9466a-439a-41ff-a425-5550127786d4",
"type": "main",
"index": 0
}
]
]
}
}
}よくある質問
このワークフローの使い方は?
上記のJSON設定コードをコピーし、n8nインスタンスで新しいワークフローを作成して「JSONからインポート」を選択、設定を貼り付けて認証情報を必要に応じて変更してください。
このワークフローはどんな場面に適していますか?
中級 - エンジニアリング, 人工知能
有料ですか?
このワークフローは完全無料です。ただし、ワークフローで使用するサードパーティサービス(OpenAI APIなど)は別途料金が発生する場合があります。
関連ワークフロー
評価指標例:RAGドキュメント関連性
評価指標サンプル:RAGドキュメント関連性
Set
Evaluation
Google Sheets
+
Set
Evaluation
Google Sheets
26 ノードDavid Roberts
エンジニアリング
評価指標の例:ツールが呼び出されたかどうかを確認
評価指標の例:ツールが呼び出しされているかチェック
Set
Evaluation
Agent
+
Set
Evaluation
Agent
15 ノードDavid Roberts
エンジニアリング
評価指標の例:分類
評価指標の例:分類
Set
Webhook
Evaluation
+
Set
Webhook
Evaluation
13 ノードDavid Roberts
エンジニアリング
AIエージェントの応答正確性をOpenAIとRAGASメソッドで評価
OpenAIとRAGASメソッドを使用してAIエージェントの応答の正確性を評価する
Set
Code
Merge
+
Set
Code
Merge
27 ノードJimleuk
エンジニアリング
AIエージェントの応答関連性をOpenAIとコサイン類似度で評価
OpenAIとコサイン類似度を使用してAIエージェントの応答の関連性を評価する
Set
Code
Evaluation
+
Set
Code
Evaluation
20 ノードJimleuk
エンジニアリング
OpenAIを使ったRAG応答の精度評価:ドキュメント・ベースライン指標
OpenAIによるRAG応答の精度評価:ドキュメントベースライン指標
Set
Evaluation
Http Request
+
Set
Evaluation
Http Request
25 ノードJimleuk
エンジニアリング