VSA Models

The bayes_hdc.vsa module provides Vector Symbolic Architecture model implementations.

All models share the same API: bind, bundle, inverse, similarity, random.

Base Class

class bayes_hdc.vsa.VSAModel(name, dimensions)[source]

Bases: object

Base class for VSA models defining the interface.

Parameters:
name: str
dimensions: int
bind(x, y)[source]

Bind two hypervectors.

Parameters:
  • x (Array)

  • y (Array)

Return type:

Array

bundle(vectors, axis=0)[source]

Bundle multiple hypervectors.

Parameters:
  • vectors (Array)

  • axis (int)

Return type:

Array

inverse(x)[source]

Compute the inverse of a hypervector.

Parameters:

x (Array)

Return type:

Array

similarity(x, y)[source]

Compute similarity between hypervectors.

Parameters:
  • x (Array)

  • y (Array)

Return type:

Array

random(key, shape)[source]

Generate random hypervectors.

Parameters:
  • key (Array)

  • shape (tuple)

Return type:

Array

__init__(name, dimensions)
Parameters:
Return type:

None

Binary Spatter Codes

class bayes_hdc.vsa.BSC(name, dimensions)[source]

Bases: VSAModel

Binary Spatter Codes (BSC).

Binary hypervectors with XOR binding, majority bundling, Hamming similarity. Originally introduced by Kanerva (1997) as the Spatter Code; the BSC acronym was retro-fitted by the modern HDC literature (Kleyko et al. 2023 Part I §2.3.6). The canonical introduction to the operations is Kanerva (2009).

References: Kanerva, P. (1997). Fully Distributed Representation. In Proc. RWC ‘97, pp. 358-365. Kanerva, P. (2009). Hyperdimensional Computing: An Introduction. Cognitive Computation 1(2): 139-159.

Parameters:
static create(dimensions=10000)[source]

Create a BSC model.

Parameters:

dimensions (int) – Dimensionality of hypervectors (default: 10000)

Returns:

Initialized BSC model

Return type:

BSC

bind(x, y)[source]

Bind using XOR.

Parameters:
  • x (Array)

  • y (Array)

Return type:

Array

bundle(vectors, axis=0)[source]

Bundle using majority rule.

Parameters:
  • vectors (Array)

  • axis (int)

Return type:

Array

inverse(x)[source]

Inverse is identity for XOR.

Parameters:

x (Array)

Return type:

Array

similarity(x, y)[source]

Compute Hamming similarity.

Parameters:
  • x (Array)

  • y (Array)

Return type:

Array

random(key, shape)[source]

Generate random binary hypervectors.

Parameters:
  • key (Array) – JAX random key

  • shape (tuple) – Shape of output array

Returns:

Random binary hypervectors with ~50% ones

Return type:

Array

__init__(name, dimensions)
Parameters:
Return type:

None

Multiply-Add-Permute

class bayes_hdc.vsa.MAP(name, dimensions)[source]

Bases: VSAModel

Multiply-Add-Permute (MAP) coding.

Real-valued vectors with element-wise multiply binding, normalized sum bundling, cosine similarity. The MAP scheme was introduced by Gayler (1998) and is the running example in Gayler (2003) where the term “Vector Symbolic Architecture” itself is coined.

References: Gayler, R. W. (1998). Multiplicative binding, representation operators and analogy. In K. Holyoak, D. Gentner, B. Kokinov (eds.), Advances in Analogy Research, pp. 1-4. New Bulgarian University Press. Gayler, R. W. (2003). Vector Symbolic Architectures answer Jackendoff’s challenges for cognitive neuroscience. arXiv:cs/0412059.

Parameters:
static create(dimensions=10000)[source]

Create a MAP model.

Parameters:

dimensions (int) – Dimensionality of hypervectors (default: 10000)

Returns:

Initialized MAP model

Return type:

MAP

bind(x, y)[source]

Bind using element-wise multiplication.

Parameters:
  • x (Array)

  • y (Array)

Return type:

Array

bundle(vectors, axis=0)[source]

Bundle using normalized sum.

Parameters:
  • vectors (Array)

  • axis (int)

Return type:

Array

inverse(x)[source]

Inverse via element-wise reciprocal.

Parameters:

x (Array)

Return type:

Array

similarity(x, y)[source]

Compute cosine similarity.

Parameters:
  • x (Array)

  • y (Array)

Return type:

Array

random(key, shape)[source]

Generate random real-valued hypervectors.

Parameters:
  • key (Array) – JAX random key

  • shape (tuple) – Shape of output array

Returns:

Random normalized hypervectors sampled from normal distribution

Return type:

Array

__init__(name, dimensions)
Parameters:
Return type:

None

Holographic Reduced Representations

class bayes_hdc.vsa.HRR(name, dimensions)[source]

