gpt4 book ai didi

openai-api - 聊天完成/v1/聊天/完成结果与 ChatGPT 结果有很大不同

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

我发现 API/v1/chat/completions 结果与网页结果有很大不同。

这是问题的 API 响应:“content”:“乔治·华盛顿的生日是哪一天”

    curl --location 'https://api.openai.com/v1/chat/completions' \
--header 'Authorization: Bearer TOKEN' \
--header 'Content-Type: application/json' \
--data '{
"model": "gpt-4",
"messages": [
{
"role": "user",
"content": "What is the birthday of George Washington"
}
]
}'
    "choices": [
{
"message": {
"role": "assistant",
"content": "George Washington was born on February 22, 1732."
},
"finish_reason": "stop",
"index": 0
}
]

这是网页上的结果。你可以看到它更长了。 enter image description here

最佳答案

使用 OpenAI 时 create completion使用 GPT,您可以转动一些“旋钮”来调整结果。

其中一个旋钮是温度。温度是 0 到 1 之间的数字。0 非常集中且确定性,1 非常随机。

要生成更长的文本,您还可以使用 max_tokens 参数。

但就你的情况而言,我认为你需要调整提示。添加诸如告诉我更多关于他的信息之类的内容,您应该会看到结果有所改善。

这是我的测试:

curl --location 'https://api.openai.com/v1/chat/completions' \
--header 'Authorization: Bearer TOKEN' \
--header 'Content-Type: application/json' \
--data '{
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "user",
"content": "What is the birthday of George Washington? Tell me more about him."
}
]
}'

答案:

{
"object": "chat.completion",
"model": "gpt-3.5-turbo-0301",
"usage": {
"prompt_tokens": 22,
"completion_tokens": 143,
"total_tokens": 165
},
"choices": [
{
"message": {
"role": "assistant",
"content": "George Washington's birthday is on February 22, 1732. He was the first president of the United States and is often known as the \"Father of His Country.\" Washington also led the Continental Army to victory over the British during the American Revolution. He is known for his strong leadership, unwavering commitment to his country, and the sacrifices he made to help establish the United States. Washington also played a key role in the creation of the U.S. Constitution, which remains a pillar of American democracy today. Throughout his life, Washington was known for his honesty, integrity, and commitment to the ideals of the American democratic system. His legacy has made him one of the most important figures in American history."
},
"finish_reason": "stop",
"index": 0
}
]
}

关于openai-api - 聊天完成/v1/聊天/完成结果与 ChatGPT 结果有很大不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76020058/

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