gpt4 book ai didi

python - OpenAI GPT-3 API : Why do I get different, 每次都对同一个问题进行不相关的随机响应?

转载 作者:行者123 更新时间:2023-12-02 22:45:35 26 4
gpt4 key购买 nike

我使用的是“text-davinci-003”模型,我从 OpenAI playground 复制了代码,但机器人每次都给我一个简单的“你好”的随机响应。

这是我正在使用的代码:

response: dict = openai.Completion.create(model="text-davinci-003",
prompt=prompt,
temperature=0.9,
max_tokens=150,
top_p=1,
frequency_penalty=0,
presence_penalty=0.6,
stop=[" Human:", " AI:"])
choices: dict = response.get('choices')[0]
text = choices.get('text')
print(text)

3 次不同时间对简单的“你好”聊天的响应:

  1. 第一次它给了我一个 Java 的 hello world 程序

  2. 它第二次回答正确 - ‘你好!今天我能为您提供什么帮助?’

  3. 第三次:

      def my_method
    puts "hello"
    end
    end
    end

    # To invoke this method we would call:
    MyModule::MyClass.my_method

我只是不明白,因为在 OpenAI 的 Playground 上使用同样简单的“你好”提示让我每次都能得到准确的回应——“嗨,你好!今天我能为您提供什么帮助?”

最佳答案

如官方所述OpenAI documentation :

The temperature and top_p settings control how deterministic the modelis in generating a response. If you're asking it for a response wherethere's only one right answer, then you'd want to set these lower. Ifyou're looking for more diverse responses, then you might want to setthem higher. The number one mistake people use with these settings isassuming that they're "cleverness" or "creativity" controls.

改变这个...

temperature = 0.9

...为此。

temperature = 0

关于python - OpenAI GPT-3 API : Why do I get different, 每次都对同一个问题进行不相关的随机响应?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75718913/

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