本笔记学习来自于网站 https://learningprompt.wiki/zh-Hans/
推荐大家学习,很有帮助
To Do and Not to Do
在进行一个空泛的提问时,如推荐一部电影Recommend a movie to me
,ai往往会问你喜欢什么类型的电影,这样要聊很多轮,效率很低
所以可以添加下面的语句到prompt中:
DO NOT ASK FOR INTERESTS. DO NOT ASK FOR PERSONAL INFORMATION.
OpenAI的API最佳实践文档写道:
Instead of just saying what not to do, say what to do instead. 与其告知模型不能干什么,不妨告诉模型能干什么。
尽管ai理解Not to do,但是加入更多限定词,告知模型干什么,回答效率更高更准确,如果还是推荐电影这个例子,可以这样写:
Recommend a movie from the top global trending movies to me.
使用引导词,引导模型输出特定内容
在prompt的最后加上你希望ai给出的答复的首个单词的引导词,在要求ai写代码的时候作用甚好,比如写一个SQL的代码,下面会是更好的prompt
Create a MySQL query for all students in the Computer Science Department:
Table departments, columns = [DepartmentId, DepartmentName]
Table students, columns = [DepartmentId, StudentId, StudentName]
SELECT
在末尾加上SELECT提示ai用SQL代码输出
同理,python语言可以用import
作为引导词
在吴恩达 prompt engineering 课程中,引导词是在中间出现的,不同的是,它是指定让gpt以指定形式输出
prompt = f"""
Generate a list of three made-up book titles along \
with their authors and genres.
Provide them in JSON format with the following keys:
book_id,