You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

调用OpenAI GPT Davinci返回错误内容,为何与ChatGPT结果不符?

问题描述

我通过以下代码调用OpenAI API的Davinci模型,提问“What is COVID-19?”:

string key = "XXXX";

OpenAIAPI api = new OpenAIAPI(key,Engine.Davinci);

var results = api.Completions.CreateCompletionsAsync(new CompletionRequest("What is COVID-19?", temperature: 0.1, max_tokens: 200), 1).Result;

var answer = results.Completions[0].Text;

但模型返回了错误内容,称COVID-19是治疗精神分裂症的复方药物,具体内容如下:

Covid-19 is a drug that is used to treat the symptoms of schizophrenia. It is a combination of two drugs, clozapine and olanzapine.

How does COVID-19 work?

Covid-19 is a combination of two drugs, clozapine and olanzapine. Clozapine is an antipsychotic drug that works by blocking the action of dopamine, a chemical messenger in the brain. Olanzapine is an antipsychotic drug that works by blocking the action of dopamine and serotonin, another chemical messenger in the brain.

How is COVID-19 used?

Covid-19 is used to treat schizophrenia.

How does COVID-19 work?

Covid-19 is a combination of two drugs, clozapine and olanzapine. Clozapine is an antipsychotic drug that works by blocking

我对此感到困惑,请问我哪里操作出错了?为何无法得到类似ChatGPT的结果?我使用的OpenAI访问NuGet包是OkGoDoIt的OpenAI-API-dotnet。

原因及解决方法
  • 模型类型与接口不匹配:你用的是Davinci这类GPT-3基础文本补全模型,调用的是Completions接口;而ChatGPT基于GPT-3.5/4系列的对话专用模型,使用的是Chat Completions接口。基础补全模型的设计目标是根据给定文本续写内容,而非像对话模型那样精准回答问题,两者定位和能力差异很大。
  • 训练数据与模型特性问题:旧版Davinci模型的训练数据截止到2021年9月,且基础补全模型没有对话模型的指令遵循优化,容易被训练数据中的边缘错误关联(比如可能存在的药物缩写混淆)误导,生成偏离事实的内容。
  • 解决方案:
    1. 切换到对话模型:将模型指定为gpt-3.5-turbo或gpt-4,而非Davinci。
    2. 使用Chat Completions接口:替换原代码中的Completions.CreateCompletionsAsync为Chat.CreateChatCompletionAsync,构造ChatCompletionRequest传递对话消息(比如设置Role.User的消息为“What is COVID-19?”)。

内容的提问来源于stack exchange,提问作者MattHodson

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.05 06:50:32