Skip to main content

JAX-native Vector Symbolic Algebra library

Project description

VSAX: Vector Symbolic Algebra for JAX

PyPI version Python Version License Documentation Code style: ruff

VSAX is a GPU-accelerated, JAX-native Python library for Vector Symbolic Architectures (VSAs). It provides composable symbolic representations using hypervectors, algebraic operations for binding and bundling, and encoding strategies for symbolic and structured data.

Features

  • 🚀 Three VSA Models: FHRR, MAP, and Binary implementations ✅
  • 🏭 Factory Functions: One-line model creation with sensible defaults ✅
  • 💾 VSAMemory: Dictionary-style symbol management ✅
  • 📊 5 Core Encoders: Scalar, Sequence, Set, Dict, and Graph encoders ✅ NEW in v0.4.0
  • 🎨 Custom Encoders: Easy-to-extend AbstractEncoder base class ✅ NEW in v0.4.0
  • GPU-Accelerated: Built on JAX for high-performance computation
  • 🧩 Modular Architecture: Clean separation between representations and operations
  • 🧬 Complete Representations: Complex, Real, and Binary hypervectors ✅
  • ⚙️ Full Operation Sets: FFT-based FHRR, MAP, and XOR/majority Binary ops ✅
  • 🎲 Random Sampling: Sampling utilities for all representation types ✅
  • 🔍 Similarity Metrics: Cosine, dot, and Hamming similarity (coming in v0.5.0)
  • 📚 Comprehensive Documentation: Full API docs and examples ✅
  • 80%+ Test Coverage: 280+ tests ensuring reliability

Installation

From PyPI (Recommended)

pip install vsax

Or with uv:

uv pip install vsax

From Source

Using uv (Recommended)

uv is a fast Python package installer and resolver. Install it first:

# Install uv (Unix/macOS)
curl -LsSf https://astral.sh/uv/install.sh | sh

# Install uv (Windows)
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"

Then install VSAX:

git clone https://github.com/vasanthsarathy/vsax.git
cd vsax

# Create virtual environment and install package
uv venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
uv pip install -e .

Using pip

git clone https://github.com/vasanthsarathy/vsax.git
cd vsax
pip install -e .

Development Installation

Using uv (Recommended)

uv venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
uv pip install -e ".[dev,docs]"

Using pip

pip install -e ".[dev,docs]"

Quick Start

New in v0.4.0: 5 core encoders for structured data!

Simple Example

from vsax import create_fhrr_model, VSAMemory, DictEncoder

# Create model with factory function (one line!)
model = create_fhrr_model(dim=512)

# Create memory for symbol management
memory = VSAMemory(model)

# Add symbols - automatically samples and stores hypervectors
memory.add_many(["subject", "action", "dog", "run", "cat", "jump"])

# Dictionary-style access
dog = memory["dog"]

# Encode structured data with DictEncoder
encoder = DictEncoder(model, memory)
sentence = encoder.encode({"subject": "dog", "action": "run"})

# Bind concepts (circular convolution)
dog_is_animal = model.opset.bind(dog.vec, memory["animal"].vec)

# Bundle concepts (sum and normalize)
pets = model.opset.bundle(memory["dog"].vec, memory["cat"].vec)

All Three Models

VSAX supports three VSA models, all with the same simple API:

from vsax import create_fhrr_model, create_map_model, create_binary_model, VSAMemory

# FHRR: Complex hypervectors, exact unbinding
fhrr = create_fhrr_model(dim=512)

# MAP: Real hypervectors, approximate unbinding
map_model = create_map_model(dim=512)

# Binary: Discrete hypervectors, exact unbinding
binary = create_binary_model(dim=10000, bipolar=True)

# Same interface for all models!
for model in [fhrr, map_model, binary]:
    memory = VSAMemory(model)
    memory.add("concept")
    vec = memory["concept"]

Advanced: Manual Model Creation

You can still create models manually if you need custom configuration:

from vsax import VSAModel, ComplexHypervector, FHRROperations, sample_complex_random

model = VSAModel(
    dim=512,
    rep_cls=ComplexHypervector,
    opset=FHRROperations(),
    sampler=sample_complex_random
)

See docs/design-spec.md for complete technical specification.

Development Status

