JAX-native Vector Symbolic Algebra library
Project description
VSAX: Vector Symbolic Algebra for JAX
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 โ
- ๐จ Custom Encoders: Easy-to-extend AbstractEncoder base class โ
- ๐ Similarity Metrics: Cosine, dot, and Hamming similarity โ NEW in v0.5.0
- โก Batch Operations: GPU-accelerated vmap operations for parallel processing โ NEW in v0.5.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 โ
- ๐ Comprehensive Documentation: Full API docs and examples โ
- โ 95%+ Test Coverage: 319 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.5.0: Similarity metrics and batch operations!
Simple Example
from vsax import create_fhrr_model, VSAMemory, DictEncoder
from vsax.similarity import cosine_similarity
from vsax.utils import vmap_bind
# 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)
# NEW: Similarity search
similarity = cosine_similarity(memory["dog"], memory["cat"])
print(f"Dog-Cat similarity: {similarity:.3f}")
# NEW: Batch operations (GPU-accelerated)
import jax.numpy as jnp
nouns = jnp.stack([memory["dog"].vec, memory["cat"].vec])
verbs = jnp.stack([memory["run"].vec, memory["jump"].vec])
actions = vmap_bind(model.opset, nouns, verbs) # Parallel binding!
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 5: Similarity Metrics & Utilities โ
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 92%+ coverage
Iteration 5 (v0.5.0): Similarity Metrics & Utilities โ
- โ Cosine, dot, and Hamming similarity functions
- โ Batch operations with JAX vmap (vmap_bind, vmap_bundle, vmap_similarity)
- โ Visualization utilities (pretty_repr, format_similarity_results)
- โ GPU-accelerated similarity search
- โ Comprehensive examples (similarity_search.py, batch_operations.py)
- โ 319 tests with 95%+ coverage
Coming Next
Iteration 6 (v0.5.x): I/O & Persistence
- Save/load functionality for basis vectors (JSON format)
- Persistence examples and documentation
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.5.0}
}
Acknowledgments
VSAX is built on JAX and inspired by the VSA/HDC research community.
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 vsax-0.5.0.tar.gz.
File metadata
- Download URL: vsax-0.5.0.tar.gz
- Upload date:
- Size: 33.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4aed53f5136367d3925d6b6ad5fd7dc141bea0c5c972bbd681fedae275daa9f1
|
|
| MD5 |
6bb06dd65cfa96af4b830f50eb3ff83b
|
|
| BLAKE2b-256 |
9b9d77eed2652f9e7a0344dc9fb5151c5c162bb3a33e8e092d646b943cedb100
|
File details
Details for the file vsax-0.5.0-py3-none-any.whl.
File metadata
- Download URL: vsax-0.5.0-py3-none-any.whl
- Upload date:
- Size: 38.5 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b81c7301d2be1eb57ff45df9028626aa257c2cca18e2d1f11d2d3c7e86ba27ee
|
|
| MD5 |
a0c31b7839bbaf761378adef1aacf5fe
|
|
| BLAKE2b-256 |
81d10ed74bbf865b949405af6c8ded1ca6de70418e29bfbc5a752aaff188856e
|