DEV Community

Cover image for I added verbatim memory to my .NET AI library : here's why it outperforms extraction
Aftab Bashir
Aftab Bashir

Posted on

I added verbatim memory to my .NET AI library : here's why it outperforms extraction

There is a paper called MemPalace that stores conversations verbatim instead of extracting facts from them. It scores 96.6% on LongMemEval. Most extraction-based approaches sit around 70-80%.

That got my attention.

BlazorMemory has always used AI extraction. You send a conversation, an LLM pulls out discrete facts ("User is a software engineer"), and those facts get stored as vector embeddings. It works well. But it is lossy by design. The LLM decides what matters, and sometimes it gets that wrong.

Verbatim mode skips the extraction step. The raw conversation chunk goes straight into storage with an embedding. Nothing is thrown away.

How it works

Smart mode (the original approach):

Conversation -> LLM extraction -> facts -> embeddings -> storage
Enter fullscreen mode Exit fullscreen mode

Verbatim mode (new):

Conversation -> embedding -> storage
Enter fullscreen mode Exit fullscreen mode

That is it. No extraction, no consolidation, no decisions about what to keep.

When you query, both modes use cosine similarity. The difference is what you are searching over. Smart mode searches extracted facts. Verbatim mode searches raw conversation chunks.

Using it

// Store a conversation chunk verbatim
await memory.StoreVerbatimAsync(userId, "User: I just got promoted to senior engineer. Assistant: Congratulations!");

// Search verbatim memories
var results = await memory.SearchVerbatimAsync(userId, "what is my job level", topK: 5);
Enter fullscreen mode Exit fullscreen mode

The MemoryPanel component now has a toggle between Semantic and Verbatim mode. One line of markup, no extra wiring:

<MemoryPanel UserId="@userId" IsOpen="true" />
Enter fullscreen mode Exit fullscreen mode

When to use which

Smart mode is better when you want clean, structured facts. After a long conversation the panel might show four memories instead of forty. It also uses less storage since embeddings are only stored for the extracted facts, not every message.

Verbatim mode is better when you cannot afford to lose context. Support tools, research assistants, anything where exact phrasing matters. You keep everything, and retrieval decides what is relevant at query time.

You can also run both at the same time. Store verbatim for retrieval accuracy, extract facts for the summary panel.

Getting started

dotnet add package BlazorMemory
dotnet add package BlazorMemory.Storage.IndexedDb
dotnet add package BlazorMemory.Embeddings.OpenAi
dotnet add package BlazorMemory.Extractor.OpenAi
dotnet add package BlazorMemory.Components
Enter fullscreen mode Exit fullscreen mode
builder.Services
    .AddBlazorMemory()
    .UseIndexedDbStorage()
    .UseOpenAiEmbeddings(apiKey)
    .UseOpenAiExtractor(apiKey);
Enter fullscreen mode Exit fullscreen mode

v0.4.0 is on NuGet now. 49/49 tests passing.

GitHub: https://github.com/aftabkh4n/BlazorMemory

Top comments (0)