LARGE LANGUAGE MODELS ARE HUMAN-LEVEL PROMPT ENGINEERS

Tags: LLM
Authors: Andrei Ioan Muresanu, Harris Chan, Jimmy Ba, Keiran Paster, Silviu Pitis, Yongchao Zhou, Ziwen Han
Created Date: October 31, 2023 10:53 AM
Status: Reading
organization: University of Toronto, University of Waterloo, Vector Institute
publisher : ICLR
year: 2023
code: https://github.com/keirp/automatic_prompt_engineer
paper: https://sites.google.com/view/automatic-prompt-engineer

介绍

在大模型时代,提示的作用非常巨大,一个好的提示可以在任务中表现出极好的性能。但通常来说最有效的提示是由人手工制作的,需要耗费大量的人工开销。因此本文就尝试让大语言模型自动生提示本并优化提示。

整体框架

整体流程如下:

  1. 利用大语言模型,根据数据集中的输入和输出,构造多个提示。
  2. 对每个提示进行打分。
  3. 筛选性能较好的提示,让大语言模型根据筛选结果生成相近的提示
  4. 选择最优的提示。

不同生成模板

为了适应不同的需求,作者还设计了三种不同的模板

迭代生成

为了更好地搜索优质提示,作者根据当前得分较好的提示进行重新生成。

实验结果

Greedy表示只生成一个提示,不进行筛选。

### 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
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值