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

HyperBinary Types

All vector types conform to a common HyperBinary interface, kept at feature parity across the underlying engines.

Python doesn’t have the concept of interface/trait, but all HyperBinary derived types share a common set of methods.

v.model()        # Model enum
v.width()
v.cardinality()
v.stable_hash()  # unique hash for this vector
v.seed128()
v.exponent()     # (numerator, denominator), in lowest terms
v.hint()         # HINT_* constant β€” the type this vector serializes as

hint(): the type on the wire

hint() reports which concrete type a vector serializes as, as one of the hv.HINT_* constants:

ConstantType
HINT_SPARSE_SEGMENTEDSparseSegmented 🍑
HINT_SPARKLESparkle ✨
HINT_LEARNERLearner πŸ’«
HINT_SETSet 🫧
HINT_SEQUENCESequence πŸ“Ώ
HINT_OCTOPUSOctopus πŸ™
HINT_KNOTKnot πŸͺ’
HINT_PARCELParcel 🎁
HINT_DARTDart 🎯
HINT_POINTPoint πŸ“
HINT_CYCLONECyclone πŸŒ€

It is the tag hv.from_message dispatches on, so it also names the type a round-trip gives back β€” which is why it reads the wire form rather than the Python class:

s = hv.Set(seed, a, b)
s.hint()                       # HINT_SET
hv.from_message(hv.to_message(s)).hint() == s.hint()   # True

s.power(0).hint()              # HINT_SPARSE_SEGMENTED β€” see below
Note

An identity vector has one canonical wire form, SparseSegmented with no offsets, whatever type produced it. So hint() reports HINT_SPARSE_SEGMENTED for any identity β€” matching what serialization actually writes, and what a round-trip hands back.

Learner is the exception: an age-0 Learner still serializes its own payload, because the RNG state has to survive. It reports HINT_LEARNER at every age.

Lazy materialization

Every type except SparseSegmented is defined by a recipe β€” much more compact than raw offsets.

The raw offsets will be computed and cached on first usage by APIs such as core(), stable_hash(), overlap and similarity, serialization of SparseSegmented, etc. Other API calls, such as model(), domain(), pod(), exponent(), never materialize anything.

This is invisible to callers: the vector holds the same semantic content whenever you ask, but it means constructing vectors you never observe is nearly free, which is the typical and common use case for hypervectors.

compact() releases the cached content again, recursively through members. The recipe is retained, so the next observation recomputes exactly the same bits.

core() is the explicit crossing from recipe to bits: it computes the offsets with any exponent folded in, and hands back a SparseSegmented reporting exponent() == (1, 1). That holds for every type. See SparseSegmented.

The tale of two equalities

Two levels are available, differing only in how hard they work:

  • equal_lazy compares recipes (and already-known content hashes), so it never materializes anything. It is conservative: a True answer is always correct, while a False answer may mean β€œnot provable this cheaply” β€” two vectors of different concrete types, for example, or a coincidence that only the actual offsets would reveal.
  • equal starts with the lazy check and falls back to comparing content hashes, materializing if it must. Use it when the answer must be exact.

Concrete Types

TypeDescription
SparseSegmented 🍑Foundational vector β€” packed per-segment offsets
Sparkle ✨Seeded, deterministic hypervector
Learner πŸ’«Online Hebbian learning
Set 🫧Unordered collection
Sequence πŸ“ΏOrdered collection with positional encoding
Octopus πŸ™Key-value composite
Knot πŸͺ’Results from bind operator
Parcel 🎁Results from bundle operator
Dart 🎯Directed pair (tail β†’ head)
Last change: , commit: 688700c