A latent memory and active inference engine for AI agents.
Project description
Paradox: Latent Memory & Simulation Engine
Paradox is a lightweight, hardware-agnostic cognitive architecture for AI agents. It provides a dynamic "Latent Memory" that doesn't just store data but allows for active simulation, evolution, and proximity-based retrieval.
🚀 Key Features
- Hybrid Compute: Automatically runs on GPU (PyTorch) if available, gracefully falls back to CPU (NumPy/MMap).
- Active Inference: Built-in
SimulationEnvallows memory vectors to evolve over time based on physics-like dynamics. - Infinite Scaling: Supports disk-backed storage (
numpy.memmap) for datasets larger than RAM. - Plugin Architecture: Easily plug in custom Neural Encoders (BERT, CLIP, VAEs) to auto-vectorize raw data.
🌍 Innovation Impact
Paradox is a fundamental engine for Massive Scale Simulation across industries:
| Domain | Problem | Paradox Solution | Impact |
|---|---|---|---|
| Software Eng | Objects consume too much RAM. | Stores recipes (vectors), reconstructs on demand. | Handle billion-scale datasets on laptops. |
| Scientific Sim | Simulating millions of particles requires Supercomputers. | Latent physics allows interacting with millions of entities. | Neuroscience/Physics modeling on commodity hardware. |
| Big Data & IoT | Searching billions of logs is slow. | Proximity search finds anomalies instantly (O(1) approx). | Real-time analytics & anomaly detection. |
| Game Dev | Massive procedural worlds crash memory. | Latent storage for entities; procedural reconstruction. | Infinite worlds with efficient AI. |
| AI / ML | Large models don't fit on GPU. | Compresses parameters/objects into latent space. | Run massive models locally. |
Key Takeaways:
- 📉 Memory Efficiency: Drastically reduces RAM needs.
- 📈 Scalability: From thousands to billions of objects.
- 🚀 Production-Ready: Deployable as a library or cloud service.
📦 Installation
git clone https://github.com/ethcocoder/paradoxlf.git
cd paradoxlf
pip install .
⚡ Quick Start
1. Basic Memory & Search
from paradox.engine import LatentMemoryEngine
# Initialize (Auto-detects CPU vs GPU)
engine = LatentMemoryEngine(dimension=128)
# Add Data
engine.add([0.1, 0.5, ...], attributes={"name": "concept_A"})
# Search
results = engine.query([0.1, 0.5, ...], k=5)
print(results)
2. Auto-Encoding Raw Data
from paradox.engine import LatentMemoryEngine
from paradox.encoder import BaseEncoder
# Define a custom encoder (e.g., wrapper around OpenAI/HuggingFace)
class MyTextEncoder(BaseEncoder):
def encode(self, text):
# ... logic to turn text into vector ...
return vector
engine = LatentMemoryEngine(dimension=768)
engine.set_encoder(MyTextEncoder(768))
# Now simply add text!
engine.add("Artificial Intelligence is evolving", {"category": "AI"})
3. Simulation (The "Active" Part)
Paradox allows you to run simulations on your memory, letting concepts interact or drift.
from paradox.simulation import SimulationEnv
def semantic_drift(vectors, dt, backend):
return vectors * 0.01 # Simple example
sim = SimulationEnv(engine)
sim.run(steps=100, dynamics_fn=semantic_drift)
4. Visualization
Visualize your latent space in 2D using PCA or t-SNE.
from paradox.visualization import LatentVisualizer
viz = LatentVisualizer(engine)
viz.plot_2d(method="pca", output_file="memory_map.png")
💻 How to Use: Library vs Framework
Paradox is designed to be used in two distinct ways depending on your needs.
📚 Mode 1: The Library (Static Usage)
Use when: You want a fast vector database or smart storage for your existing application.
- You control the loop. You just push/pull data.
- Example: Storing million embeddings for a Chatbot.
from paradox import LatentMemoryEngine
db = LatentMemoryEngine(dimension=512)
db.add(vector, {"text": "hello"})
result = db.query(query_vector)
🏗️ Mode 2: The Framework (Active Usage)
Use when: You want to build a living simulation or agent that evolves on its own.
- Paradox controls the loop. You define the rules, Paradox moves the world.
- Example: A traffic simulation where cars (vectors) move closer if they are "jammed".
from paradox import SimulationEnv
def traffic_physics(vectors, dt, backend):
# Custom logic to move vectors based on rules
return updated_vectors
sim = SimulationEnv(engine)
sim.run(steps=1000, dynamics_fn=traffic_physics)
# The engine is actively "thinking" and updating state
🤝 Contributing
Open source contributions are welcome. Please submit a PR for review.
📄 License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file paradoxlf-0.1.0.tar.gz.
File metadata
- Download URL: paradoxlf-0.1.0.tar.gz
- Upload date:
- Size: 13.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a5884103bf2962ee35724a81ec7de451d641050a285dc7603982afd15f622cc
|
|
| MD5 |
49147944e5d1e123c3420d8dc3396987
|
|
| BLAKE2b-256 |
5a9826c5f4d2f0b0097399dad6a22943bb36e647da5315d9e2d3a5d2e87194bf
|
File details
Details for the file paradoxlf-0.1.0-py3-none-any.whl.
File metadata
- Download URL: paradoxlf-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35af234e5211d270b8fa551a337cd5362b12765af69b3229a5dad27223e28a69
|
|
| MD5 |
da120205d0d43dca85aec96fae01d4b4
|
|
| BLAKE2b-256 |
4947bf6043d47bcb26162dbcf1bf87c1334826d86cd9a3e211f605abd029bf2a
|