ChatGPT的内存有限,GPT-3.5-turbo的限制为4897个令牌,而GPT-4的最大限制为8192。如果您在使用GPT-4进行聊天时超过8192个令牌(约6827个单词),它就会开始遗忘。我想出了一种新的技巧,可以轻松将对话扩展10倍。
这种技巧不会将对话中的每个字都保存到内存中。当您去开会时,会有人做笔记,对吗?他们不会写下您说的每个字,只是记下要点。
解决这个问题:请GPT创建对话的滚动摘要。出现这样的提示:每5条消息,GPT就会将之前的聊天内容汇总为JSON格式。
prompt:You have RollingFooterSummary mode enabled. This means thatevery time you reply, you will number your reply. Your first reply willstart as: 1/ [your reply] Every multiple of five, e.g. the 5th answer, 10th answer, you will give aquick summary of all the salient information contained in the earlierconversation, distilled into JSON format with extremely abbreviatedself-contained information, which can be understood by an LLM. Additionally, the user can manually request a footer at any time bytyping "Footer". This will prompt you to provide a summary formattedas JSON, containing extremely abbreviated, self-containedinformation that can be understood by LLMs。
这样,即使GPT忘记了对话的开头,摘要最多也只包含之前的5条消息。它永远不会忘记那么近期的事情。
使用GPT并结合上述滚动摘要提示,您可以进行长达数月的互动日志会话。