type
Post
status
Published
date
Apr 28, 2023
summary
Andrew Ng的开一个视频课程教你如何开发基于ChatGPT的应用。这里总结个人感觉有启发的点。
slug
ChatGPT_Prompt_Engineering_for_Developers_Study_Notes
tags
ChatGPT
开发
category
学习阅读笔记
password
icon
Andrew Ng的开一个视频课程教你如何开发基于ChatGPT的应用。这里总结个人感觉有启发的点。
ChatGPT Prompt Engineering for Developers
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F268e474b-9c49-418a-872f-5a0bebbbaa04%2FUntitled.png?table=block&id=c382f41c-4522-4b52-8c0a-01174043d6e1)
Indroduction
所用语言模型类型:教程针对ChatGPT之类的经过intstucted的大语言模型
目标受众:正对使用LLM进行程序开发的开发人员
Guidlines
给清晰的指令
可以达到效果:
更好的答案
直接输出json格式
避免注入
技巧1:用引号之类的标记将用户输入文本和指令区分开
这样即可告诉模型区分什么事指令什么是附加信息。同时避免注入导致的安全问题。
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2Fe40ab7e0-2fe0-4b7a-a113-0b471e8505e8%2FUntitled.png?table=block&id=25ecf1d7-842d-47d0-8c91-278abbc5e7fb)
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F25b2324e-e50b-4f84-a855-7c5a00f722ea%2FUntitled.png?table=block&id=7e537e7a-c4b3-442c-91a0-8f9f25f1221a)
技巧2:告诉模型直接输出Json格式的结果,方便后续编程处理
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F9845e338-6a9f-4a61-85a9-923c2e4a5494%2FUntitled.png?table=block&id=01e87ef2-2415-4655-9fcd-4791fb60ce68)
技巧3:处理意外情况(类似于编程语言的错误处理)。让AI对无效输入回答特定文字。
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F6f6803a3-a11a-4909-b4aa-021b81c29f12%2FUntitled.png?table=block&id=a41042d1-1a95-49ac-9350-59d5aec90784)
技巧4:Few shot给案例。
PS这个用我个人让AI将笑话的案例会非常直观的看到效果提升
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F47dd4dae-6d59-4dda-b693-56455154b88a%2FUntitled.png?table=block&id=166faf37-5605-47f3-9074-54294ee6a7a0)
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F31fc2e06-e3ff-4481-a82c-96e74c307e0f%2FUntitled.png?table=block&id=5155ccb1-aebd-4400-8706-23591600c1fd)
给模型足够时间思考
其实就是你现将问题拆解成大纲一样的步骤,这样AI就会一步一步去思考。
技巧一:直接列出步骤
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F3dd00c3e-6ae0-45cd-94d5-3841bf70af89%2FUntitled.png?table=block&id=36a6ebbb-fe33-4858-96ae-ee0998271b79)
下面这条让目标按步骤干活,还输出json格式
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F793396b8-8d21-44ea-b59e-a7777154bb26%2FUntitled.png?table=block&id=063068fd-71e2-43ca-af6c-1c01a9310924)
技巧2:框架式引导思维过程,而不是让直接给答案
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F979f5945-d015-406d-848b-c4dccd75f85f%2FUntitled.png?table=block&id=1047a1f7-ec73-4ffc-bc0a-0b2747bff227)
避免AI幻想
让AI先回顾相关信息,然后再回答问题
教程没有给案例,我测试比较好的prompt是:
先回顾相关的3条事实信息,然后再回答问题
看下图片对比效果还是蛮明显的。
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F6c127616-0575-457b-952f-c8ec2316514b%2FUntitled.png?table=block&id=c0f88474-4e5d-4c70-8343-f1fdbf3c34a1)
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F39f8d374-00ff-4377-85a8-39742f3587eb%2FUntitled.png?table=block&id=da305d26-e2ca-4bf0-9a0a-9395956ae889)
第二章 Iterative 迭代式的Prompt开发
精髓在这一句:
成为一名有效的提示工程师的关键不在于知道完美的提示,而在于有一个良好的流程来开发对你的应用有效的提示。
测试,发现问题,修改,测试,发现新问题。。
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2Fa4486721-1f58-451b-8c83-bf303932cd4a%2FUntitled.png?table=block&id=fccce3b1-3828-408d-8046-cde56510e810)
示例
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2Fba42e130-757a-4dce-88eb-31b1376b2878%2FUntitled.png?table=block&id=8581e3fc-0957-4354-aa3d-240525141f0d)
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F3e014f0e-2cb0-47b5-99a0-af2b845ae7c2%2FUntitled.png?table=block&id=157fa6d7-c8b8-48b4-8c15-999c8a5d22be)
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2Fee5e59fd-bd62-4e60-a65c-f68df83ffdfe%2FUntitled.png?table=block&id=a242e084-05bf-4fe2-8d4c-4dd180fdade1)
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2Fe4bbc417-0a47-441e-98e0-c5dbb7af49b6%2FUntitled.png?table=block&id=8d5a5063-a838-474e-accf-6bccbf63c87d)
最后输出网页
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F5d5877d7-f590-4b49-8bdd-e35fb98e015b%2FUntitled.png?table=block&id=e6065b55-db05-4ee6-a121-fbaec7c0e396)
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F652e3c1b-f700-4480-9440-a588cbc64af3%2FUntitled.png?table=block&id=08939ac5-d260-40f4-9850-101250ea8f20)
其他章节
干货较少。如果你想不知道如何做对应的开发,视频中的示例可以是一个不错的开始。