How it works
The context is JSON with the user’smessage and memories, an object
that maps an ID to each memory’s text. The keys are yours to choose. One single
decision, recall, asks which memory would most help answer the message.
It has one outcome per memory, plus none.
The outcome IDs must match the keys in context.memories. That is how the model knows which
outcome is which memory. Your memory store stays in your system: you send only the candidates your
search found, up to a few dozen.
Try it
Open this recipe in the playground to run it without an account. The message there asks what kind of films to watch this weekend. Six memories are offered, from a note about The Godfather to a flight to Lisbon. To run it from your code, setSQWISH_API_KEY as in the quickstart, then send this request:
Act on the answer
The probabilities add up to 1 across all the memories andnone. When several memories help,
they share the probability, so don’t wait for each one to pass 0.5. Recall every memory whose
probability is above that of none:
recalled is empty, answer from the message alone.
Adapt it to your data
- Your IDs. Use your store’s own IDs, or short ones such as
m1that you map back. Each one must be both a key incontext.memoriesand an outcome. - Dates. Keep each memory’s date in its text, as the sample does.
- How many. Send the memories your search found most similar, up to a few dozen. It is one
decision however many you send, and a decision can have up to 255 outcomes,
noneincluded. - Many messages. Send one request per message.
What to watch
- Useful memories left out, and stale ones pulled in. Both show up as odd replies.
- Your search sets the limit. A memory it doesn’t find can’t be recalled.
How well it works
Measured withkettei-core on 600 examples from a public dataset, it chose the right answer 86.3% of the time. Always picking the most common answer scores 33.3%. Your own data will differ, so measure it on examples of yours before you rely on it (improve a decision).
Full results
Full results
- Dataset: MemBench (single-hop, multi-hop and preference questions) (MIT).
- Sample: 600 rows, 600 measured decisions.
- Decisions measured:
recall. - Wording: hand-written.
Always picking the most common answer has an accuracy of 0.3333, and guessing by how common each answer is has a log loss of 1.9279.These are past results on one dataset, not a promise of accuracy on yours.
Next steps
- Grade how well each passage answers the query: the same idea for documents your search returns.
- Improve a decision: measure it on your own conversations and make it more accurate.
- API reference: every field in the request and the answer.
