Skip to main content

One-shot attractor memory for LLMs — vector-search accuracy at 98% fewer tokens.

Project description

slate-memory

One-shot attractor memory for LLMs. Vector-search accuracy at 98% fewer tokens.

The number

Setup Accuracy Cost per 1k queries Latency
haiku + slate 100% $0.10 0.6s
opus + full context 100% $64.04 1.7s
opus bare 0% $0.19 1.2s
haiku bare 0% $0.04 0.7s

A cheap model with slate-memory ties the most expensive model with the entire corpus in context — at 1/640th the cost. Both models score 0% without memory (facts are synthetic, unknowable parametrically). Benchmark: N=25 questions, K=600 stored facts, hermetic SDK calls. Full methodology and reproduction scripts in slate-bench.

How it works

Slate-memory is a modern Hopfield network (Ramsauer et al. 2020) — the same math as transformer attention, but used as a memory instead of a layer. Embeddings are sign-projected onto 10,000 bipolar cells (SimHash) and stored one-shot. On recall, the query settles into the nearest stored attractor via softmax-weighted feedback. Two cycles. No training. No index. No database.

The attractor dynamics error-correct: noisy, partial, or corrupted queries converge to the exact stored pattern. Verified at 20,000 stored patterns with 25% corruption.

Install

pip install slate-memory

For the built-in embedder convenience wrapper:

pip install slate-memory[embed]

Quick start

from slate_memory import SlateBank
import numpy as np

# Your embeddings (384-dim for MiniLM, 1536 for OpenAI, etc.)
bank = SlateBank(dim=384)

# Commit facts one-shot
bank.commit(embed("The capital of France is Paris"), {"text": "Paris is the capital of France", "id": "fact-1"})
bank.commit(embed("Python was created by Guido van Rossum"), {"text": "Guido created Python", "id": "fact-2"})

# Recall — even from a noisy or partial query
winner, ranked, confidence, cycles = bank.recall(embed("What's the capital of France?"))
print(winner)  # {"text": "Paris is the capital of France", "id": "fact-1"}
print(f"Confidence: {confidence:.3f}, settled in {cycles} cycles")

With sentence-transformers

from slate_memory import SlateBank
from sentence_transformers import SentenceTransformer

model = SentenceTransformer("all-MiniLM-L6-v2")
bank = SlateBank(dim=384)

# Commit
texts = ["The Earth orbits the Sun", "Water boils at 100°C", "Light travels at 299,792 km/s"]
for text in texts:
    bank.commit(model.encode(text), {"text": text})

# Recall
query = model.encode("what temperature does water boil")
winner, ranked, confidence, cycles = bank.recall(query)
print(winner["text"])  # "Water boils at 100°C"

With OpenAI embeddings

from slate_memory import SlateBank
from openai import OpenAI

client = OpenAI()
bank = SlateBank(dim=1536)  # text-embedding-3-small

def embed(text):
    return client.embeddings.create(input=text, model="text-embedding-3-small").data[0].embedding

bank.commit(embed("Revenue was $4.2M in Q3"), {"text": "Q3 revenue: $4.2M"})
winner, _, conf, _ = bank.recall(embed("how much revenue in Q3"))

Persistence

# Save
bank.save("./my_memory")

# Load
bank2 = SlateBank(dim=384)
n = bank2.load("./my_memory")
print(f"Loaded {n} patterns")

The entire memory is two files: patterns.npy (the attractor states) and meta.json (your metadata). No server. No database. Copy them anywhere.

API

SlateBank(dim, n_cells=10000, beta=60.0, distinctiveness=True, dedup_threshold=0.95, seed=7)

  • dim: Embedding dimensionality (must match your embedder)
  • n_cells: Bipolar cells in the attractor state. 10,000 is verified for up to 20k patterns
  • beta: Winner-take-all sharpness. 60.0 is benchmarked; don't change without reason
  • distinctiveness: Down-weight cells where all patterns agree. Essential for images; neutral for text
  • dedup_threshold: Refuse commits with overlap above this. 0.95 prevents near-duplicates
  • seed: RNG seed for the projection matrix. Same seed = same projections = portable patterns

bank.commit(embedding, meta) → (bool, str)

One-shot storage. Returns (True, "committed") or (False, "duplicate (...)").

bank.recall(embedding, top_k=3, max_cycles=5) → (winner, ranked, confidence, cycles)

Full attractor settle. Returns the winner's metadata, top-k ranked results, confidence score, and settle cycles.

bank.familiar(embedding) → (meta, score)

Quick overlap check without settling. Use for "have I seen this before?" checks.

bank.save(path) / bank.load(path)

Persist to / restore from a directory.

Benchmarks

Full retrieval benchmarks across 5 corruption conditions and 4 capacity levels show accuracy parity with exact cosine search (±1 point). The attractor substrate recalls 20,000 random patterns perfectly at 25% corruption. Capacity is limited by embedding discriminability (the embedder), not the attractor.

Honest limitations in software: per-query latency is ~35x slower than exact vector search (19ms vs 0.5ms at K=2000) because the projected patterns are 10,000-d vs 384-d. The speed case is the photonic implementation where recall is one pass of light — that's the roadmap, not the demo.

See slate-bench for full reproduction scripts and results.

License

Apache 2.0. Patent pending.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

slate_memory-0.1.1.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

slate_memory-0.1.1-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file slate_memory-0.1.1.tar.gz.

File metadata

  • Download URL: slate_memory-0.1.1.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for slate_memory-0.1.1.tar.gz
Algorithm Hash digest
SHA256 67bafa0f49f50027bca02c62e20606a74f046027169d987d7c5d6d225eb79f11
MD5 b8eb8e13ba410b599bdb2a9ce26d60f4
BLAKE2b-256 a2b506576f39f66ac9a5f203d59151951678e058251aa6241d8135fd8e768eed

See more details on using hashes here.

File details

Details for the file slate_memory-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: slate_memory-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for slate_memory-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1cacba162b57682fe2df4a4b9b50053de9d39a54cb26decfc34ec6dcfe39b9fa
MD5 23737e391f6fe9ddbe4a62ffc8441cd2
BLAKE2b-256 05004abe078c036f4239dd3de178ad841b2fe76e7df39f94417ecf0bbede3d81

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page