Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Hypervectors

What is Hyperdimensional Computing?

Hyperdimensional computing (HDC) represents concepts as high-dimensional vectors (also called hypervectors) and manipulates them with algebraic operations, typically the dimension (of vectors) can be as high as thousands or millions.

The key insight is that random vectors in high-dimensional spaces are nearly orthogonal: giving each concept a unique, robust representation that tolerates potential ambiguity and interference, all without central orchestration.

In that sense, the traditional mantra of curse of dimensionality becomes the blessing of dimensionality.

Motivated readers should perform their own background research on this topic and make judgement of their own. There are many introductory papers covering this topic of hyperdimensional computing, or equivalently VSA (Vector Symbolic Architecture).

Sparse Binary Representation

kongming specializes in sparse binary hypervectors. Each vector has a fixed, large number of dimensions (e.g., 65,536/64K or 1,048,576/1M), but only a very small fraction of them are “on” (set to 1). The sparsity is controlled by the Model configuration.

Furthermore, we focus on a special sparse binary arrangement, where each vector is divided into equal-sized segments, and exactly one bit is ON per segment. For example, each of the 8bit-model hypervectors will have total dimension of , divided into segments, where each segment of dimension will have one (and only one) ON bit.

Alternatively you can imagine each hypervector as a list of phasors, where the offset of ON bit (within the host segment) represents the discretized phase of a unit circle. For the above-mentioned 8bit models, each hypervector will have such phasors, each with discrete phases around the unit circle, ranging over .

In general, this unique constraint enables:

  • Compact storage: only the offsets of ON bit are needed, which is exactly the minimal entropy for the representation;
  • Efficient operations: Unlike neural nets where weights are recorded in float-point numbers, binary/integer operations can be performed very efficiently with modern memory / CPUs, and without the need of GPU for either float-point operations or matrix manipulations.

Similarity and distance measure

Two vectors are compared via overlap — the count of segments with the same ON bit offset. This is conceptually equivalent to a dimension-wise AND operation.

For a model (for example, 8bit model), with dimension and sparsity :

Naturally, a vector’s overlap with itself equals its cardinality .

The overlap (of random vectors and ) follows a Poisson distribution with , so the expectation follows:

The commonly-used distance measure (or dis-similar measure) for binary vectors is Hamming distance, equivalent to a bitwise XOR operation.

As we discussed (and proved) in the paper, the overlap and Hamming distance for sparse binary hypervectors are two sides of the same coin, with the following equation:

the more overlap they have, the closer two vectors in Hamming space.

To visualize this, we have two random 8-bit hypervectors drawn over the same grid. Each of the segments contributes one dot, placed inside its own segment group at the offset of that segment’s ON bit — red for the first vector, blue for the second. The heavy grid lines delimit the segment groups, while the fine ones are individual offsets.

Two random 8-bit hypervectors overlaid; they share exactly one segment
Fig. 1: two random 8-bit hypervectors over one grid, agreeing on exactly one segment

This is what near-orthogonality looks like: two vectors drawn independently from a -dimensional space, agreeing by coincidence on a single segment out of — and nowhere else.

Lee distance: the graded alternative

Both measures above are binary per segment: two offsets either agree or they do not, and an offset one step away counts exactly like one on the far side of the ring. That is the honest reading for a Sparkle, whose offsets are independent random draws — “how far apart” is noise.

But recall the phasor view: an offset is a discretized phase. Where an offset carries an ordinal meaning, the gap between two of them is real information, and Lee distance reads it — the circular gap for a segment of positions, averaged over the segments:

Like Hamming distance, Lee distance is also a distance metric. Reported per segment, so it is comparable across models: chance is and the maximum whatever is. Two offsets one step apart contribute , where Hamming would already charge the full penalty.

Lee is NOT a restatement of overlap the way Hamming is. Overlap only ever asks whether two offsets match, never how far apart they are, so it constrains Lee only loosely — two vectors of identical overlap can sit at very different Lee distances.

Supported Models

A Model is named for its one free parameter: the segment size in bits. Cardinality equals the segment size, so an -bit model carries offsets of bits each — and a HyperPhaser carries phasors on a ring of . The binary width follows from that one choice and matters only to the binary form; the storage and compute characteristics follow from all three.

ModelWidth Sparsity BitsCardinality Segment Size
MODEL_8BIT65,5368256256
MODEL_10BIT1,048,576101,0241,024
MODEL_12BIT16,777,216124,0964,096
MODEL_14BIT268,435,4561416,38416,384
MODEL_16BIT4,294,967,2961665,53665,536

Model properties

All model functions take a Model enum value and return the derived property:

Note

For simplicity, we use function names from Python. The counterparts from Go / Rust can be found by consulting their respective references.

FunctionDescription
widthTotal dimension count (2^width_bits)
cardinalityNumber of ON bits (= number of segments)
sparsityFraction of ON bits (1 / segment_size)
segment_sizeDimensions per segment

How to Choose a Model

  • MODEL_8BIT: Fast prototyping, with minimal memory footprint and high performance (due to SIMD). Good for tests, experiments and production.
  • MODEL_10BIT: General-purpose, balances performance and storage.
  • MODEL_12BIT: General-purpose, for the adventurous.
  • MODEL_14BIT / MODEL_16BIT: Very high capacity, not there yet.

In general, larger models provide more orthogonal space (lower collision probability) at the cost of more memory per vector.

Note

The storage consideration above applies to SparseSegmented, the particular type containing raw offsets. There are other types of sparse binary hypervector, typically defined by a recipe: a seed, or a seed plus members, and carries only that instead of raw offsets. For example, Sparkle stores its seed and derives its offsets on demand; composites such as Set and Sequence hold references to their members, so they cost far less than a materialized vector both in memory and on the wire.

Additionally, the bits are computed on first observation and cached, then released again on compact(). Constructing a vector you never observe therefore costs almost nothing — see lazy materialization.

Last change: , commit: 6051243