Currently in Iteration 4: Encoders + ExamplesFIRST USABLE RELEASE!

Completed

Iteration 1 (v0.1.0): Foundation & Infrastructure ✅

  • ✅ Core abstract classes (AbstractHypervector, AbstractOpSet)
  • ✅ VSAModel dataclass
  • ✅ Package structure
  • ✅ Testing infrastructure (pytest, coverage)
  • ✅ CI/CD pipeline (GitHub Actions)
  • ✅ Documentation site (MkDocs)
  • ✅ Development tooling (ruff, mypy)

Iteration 2 (v0.2.0): All 3 Representations + All 3 OpSets ✅

  • ✅ ComplexHypervector, RealHypervector, BinaryHypervector
  • ✅ FHRROperations, MAPOperations, BinaryOperations
  • ✅ Sampling utilities (sample_random, sample_complex_random, sample_binary_random)
  • ✅ 175 comprehensive tests with 96% coverage
  • ✅ Full integration tests for all model combinations

Iteration 3 (v0.3.0): VSAMemory + Factory Functions ✅

  • ✅ VSAMemory class - dictionary-style symbol management
  • ✅ Factory functions (create_fhrr_model, create_map_model, create_binary_model)
  • ✅ Utility functions (coerce_to_array, validation helpers)
  • ✅ 230 tests with 89% coverage
  • ✅ Comprehensive documentation guides

Iteration 4 (v0.4.0): Encoders + Examples ✅ FIRST USABLE RELEASE!

  • ✅ ScalarEncoder - Numeric values with power encoding
  • ✅ SequenceEncoder - Ordered sequences (lists, tuples)
  • ✅ SetEncoder - Unordered collections (sets)
  • ✅ DictEncoder - Key-value pairs (dictionaries)
  • ✅ GraphEncoder - Graph structures (edge lists)
  • ✅ AbstractEncoder - Base class for custom encoders
  • ✅ Complete integration examples for all 3 models
  • ✅ Custom encoder examples (DateEncoder, ColorEncoder)
  • ✅ 280+ tests with 80%+ coverage

Coming Next

Iteration 5 (v0.5.0): Similarity Metrics & I/O

  • Cosine, dot, and Hamming similarity functions
  • Save/load functionality for basis vectors
  • Batch operations with JAX vmap

See todo.md for the complete development roadmap.

Documentation

Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

Development

Run tests:

pytest

Run tests with coverage:

pytest --cov=vsax --cov-report=term-missing

Type checking:

mypy vsax

Linting:

ruff check vsax tests

Build documentation:

mkdocs serve

License

VSAX is released under the MIT License. See LICENSE for details.

Citation

If you use VSAX in your research, please cite:

@software{vsax2025,
  title = {VSAX: Vector Symbolic Algebra for JAX},
  author = {Sarathy, Vasanth},
  year = {2025},
  url = {https://github.com/vasanthsarathy/vsax},
  version = {0.2.0}
}

Acknowledgments

VSAX is built on JAX and inspired by the VSA/HDC research community.

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

vsax-0.4.2.tar.gz (28.4 kB view details)

Uploaded Source

Built Distribution

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

vsax-0.4.2-py3-none-any.whl (31.0 kB view details)

Uploaded Python 3

File details

Details for the file vsax-0.4.2.tar.gz.

File metadata

  • Download URL: vsax-0.4.2.tar.gz
  • Upload date:
  • Size: 28.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for vsax-0.4.2.tar.gz
Algorithm Hash digest
SHA256 07c5e9df10ac1627fad9981afa304c6ef1dd2a45974d72d7bd32d429a083bf96
MD5 880f584b5d88f7d76abd7d3d324d79b2
BLAKE2b-256 7d30daf67f6b78f6fa4c7d8c902a178edc3e3e1099903fa928359473c142b171

See more details on using hashes here.

File details

Details for the file vsax-0.4.2-py3-none-any.whl.

File metadata

  • Download URL: vsax-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 31.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for vsax-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 227b4e03a7d1ecf950d94405865e630797efa9679d2b7b8ad746502850a72f81
MD5 f1588dee11379ec498844488e33f6502
BLAKE2b-256 214aab7f0931d07a43eaba03fa98368ee29461595b7f906ad91f8f0a635c87de

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