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 ✅
  • 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 ✅
  • 📊 Encoders: Scalar and dictionary encoders for structured data (coming in iteration 4)
  • 💾 Persistent Storage: Save and load basis vectors (coming in iteration 6)
  • 🔍 Similarity Metrics: Cosine, dot, and Hamming similarity (coming in iteration 5)
  • 📚 Comprehensive Documentation: Full API docs and examples
  • 96% Test Coverage: 175 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

FHRR Model (Complex Hypervectors)

import jax
from vsax import VSAModel, ComplexHypervector, FHRROperations, sample_complex_random

# Create an FHRR model
model = VSAModel(
    dim=512,
    rep_cls=ComplexHypervector,
    opset=FHRROperations(),
    sampler=sample_complex_random
)

# Sample and create hypervectors
key = jax.random.PRNGKey(42)
vectors = model.sampler(dim=model.dim, n=2, key=key)
a = model.rep_cls(vectors[0]).normalize()
b = model.rep_cls(vectors[1]).normalize()

# Bind two vectors
bound = model.opset.bind(a.vec, b.vec)
print(f"Bound vector shape: {bound.shape}")

# Bundle multiple vectors
bundled = model.opset.bundle(a.vec, b.vec)
print(f"Bundled vector: unit magnitude = {jax.numpy.allclose(jax.numpy.abs(bundled), 1.0)}")

MAP Model (Real Hypervectors)

from vsax import RealHypervector, MAPOperations, sample_random

# Create a MAP model
model = VSAModel(
    dim=512,
    rep_cls=RealHypervector,
    opset=MAPOperations(),
    sampler=sample_random
)

# Use the model
key = jax.random.PRNGKey(42)
vectors = model.sampler(dim=model.dim, n=2, key=key)
a = model.rep_cls(vectors[0]).normalize()
b = model.rep_cls(vectors[1]).normalize()

# Element-wise multiplication for binding
bound = model.opset.bind(a.vec, b.vec)

# Mean for bundling
bundled = model.opset.bundle(a.vec, b.vec)

Binary Model (Bipolar Hypervectors)

from vsax import BinaryHypervector, BinaryOperations, sample_binary_random

# Create a Binary model
model = VSAModel(
    dim=512,
    rep_cls=BinaryHypervector,
    opset=BinaryOperations(),
    sampler=sample_binary_random
)

# Sample bipolar vectors
key = jax.random.PRNGKey(42)
vectors = model.sampler(dim=model.dim, n=2, key=key, bipolar=True)
a = model.rep_cls(vectors[0], bipolar=True)
b = model.rep_cls(vectors[1], bipolar=True)

# XOR binding
bound = model.opset.bind(a.vec, b.vec)

# Majority voting
bundled = model.opset.bundle(a.vec, b.vec)

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

Development Status

Currently in Iteration 2: Core Algebras

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

Coming Next

Iteration 3 (v0.3.0): VSAModel + VSAMemory

  • Symbol table and memory management
  • Factory functions for easy model creation

Iteration 4 (v0.4.0): First Usable Release

  • ScalarEncoder and DictEncoder
  • Working examples for all three models

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.3.0.tar.gz (24.0 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.3.0-py3-none-any.whl (24.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: vsax-0.3.0.tar.gz
  • Upload date:
  • Size: 24.0 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.3.0.tar.gz
Algorithm Hash digest
SHA256 5e088868542401b9c825aa887b18f07da3cb2ce545ea1677a1756fce7b358090
MD5 7ca19b6520ccb0abe9b9b84284dcab33
BLAKE2b-256 fd62a39b1e3ccc71efb7ff132ee8dc9fd090b8210949f7c0b0e6bdcc3b9ede8f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vsax-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 24.1 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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 85b9d2106c82599c5465c7a0b767e55301394ae6833e0b02628e909965fee86a
MD5 61e6848f8657678f730a5984889d0ea6
BLAKE2b-256 57af5bc875d442de82bd8df6c524061d720b5b1e5b39525998937ebdbcacfa8c

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