0


【大模型】chat/completions和completions区别

chat/completions

completions

是 OpenAI API 中的两个不同的端点,它们提供了不同的功能和交互模式。以下是它们的主要区别:

completions

端点

  1. 用途:- 主要用于生成文本补全。你提供一个提示(prompt),模型会基于这个提示生成后续的文本。
  2. 交互模式:- 单次请求-响应模式。你发送一个提示,模型返回一个补全结果。
  3. 适用场景:- 适用于需要连续生成文本的场景,如编写文章、代码补全、生成故事等。
  4. 示例请求:{"model":"text-davinci-003","prompt":"Once upon a time, in a land far, far away,","max_tokens":100}
  5. 示例响应:{"id":"cmpl-5eU3oZz1w9Q8Jt3B3o5Q5Z5Z1","object":"text_completion","created":1609459200,"model":"text-davinci-003","choices":[{"text":" there lived a wise old owl who knew all the secrets of the forest...","index":0,"logprobs":null,"finish_reason":"length"}],"usage":{"prompt_tokens":10,"completion_tokens":100,"total_tokens":110}}

chat/completions

端点

  1. 用途:- 主要用于对话生成。你提供一系列对话消息,模型会基于这些消息生成下一条回复。
  2. 交互模式:- 多轮对话模式。你可以提供一个包含多轮对话的消息列表,模型会基于整个对话上下文生成回复。
  3. 适用场景:- 适用于需要多轮对话的场景,如聊天机器人、客户服务、对话系统等。
  4. 示例请求:{"model":"gpt-4","messages":[{"role":"system","content":"You are a helpful assistant."},{"role":"user","content":"Who won the world series in 2020?"},{"role":"assistant","content":"The Los Angeles Dodgers won the World Series in 2020."},{"role":"user","content":"Where was it played?"}]}
  5. 示例响应:{"id":"chatcmpl-5eU3oZz1w9Q8Jt3B3o5Q5Z5Z1","object":"chat.completion","created":1609459200,"model":"gpt-4","choices":[{"message":{"role":"assistant","content":"The 2020 World Series was played at Globe Life Field in Arlington, Texas."},"index":0,"finish_reason":"stop"}],"usage":{"prompt_tokens":50,"completion_tokens":20,"total_tokens":70}}

总结

  • completions 端点适用于单次文本补全任务,通常用于连续文本生成。
  • chat/completions 端点适用于多轮对话生成任务,提供更自然的对话体验。

选择哪个端点取决于你的具体需求。

  • 如果你需要生成连续的文本,completions 端点可能更合适。
  • 如果你需要处理多轮对话,chat/completions 端点会更适合。
标签: java servlet 前端

本文转载自: https://blog.csdn.net/weixin_31866177/article/details/140831145
版权归原作者 sdbhewfoqi 所有, 如有侵权,请联系我们删除。

“【大模型】chat/completions和completions区别”的评论:

还没有评论