目錄
- Introduce 簡介
- setting 設定
- Prompt 提示
- Sample response 回復樣本
- API request 介面請求
- python介面請求示例
- node.js介面請求示例
- curl命令示例
- json格式示例
- 其它資料下載

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-003
Max tokens:60
Temperature:0
Top p:1.0
Frequency penalty:0.0
Presence penalty:0.0
說明:
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,則表示不會有任何懲罰,
Prompt 提示
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:兩顆,火衛一和火衛二,
問:什么是語言模型?
答:
Sample response 回復樣本
A language model is a type of artificial intelligence that uses statistical techniques to predict the probability of a sequence of words.
語言模型是一種人工智能,它使用統計技術來預測單詞序列的概率,
API request 介面請求
python介面請求示例
import os
import openai
openai.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相關資料,希望能幫助到所有小伙伴們,
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/548615.html
標籤:其他
下一篇:使用卷積神經網路實作圖片去摩爾紋
