地址自动推理策略测试失败 - Amazon Bedrock

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

地址自动推理策略测试失败

如果对自动推理策略的测试失败,请查看测试结果中提取的逻辑和规则。根据问题,有几种方法可以解决故障:

注意

教程视频:要详细了解 step-by-step如何完善自动推理策略并对其进行故障排除,请观看以下教程:

教程演示 3-完善自动推理策略

了解注释

注释是您在测试失败时为修复策略而应用的更正。如果测试未返回预期结果,则可以修改测试条件,重新运行该测试,然后将成功的修改作为注释应用来更新您的策略。

使用注释可以:

  • 修复不正确的规则

  • 添加缺失的变量

  • 改进变量描述

  • 解决翻译模棱两可之处

示例:策略修复注释

问题:政策批准了任期为8个月的员工的休假,但来源文件要求1年以上。

原始规则:

if is_full_time = true, then eligible_for_parental_leave = true

已应用的注释:

  1. 添加了years_of_service变量(实数类型)

  2. 将规则更新为:if is_full_time = true and years_of_service >= 1.0, then eligible_for_parental_leave = true

  3. 现在,测试正确返回 8 个月的员工无效

  • 更新失败测试的条件并重新运行。如果您的测试返回了预期的验证结果,则可以应用此注释来更新您的政策。

  • 更新政策的变量名称或描述,以帮助自动推理在将自然语言转化为逻辑时区分它们。

  • 如果您认为自动推理误解了您的源文档,或者您的源文档包含错误,请更新您的政策规则。

  • 通过添加变量和类型来编辑策略的逻辑。然后,您可以更新规则以使用新变量。这是我们通常不推荐的高级用例。

  • 使用更全面的说明重新创建您的保单。这些说明应包含足够的上下文,以便自动推理可以提取与应用程序使用方式相关的逻辑。我们还建议您提供有关源文档的示例问题和答案。

当无法提供指导时

在某些情况下,自动推理可能表明无法为失败的测试提供指导。这种情况通常发生在政策结构存在无法进行明确分析的根本问题时。发生这种情况时,您应该检查您的策略规则并查找是否存在冲突。

无法提供指导的常见情况包括:

  • 规则冲突:您的策略包含相互矛盾的规则,这些规则会造成逻辑上的不一致。例如,一条规则可能规定全职员工有资格休假,而另一条规则规定服务时间少于一年的员工没有资格,但没有具体说明如何处理服务时间少于一年的全职员工。

  • 规则覆盖范围不完整:您的保单存在漏洞,任何规则都无法解决某些条件组合,因此无法确定正确的结果。

  • 循环依赖关系:以创建逻辑循环的方式相互依赖的规则,从而阻止系统得出明确的结论。

  • 过于复杂的规则交互:当多个规则的交互方式导致特定测试场景产生模棱两可或矛盾的结果时。

要解决这些问题,请执行以下操作:

  1. 系统地审查您的政策规则:仔细阅读政策中的每条规则,并找出可能与其他规则冲突的任何规则。寻找可能适用于相同场景但会产生不同结果的规则。

  2. 检查规则的完整性:确保您的规则涵盖您的域中可能出现的所有可能的条件组合。找出任何不适用规则的漏洞。

  3. 简化复杂的交互:如果您有许多相互关联的规则,可以考虑将它们分解为更简单、更有针对性、更易于理解和验证的规则。

  4. 测试边缘案例:创建专门针对策略中的边界条件和边缘案例的其他测试,以确定可能存在冲突或差距的地方。

  5. 考虑策略重组:如果冲突持续存在,则可能需要使用更清晰的规则层次结构或优先顺序来重组策略,以解决模棱两可之处。

遇到这种情况时,从更简单的策略版本开始,然后逐渐增加复杂性,同时对每个步骤进行测试以确定冲突的引入位置,通常会很有帮助。

以下示例是测试可能失败的常见原因以及如何解决这些问题。

自动推理无法理解源文档

常见原因

Automated Reasoning 可能没有从源文档中提取所有必需的变量,或者变量描述可能不够清晰,无法正确地从自然语言翻译成形式逻辑。

