Reference
[@alammarPromptEngineering2023] : reference
Introduction
對於生成式 AI (generative AI) 而言,prompt 佔有非常重要的地位,乍看有點難以想像。不過如果瞭解 generative AI 的特性就是根據前文(或是上下文)prompt 做回文的預測,可能也沒有這麽奇怪。
我們以 language model 爲例,prompt 的作用就是盡量引導 LLM (更精確是 transformer 的 decoder 或是 encoder) 提供接近想要的回答。
不止如此,傳統的 (analytic) AI 把 instruction/task (e.g. Q&A, sentimental analysis, summary) 和 context (Question, or knowledge in the LLM) 等等分開。但在 generative AI 比較傾向全部合而爲一個 prompt, 或是在一串的 prompts 中。因此 prompt 就得很重要。甚至成爲 prompt engineering.
Prompt Engineering Principle
就是盡量清楚。另一個要點是 “temperature”, 就是調控 output 的隨機性。
-
一個 prompt 引導 LLM 產生有用的 output.
-
例如要 summarize 一篇 article, 就提供兩個 inputs: article and in summary.
-
-
用多個 prompts 得到比較好的 output.
- 如果 in summary 不好。可以用 “To summarize in plain language,“ or “The main point to take from this article is that”.
-
用比較結構的方法描述
- 先描述 task (summary), 再提供 article, 最後要求 summary.
- 先描述 task (Q & A), 再提供 dialogs, 最後提供 indicator 和要求答案。
- 先描述 task (summary), 再提供 article, 最後要求 summary.
Reference
Alammar, Jay. 2023. “Prompt Engineering.” Cohere AI. 2023.