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

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.2
File Size Uploaded
dspm_memory-0.1.2.tar.gz 16.0 kB Details

Built distribution (wheel)

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

Total release size: 31.4 kB

Release files / dspm_memory-0.1.2.tar.gz

Download URL dspm_memory-0.1.2.tar.gz
Size 16.0 kB
Tags Source
SHA-256 checksum
How to use checksums
48c442d4ce83582f04b856d00b144eb30a39b4d94e427c24ceb0d665488adb4e
BLAKE2b-256 checksum
How to use checksums
337a837e61310446b5bb966a4bf66ffa797c7e33193f1d23d036090cf583a297
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.2-py3-none-any.whl

Download URL dspm_memory-0.1.2-py3-none-any.whl
Size 15.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
18eef293c8df0fb3b7ab0f6852f15d1f32ef231cab89873aede043c763f7bb1e
BLAKE2b-256 checksum
How to use checksums
bd7b0ef251f22ddfbb04040b0806f509e5cc601ad29a191fefbbe2900193da04
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

This release

0.1.2 This release

2 release files

0.1.1

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