人工智能入门
原来大预言模型,每输出一个 Token 就要做一次计算,是根据过去所有的文字,来预测下一个字。
原来图像生成Diffusion,是先把好的图片一步一步加噪声到纯噪声图片,然后再让网络一步一步预测回去训练的。生成图片就是用噪声生成图片。
Zero-shot Prompting:只让 LLM 做事情
K-shot Prompting:给几个例子,适合特定领域的 API、生成特定风格的代码。不要用于知名库和通用编码任务,以及过度的限制和例子。
1 | Write a for-loop iterating over a list of strings using the naming convention in our repo. |
1 | Write a for-loop iterating over a list of strings using the naming convention in our repo. Here are some examples of how we typically format variable names. |
chain of thought prompting.Show reasoning steps for a given task.COT Chain of Thought,思维链。
最适合需要包含多个逻辑步骤的任务
1 | Write a function to check if a number is a perfect cube and a perfect square. |
1 | I want to write a function to check if a number is a perfect cube and a perfect square. Make sure to provide your reasoning first. Here are some examples of how to provide reasoning for a coding task. |
zero-shot cot, multishot cot.
self-consistency prompting:让LLM输出多次,取个最好的
让 LLM 能够 defer to 一个外部系统,遵从外部系统,使用工具,也是降低幻觉的好办法。
1 | After you have fixed this IndexError can you ensure that the CI tests still pass? |
1 | Fix the IndexError. Ensure the CI tests still pass once you have made the fix. Here are the available tools. |
Retrieval Augmented Generation,RAG,检索增强生成,向 LLM Infuse(注入)上下文数据,让LLM在没重新训练的情况下保持最新状态。
1 | Extend the UserAuthService class to check that the client provides a valid OAuth token. |
1 | I want to extend the UserAuthService class to check that the client provides a valid OAuth token. |
Reflexion 就是让 LLM 能够根据它自己的输出来进行反映,这是目前全代理行为在IDE中的核心行为
系统级提示,可以做一些整体的风格。
向上下文信息有限的人提供提示,如果他们感到困惑,LLM(语言学习导师)也会感到困惑。
Prompt的最佳实践,Prompt应该用Structure来结构化:
1 | Here are the logs: |
确切地明白自己要做什么,分解任务。