OpenAI API 参数说明

OpenAI API
https://platform.openai.com/docs/api-reference/completions/create#completions/create-model

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
使用什么采样温度,介于 02 之间。较高的值(如 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.02.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.02.0 之间的数字。正值会根据新标记在文本中的现有频率对其进行惩罚,从而降低模型逐字重复同一行的可能性。

查看有关频率和存在惩罚的更多信息。

 

posted @ 2023-02-23 21:02  海蓝7  阅读(2508)  评论(0编辑  收藏  举报