ChatGPT是目前最先进的AI聊天机器人,它能够理解图片和文字,生成流畅和有趣的回答。如果你想跟上AI时代的潮流,你一定要学会使用ChatGPT。如果你想了解OpenAI最新发布的GPT-4模型,以及它如何为ChatGPT聊天机器人带来更强大的功能,那么你一定不要错过OpenAI官网推荐的48种最佳应用场景,不管你是资深开发者、初学者,你都能够从0到1快速入门,并掌握他们。
【资料图】
在这个AI大时代,如果不想被人颠覆,就要先颠覆别人。如果你颠覆不了别人,那你就努力运用ChatGPT提高你的技术水平和创造力。
ChatGPT 可以通过模仿真实用户,向模型展示如何回答各种问题来引导模型正确回答。这种方法不仅可以帮助用户解决超出其知识库范围的问题,而且还可以帮助模型学习如何作出符合事实的正确回答,从而大大提升模型性能。ChatGPT 利用这种方法可以帮助用户更快速、更准确地获取信息,并且在各种场景中提供更好的服务。
Introduce 简介Factual answering事实性回答Guide the model towards factual answering by showing it how to respond to questions that fall outside its knowledge base. Using a "?" to indicate a response to words and phrases that it doesn"t know provides a natural response that seems to work better than more abstract replies.通过向模型展示如何回答超出其知识库范围的问题,引导模型做出符合事实的回答。用"?“来指示对它不知道的单词和短语的响应提供了似乎比更抽象的响应更有效的自然响应。
setting 设置Engine
:text-davinci-003Max tokens
:60Temperature
:0Top p
:1.0Frequency penalty
:0.0Presence penalty
:0.0
Prompt 提示说明:0、
Engine
设置定义了你要使用的模型,例如 text-davinci-003 是一个文本生成模型。这种模型可以根据输入的文本,生成新的、相关的文本。1、Max tokens
是指在请求中最多允许返回的 token 数目,比如你可以指定 chatGPT 返回最多60个 token。这可以帮助你控制输出的内容大小,以便更好地控制响应速度和结果。一般1个token约4个字符或者0.75个单词2、Temperature
是一个参数,用于控制 chatGPT 的输出。它决定了 chatGPT 在生成文本时会多么“随意”。值越高,chatGPT 生成的文本就越不可预测;值越低,chatGPT 生成的文本就越可预测。它在0.0到2.0之间,Temperature设置为0意味着ChatGPT将会生成更加保守的回复,即更少的随机性和更多的准确性,这可以帮助你在聊天中更好地控制语义,并且可以防止ChatGPT产生不相关的内容。通常建议更改此值或Top P
,但不要同时更改这两个值。3、Top p
是随温度采样的替代方案,称为核采样,其中模型考虑具有top_p概率质量的标记的结果。因此0.1意味着仅考虑包括前10%概率质量的记号。通常建议更改此值或temperature
,但不要同时更改这两个值。4、Frequency penalty
是指在训练时,模型会根据词频来调整每个单词的重要性。它可以帮助模型更好地理解文本,并减少过拟合。介于-2.0和2.0之间的数字。正值会根据新标记在文本中的现有频率惩罚新标记,从而降低模型逐字重复同一行的可能性。Frequency penalty设置为0意味着模型不会对重复的词进行惩罚。它可以帮助模型生成更多的新词,而不是重复使用已有的词。5、Presence penalty
是指在ChatGPT中,一些预先定义的条件或者状态可能会影响机器人回答的质量,介于-2.0和2.0之间的数字。正值会根据新标记到目前为止是否出现在文本中来惩罚它们,从而增加模型谈论新主题的可能性。如果将 Presence penalty 设置为 0,则表示不会有任何惩罚。
Sample response 回复样本Q: Who is Batman?A: Batman is a fictional comic book character.
Q: What is torsalplexity?A: ?
Q: What is Devz9?A: ?
Q: Who is George Lucas?A: George Lucas is American film director and producer famous for creating Star Wars.
Q: What is the capital of California?A: Sacramento.
Q: What orbits the Earth?A: The Moon.
Q: Who is Fred Rickerson?A: ?
Q: What is an atom?A: An atom is a tiny particle that makes up everything.
Q: Who is Alvan Muntz?A: ?
Q: What is Kozar-09?A: ?
Q: How many moons does Mars have?A: Two, Phobos and Deimos.
Q: What"s a language model?A:问:蝙蝠侠是谁?蝙蝠侠是一个虚构的漫画人物。问:什么是躯干复杂性?答:是吗?问:什么是Devz 9?答:是吗?问:乔治·卢卡斯是谁?乔治·卢卡斯是美国电影导演和制片人,因创作《星星大战》而闻名。问:加州的首府是哪里?A:萨克拉门托。问:什么东西绕地球运行?A:月球。问:弗雷德·里克森是谁?答:是吗?问:什么是原子?原子是构成一切的微小粒子。问:阿尔文·孟茨是谁?答:是吗?问:什么是Kozar-09?答:是吗?问:火星有多少颗卫星?A:两颗,火卫一和火卫二。问:什么是语言模型?答:
API request 接口请求python接口请求示例A language model is a type of artificial intelligence that uses statistical techniques to predict the probability of a sequence of words.语言模型是一种人工智能,它使用统计技术来预测单词序列的概率。
import osimport openaiopenai.api_key = os.getenv("OPENAI_API_KEY")response = openai.Completion.create( model="text-davinci-003", prompt="Q: Who is Batman?\nA: Batman is a fictional comic book character.\n\nQ: What is torsalplexity?\nA: ?\n\nQ: What is Devz9?\nA: ?\n\nQ: Who is George Lucas?\nA: George Lucas is American film director and producer famous for creating Star Wars.\n\nQ: What is the capital of California?\nA: Sacramento.\n\nQ: What orbits the Earth?\nA: The Moon.\n\nQ: Who is Fred Rickerson?\nA: ?\n\nQ: What is an atom?\nA: An atom is a tiny particle that makes up everything.\n\nQ: Who is Alvan Muntz?\nA: ?\n\nQ: What is Kozar-09?\nA: ?\n\nQ: How many moons does Mars have?\nA: Two, Phobos and Deimos.\n\nQ: What"s a language model?\nA:", temperature=0, max_tokens=60, top_p=1.0, frequency_penalty=0.0, presence_penalty=0.0)
node.js接口请求示例const { Configuration, OpenAIApi } = require("openai");const configuration = new Configuration({ apiKey: process.env.OPENAI_API_KEY,});const openai = new OpenAIApi(configuration);const response = await openai.createCompletion({ model: "text-davinci-003", prompt: "Q: Who is Batman?\nA: Batman is a fictional comic book character.\n\nQ: What is torsalplexity?\nA: ?\n\nQ: What is Devz9?\nA: ?\n\nQ: Who is George Lucas?\nA: George Lucas is American film director and producer famous for creating Star Wars.\n\nQ: What is the capital of California?\nA: Sacramento.\n\nQ: What orbits the Earth?\nA: The Moon.\n\nQ: Who is Fred Rickerson?\nA: ?\n\nQ: What is an atom?\nA: An atom is a tiny particle that makes up everything.\n\nQ: Who is Alvan Muntz?\nA: ?\n\nQ: What is Kozar-09?\nA: ?\n\nQ: How many moons does Mars have?\nA: Two, Phobos and Deimos.\n\nQ: What"s a language model?\nA:", temperature: 0, max_tokens: 60, top_p: 1.0, frequency_penalty: 0.0, presence_penalty: 0.0,});
curl命令示例curl https://api.openai.com/v1/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -d "{ "model": "text-davinci-003", "prompt": "Q: Who is Batman?\nA: Batman is a fictional comic book character.\n\nQ: What is torsalplexity?\nA: ?\n\nQ: What is Devz9?\nA: ?\n\nQ: Who is George Lucas?\nA: George Lucas is American film director and producer famous for creating Star Wars.\n\nQ: What is the capital of California?\nA: Sacramento.\n\nQ: What orbits the Earth?\nA: The Moon.\n\nQ: Who is Fred Rickerson?\nA: ?\n\nQ: What is an atom?\nA: An atom is a tiny particle that makes up everything.\n\nQ: Who is Alvan Muntz?\nA: ?\n\nQ: What is Kozar-09?\nA: ?\n\nQ: How many moons does Mars have?\nA: Two, Phobos and Deimos.\n\nQ: What"s a language model?\nA:", "temperature": 0, "max_tokens": 60, "top_p": 1.0, "frequency_penalty": 0.0, "presence_penalty": 0.0}"
json格式示例{ "model": "text-davinci-003", "prompt": "Q: Who is Batman?\nA: Batman is a fictional comic book character.\n\nQ: What is torsalplexity?\nA: ?\n\nQ: What is Devz9?\nA: ?\n\nQ: Who is George Lucas?\nA: George Lucas is American film director and producer famous for creating Star Wars.\n\nQ: What is the capital of California?\nA: Sacramento.\n\nQ: What orbits the Earth?\nA: The Moon.\n\nQ: Who is Fred Rickerson?\nA: ?\n\nQ: What is an atom?\nA: An atom is a tiny particle that makes up everything.\n\nQ: Who is Alvan Muntz?\nA: ?\n\nQ: What is Kozar-09?\nA: ?\n\nQ: How many moons does Mars have?\nA: Two, Phobos and Deimos.\n\nQ: What"s a language model?\nA:", "temperature": 0, "max_tokens": 60, "top_p": 1.0, "frequency_penalty": 0.0, "presence_penalty": 0.0}
其它资料下载如果大家想继续了解人工智能相关学习路线和知识体系,欢迎大家翻阅我的另外一篇博客《重磅 | 完备的人工智能AI 学习——基础知识学习路线,所有资料免关注免套路直接网盘下载》这篇博客参考了Github知名开源平台,AI技术平台以及相关领域专家:Datawhale,ApacheCN,AI有道和黄海广博士等约有近100G相关资料,希望能帮助到所有小伙伴们。
关键词: