提示工程 Prompt Engineering 技巧总结

基础版

基础类的prompt基本都是一些小技巧,比如包含一些关键词、prompt的写法套路等。

Few-shot Prompt

Role-play Prompt

比如文字工作人员:

I want you to act as an English translator, spelling corrector and improver. I will speak to you in any language and you will detect the language, translate it and answer in the corrected and improved version of my text, in English. I want you to replace my simplified A0-level words and sentences with more beautiful and elegant, upper level English words and sentences. Keep the meaning same, but make them more literary. I want you to only reply the correction, the improvements and nothing else, do not write explanations. My first sentence is "istanbulu cok seviyom burada olmak cok guzel"

Personality-added Prompt

需要多样的情感表达时使用

Write a witty 500-blog post on why AI will not replace humans. Write in the style of an expert in artificial intelligence with 10+ years of experience. Explain using funny examples

Multi-rounded Prompt

比如:第一轮对话要求ChatGPT给出一些知识,第二轮要他基于以上知识写一篇总结。

Chain-of-Thought Prompt

引导其给出推理过程提高答案的正确率。

Let’s think step by step.

Ref: chain of thought

Let's work this out in a step-by-step way to be sure we have the correct answer.

Ref: https://sites.google.com/view/automatic-prompt-engineer

Self-Reflection Prompt


Ref: Constitutional AI: Harmlessness from AI Feedback

进阶版

进阶版结合了人类分析、解决问题的方法论以及基础版的技巧,能够进一步提升LLM的准确率。

Task break-down Prompt


Ref: Recursive Reprompting and Revision

Discuss-between-LLMs


Ref: DERA: Enhancing Large Language Model Completions with Dialog-Enabled Resolving Agents

ReAct


Reason + Act
拿到任务,首先思考需要什么(thought1),再搜索相关信息(act1)得到结果(observation1),基于结果再思考现在需要什么(thought2)(thought2不仅是对下一步action的规划,同时也是对之前步骤的总结)……多次迭代以上步骤,将更大概率得到正确答案。
用Few-shot引导LLM遵循ReAct行为框架。

Ref: ReAct: Synergizing Reasoning and Acting in Language Models

Reflexion


通过让LLM失败后进行反思(总结之前尝试失败的经验),结合ReAct可以进一步提升的正确率。
Ref: Reflexion: Language Agents with Verbal Reinforcement Learning

posted @ 2023-11-29 16:25  LexLuc  阅读(175)  评论(0编辑  收藏  举报