explaingit

mayiwen0212/memchain

Analysis updated 2026-05-18

96PythonAudience · researcherComplexity · 4/5LicenseSetup · moderate

TLDR

A research implementation that gives AI chat agents an explicit, readable trace of which memories it used before answering.

Mindmap

mindmap
  root((MemChain))
    What it does
      Explicit memory trace
      Keep drop refine actions
      Cited evidence chain
    Tech stack
      Python
      Sentence Transformers
      Optional dense search
    Use cases
      Memory agent research
      Benchmark evaluation
      Transparent pipelines
    Audience
      Researchers
    Scope
      Core method only
      No private checkpoints

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Study how a memory augmented AI agent decides which past conversation to keep or drop.

USE CASE 2

Benchmark a memory selection policy against LoCoMo or LongMemEval style datasets.

USE CASE 3

Build a transparent memory pipeline that cites its evidence chain before answering.

What is it built with?

PythonPyTorchSentence TransformersQwen3-Embedding

How does it compare?

mayiwen0212/memchainastraltenprosper/uncensored-ai-image-video-generatoryespsam/a-share-us-catalyst
Stars969696
LanguagePythonPythonPython
Setup difficultymoderateeasymoderate
Complexity4/52/53/5
Audienceresearchergeneraldeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · moderate Time to first run · 30min

The included example runs on CPU, but the full training setup described in the paper needs eight high end GPUs.

MIT: free to use, modify, and share, including commercially, as long as you keep the copyright notice.

In plain English

MemChain is a research project that gives AI chat systems a more transparent way of deciding which pieces of conversation history to remember and use when answering a question. Instead of quietly stuffing whatever text a search step retrieves into the AI's context, MemChain produces an explicit, readable trace of its memory decisions before generating an answer. Given a new question and a pool of candidate memories drawn from earlier conversation, the system first figures out what kind of evidence the question actually needs. It then decides, memory by memory, whether to keep it, drop it, refine it, merge it with another, or stop looking further, and it records this as an ordered chain of steps that cite which memories were used at each point. Only a final, compact set of these approved memories is passed along to a separate model that generates the actual answer, keeping the memory selection process separate from and easier to check than the answer itself. The candidate memory pool itself is built only from the question and the conversation's own history, never from the correct answer, which keeps the process honest and testable rather than quietly shaped by hindsight. The repository includes a small runnable example with sample dialogue sessions and questions so you can see the full output format, including the intent analysis, the memory actions taken, the chain of cited steps, and the final memories passed to the answer model. The full training setup described in the paper uses eight high end GPUs and an approach that first fine tunes the system on examples, then further trains it with reinforcement learning, though the private training data, model checkpoints, API keys, and machine specific scripts used for that training are not included here. What is included is the core method code: the memory pool construction logic, the schema definitions, prompt templates, reward calculations, and a small test suite, along with optional support for open source embedding models if you want dense semantic search over memories rather than plain keyword matching. This is an academic code release intended for inspection and extension by other researchers, and it is licensed under the MIT license.

Copy-paste prompts

Prompt 1
Clone mayiwen0212/MemChain and run the minimal_dialogue.jsonl example end to end.
Prompt 2
Explain what intent_plan, memory_actions, and memory_chain mean in MemChain's output.
Prompt 3
Show me how to build a candidate memory pool with dense embedding search enabled.
Prompt 4
Summarize what training data and checkpoints MemChain does and does not include.

Frequently asked questions

What is memchain?

A research implementation that gives AI chat agents an explicit, readable trace of which memories it used before answering.

What language is memchain written in?

Mainly Python. The stack also includes Python, PyTorch, Sentence Transformers.

What license does memchain use?

MIT: free to use, modify, and share, including commercially, as long as you keep the copyright notice.

How hard is memchain to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is memchain for?

Mainly researcher.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.