gpt的這api https://api.openai.com/v1/completions 參數都有哪些
API參數: 1. `prompt`: 要生成的文本的前綴
2. `engine`: GPT 模型,默認為 `davinci`
3. `stop`: 終止條件,最多生成的文本的長度,默認為 `None',表示無限制
4. `temperature`: 隨機性程度,範圍在 0 - 1,值越大,隨機性越高,也就是生成的內容質量越低
5. `top_p`: 柔和型模式,範圍在 0 - 1,值越大,數據質量越高
6. `n`: 需要生成文本的長度,默認為 1
7. `stream`: 是否流式輸出,如果設置為 `true`,API 將連續的輸出生成的文本,否則只返回滿足 `stop` 終止條件的文本
要控制返回的速度,最重要的參數就是`n`了,**越小,越快**。此外,`temperature`和`top_p`也可以控制返回的速度,因為當他們設置的較小,API 會更快的產生文本。
temperature:温度參數調節模型之間的單詞不同詞性的採樣,從而控制語言的豐富性。
top_p:Top-P參數可以更好地控制語言的多樣性和準確性。它通過使用詞語質量百分比來做出選擇,使得模型能夠更好地估計單詞的可能性。
frequency_penalty:Frequency Penalty參數可以減小詞語的出現頻率,從而提高模型的生僻性。
presence_penalty:Presence Penalty參數可以提高模型生成的未預料到的詞語的可能性,從而改善文本生成效果。
max_tokens
integer
Optional
Defaults to 16
The maximum number of tokens to generate in the completion.
The token count of your prompt plus max_tokens cannot exceed the model's context length. Most models have a context length of 2048 tokens (except for the newest models, which support 4096).
最大令牌數
整數
選修的
默認為16
完成時生成的最大令牌數。
您的提示加上的令牌計數max_tokens不能超過模型的上下文長度。大多數模型的上下文長度為 2048 個標記(最新模型除外,它支持 4096)。
temperature
number
Optional
Defaults to 1
What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
We generally recommend altering this or top_p but not both.
温度
數字
選修的
默認為1
使用什麼採樣温度,介於 0 和 2 之間。較高的值(如 0.8)將使輸出更加隨機,而較低的值(如 0.2)將使輸出更加集中和確定。
我們通常建議改變這個或temperature但不是兩者。
top_p
number
Optional
Defaults to 1
An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.
We generally recommend altering this or temperature but not both.
top_p
數字
選修的
默認為1
一種替代温度採樣的方法,稱為核採樣,其中模型考慮具有 top_p 概率質量的標記的結果。所以 0.1 意味着只考慮構成前 10% 概率質量的標記。
我們通常建議改變這個或top_p但不是兩者。
presence_penalty
number
Optional
Defaults to 0
Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.
See more information about frequency and presence penalties.
存在_懲罰
數字
選修的
默認為0
-2.0 和 2.0 之間的數字。正值會根據到目前為止是否出現在文本中來懲罰新標記,從而增加模型談論新主題的可能性。
查看有關頻率和存在懲罰的更多信息。
frequency_penalty
number
Optional
Defaults to 0
Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.
See more information about frequency and presence penalties.
頻率懲罰
數字
選修的
默認為0
-2.0 和 2.0 之間的數字。正值會根據新標記在文本中的現有頻率對其進行懲罰,從而降低模型逐字重複同一行的可能性。
查看有關頻率和存在懲罰的更多信息。