RAG++: High-performance retrieval for memory-conditioned selection (Rust core with Python bindings)
Project description
rag-plusplus
High-performance retrieval for memory-conditioned selection with Python bindings to a Rust core.
Installation
pip install rag-plusplus
Features
- SIMD-accelerated vector search - AVX2-optimized distance calculations
- HNSW indexing - Approximate nearest neighbor with sub-linear scaling
- Trajectory coordinates - 5D positioning for conversation context
- IRCP propagator - Information-Relevance Causal Propagation
- Salience scoring - Turn importance with recency decay
- Chain management - Cross-conversation knowledge links
Quick Start
import numpy as np
from rag_plusplus import HNSWIndex, FlatIndex, InMemoryStore, MemoryRecord
# Create an HNSW index for fast approximate search
index = HNSWIndex(dimension=128, m=16, ef_construction=200)
# Add vectors
for i in range(1000):
vec = np.random.randn(128).astype(np.float32)
index.add(f"vec_{i}", vec)
# Search
query = np.random.randn(128).astype(np.float32)
results = index.search(query, k=10)
for result in results:
print(f"{result.id}: score={result.score:.4f}")
Trajectory Coordinates
from rag_plusplus import TrajectoryCoordinate5D, trajectory_weighted_cosine_5d
# Create 5D trajectory coordinates
# (depth, sibling_order, homogeneity, temporal, complexity)
coord1 = TrajectoryCoordinate5D(3, 0, 0.9, 0.7, 1)
coord2 = TrajectoryCoordinate5D(4, 1, 0.8, 0.6, 2)
# Trajectory-weighted similarity
score = trajectory_weighted_cosine_5d(vec1, vec2, coord1, coord2, coord_weight=0.3)
IRCP Propagation
from rag_plusplus import IRCPPropagator, IRCPConfig
config = IRCPConfig() # temperature=1.0, spatial_weight=0.3
propagator = IRCPPropagator(config)
# Propagate attention through conversation turns
# attention_weights = propagator.propagate(...)
Available Classes
Core
HNSWIndex- Hierarchical Navigable Small World graph for ANNFlatIndex- Exact brute-force searchInMemoryStore- Fast in-memory record storageMemoryRecord- Record with embedding and outcomeQueryCache- LRU cache with TTL
Trajectory
TrajectoryCoordinate- 4D coordinate (depth, sibling, homogeneity, temporal)TrajectoryCoordinate5D- 5D coordinate (+complexity)TrajectoryPhase- Conversation phase enumPhaseInferencer- Infer phase from turn features
IRCP & Salience
IRCPPropagator- Attention propagationSalienceScorer- Turn importance scoringTurnSalience- Salience result with factors
Chain Systems
ChainManager- Cross-conversation chain managementChainLinkEstimator- Link strength estimationTrajectoryGraph- Episode graph structure
Performance
The Rust core provides:
- ~10x faster vector distance than pure Python
- Sub-linear search with HNSW indexing
- Zero-copy numpy array handling
- Parallel search across multiple indexes
License
MIT
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
rag_plusplus-0.1.0.tar.gz
(227.2 kB
view details)
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 rag_plusplus-0.1.0.tar.gz.
File metadata
- Download URL: rag_plusplus-0.1.0.tar.gz
- Upload date:
- Size: 227.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea3cfd733149c6847149bb32ff489ab595bceeec800b52d7dd2b8134bf1d316a
|
|
| MD5 |
5a3b510f6d94e7109af21700779d64d3
|
|
| BLAKE2b-256 |
551e164d83c07159926ef6f9b77046f7d7de154e96d2bcbbf64afe51e549cf14
|
File details
Details for the file rag_plusplus-0.1.0-cp39-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: rag_plusplus-0.1.0-cp39-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 606.1 kB
- Tags: CPython 3.9+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e78bec0cb75d134225d8c0a3210a145364ca4725965174cc50c77d7c3dca039c
|
|
| MD5 |
16a69e3167a28c410e25e942e29df055
|
|
| BLAKE2b-256 |
1f600121821799ff2086e24bc314a36f502e4c7f2c4e141efd4bb29214602ac1
|