← 返回目录

Prompt engineering

第 2 / 34 卷日期:

当您与 Gemini 聊天机器人对话时,本质上是在编写提示词。本白皮书重点介绍如何为 Ve ex AI 平台内或通过 API 调用的 Gemini 模型编写提示词,因为直接对模型进行提示时,您将能访问温度等配置参数。

本白皮书详细探讨提示工程技术。我们将分析多种提示技巧以帮助您快速入门,并分享成为提示专家的实用建议与最佳实践,同时讨论编写提示时可能遇到的一些挑战。

提示工程

记住大语言模型( LLM)的工作原理:它是一个预测引擎。模型接收序列文本作为输入,然后根据其训练数据预测下一个标记应该是什么。LLM 通过不断重复这一过程运作,将先前预测的标记添加到序列文本末尾以预测后续标记。下一个标记的预测基于先前标记内容与 LLM 训练期间所见模式之间的关系。

编写提示词时,你实际上是在引导 LLM 预测正确的标记序列。提示工程就是设计高质量提示的过程,这些提示能指导大语言模型生成准确输出。该过程包括调试寻找最佳提示、优化提示长度,以及根据任务需求评估提示的写作风格和结构。在自然语言处理和 LLM 领域,提示是指为生成响应或预测而提供给模型的输入内容。

全站分卷索引 · 34 卷
  1. 1Introduction
  2. 2Prompt engineering
  3. 3LLM output configuration
  4. 4Sampling controls
  5. 5Top-K and top-P
  6. 6Putting it all together
  7. 7Prompting techniques
  8. 8One-shot & few-shot
  9. 9System, contextual and role prompting
  10. 10System prompting
  11. 11Role prompting
  12. 12Contextual prompting
  13. 13Step-back prompting
  14. 14Chain of Thought (CoT)
  15. 15Self-consistency
  16. 16Tree of Thoughts (ToT)
  17. 17ReAct (reason & act)
  18. 18Automatic Prompt Engineering
  19. 19Code prompting
  20. 20Prompts for explaining code
  21. 21Prompts for translating code
  22. 22Prompts for debugging and reviewing code
  23. 23What about multimodal prompting?
  24. 24Design with simplicity
  25. 25Be specific about the output
  26. 26Control the max token length
  27. 27Experiment with input formats and writing styles
  28. 28Adapt to model updates
  29. 29JSON Repair
  30. 30Working with Schemas
  31. 31Experiment together with other prompt engineers
  32. 32CoT Best practices
  33. 33Summary
  34. 34Endnotes