#Context related questions consultation

13 messages · Page 1 of 1 (latest)

cursive flower
#

How to implement contextual dialogue function through API

honest marsh
cursive flower
honest marsh
#

Yeah, you're restricted to the tokens limit

#

After that, you need to implement other strategies, such as using embeddings, or creating summaries of the chat

#

in order to prolong the chat

cursive flower
# honest marsh in order to prolong the chat

Can you give me a demo case? After I merge the historical dialogue content into prompt, I will always prompt "This model's maximum context length is 4097 tokens, however you requested 4190 tokens, Please reduce your prompt; or completion length.", openai seems to have calculated the tokens length of prompt as well. If the conversation continues, the historical dialogue content will cause the prompt to get bigger and bigger, and it will soon be overrun. I don't know if there is a better solution.

honest marsh
#

Yes, the prompt token length is also included

#

So you need to tokenizer your prompt, and then subtract the amount of tokens in your prompt from 4096

#

you can use the various tokenizer libraries available online for GPT2 and GPT3

cursive flower
honest marsh
#

i use the GPT2Tokenizer library from HuggingFace