OpenAI GPT-3 API: 如何使模型记住以前的对话?

huangapple go评论83阅读模式
英文:

OpenAI GPT-3 API: How to make a model remember past conversations?

问题

有没有一种方法可以训练一个大型语言模型(LLM)来存储特定的上下文?例如,我有一个长故事,我想提问题,但我不想在每个提示中都放入整个故事。如何让LLM“记住故事”?

英文:

Is there a way to train a Large Language Model (LLM) to store a specific context? For example, I had a long story I want to ask questions about, but I don't want to put the whole story in every prompt. How can I make the LLM "remember the story"?

答案1

得分: 6

考虑到GPT-3模型没有启用过去对话记忆的参数,目前唯一的方法似乎是在提示中包含以前的对话

如果我们看一下以下示例

您是一位友善的支持人员。客户会向您提问,您将提供礼貌的回应

Q: 我的手机无法启动。我该怎么办? <-- 这是一个以前的问题
A: 尝试将手机插入充电器充电一个小时,然后打开它。手机无法启动的最常见原因是电池没有电了。

Q: 我试过了。我还能尝试什么? <-- 这是一个以前的问题
A: 按住按钮15秒。可能需要重置。

Q: 我做了。它启动了,但屏幕是空白的。 <-- 这是一个当前的问题
A:

遵循的规则:

  • 在提示中包含以前的提示-完成对,将最旧的对话放在顶部。

你将面临的问题:

  • 如果聊天时间足够长,您将达到令牌限制。每个GPT-3模型都有您可以传递给它的最大令牌数。在text-davinci-003的情况下,它是4096个令牌。当达到此限制时,OpenAI API将抛出错误。当发生这种情况时,您需要减少以前提示-完成对的数量(例如,只包含最近的4个以前提示-完成对)。

优点:

  • 通过在提示中包含以前的提示-完成对,我们能够为GPT-3模型提供对话的上下文。

缺点:

  • 如果用户提出与超过4个提示-完成对之前的对话相关的问题怎么办?

  • 在提示中包含以前的提示-完成对将耗费(大量的)资金!

英文:

Taking into account that GPT-3 models have no parameter that enables memorization of past conversations, it seems the only way at the moment to "memorize" past conversations is to include past conversations in the prompt.

If we take a look at the following example:

You are a friendly support person. The customer will ask you questions, and you will provide polite responses

Q: My phone won't start. What do I do? <-- This is a past question
A: Try plugging your phone into the charger for an hour and then turn it on. The most common cause for a phone not starting is that the battery is dead.

Q: I've tried that. What else can I try? <-- This is a past question
A: Hold the button in for 15 seconds. It may need a reset.

Q: I did that. It worked, but the screen is blank. <-- This is a current question
A:

Rule to follow:

  • Include prompt-completion pairs in the prompt, with the oldest conversations at the top.

The problem you'll face:

  • You will hit a token limit at some point (if you chat long enough). Each GPT-3 model has a maximum number of tokens you can pass to it. In the case of text-davinci-003, it is 4096 tokens. When you hit this limit, the OpenAI API will throw an error. When this happens, you need to reduce the number of past prompt-completion pairs (e.g., include only the most recent 4 past prompt-completion pairs).

Pros:

  • By including past prompt-completion pairs in the prompt, we are able to give
    GPT-3 models the context of the conversation.

Cons:

  • What if a user asks a question that relates to a conversation that occurred more than 4 prompt-completion pairs ago?
  • Including past prompt-completion pairs in the prompt will cost (a lot of) money!

huangapple
  • 本文由 发表于 2023年2月19日 23:38:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/75501276.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定