- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如何指定 Open AI 补全应返回的字数?
例如,想象一下我问 AI 这个问题
Who is Elon Musk?
我可以使用什么参数来确保 AI 发回的结果少于或等于 300 个单词。
我在想 max_tokens
参数是为了那个,但似乎 max_tokens
是为了分解输入而不是输出。
任何想法将不胜感激。谢谢
最佳答案
您在 Playground 中查找的参数称为 Maximum length
,在 API 中为 "max_tokens" . token 在提示和完成之间共享。
The number of tokens processed in a given API request depends on thelength of both your inputs and outputs. As a rough rule of thumb, 1token is approximately 4 characters or 0.75 words for English text.One limitation to keep in mind is that your text prompt and generatedcompletion combined must be no more than the model's maximum contextlength (for most models this is 2048 tokens, or about 1500 words).Check out our tokenizer tool to learn more about how text translatesto tokens.
参见 docs
请注意,此参数处理的是标记而不是单词。如果你想找到与标记相等的单词数,请使用 tokenizer .
关于javascript - 如何指定 OpenAI 完成应返回的最大字数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71888625/
我是一名优秀的程序员,十分优秀!