English.guru
返回

Prompt 写作技巧免费详解:举例子、分步推理与不断迭代

让回答更好的三个技巧——举例说明、让模型分步推理,以及通过反复尝试打磨 prompt。

基础能给你一个答案。技巧能给你一个好答案。下面这三个技巧回报最快,而且每一个都是英语表达的问题,而不是技术问题:向模型展示你的意思,而不只是说出来。

举一个例子

prompt 写作里最有力的一招,就是向模型展示你想要的样子。英语里有一个来自教学领域的词专门指这个:few-shot——包含一两个示例的 prompt。

没有示例时,你是在描述:

Rewrite this sentence in a formal style.

有了示例——你是在展示:

Rewrite this sentence in a formal style, like this:

Informal: "We need to fix this fast." → Formal: "This requires prompt attention."

Now rewrite: "Can you send me the file?"

示例消除了关于 formal 对你来说到底意味着什么的所有猜测。模型只需模仿这个样本,而不用去解读一个抽象的词。

示例就是把限制条件写得具体。 说 formal,语域仍然是开放的;展示 「This requires prompt attention」,就把它固定下来了。每当 professional、concise 或 engaging 这类词显得太模糊时,就不要再描述了,直接给一个示例。

让模型分步推理

对于需要多个步骤的任务——决策、诊断、比较——加上一句能让模型展示推理过程的话:

  • Think step by step.
  • Explain your reasoning before the answer.
  • List the steps, then give the conclusion.

这会改变模型输出的内容:不再是一个光秃秃的结论,而是一条可以核查的推理链。这项技巧有个名字,chain-of-thought,但用它其实并不需要知道这个名字。

  • 弱:Which supplier should we choose?
  • 强:Compare the two suppliers on price, reliability and lead time, think through the trade-offs, then recommend one with your reasoning.

强的版本同时做了两件事:强迫模型推理,并且固定了回答的结构,让模型不会漏掉任何一个标准。

不断迭代

prompt 很少第一次就写到位。真正的技能是一个循环:运行、用挑剔的眼光读结果、再重写 prompt 来补上差距。每一轮都会补上上一次回答里缺的东西。

第一轮:Write an email asking for a deadline extension. 回答:一封正确但平淡的邮件。 第二轮:Write an email asking for a deadline extension. It is going to a strict manager, so be respectful, give a concrete reason, and propose a new date.

迭代正是之前所学技能汇聚的地方:prompt 的四个部分会一个接一个地被补上,因为每次的回答都会告诉你漏掉了哪一个。而用挑剔的眼光读回答,靠的正是你在描述技术问题时用到的那种精确。

让模型自我批评

一个有用的收尾动作:让模型回头审视自己的回答,找出其中的弱点。

  • What is the weakest point in this argument?
  • What could be wrong with this answer?
  • Rewrite this, then list the assumptions you made.

这是防范模型习惯性表现得很自信的一道保险——包括在产生幻觉的时候。你不是在要求它给出正确答案;你是在要求它指出自己可能哪里错了,而这本身就是一条有用的信息。

把技巧组合起来

一个 prompt 可以把它们全部组合起来:

Act as a careful editor. Rewrite this paragraph to be clearer. Here is an example of the clarity I want: "The meeting was delayed" → "We moved the meeting to Thursday." Think about what makes the example clearer, then apply that to the paragraph. List the changes you made.

角色、示例、推理,以及要求展示过程——短短四句话,全套技巧都用上了。

自我检测

下面的测验考察这些技巧,以及让它们真正起作用的具体说法。

自我检测:测试:Prompt 写作技巧 →