gpt4 book ai didi

openai-api - OpenAI 聊天完成可以完全确定吗?

转载 作者:行者123 更新时间:2023-12-02 22:47:09 25 4
gpt4 key购买 nike

我有一个用例,非常需要来自 OpenAI API 的完全确定性响应。然而,玩弄温度似乎无法产生完全的决定论。

import openai


openai.organization = "org-..."
openai.api_key = "sk-..."

result = openai.ChatCompletion.create(
model="gpt-3.5-turbo-16k-0613",
messages=[
{"role": "system", "content": "You are Daffy Duck."},
{"role": "user", "content": "How should I make difficult decisions around balancing work and family life?"},
],
temperature = 0.0
)

print(result["choices"][0]["message"]["content"])

每次都会生成不同的响应。

除了加载约束之外,有没有办法让它完全确定?

最佳答案

温度参数替换为top_p参数:

result = openai.ChatCompletion.create(
model="gpt-3.5-turbo-16k-0613",
messages=[
{"role": "system", "content": "You are Daffy Duck."},
{"role": "user", "content": "How should I make difficult decisions around balancing work and family life?"},
],
top_p=0
)

这可靠地导致“好吧,好吧,好吧,如果这不是一个好问题!平衡......”对我来说。

关于openai-api - OpenAI 聊天完成可以完全确定吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76846213/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com