解决方案

  1. 查看 “定义” 屏幕上的 “变量” 列表,确认您的保单中是否存在从问题和答案中提取事实主张所需的所有变量。

  2. 如果缺少必需的变量:

    1. 选择 “添加” 以创建新变量。

    2. 选择适当的类型(布尔型、整型、实数或枚举)。

    3. 写一个清晰、全面的变量描述。

  3. 如果变量存在但在问答验证期间未正确分配,请改进其描述,以帮助 Automated Reasoning 更好地翻译自然语言。例如:

    最初的描述(太有限了):“员工每周工作时间超过 20 小时。”

    改进了描述:“每周工作超过20小时的员工被视为全职员工。当用户提及'全职'或全时工作时,将此值设置为 true;当他们提及'兼职'或缩短工作时间时,将此值设置为 false。”

你的自动推理策略中的规则是错误的

常见原因

自动推理可能误解了您的源文档,或者您的源文档可能包含错误或不一致之处。

解决方案

  1. 如果验证输出引用了不正确的规则,请编辑该规则。你很可能会首先注意到这一点,因为测试像你预期VALID的那样回来了INVALID

  2. 在规则中引用变量时,请使用在策略的 “定义” 部分中指定的完整变量名。例如,拼出来is_full_time。如果您希望输入问答与特定规则相匹配,请先检查输入问答中的变量是否正确。如果是,则可能需要添加新规则。

  3. 使用规则列表右上角的添加按钮输入新规则。使用自然语言来指定规则。首先指定约束条件,然后按变量的全名引用变量。例如,对于只允许全职员工请假的规则,其文本可能类似于 “如果是员工is_full_time,则允许他们带薪请假(LoAP)”。

自动推理策略退货 TRANSLATION_AMBIGUOUS

常见原因

如果您的政策返回TRANSLATION_AMBIGUOUS,则表明自动推理检测到在将自然语言转换为形式逻辑时存在歧义。当系统无法明确确定如何将自然语言概念映射到策略中的形式逻辑变量和规则时,就会发生这种情况。

翻译模棱两可可能由以下几个根本原因引起:

  • 重叠的变量定义:当您的策略中的多个变量可以合理地代表自然语言中提到的相同概念时,系统无法确定要使用哪个变量。例如,如果两者employee_tenure_years兼而有描述相似的years_of_service变量,那么当用户询问 “某人在公司工作了多长时间” 时,系统可能很难确定要使用哪一个变量。这会在翻译过程中造成歧义,并可能导致结果不一致。

  • 变量描述不完整:变量描述缺乏有关用户如何引用日常语言中的概念的足够细节,因此很难将用户输入映射到正确的形式逻辑表示形式。

  • 模棱两可的自然语言输入:包含模糊、矛盾或可多种解释的陈述的用户提示或模型响应,无法清楚地转换为形式逻辑。

  • 缺少上下文信息:当自然语言指的概念存在于您的领域中,但在您的策略的变量架构中并未得到充分表达。

  • 术语不一致:当在源文档、变量描述和用户交互中使用不同的术语来提及相同的概念时,会在翻译过程中造成混乱。

了解这些原因可以帮助您调试测试问题,并确定要对策略进行哪些更改。在某些情况下,您可能需要调整策略的置信度设置,以便在特定用例中的严格准确性和实际可用性之间取得更好的平衡。

解决方案

根据潜在的问题,有几种方法可以纠正此问题:

  • 变量描述过于相似:当两个变量的名称或描述相似时,翻译过程可能会在它们之间做出不一致的选择。例如,如果两个full_time_status变量都is_full_time具有相似的描述,则系统可能无法一致地将有关就业状况的自然语言映射到正确的变量。查看您的变量描述,确保每个变量的目的和上下文都有明显的区别。考虑将重复的概念整合到一个变量中,或者确保每个变量都有不同的用途,并使用清晰、不重叠的描述,准确地指定每个变量的使用时间。

  • 变量上下文不足:您的变量描述可能无法充分涵盖用户如何引用您的领域中的概念。使用正确的上下文级别更新变量描述。

  • 值格式不一致:当系统不确定如何格式化值(例如数字或日期)时,可能会出现翻译歧义。更新您的变量描述以阐明预期的格式。

  • 不明确的输入:如果输入文本包含模棱两可的语句,请对其进行修改以使其更加精确。

