Skip to content

OpenClaudex/linmem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LinMem

Linear Models as Memorizers for Agents.

LinMem is the code companion for the blog post:

https://chenxinli001.github.io/blogs/linear-attention-memory/

The project explores linear models as memory backends: replacing vector-database retrieval with parametric memorizers such as Kimi-Linear. In this repo, the M3-Agent control loop is used as the evaluation harness, not the project identity.

What Is Included

  • mmagent/linear_memory.py: linear and context memory backends for Kimi-Linear, Qwen, RWKV, Mamba, and a lightweight delta-retention baseline.
  • mmagent/retrieve.py: retrieval integration with the method mapping used in the blog.
  • m3_agent/control.py: control-loop entry point with --backend and --method switches.
  • scripts/ablation/test_retrieval_accuracy.py: clip retrieval and summary-QA ablations.
  • scripts/ablation/test_scalability.py: long-context stress test for Kimi-Linear versus a softmax transformer backend.
  • data/experiment_results/: non-debug result artifacts used to sanity-check the blog tables.

Method Mapping

Blog setting Code method Backend examples
Embedding baseline embedding --backend embedding
Raw captions + linear summary 1b --backend kimi --method 1b
Structured memory + linear summary 2a --backend kimi --method 2a
Linear-model retrieval comparison retrieval scripts kimi, rwkv, mamba
Kimi vs Qwen context length scalability script --backend both

See docs/BLOG_MAPPING.md and docs/LINEAR_MEMORY_METHODS.md for more detail.

Setup

python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
cp configs/api_config.example.json configs/api_config.local.json
export M3_API_CONFIG=configs/api_config.local.json

Fill in API credentials in configs/api_config.local.json. The checked-in configs/api_config.json intentionally contains empty placeholders.

Example Runs

Run the control loop with the original embedding backend:

python m3_agent/control.py \
  --data_file data/annotations/robot_5case.json \
  --backend embedding \
  --output_file results/robot_5case_embedding.json

Run Kimi-Linear as the raw-caption summary memory backend:

python m3_agent/control.py \
  --data_file data/annotations/robot_5case.json \
  --backend kimi \
  --method 1b \
  --output_file results/robot_5case_kimi_1b.json

Run the long-context stress test:

python scripts/ablation/test_scalability.py \
  --backend both \
  --context_lengths 100,200,300,500 \
  --queries_per_length 20 \
  --output results/ablation/scalability_test.json

Acknowledgement

LinMem builds on the original M3-Agent codebase and M3-Bench benchmark. We thank the M3-Agent authors for releasing the agent framework, benchmark, and artifacts that make these linear-memory experiments possible.

About

Linear Models as Memorizers for Agents

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages