Skip to main content

DSPM Memory

Compress multi-turn LLM conversations by 80%+ while guaranteeing every constraint and decision survives.

dspm-memory is a training-free semantic memory compression package for conversations. It records typed semantic patches from turns and keeps critical constraint and decision patches protected under a fixed token budget.

Install

pip install dspm-memory

Quickstart

from dspm import DSPMMemory

# Option A: use an OpenAI-compatible client
# llm_client = OpenAIClient(api_key="...", base_url="https://api.openai.com/v1")
# model = "gpt-4o-mini"

llm_client = None  # Replace with your own client in production.
memory = DSPMMemory(budget=250, llm_client=llm_client, model="gpt-4o-mini")

memory.add_turn("user", "Create an API that accepts a user id and returns JSON. Require auth tokens.")
memory.add_turn("assistant", "We will add an endpoint POST /v1/users and enforce bearer token authentication.")
memory.add_turn("user", "Only allow admin roles to list accounts.")
memory.add_turn("assistant", "I will add a decision that admin-only access is enforced in the route guard.")

context = memory.get_context(query="What constraints and decisions should the API remember?")
print(context)
print(memory.stats)

Guarantee

The package converts multi-turn chats into semantic patches and compresses them under a budget. Constraint and decision patches are marked as critical and are retained structurally before all other patch types are considered. They may be trimmed to satisfy a hard budget, but they are not dropped unless the absolute last resort is reached.

Results

Budget TRR CRR
250 82.84% 100%
400 72.39% 100%

More details are available in the included package docs and example.

ArXiv Paper

A placeholder reference paper can be found at https://arxiv.org/abs/0000.00000.

License

This project is licensed under the MIT License.

Metadata

Release files for dspm-memory 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dspm-memory 0.1.0
File Size Uploaded
dspm_memory-0.1.0.tar.gz 14.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dspm-memory 0.1.0
File Interpreter ABI Platform
dspm_memory-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 27.4 kB

Release files / dspm_memory-0.1.0.tar.gz

Download URL dspm_memory-0.1.0.tar.gz
Size 14.0 kB
Tags Source
SHA-256 checksum
How to use checksums
69a82684b09bb0d309db5f740b6957e7a5e8f88e946bf8387b0fa82a5379e1b2
BLAKE2b-256 checksum
How to use checksums
e897d37f8b81ffc83978d5e4169e7847ed81b66905908958e26cc4f1572f607d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.15

Release files / dspm_memory-0.1.0-py3-none-any.whl

Download URL dspm_memory-0.1.0-py3-none-any.whl
Size 13.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dfa43f4826f0763df458465570f5070f6983186057e4e1cba51ff77128fef165
BLAKE2b-256 checksum
How to use checksums
aa8b824d85e22daecb0e7996a192a8347ca7ea45c8a58d3f318bb3ed1c33a363
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.15

Release history Release notifications | RSS feed

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page