提升大模型输出的9种提示词技巧
9 techniques to generate better LLM outputs:
9 techniques to generate better LLM outputs:
9 种生成更优 LLM 输出的技巧:
An instruction alone, with no examples, schema, or stated constraints, is the default way to generate an LLM response.
仅凭指令,没有示例、模式或明确约束,是生成 LLM 响应的默认方式。
This is zero-shot prompting, and it serves as the baseline. But when outputs aren't good enough, the first thing you should try is to improve the prompt, not a model upgrade.
这是零样本提示(zero-shot prompting),它作为基线存在。但当输出不够理想时,你首先应该尝试的是改进提示词,而不是升级模型。
There are 8 prompting techniques that you can use:
有 8 种提示技巧你可以使用:
- Few-shot prompting: Show the model a few input-output examples. It picks up the pattern and applies it to new inputs.
- Chain-of-thought (CoT): Ask for step-by-step reasoning. Breaks complex problems into smaller, verifiable steps.
- Prompt hierarchy: Use system, developer, and user prompts at different authority levels. Higher levels override lower ones.
- Role-specific prompting: Assign a persona like "You are a security researcher." The model conditions on a different slice of its training data.
- Negative prompting: Specify what the LLM should NOT do. "Do not use marketing language" works as a hard constraint.
- JSON prompting: Define a JSON schema in the prompt. The LLM returns structured output matching that schema.
- Attentive reasoning queries (ARQ): Replace free-form CoT with structured, domain-specific questions. In testing, it hit 90.2% instruction adherence vs. 81.5% for direct prompting.
- Verbalized sampling: Explicitly prompt the LLM to generate multiple responses with probability scores. Recovers the output diversity that RLHF alignment suppresses.
- 少样本提示(Few-shot prompting):向模型展示几个输入-输出示例。它会捕捉模式并将其应用于新输入。
- 思维链(Chain-of-thought, CoT):要求逐步推理。将复杂问题分解为更小、可验证的步骤。
- 提示层级结构(Prompt hierarchy):在不同权限级别使用系统提示、开发者提示和用户提示。高级别会覆盖低级别。
- 角色特定提示(Role-specific prompting):分配一个角色,例如“你是一名安全研究员”。模型会根据其训练数据的不同切片进行条件生成。
- 负向提示(Negative prompting):指定 LLM 不应该做什么。“不要使用营销语言”可作为硬性约束。
- JSON 提示(JSON prompting):在提示中定义 JSON 模式。LLM 返回与该模式匹配的结构化输出。
- 注意力推理查询(Attentive reasoning queries, ARQ):用结构化、领域特定的问题取代自由形式的思维链。在测试中,其指令遵循率达到 90.2%,而直接提示仅为 81.5%。
- 言语化采样(Verbalized sampling):明确提示 LLM 生成多个带有概率分数的响应。恢复了被 RLHF 对齐所抑制的输出多样性。
They stack well together. Few-shot + CoT. JSON + Negative prompting. ARQ is essentially a structured version of CoT for agentic conversations.
它们可以很好地组合使用。少样本 + 思维链。JSON + 负向提示。ARQ 本质上是用于智能体对话的结构化思维链版本。
Of course, better outputs will also come from better context, tool access, and retrieval.
当然,更好的输出也将来自更好的上下文、工具访问和检索。
But these 9 techniques live entirely in the prompt and involve working with the same model, infrastructure, and setup. You are just structuring the prompt differently to get better outputs from an LLM.
但这 9 种技巧完全存在于提示词中,涉及使用相同的模型、基础设施和设置。你只是通过不同的方式构建提示词,从而从 LLM 获得更好的输出。
Once the prompt is doing its job, the next lever is how much compute the model spends before it answers.
一旦提示词发挥了作用,下一个杠杆就是模型在回答之前花费多少计算资源。
I covered that separately, walking through chain of thought, best-of-N, self-refinement, and tree search, and why each of them only keeps paying off when you have a reliable way to verify the output.
我单独讨论过这一点,逐步介绍了思维链、N 选最佳(best-of-N)、自我完善和树搜索,以及为什么只有在你有可靠的方法来验证输出时,这些方法才能持续带来收益。
Read it below.
请阅读下文。
PS: This visual was inspired by ByteByteGo's post on a similar topic. I added some latest research-driven techniques like ARQ, Verbalized sampling, and JSON prompting.
附注:此视觉灵感来源于 ByteByteGo 关于类似主题的文章。我添加了一些最新的研究驱动技巧,如 ARQ、言语化采样和 JSON 提示。
更进一步:量化金融体系
看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力