Chain of Logic: Rule-Based Reasoning with Large Language Models

828 篇文章

已下架不支持订阅

本文探讨了使用大型语言模型进行基于规则的推理,特别是处理复杂逻辑表达式的组成规则。提出逻辑链提示方法,受律师的IRAC推理框架启发,通过分解和重组来引导推理。实验显示,逻辑链在基于规则的推理任务中优于其他方法,对增强语言模型的推理能力和减少对注释法律数据的依赖具有潜力。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

本文是LLM系列文章,针对《Chain of Logic: Rule-Based Reasoning with Large Language Models》的翻译。

摘要

基于规则的推理是法律推理的一种基本类型,它使我们能够通过将规则准确地应用于一组事实来得出结论。我们探索因果语言模型作为基于规则的推理器,特别是关于组成规则——由多个元素组成的规则,这些元素形成了复杂的逻辑表达式。关于组成规则的推理是具有挑战性的,因为它需要多个推理步骤,并注意元素之间的逻辑关系。我们介绍了一种新的提示方法——逻辑链,它通过分解(将元素作为独立的逻辑线程来求解)和重组(将这些子答案重新组合以求解底层逻辑表达式)来引发基于规则的推理。这种方法的灵感来自律师使用的顺序推理方法IRAC(问题、规则、应用、结论)框架。我们评估了八个基于规则的推理任务的逻辑链,这些任务涉及来自LegalBench基准的三个不同的组成规则,并使用开源和商业语言模型证明它始终优于其他提示方法,包括思维链和自问。

1 引言

2 背景

3 逻辑链

4 实验

5 结果与讨论

6 相关工

已下架不支持订阅

### Chain-of-Thought Prompting Mechanism in Large Language Models In large language models, chain-of-thought prompting serves as a method to enhance reasoning capabilities by guiding the model through structured thought processes. This approach involves breaking down complex problems into simpler components and providing step-by-step guidance that mirrors human cognitive processing. The creation of these prompts typically includes selecting examples from training datasets where each example represents part of an overall problem-solving process[^2]. By decomposing tasks into multiple steps, this technique encourages deeper understanding and more accurate predictions compared to traditional methods. For instance, when faced with multi-hop question answering or logical deduction challenges, using such chains allows models not only to generate correct answers but also articulate intermediate thoughts leading up to those conclusions. Such transparency facilitates better interpretability while improving performance on various NLP benchmarks. ```python def create_chain_of_thought_prompt(task_description, examples): """ Creates a chain-of-thought prompt based on given task description and examples. Args: task_description (str): Description of the task at hand. examples (list): List containing tuples of input-output pairs used for demonstration purposes. Returns: str: Formatted string representing the final prompt including both instructions and sample cases. """ formatted_examples = "\n".join([f"Input: {ex[0]}, Output: {ex[1]}" for ex in examples]) return f""" Task: {task_description} Examples: {formatted_examples} Now try solving similar questions following above pattern. """ # Example usage examples = [ ("What color do you get mixing red and blue?", "Purple"), ("If it rains tomorrow, will we have our picnic?", "No") ] print(create_chain_of_thought_prompt("Solve logic puzzles", examples)) ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

UnknownBody

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值