[OpenAI API] Meaning of parameters in Request body

https://platform.openai.com/docs/api-reference/completions/create

parameter type Is it necessary Defaults explain
model string Required - The ID of the model to use. You can use the list models API to see all available models, or see our models overview for their descriptions.
prompt string or array Optional endoftext The prompt used to generate completions, encoded as a string, an array of strings, an array of tokens, or an array of tokens. Note that endoftext is the document separator that the model sees during training, so if no prompt is specified, the model will generate as if it were generated from the beginning of a new document.
suffix string Optional null A suffix that appears after the inserted text is complete.
max_tokens integer Optional 16 Output the maximum number of tokens generated. The number of input tokens plus max_tokens cannot exceed the context length of the model. Most models have a context length of 2048 tokens (except the latest model, which supports 4096).
temperature number Optional 1 What sampling temperature to use. Higher values ​​mean the model will take more risk. For more creative applications try 0.9 and for applications with a definitive answer try 0 (argmax sampling). We generally recommend modifying this or top_p, but not both.
top_p number Optional 1 An alternative to temperature sampling is called kernel sampling, where the model considers the results of labels with top_p probability quality. So 0.1 means that only tokens containing the top 10% probability quality are considered. We generally recommend changing either this or the temperature, but not both.
n integer Optional 1 How many outputs to generate for each input. Note: Because this parameter generates a lot of output, it can eat up your token quota very quickly. Use with caution and make sure you have a reasonable setting for max_tokens, then stop.
stream boolean Optional false Whether to reflow part of the progress. If set, tokens will be sent as data-only server-sent events when they become available, with the stream terminated by a "data: [DONE] message".
logprobs integer Optional null Include logprobs the log probability of the most likely token, and the selected token. For example, if logprobs is 5, the API will return a list of the 5 most probable tokens. The API will always return a logprob of the sampling token, so there may be at most logprobs+1 elements in the response. The maximum value of logprobs is 5. If you need more, please contact us via our help center and describe your use case.
echo boolean Optional false Echo input in addition to output
stop string or array Optional null Up to 4 sequences, the API will stop generating further tokens. The returned text will not contain stop sequences.
presence_penalty number Optional 0 A number between -2.0 and 2.0. Positive values ​​penalize new tokens based on whether they have appeared in the text so far, increasing the likelihood that the model talks about new topics. See more information on frequency and presence penalties.
frequency_penalty number Optional 0 A number between -2.0 and 2.0. Positive values ​​penalize new symbols based on their existing frequency in the text, making the model less likely to repeat the same line verbatim. See more information on frequency and presence penalties.
best_of integer Optional 1 Generate best_of completions on the server side, and return "best" (the one with the highest log probability for each token). Results cannot be streamed. best_of controls the number of candidate completions when used with n, where n specifies how many to return - best_of must be greater than n. NOTE: Because this parameter generates a lot of completions, it can eat up your token quota very quickly. Use with caution and make sure you have a reasonable setting for max_tokens, then stop.
logit_bias map Optional null Modifies the likelihood of the specified token appearing in completions. Accepts a json object that maps markers (specified by marker IDs in GPT markers) to associated bias values ​​from -100 to 100. You can use this tokenizer tool (for GPT-2 and GPT-3) to convert text to token ids. Mathematically, the bias is added to the log generated by the model before sampling. The exact effect will vary for each model, but values ​​between -1 and 1 should reduce or increase the likelihood of selection; values ​​like -100 or 100 should result in forbidden or exclusive selection of associated tokens . For example, you can pass {"50256":-100} to prevent generating <
user string Optional - A unique identifier representing an end user that can help OpenAI monitor and detect abuse. learn more knowledge.

Guess you like

Origin blog.csdn.net/m0_60641871/article/details/128943999