kernel-memory icon indicating copy to clipboard operation
kernel-memory copied to clipboard

[Question] How to implement Short Term Memory

Open roldengarm opened this issue 1 year ago • 3 comments

Context / Scenario

We are building a chat bot and would like to use Kernel Memory to allow users to ask questions. How can we implement a short term memory / chat context? The docs list this as a feature (Short Term Memory (partially implemented/work in progress), but I can't find any documentation about how to use it. Semantic Kernel has some documentation about it.

We're using the Kernel Memory Webclient from our chat bot.

Question

How can I add a context / short term memory when using the Kernel Memory Webclient package and the AskAsync method to ask questions?

roldengarm avatar Jan 26 '24 23:01 roldengarm

Hi @roldengarm!

I have implemented a simple solution in my Kernel Memory Service repository: https://github.com/marcominerva/KernelMemoryService. In particular, take a look to the ChatService.cs file and how it is used.

marcominerva avatar Feb 07 '24 14:02 marcominerva

@marcominerva thanks for the tip. So you're using Semantic Kernel to do that. We're running the complete Kernel Memory service, so not sure where to inject/add that.

roldengarm avatar Feb 07 '24 22:02 roldengarm

You just need to use it just before calling AskAsync or SearchAsync.

marcominerva avatar Feb 08 '24 07:02 marcominerva

here's another take on long term and short term memory: https://github.com/microsoft/kernel-memory/tree/main/examples/302-dotnet-sk-km-chat

  • short term: the chat history acts as short term memory, so it's maintained only while the chat is active
  • long term: KM memory records provide long term information, which is injected in the initial system message. to avoid polluting the short term memory, the initial system message contains long term memory records relevant only to the last chat message

dluc avatar Jun 04 '24 19:06 dluc