Bases: VSAModel

Holographic Reduced Representations (HRR).

Real-valued vectors with circular convolution binding, normalized sum bundling, cosine similarity. HRR was introduced by Plate (1995, IEEE TNN) as a fixed-dimensional alternative to Smolensky’s tensor-product binding; the book-length treatment is Plate (2003). Circular convolution is the canonical single-argument shift-equivariant bilinear operator on R^d (see bayes_hdc.equivariance).

References: Plate, T. A. (1995). Holographic Reduced Representations. IEEE Transactions on Neural Networks 6(3): 623-641. Plate, T. A. (2003). Holographic Reduced Representation: Distributed Representation for Cognitive Structures. CSLI Publications.

Parameters:
static create(dimensions=10000)[source]

Create an HRR model.

Parameters:

dimensions (int) – Dimensionality of hypervectors (default: 10000)

Returns:

Initialized HRR model

Return type:

HRR

bind(x, y)[source]

Bind using circular convolution.

Parameters:
  • x (Array)

  • y (Array)

Return type:

Array

bundle(vectors, axis=0)[source]

Bundle using normalized sum.

Parameters:
  • vectors (Array)

  • axis (int)

Return type:

Array

inverse(x)[source]

Inverse via element reversal.

Parameters:

x (Array)

Return type:

Array

similarity(x, y)[source]

Compute cosine similarity.

Parameters:
  • x (Array)

  • y (Array)

Return type:

Array

random(key, shape)[source]

Generate random real-valued hypervectors.

Parameters:
  • key (Array) – JAX random key

  • shape (tuple) – Shape of output array

Returns:

Random normalized hypervectors sampled from normal distribution

Return type:

Array

__init__(name, dimensions)
Parameters:
Return type:

None

Fourier HRR

class bayes_hdc.vsa.FHRR(name, dimensions)[source]

Bases: VSAModel

Fourier Holographic Reduced Representations (FHRR).

Complex-valued unit-phasor vectors with element-wise multiply binding, normalized sum bundling. FHRR was introduced by Plate (1994/2003) as the frequency-domain dual of HRR: circular convolution in the spatial domain becomes element-wise complex multiplication in the Fourier domain.

References: Plate, T. A. (2003). Holographic Reduced Representation: Distributed Representation for Cognitive Structures. CSLI Publications. (FHRR is treated alongside HRR; see chapters on the Fourier-domain formulation.)

Parameters:
static create(dimensions=10000)[source]

Create an FHRR model.

Parameters:

dimensions (int) – Dimensionality of hypervectors (default: 10000)

Returns:

Initialized FHRR model

Return type:

FHRR

bind(x, y)[source]

Bind using element-wise multiplication.

Parameters:
  • x (Array)

  • y (Array)

Return type:

Array

bundle(vectors, axis=0)[source]

Bundle using normalized sum.

Parameters:
  • vectors (Array)

  • axis (int)

Return type:

Array

inverse(x)[source]

Inverse via complex conjugate.

Parameters:

x (Array)

Return type:

Array

similarity(x, y)[source]

Compute cosine similarity of complex vectors.

Parameters:
  • x (Array)

  • y (Array)

Return type:

Array

random(key, shape)[source]

Generate random complex hypervectors on unit circle.

Parameters:
  • key (Array) – JAX random key

  • shape (tuple) – Shape of output array

Returns:

Random unit complex hypervectors

Return type:

Array

__init__(name, dimensions)
Parameters:
Return type:

None

Binary Sparse Block Codes

class bayes_hdc.vsa.BSBC(name, dimensions, block_size=100, k_active=5)[source]

Bases: VSAModel

Binary Sparse Block Codes (B-SBC).

Block-sparse binary vectors with k_active ones per block, XOR binding, majority bundling. The BSC operations carry over directly (Kanerva 1997); the sparse-block construction follows the line traced in Kleyko et al. (2023) Part I §2.3.7 (sparse binary HDC family).

References: Kanerva, P. (1997). Fully Distributed Representation. In Proc. RWC ‘97, pp. 358-365. Kleyko, D., Rachkovskij, D. A., Osipov, E., Rahimi, A. (2023). A Survey on HDC aka VSA, Part I. ACM Computing Surveys 55(6).

Parameters:
  • name (str)

  • dimensions (int)

  • block_size (int)

  • k_active (int)

block_size: int = 100
k_active: int = 5
static create(dimensions=10000, block_size=100, k_active=5)[source]

Create a B-SBC model.

Parameters:
  • dimensions (int) – Total dimensionality (must be divisible by block_size)

  • block_size (int) – Size of each block

  • k_active (int) – Number of ones per block (sparsity)

Returns:

Initialized BSBC model

Return type:

BSBC

bind(x, y)[source]

