Skip to main content

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 ANN
  • FlatIndex - Exact brute-force search
  • InMemoryStore - Fast in-memory record storage
  • MemoryRecord - Record with embedding and outcome
  • QueryCache - LRU cache with TTL

Trajectory

  • TrajectoryCoordinate - 4D coordinate (depth, sibling, homogeneity, temporal)
  • TrajectoryCoordinate5D - 5D coordinate (+complexity)
  • TrajectoryPhase - Conversation phase enum
  • PhaseInferencer - Infer phase from turn features

IRCP & Salience

  • IRCPPropagator - Attention propagation
  • SalienceScorer - Turn importance scoring
  • TurnSalience - Salience result with factors

Chain Systems

  • ChainManager - Cross-conversation chain management
  • ChainLinkEstimator - Link strength estimation
  • TrajectoryGraph - 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


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)

Uploaded Source

Built Distribution

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

rag_plusplus-0.1.0-cp39-abi3-macosx_11_0_arm64.whl (606.1 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

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

Hashes for rag_plusplus-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ea3cfd733149c6847149bb32ff489ab595bceeec800b52d7dd2b8134bf1d316a
MD5 5a3b510f6d94e7109af21700779d64d3
BLAKE2b-256 551e164d83c07159926ef6f9b77046f7d7de154e96d2bcbbf64afe51e549cf14

See more details on using hashes here.

File details

Details for the file rag_plusplus-0.1.0-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rag_plusplus-0.1.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e78bec0cb75d134225d8c0a3210a145364ca4725965174cc50c77d7c3dca039c
MD5 16a69e3167a28c410e25e942e29df055
BLAKE2b-256 1f600121821799ff2086e24bc314a36f502e4c7f2c4e141efd4bb29214602ac1

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