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.1

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.1
File Size Uploaded
dspm_memory-0.1.1.tar.gz 15.5 kB Details

Built distribution (wheel)

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

Total release size: 30.4 kB

Release files / dspm_memory-0.1.1.tar.gz

Download URL dspm_memory-0.1.1.tar.gz
Size 15.5 kB
Tags Source
SHA-256 checksum
How to use checksums
4d69bf2cab252e0f878baf67306cfde7be0c964063850a33c63b1433e9c8f12b
BLAKE2b-256 checksum
How to use checksums
650e961d3a313c813f76cfe6ad4f2e0fdc3a6a5f27c8af894362df923779cba5
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.1-py3-none-any.whl

Download URL dspm_memory-0.1.1-py3-none-any.whl
Size 14.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4022d7372e401cb2b4eda11fc848a23eabae406d3956ec16764881d45ed36a9b
BLAKE2b-256 checksum
How to use checksums
a60e60f7286e78c0e7e2db91eb5bc25a7d564100065321aca425ce28165efd70
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

This release

0.1.1 This release

2 release files

0.1.0

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