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:
| Constant | Type |
|---|---|
HINT_SPARSE_SEGMENTED | SparseSegmented π‘ |
HINT_SPARKLE | Sparkle β¨ |
HINT_LEARNER | Learner π« |
HINT_SET | Set π«§ |
HINT_SEQUENCE | Sequence πΏ |
HINT_OCTOPUS | Octopus π |
HINT_KNOT | Knot πͺ’ |
HINT_PARCEL | Parcel π |
HINT_DART | Dart π― |
HINT_POINT | Point π |
HINT_CYCLONE | Cyclone π |
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
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_lazycompares recipes (and already-known content hashes), so it never materializes anything. It is conservative: aTrueanswer is always correct, while aFalseanswer may mean βnot provable this cheaplyβ β two vectors of different concrete types, for example, or a coincidence that only the actual offsets would reveal.equalstarts 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
| Type | Description |
|---|---|
| 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) |