Skip to content

yaman1337/compressmemory

Repository files navigation

npm version Work in Progress License: MIT

compressmemory

Status: 🚧 Prototype | 🔬 Under Active Research

compressmemory is an experimental memory optimization layer designed to plug into Supermemory. It aims to reduce storage usage and token costs by compressing memory content before storing it and decompressing only when necessary.

⚠️ This is a non-production prototype. The current implementation stores both the original memory content and its compressed version, which increases storage size rather than reducing it. This is intentional for early-stage testing and will be fixed in future iterations.


✨ Goals

This project is the beginning of a larger initiative to build intelligent compression for memory-based LLM systems. Long-term, it will support:

  • ✅ Canonical compressed memory (raw content removed)
  • ✅ Lazy decompression (only during read())
  • ✅ Semantic compression (summarization, clustering)
  • ✅ Memory deduplication and merging
  • ✅ Benchmarking against Supermemory baseline
  • ✅ Modular adapter design for other memory layers (LangChain, LlamaIndex, etc.)

📦 Installation

Install via npm:

npm install compressmemory

Or with Yarn:

yarn add compressmemory

🚀 Usage

Example

import { CompressMemory } from 'compressmemory';
import { SupermemoryAdapter } from 'compressmemory/supermemory';
import { SupermemoryClient } from '@supermemory/client';

const supermemoryClient = new SupermemoryClient({
  apiKey: process.env.SUPERMEMORY_API_KEY!,
});

const memory = new CompressMemory({
  adapter: new SupermemoryAdapter(supermemoryClient),
});

// Save compressed memory
await memory.write({
  content: "The quick brown fox jumps over the lazy dog.",
  metadata: { topic: "demo" }
});

// Retrieve and decompress memory
const results = await memory.read({
  query: "fox",
  topK: 3,
});

console.log(results);

📍 Current Limitations

This project is under early-stage development and currently not efficient:

  • ❌ Both original and compressed content are stored
  • ❌ No lazy decompression (everything is eagerly decompressed)
  • ❌ No deduplication or semantic summarization yet

We are actively working to eliminate these flaws. You’re welcome to follow along or contribute.


🧠 Roadmap

Milestone Status
MVP adapter for Supermemory ✅ Done
Remove raw + compressed double storage 🔜 Planned
Implement lazy decompression on read() 🔜 Planned
Add semantic summarization & deduplication 🔜 Planned
Run benchmarks against Supermemory 🔜 Planned
Open up to other memory providers ⏳ Future

🤝 Contributing

All ideas, bug reports, and PRs are welcome — especially around:

  • memory optimization
  • prompt engineering
  • embedding compression
  • LLM infra / adapters

This repo is still experimental, so please approach with curiosity and constructive suggestions.


🙏 Credits

  • Built on top of Supermemory
  • Inspired by real-world challenges in managing memory, context, and token cost at scale

🪪 License

MIT

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published