- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在向完成端点发出请求。我的提示是 1360 个 token ,由 Playground 和 Tokenizer 验证。我不会显示提示,因为对于这个问题来说它有点太长了。
这是我使用 openai npm 包在 Nodejs 中对 openai 的请求。
const response = await openai.createCompletion({
model: 'text-davinci-003',
prompt,
max_tokens: 4000,
temperature: 0.2
})
在 Playground 上测试时,响应后我的总标记为 1374。
通过完成 API 提交我的提示时,出现以下错误:
error: {
message: "This model's maximum context length is 4097 tokens, however you requested 5360 tokens (1360 in your prompt; 4000 for the completion). Please reduce your prompt; or completion length.",
type: 'invalid_request_error',
param: null,
code: null
}
如果您能够解决这个问题,我很想听听您是如何解决的。
最佳答案
max_tokens
参数在提示和完成之间共享。来自提示和完成的 token 加起来不应超过特定 GPT-3 模型的 token 限制。
如官方所述OpenAI article :
Depending on the model used, requests can use up to
4097
tokens sharedbetween prompt and completion. If your prompt is4000
tokens, yourcompletion can be97
tokens at most.The limit is currently a technical limitation, but there are oftencreative ways to solve problems within the limit, e.g. condensing yourprompt, breaking the text into smaller pieces, etc.
关于openai-api - OpenAI GPT-3 API 错误 : "This model' s maximum context length is 4097 tokens",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75396481/
我是一名优秀的程序员,十分优秀!