Bind using XOR (same as BSC).

Parameters:
  • x (Array)

  • y (Array)

Return type:

Array

bundle(vectors, axis=0)[source]

Bundle using majority rule.

Parameters:
  • vectors (Array)

  • axis (int)

Return type:

Array

inverse(x)[source]

Inverse is identity for XOR.

Parameters:

x (Array)

Return type:

Array

similarity(x, y)[source]

Compute Hamming similarity.

Parameters:
  • x (Array)

  • y (Array)

Return type:

Array

random(key, shape)[source]

Generate random block-sparse binary hypervectors.

Parameters:
  • key (Array)

  • shape (tuple)

Return type:

Array

__init__(name, dimensions, block_size=100, k_active=5)
Parameters:
  • name (str)

  • dimensions (int)

  • block_size (int)

  • k_active (int)

Return type:

None

Cyclic Group Representation

class bayes_hdc.vsa.CGR(name, dimensions, q=8)[source]

Bases: VSAModel

Cyclic Group Representation (CGR).

Integer hypervectors in Z_q with modular addition binding, component-wise mode bundling.

Parameters:
q: int = 8
static create(dimensions=10000, q=8)[source]
Parameters:
Return type:

CGR

bind(x, y)[source]

Bind using modular addition.

Parameters:
  • x (Array)

  • y (Array)

Return type:

Array

bundle(vectors, axis=0)[source]

Bundle using component-wise mode.

Parameters:
  • vectors (Array)

  • axis (int)

Return type:

Array

inverse(x)[source]

Inverse via modular negation.

Parameters:

x (Array)

Return type:

Array

similarity(x, y)[source]

Compute fraction of matching elements.

Parameters:
  • x (Array)

  • y (Array)

Return type:

Array

random(key, shape)[source]

Generate random integer hypervectors in {0, …, q-1}.

Parameters:
  • key (Array)

  • shape (tuple)

Return type:

Array

__init__(name, dimensions, q=8)
Parameters:
Return type:

None

Modular Composite Representation

class bayes_hdc.vsa.MCR(name, dimensions, q=64)[source]

Bases: VSAModel

Modular Composite Representation (MCR).

Integer phase vectors with modular addition binding, phasor sum bundling.

Parameters:
q: int = 64
static create(dimensions=10000, q=64)[source]
Parameters:
Return type:

MCR

bind(x, y)[source]

Bind using modular addition (phase addition).

Parameters:
  • x (Array)

  • y (Array)

Return type:

Array

bundle(vectors, axis=0)[source]

Bundle using phasor sum with snap-to-grid.

Parameters:
  • vectors (Array)

  • axis (int)

Return type:

Array

inverse(x)[source]

Inverse via modular negation (phase conjugate).

Parameters:

x (Array)

Return type:

Array

similarity(x, y)[source]

Compute phasor similarity.

Parameters:
  • x (Array)

  • y (Array)

Return type:

Array

random(key, shape)[source]

Generate random integer hypervectors in {0, …, q-1}.

Parameters:
  • key (Array)

  • shape (tuple)

Return type:

Array

__init__(name, dimensions, q=64)
Parameters:
Return type:

None

Vector-Derived Transformation Binding

class bayes_hdc.vsa.VTB(name, dimensions)[source]

Bases: VSAModel

Vector-Derived Transformation Binding (VTB).

Real-valued vectors with matrix multiplication binding, normalized sum bundling.

Parameters:
static create(dimensions=10000)[source]
Parameters:

dimensions (int)

Return type:

VTB

bind(x, y)[source]

Bind using matrix multiplication.

Parameters:
  • x (Array)

  • y (Array)

Return type:

Array

bundle(vectors, axis=0)[source]

Bundle using normalized sum.

Parameters:
  • vectors (Array)

  • axis (int)

Return type:

Array

inverse(x)[source]

Inverse via matrix pseudoinverse.

Parameters:

x (Array)

Return type:

Array

similarity(x, y)[source]

Compute cosine similarity.

Parameters:
  • x (Array)

  • y (Array)

Return type:

Array

random(key, shape)[source]

Generate random normalized real-valued hypervectors.

Parameters:
  • key (Array)

  • shape (tuple)

Return type:

Array

__init__(name, dimensions)
Parameters:
Return type:

None

Factory Function

bayes_hdc.vsa.create_vsa_model(model_type='map', dimensions=10000)[source]

Factory function to create VSA models.

Parameters:
  • model_type (str) – Type of VSA model (‘bsc’, ‘map’, ‘hrr’, ‘fhrr’, ‘bsbc’, ‘cgr’, ‘mcr’, ‘vtb’)

  • dimensions (int) – Dimensionality of hypervectors (default: 10000)

Returns:

Initialized VSA model

Return type:

VSAModel