全网最详细中英文ChatGPT-GPT-4示例文档-从0到1快速入门AI智能问答应用场景——官网推荐的48种最佳应用场景(附python/node.js/curl命令源代码,小白也能学)
從0到1快速入門AI智能問答應用場景
- Introduce 簡介
- setting 設置
- Prompt 提示
- Sample response 回復樣本
- API request 接口請求
- python接口請求示例
- node.js接口請求示例
- curl命令示例
- json格式示例
- 其它資料下載
ChatGPT是目前最先進的AI聊天機器人,它能夠理解圖片和文字,生成流暢和有趣的回答。如果你想跟上AI時代的潮流,你一定要學會使用ChatGPT。如果你想了解OpenAI最新發(fā)布的GPT-4模型,以及它如何為ChatGPT聊天機器人帶來更強大的功能,那么你一定不要錯過OpenAI官網(wǎng)推薦的48種最佳應用場景,不管你是資深開發(fā)者、初學者,你都能夠從0到1快速入門,并掌握他們。
Introduce 簡介
Answer questions based on existing knowledge.
根據(jù)現(xiàn)有知識回答問題。
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 是一個文本生成模型。這種模型可以根據(jù)輸入的文本,生成新的、相關的文本。
1、Max tokens是指在請求中最多允許返回的 token 數(shù)目,比如你可以指定 chatGPT 返回最多 100個 token。這可以幫助你控制輸出的內容大小,以便更好地控制響應速度和結果。一般1個token約4個字符或者0.75個單詞
2、Temperature 是一個參數(shù),用于控制 chatGPT 的輸出。它決定了 chatGPT 在生成文本時會多么“隨意”。值越高,chatGPT 生成的文本就越不可預測;值越低,chatGPT 生成的文本就越可預測。它在0.0到2.0之間,Temperature設置為0意味著ChatGPT將會生成更加保守的回復,即更少的隨機性和更多的準確性,這可以幫助你在聊天中更好地控制語義,并且可以防止ChatGPT產(chǎn)生不相關的內容。
3、Top P 是隨溫度采樣的替代方案,稱為核采樣,其中模型考慮具有top_p概率質量的標記的結果。因此0.1意味著僅考慮包括前10%概率質量的記號。通常建議更改此值或 temperature,但不要同時更改這兩個值。
4、Frequency penalty是指在訓練時,模型會根據(jù)詞頻來調整每個單詞的重要性。它可以幫助模型更好地理解文本,并減少過擬合。介于-2.0和2.0之間的數(shù)字。正值會根據(jù)新標記在文本中的現(xiàn)有頻率懲罰新標記,從而降低模型逐字重復同一行的可能性。Frequency penalty設置為0意味著模型不會對重復的詞進行懲罰。它可以幫助模型生成更多的新詞,而不是重復使用已有的詞。
5、Presence penalty是指在ChatGPT中,一些預先定義的條件或者狀態(tài)可能會影響機器人回答的質量,介于-2.0和2.0之間的數(shù)字。正值會根據(jù)新標記到目前為止是否出現(xiàn)在文本中來懲罰它們,從而增加模型談論新主題的可能性。如果將 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年的美國總統(tǒng)?答:Dwight D. Eisenhower 是1955年的美國總統(tǒng)。
————————————————————————————
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"] }其它資料下載
如果大家想繼續(xù)了解人工智能相關學習路線和知識體系,歡迎大家翻閱我的另外一篇博客《重磅 | 完備的人工智能AI 學習——基礎知識學習路線,所有資料免關注免套路直接網(wǎng)盤下載》
這篇博客參考了Github知名開源平臺,AI技術平臺以及相關領域專家:Datawhale,ApacheCN,AI有道和黃海廣博士等約有近100G相關資料,希望能幫助到所有小伙伴們。
總結
以上是生活随笔為你收集整理的全网最详细中英文ChatGPT-GPT-4示例文档-从0到1快速入门AI智能问答应用场景——官网推荐的48种最佳应用场景(附python/node.js/curl命令源代码,小白也能学)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 自定义listview和Progress
- 下一篇: 简单的在html中引入地图