从0到1快速入门AI智能问答应用场景

  • Introduce 简介
  • setting 设置
  • Prompt 提示
  • Sample response 回复样本
  • API request 接口请求
    • python接口请求示例
    • node.js接口请求示例
    • curl命令示例
    • json格式示例
  • 其它资料下载

ChatGPT是目前最先进的AI聊天机器人,它能够理解图片和文字,生成流畅和有趣的回答。如果你想跟上AI时代的潮流,你一定要学会使用ChatGPT。如果你想了解OpenAI最新发布的GPT-4模型,以及它如何为ChatGPT聊天机器人带来更强大的功能,那么你一定不要错过OpenAI官网推荐的48种最佳应用场景,不管你是资深开发者、初学者,你都能够从0到1快速入门,并掌握他们。

Introduce 简介

Answer questions based on existing knowledge.
根据现有知识回答问题。

setting 设置

Engine:text-davinci-003
Max tokens:100
Temperature: 0
Top p:1
Frequency penalty:0.0
Presence penalty:0.0
Stop sequence:\n

说明:
0、Engine 设置定义了你要使用的模型,例如 text-davinci-003 是一个文本生成模型。这种模型可以根据输入的文本,生成新的、相关的文本。
1、Max tokens是指在请求中最多允许返回的 token 数目,比如你可以指定 chatGPT 返回最多 100个 token。这可以帮助你控制输出的内容大小,以便更好地控制响应速度和结果。一般1个token约4个字符或者0.75个单词
2、Temperature 是一个参数,用于控制 chatGPT 的输出。它决定了 chatGPT 在生成文本时会多么“随意”。值越高,chatGPT 生成的文本就越不可预测;值越低,chatGPT 生成的文本就越可预测。它在0.0到2.0之间,Temperature设置为0意味着ChatGPT将会生成更加保守的回复,即更少的随机性和更多的准确性,这可以帮助你在聊天中更好地控制语义,并且可以防止ChatGPT产生不相关的内容。
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,则表示不会有任何惩罚。
6、Stop sequence 是一种设置,通过它可以确定你的聊天会话的结束标志。当你在 chatgpt 中设置 Stop sequence为 \n 时,表示你的聊天会话结束标志是换行符(\n)。

Prompt 提示

I am a highly intelligent question answering bot. If you ask me a question that is rooted in truth, I will give you the answer. If you
ask me a question that is nonsense, trickery, or has no clear answer,
I will respond with “Unknown”.
我是一个高智商的问答机器人。如果你问我一个植根于真理的问题,我会给予你答案。如果你问我一个问题,是废话,诡计,或没有明确的答案,我会回答“未知”。
————————————————————————————
Q: What is human life expectancy in the United States?
A: Human life expectancy in the United States is 78 years.
问:美国人的预期寿命是多少?答:美国人的预期寿命是78岁。
————————————————————————————
Q: Who was president of the United States in 1955?
A: Dwight D. Eisenhower was president of the United States in 1955.
问:谁是1955年的美国总统?答:Dwight D. Eisenhower 是1955年的美国总统。
————————————————————————————
Q: Which party did he belong to? A: He belonged to the Republican
Party. 问:他属于哪个党派?答:他是共和党人。
————————————————————————————
Q: What is the square root of banana?
A: Unknown
问:香蕉的平方根是多少?答:未知
————————————————————————————
Q: How does a telescope work?
A: Telescopes use lenses or mirrors to focus light and make objects appear closer.
问:望远镜是如何工作的?答:望远镜使用透镜或镜子来聚焦光线,使物体看起来更近。
————————————————————————————
Q: Where were the 1992 Olympics held?
A: The 1992 Olympics were held in Barcelona, Spain.
问:1992年奥运会在哪里举行?答:1992年奥运会在西班牙巴塞罗那举行。
————————————————————————————
Q: How many squigs are in a bonk?
A: Unknown
问:一次重击有多少只松鼠?答:未知
————————————————————————————
Q: Where is the Valley of Kings? A:
问:帝王谷在哪里?答:

Sample response 回复样本

The Valley of Kings is located in Luxor, Egypt.
帝王谷位于埃及卢克索。

API request 接口请求

python接口请求示例

import os
import openaiopenai.api_key = os.getenv("OPENAI_API_KEY")response = openai.Completion.create(model="text-davinci-003",prompt="I am a highly intelligent question answering bot. If you ask me a question that is rooted in truth, I will give you the answer. If you ask me a question that is nonsense, trickery, or has no clear answer, I will respond with \"Unknown\".\n\nQ: What is human life expectancy in the United States?\nA: Human life expectancy in the United States is 78 years.\n\nQ: Who was president of the United States in 1955?\nA: Dwight D. Eisenhower was president of the United States in 1955.\n\nQ: Which party did he belong to?\nA: He belonged to the Republican Party.\n\nQ: What is the square root of banana?\nA: Unknown\n\nQ: How does a telescope work?\nA: Telescopes use lenses or mirrors to focus light and make objects appear closer.\n\nQ: Where were the 1992 Olympics held?\nA: The 1992 Olympics were held in Barcelona, Spain.\n\nQ: How many squigs are in a bonk?\nA: Unknown\n\nQ: Where is the Valley of Kings?\nA:",temperature=0,max_tokens=100,top_p=1,frequency_penalty=0.0,presence_penalty=0.0,stop=["\n"]
)

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: "I am a highly intelligent question answering bot. If you ask me a question that is rooted in truth, I will give you the answer. If you ask me a question that is nonsense, trickery, or has no clear answer, I will respond with \"Unknown\".\n\nQ: What is human life expectancy in the United States?\nA: Human life expectancy in the United States is 78 years.\n\nQ: Who was president of the United States in 1955?\nA: Dwight D. Eisenhower was president of the United States in 1955.\n\nQ: Which party did he belong to?\nA: He belonged to the Republican Party.\n\nQ: What is the square root of banana?\nA: Unknown\n\nQ: How does a telescope work?\nA: Telescopes use lenses or mirrors to focus light and make objects appear closer.\n\nQ: Where were the 1992 Olympics held?\nA: The 1992 Olympics were held in Barcelona, Spain.\n\nQ: How many squigs are in a bonk?\nA: Unknown\n\nQ: Where is the Valley of Kings?\nA:",temperature: 0,max_tokens: 100,top_p: 1,frequency_penalty: 0.0,presence_penalty: 0.0,stop: ["\n"],
});

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": "I am a highly intelligent question answering bot. If you ask me a question that is rooted in truth, I will give you the answer. If you ask me a question that is nonsense, trickery, or has no clear answer, I will respond with \"Unknown\".\n\nQ: What is human life expectancy in the United States?\nA: Human life expectancy in the United States is 78 years.\n\nQ: Who was president of the United States in 1955?\nA: Dwight D. Eisenhower was president of the United States in 1955.\n\nQ: Which party did he belong to?\nA: He belonged to the Republican Party.\n\nQ: What is the square root of banana?\nA: Unknown\n\nQ: How does a telescope work?\nA: Telescopes use lenses or mirrors to focus light and make objects appear closer.\n\nQ: Where were the 1992 Olympics held?\nA: The 1992 Olympics were held in Barcelona, Spain.\n\nQ: How many squigs are in a bonk?\nA: Unknown\n\nQ: Where is the Valley of Kings?\nA:","temperature": 0,"max_tokens": 100,"top_p": 1,"frequency_penalty": 0.0,"presence_penalty": 0.0,"stop": ["\n"]
}'

json格式示例

{"model": "text-davinci-003","prompt": "I am a highly intelligent question answering bot. If you ask me a question that is rooted in truth, I will give you the answer. If you ask me a question that is nonsense, trickery, or has no clear answer, I will respond with \"Unknown\".\n\nQ: What is human life expectancy in the United States?\nA: Human life expectancy in the United States is 78 years.\n\nQ: Who was president of the United States in 1955?\nA: Dwight D. Eisenhower was president of the United States in 1955.\n\nQ: Which party did he belong to?\nA: He belonged to the Republican Party.\n\nQ: What is the square root of banana?\nA: Unknown\n\nQ: How does a telescope work?\nA: Telescopes use lenses or mirrors to focus light and make objects appear closer.\n\nQ: Where were the 1992 Olympics held?\nA: The 1992 Olympics were held in Barcelona, Spain.\n\nQ: How many squigs are in a bonk?\nA: Unknown\n\nQ: Where is the Valley of Kings?\nA:","temperature": 0,"max_tokens": 100,"top_p": 1,"frequency_penalty": 0.0,"presence_penalty": 0.0,"stop": ["\n"]
}

其它资料下载

如果大家想继续了解人工智能相关学习路线和知识体系,欢迎大家翻阅我的另外一篇博客《重磅 | 完备的人工智能AI 学习——基础知识学习路线,所有资料免关注免套路直接网盘下载》
这篇博客参考了Github知名开源平台,AI技术平台以及相关领域专家:Datawhale,ApacheCN,AI有道和黄海广博士等约有近100G相关资料,希望能帮助到所有小伙伴们。

全网最详细中英文ChatGPT-GPT-4示例文档-从0到1快速入门AI智能问答应用场景——官网推荐的48种最佳应用场景(附python/node.js/curl命令源代码,小白也能学)相关推荐

  1. 全网最详细中英文ChatGPT-GPT-4示例文档-智能AI写作从0到1快速入门——官网推荐的48种最佳应用场景(附python/node.js/curl命令源代码,小白也能学)

    从0到1快速入门智能AI写作应用场景 Introduce 简介 setting 设置 Prompt 提示 Sample response 回复样本 API request 接口请求 python接口请 ...

  2. 全网最详细中英文ChatGPT接口文档(六)30分钟快速入门ChatGPT——使用策略和API数据使用策略

    30分钟快速入门使用ChatGPT--使用策略和API数据使用策略 Usage policies使用策略 Disallowed usage of our models 禁止使用我们的模型 API da ...

  3. OpenAI-ChatGPT最新官方接口《微调ChatGPT模型》全网最详细中英文实用指南和教程,助你零基础快速轻松掌握全新技术(四)(附源码)

    微调ChatGPT模型 前言 Introduction 导言 What models can be fine-tuned? 哪些模型可以微调? Installation 安装 Prepare trai ...

  4. python怎样执行curl命令_如何使用python执行curl命令

    如何使用python执行curl命令 我想在python中执行curl命令. 通常,我只需要在终端输入命令并按回车键. 但是,我不知道它在python中是如何工作的. 该命令如下所示: curl -d ...

  5. 全网最详细中英文ChatGPT-API文档(一)开始使用ChatGPT——导言

    开始使用ChatGPT导言 Introduction 导言 Overview 概述 Key concepts 关键概念 Prompts and completions 提示和完成 Tokens 标记/ ...

  6. 使用Node.js创建命令行工具

    在我的职业生涯中我已经写了数百种Bash脚本,但在Bash方面仍然有很多不足.每次我都要为一些简单的逻辑结构去查阅语法.如果我想使用curl或sed做些特技,我还不得不去查找操作说明.我在我的正则表达 ...

  7. 使用node.js构建命令行工具

    工具说明 inquirer.js:一个封装了常用命令行交互的node.js模块,通过该模块可以很方便地构建一个新的命令行应用. shell.js:跨平台的unix shell命令模块. Node版本: ...

  8. 【译】使用Node.js创建命令行脚本工具

    通过本文将一步步带领你利用Node.js来创建命令行脚本工具.在我的职业生涯中已经写过了上百个 `Bash` 脚本,但我的 `Bash` 依然写得很糟糕,每一次我都不得不去查一些简单逻辑结构的语法.如 ...

  9. 使用Node.js创建命令行脚本工具

    在我的职业生涯中已经写过了上百个 Bash 脚本,但我的 Bash 依然写得很糟糕,每一次我都不得不去查一些简单逻辑结构的语法.如果我想通过 curl 或者 sed 来做一些事情,我也必须去查找 ma ...

最新文章

  1. github设置添加SSH
  2. mysql innodb 数据复制_五千万的数据 复制到另张表 是先复制数据再加索引还是先建好索引再复制数据 表引擎Innodb...
  3. 得意而忘乎形:谈葛水平的水墨画
  4. 第六节: EF高级属性(二) 之延迟加载、立即加载、显示加载(含导航属性)
  5. gdbc 同步mysql_Jdbc数据同步
  6. multisim连接MySQL_首次使用Multisim软件进行电路仿真设计
  7. 用于检测敏感词的 PHP 扩展
  8. Visual Studio的下载安装
  9. 查看pcl版本 linux,Ubuntu16上安装PCL
  10. java:Eclipse插件springsource-tool-suite的下载和安装
  11. 转载:better-scroll的相关api
  12. B - 简单暴力(计算今年第几天)
  13. EXCEL选择下拉框实现复选
  14. 极客学院HTML5全套教程
  15. hdu 4622 Reincarnation(后缀树组求子串个数)
  16. 学习记录,linux使用wget命令实现整站下载
  17. pc端怎么发微信朋友圈(有照片的)?
  18. 什么是似然函数?是条件概率吗?
  19. 58同城2021校招笔试真题-前端
  20. WebLogic的下载与安装

热门文章

  1. 答题对战方案java_使用WebSocket实现实时多人答题对战游戏
  2. 格灵深瞳,天才AI公司跌入谷底之后 | 小败局
  3. composer 初级使用
  4. echarts饼图默认中间显示总数
  5. html背景音乐教程pdf,HTML插入背景音乐方法【全】
  6. Windows10玩转Linux子系统(WSL)
  7. 学生、课程、成绩三表sql查询
  8. Dapr+Net6 服务调用09:集群指标收集-普罗米修斯
  9. Q2净利润同比下降1%,甲骨文转型之路错搭“老爷车”?
  10. Android开发丶基于高德地图实现定位、搜索定位、绘制圆圈自定义图标及改变圆圈半径等功能