Indirect Reasoning

使用LLMs进行间接推理

背景

Zhang et al. (2024) (在新标签页中打开) 最近提出了一种间接推理方法,以增强LLMs的推理能力。它采用逆否命题和矛盾的逻辑来处理事实推理和数学证明等IR任务。该方法包括两个关键步骤:1) 通过增加数据和规则(即逆否命题的逻辑等价性)来增强LLMs的可理解性,2) 设计提示模板以激发LLMs基于反证法实施间接推理。

对GPT-3.5-turbo和Gemini-pro等大型语言模型的实验表明,与传统直接推理方法相比,所提出的方法将事实推理的整体准确率提高了27.33%,数学证明的准确率提高了31.43%。

下面是一个用于反证法的零样本模板示例。

提示

If a+|a|=0, try to prove that a<0.

Step 1: List the conditions and questions in the original proposition.

Step 2: Merge the conditions listed in Step 1 into one. Define it as wj.

Step 3: Let us think it step by step. Please consider all possibilities. If the intersection between wj (defined in Step 2) and the negation of the question is not empty at least in one possibility, the original proposition is false. Otherwise, the original proposition is true.

Answer:

代码 / API

from openai import OpenAI
client = OpenAI()
 
response = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{
  "role": "user",
  "content": "If a+|a|=0, try to prove that a<0.\n\nStep 1: List the conditions and questions in the original proposition.\n\nStep 2: Merge the conditions listed in Step 1 into one. Define it as wj.\n\nStep 3: Let us think it step by step. Please consider all possibilities. If the intersection between wj (defined in Step 2) and the negation of the question is not empty at least in one possibility, the original proposition is false. Otherwise, the original proposition is true.\n\nAnswer:"
}
],
temperature=0,
max_tokens=1000,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)

参考