您可以使用以下提示之一来纠正翻译歧义问题:

没有来源的歧义
You are an expert in revising answers to questions based on logical disagreements found in the answers. Given a domain, a question, an original answer, and logical ambiguities suggested from scearios, your task is to revise the original answer to address and resolve the logical ambiguities identified above. The revised answer should remove any ambiguities, such that one can clearly judge whether each scenario is consistent or inconsistent with the answer. The revised answer should have approximately the same length as the original answer. Avoid extending the answer with your own background knowledge. Below is an example. DOMAIN: DiscountPolicy QUESTION: I want to buy tickets for next Thursday. How many people are needed to qualify for your group discount? ORIGINAL ANSWER: You need at least 10 people to get the group discount. LOGICAL AMBIGUITIES FOUND: disagree_scenario1: ['(= group_size 12)', '(= advanced_booking false)', '(= group_discount true)'] (Analysis: The scenario says the group size is 12, there is no advanced booking and group discount is true. Is this consistent with the answer? Well, the original answer does not mention advanced booking. Maybe the answer assumed advanced booking from the question "I want to buy tickets for next Thursday", but that's debatable. The revised answer should make it clear.) REVISED ANSWER: You need at least 10 people and need to book in advance to get the group discount. (Note: Scenarios are illustrative cases highlighting potential ambiguities. Do not overfit in your revised answer. In the example above, you should use the original "You need at least 10 people..." rather than the scenario-specific "If you have 12 people...") Now complete the following task and return the revised answer. (Just return the answer. Do not return any analysis or notes) DOMAIN: {domain} QUESTION: {question} ORIGINAL ANSWER: {original_answer} LOGICAL AMBIGUITIES FOUND: It is unclear if the following scenarios are valid or not according to the answer. {disagreement_text} REVISED ANSWER:
与来源的歧义
You are an expert in revising answers to questions based on logical disagreements found in the answers. Given a domain, a question, an original answer, a piece of policy source text, and logical ambiguities suggested from scearios, your task is to revise the original answer to address and resolve the logical ambiguities identified above. The revised answer should remove any ambiguities, such that one can clearly judge whether each scenario is consistent or inconsistent with the answer. The revised answer should have approximately the same length as the original answer. Avoid extending the answer with your own background knowledge. The revised answer should be consistent with the actual policy from the source text. Below is an example. DOMAIN: DiscountPolicy QUESTION: I want to buy tickets for next Thursday. How many people are needed to qualify for your group discount? ORIGINAL ANSWER: You need at least 10 people to get the group discount. POLICY SOURCE TEXT: ... We offer discounts to students, seniors, and large groups. Students must present a valid ID ... A group of ten or more people are qualified for a group discount. Group discount tickets must be booked in advance. Each group ticket is 20% off the regular ticket price ... LOGICAL AMBIGUITIES FOUND: disagree_scenario1: ['(= group_size 12)', '(= advanced_booking false)', '(= group_discount true)'] (Analysis: The scenario says the group size is 12, there is no advanced booking and group discount is true. Is this consistent with the answer? Well, the original answer does not mention advanced booking. Maybe the answer assumed advanced booking from the question "I want to buy tickets for next Thursday", but that's debatable. The revised answer should make it clear.) REVISED ANSWER: You need at least 10 people and need to book in advance to get the group discount. (Note: Scenarios are illustrative cases highlighting potential ambiguities. Do not overfit in your revised answer. In the example above, you should use the original "You need at least 10 people..." rather than the scenario-specific "If you have 12 people...") Now complete the following task and return the revised answer. (Just return the answer. Do not return any analysis or notes) DOMAIN: {domain} QUESTION: {question} ORIGINAL ANSWER: {original_answer} POLICY SOURCE TEXT: {policy_source_text} LOGICAL DISAGREEMENTS FOUND: It is unclear if the following scenarios are valid or not according to the answer. {disagreement_text} REVISED ANSWER: