Do HRR and MAP preserve the same similarity structure?
A reproducible experiment that tests whether HRR and MAP preserve the same similarity structure in a shared encoder.
On this page
Holographic Reduced Representations (HRR) and Multiply-Add-Permute (MAP) are two popular algebras used for hyperdimensional computing. HRR uses real-valued hypervectors and circular convolution. MAP uses bipolar hypervectors and element-wise multiplication. We studied how these algebras capture relationships in the data, even though the underlying operations are expressed differently.
Research question
In this study, we conduct a controlled set of experiments that answer this question:
If we hold the encoder design fixed and change only the algebra, do HRR and MAP preserve the same relationships within the underlying data?
We compare HRR and MAP on a shared encoder over a small dataset of 20 structured records. Each record is represented as eight key-value pairs in JSON, which are then encoded as role-value pairs, first in an independent HRR space and next in an independent MAP space.
The experiments evaluate all 190 unordered record pairs against an exact, encoder-defined source similarity. We also repeat the experiment across six hypervector dimensions and five random seeds, then perform a small nearest-neighbor retrieval check in LanceDB to study the similarity results.
At 4,096 dimensions and random seed 2026, both HRR and MAP achieved Pearson correlations above 0.99 between their pairwise cosine similarities and the source baseline, and each mean absolute error rounded to 0.01. Across five seeds, their mean correlations with the same baseline exceeded 0.99 from 2,048 dimensions onward. The retrieval check produced 0.92 exact record-ID overlap across the top-four results.
The experiments validate the idea that even though HRR and MAP don’t produce equivalent hypervector spaces, they can be swapped behind a shared encoder while preserving essentially the same relational structure in either algebra.
The result also suggests a broader, testable hypothesis: HRR and MAP may preserve the same encoder-defined relationships across many other real-world datasets, making an experiment like this a practical way to inform the algebra choice, as well as the dimensionality of hypervectors, to adequately model the data for the tasks at hand.
Hypotheses we tested
An encoder and an algebra answer different design questions. The encoder decides which facts enter the representation and how they compose. The algebra supplies the numerical space and operations used to represent that composition.
| Property | HRR | MAP |
|---|---|---|
| Hypervector values | Real-valued | Bipolar () |
| Binding | Circular convolution | Element-wise multiplication |
| Bundling | Addition | Addition |
Our earlier summary report on the history of vector symbolic architectures explains how both approaches arrived at fixed-width binding and bundling through different mathematical routes. The present study moves from conceptual comparison to measurement. We keep the encoder design fixed, where a hypervector in either space is constructed as follows:
The binding operator means circular convolution for HRR and element-wise multiplication for MAP. The experiment tests three hypotheses:
- H1: Algebra translation preserves encoder-defined similarity. Pairwise cosine similarities in both hypervector spaces should closely follow the relationships defined directly by the encoded source terms.
- H2: Relationship preservation improves with dimensionality. Increasing the hypervector dimension should reduce random cross-talk1 and make both algebras reproduce the encoder-defined relationships more consistently across random seeds.
- H3: Both algebras retrieve equally similar neighbors. Given the same query record, HRR and MAP should return neighbors with matching encoder-defined source-similarity scores.
Each algebra independently initializes the field and value hypervectors it uses. The same encoder is used, so the only difference between the two runs is the algebra itself. The experiment therefore isolates the effect of changing the algebra while keeping the encoder and its intended relationships fixed.
Experimental design
We place HRR and MAP operations behind a common Algebra abstraction that exposes four encoding steps as methods: deterministic hypervector generation, binding, bundling, and normalization. A small factory constructs a TorchHD-backed implementation. The experimental loop can therefore switch the algebra without changing the encoder, keeping the record semantics and control flow fixed while isolating the numerical representation and binding operation being tested.
# Pseudocode: both implementations satisfy the same interface.
class Algebra(Protocol):
def hypervector(key):
# ...
def bind(left, right):
# ...
def bundle(hypervectors):
# ...
def normalize(hypervector):
# ...
def make_algebra(name, dimensions, seed):
implementations = {"hrr": HRR, "map": MAP}
return implementations[name](dimensions=dimensions, seed=seed)
encoded = {}
for name in ("hrr", "map"):
algebra = make_algebra(name, dimensions=4096, seed=2026)
encoded[name] = encode_all(records, algebra) # Same encoder path
The HRR implementation supplies real-valued TorchHD hypervectors and circular-convolution binding. The MAP implementation supplies bipolar TorchHD hypervectors and element-wise multiplicative binding. Both satisfy the same bundling and normalization contract.
The encoder design follows the same record-to-hypervector pipeline for both algebras:
Across both runs, the source records and their order, field-value vocabulary, preprocessing, term weights, bundling structure, evaluation pairs, and source baseline remain fixed. Only the independently initialized hypervectors, value domain, and binding operation change. The resulting coordinates and finite-dimensional cross-talk therefore belong to the selected algebra rather than to a change in the underlying record semantics.
Dataset and encoder
The experiments evaluate the HDC representation using an intentionally simple dataset that contains 20 tea records. The simplicity of the dataset allows us to explicitly verify the source similarity and the relationships it defines. The dataset is small enough to inspect by hand, but large enough to produce 190 unordered record pairs for evaluation.
An example tea record looks like this:
{
"sample_id": "T13",
"name": "Oriental Beauty",
"tea_type": "oolong",
"origin": "Taiwan",
"oxidation": "high",
"roast": "light",
"aroma_notes": ["honey", "muscatel", "floral"],
"elevation_m": 600
}
Each record contributes eight unit-weight terms:
| Field | Encoded terms | Matching rule |
|---|---|---|
tea_type | 1 | Exact normalized value |
origin | 1 | Exact normalized value |
oxidation | 1 | Exact normalized value |
roast | 1 | Exact normalized value |
elevation_m | 1 | Exact 500-meter bin |
aroma_notes | 3 | One term per distinct normalized note |
| Total | 8 |
The encoder assigns exact entity semantics2 to the current values. floral and orchid are distinct terms, oxidation and roast levels are categorical, and elevations match when they fall inside the same 500-meter bin. Those choices define the relationships the experiment asks HRR and MAP to preserve.
An exact reference for similarity
Directly comparing HRR and MAP hypervectors wouldn’t answer the research question because each algebra represents the data using an entirely different geometry in high-dimensional space.
Our goal is to establish whether these geometries adequately represent the source data, and whether the same relationships between records hold across these spaces. We therefore need a canonical baseline that is independent of both algebras and simple enough to verify through human inspection.
For each pair of records, the baseline measures the overlap between their explicit field-value terms. We then compare the HRR and MAP cosine similarities with that independently calculated score.
For records and , let and be their sets of encoded role-value terms. The encoder-defined source similarity (which we call the canonical baseline) is:
Every record contains eight terms, so the score simplifies to the number of shared terms divided by eight. The formula is cosine similarity in an explicit one-hot space of the encoder’s role-value facts.
Oriental Beauty, an oolong tea (T13), is the reference sample for this worked example. We compare Dong Ding, another oolong tea (T12), against it:
| Field | Oriental Beauty, oolong (T13) | Dong Ding, oolong (T12) | Shared terms |
|---|---|---|---|
tea_type | oolong | oolong | 1 |
origin | taiwan | taiwan | 1 |
oxidation | high | medium | 0 |
roast | light | medium | 0 |
elevation_m | [500,1000) | [500,1000) | 1 |
aroma_notes | honey, muscatel, floral | roasted nuts, honey, orchid | 1 |
The pair shares four of eight encoded terms:
At 4,096 dimensions and random seed 2026, HRR gives the pair a cosine similarity of 0.50 and MAP gives it 0.51. The canonical source baseline is 0.50 because the records share four of eight equally weighted encoded facts, so both algebra-derived similarities closely reproduce it.
Results
H1: Both algebras preserve the source structure
The first experiment fixes the dimension at 4,096 and the seed at 2026. We encode all 20 records in both algebras, calculate cosine similarity for all 190 unordered pairs, then compare both sets of scores with the same source baseline.
| Metric | HRR | MAP |
|---|---|---|
| Pearson correlation with source similarity | 0.997201 | 0.997460 |
| Mean absolute error from source similarity | 0.010456 | 0.010106 |
The two algebras show a high Pearson correlation of 0.997 with each other. However, comparing them with the source is the stronger test, because it evaluates each representation independently against the relationships specified by the encoder.
Both point clouds in the plot follow the ideal line closely, but the spread is more visible at lower source similarities. Most record pairs are concentrated there: 145 of the 190 pairs have a source similarity of 0.25 or less. These pairs also share few facts, so random cross-talk1 between unrelated bound terms makes up a larger part of their cosine score.
As two records share more facts, the intended similarity signal becomes stronger and the points cluster more tightly around the ideal line. The observed HRR and MAP errors are nearly the same size, and neither algebra shows a meaningful loss of the intended pairwise structure in this configuration.
H2: More dimensions improve fidelity (up to a point)
The fixed run leaves a capacity question: do we really need to go as high as 10,000 dimensions, or can we get away with fewer? We repeated the all-pairs evaluation at six dimensions using five deterministic seeds per dimension3 :
The dataset, term vocabulary, record order, field weighting, source baseline, and algebra definitions remain fixed across all 30 experiment cells. Only dimension and random seed change.
| Dimensions | HRR vs source | MAP vs source |
|---|---|---|
| 512 | 0.9706 ± 0.0033 | 0.9760 ± 0.0032 |
| 1,024 | 0.9849 ± 0.0041 | 0.9870 ± 0.0030 |
| 2,048 | 0.9928 ± 0.0024 | 0.9944 ± 0.0012 |
| 4,096 | 0.9966 ± 0.0005 | 0.9974 ± 0.0001 |
| 8,192 | 0.9981 ± 0.0003 | 0.9987 ± 0.0002 |
| 10,000 | 0.9981 ± 0.0005 | 0.9988 ± 0.0004 |
Both algebras preserve most of the intended structure at 512 dimensions and improve rapidly as the representations grow. At 2,048 dimensions, their mean Pearson correlations with the encoder-defined source similarity first exceed 0.99; beyond that point, improvements and variation across seeds are small.
We therefore use 4,096 dimensions as a conservative working default for this workload, giving us a measurement-based capacity choice instead of adopting a rigid convention of 10,000 dimensions. The right capacity will vary with the dataset and encoding strategy, so we recommend running a similar sweep for each new encoder and dataset combination.
H3: Both algebras retrieve equally similar neighbors
The third experiment tests whether preserving pairwise similarity also produces consistent similarity search results. At 4,096 dimensions and seed 2026, we computed and stored separate HRR and MAP hypervectors and then queried the same six records for their top-four neighbors.
The aggregate result is:
| Comparison across six top-four result sets | Agreement |
|---|---|
| Same record ID | 22 / 24 |
| Same number of encoded facts shared with the query | 24 / 24 |
HRR and MAP returned the same record in 22 of the 24 results. The two differences came from tied scores: in both cases, the selected records shared the same number of encoded facts with the query, even though the matching facts differed.4
To see how a tie arises, consider Dragon Well, a green tea (T08) in the dataset. We use its HRR hypervector to search the HRR column and its MAP hypervector to search the MAP column. Both searches return the same three record IDs among their first three results, but the fourth neighbor differs:
{
"query": {
"id": "T08",
"name": "Dragon Well",
"tea_type": "green"
},
"fourth_neighbor": {
"HRR": {
"id": "T07",
"name": "Gyokuro",
"tea_type": "green"
},
"MAP": {
"id": "T05",
"name": "Keemun Hao Ya",
"tea_type": "black"
}
}
}
The two different fourth neighbors share the same number of encoded facts with the query, but they differ in which facts they share.
| Candidate | Tea type | Facts shared with the green tea query | Source similarity |
|---|---|---|---|
| Gyokuro | Green | tea_type: green, oxidation: low, same 500-meter elevation bin | 3/8 = 0.375 |
| Keemun Hao Ya | Black | origin: China, roast: light, aroma_note: orchid | 3/8 = 0.375 |
Scope of the findings and next steps
The study answers its research questions in a controlled setting: 20 structured records, 8 exact terms per record, 5 seeds in the capacity sweep, and a 6-query retrieval check. Exact aroma identity, categorical oxidation and roast, and the discretization of elevation into 500-meter bins make the source geometry transparent enough to audit by hand.
The next useful step would be to keep the experimental structure and increase the semantic pressure on the encoder. A larger real dataset could add learned aroma similarity embeddings and a different mixture of ordinal fields, continuous features, unequal record lengths, or deeper compositions. Separate benchmarks could then measure unbinding accuracy, approximate indexing, throughput, memory use, and accelerator behavior. Each extension asks a new question while retaining the same reproducible comparison framework.
Reproducibility
The complete implementation, source fixture, methodology, raw result tables, and plotting code are available in the HRR and MAP similarity repository . The METHODOLOGY.md supplement defines every field transformation and the source-similarity formula.
Run the workflow in order:
# Install the exact environment recorded in uv.lock.
uv sync --frozen
# Load the 20 inspectable source records into LanceDB.
uv run src/01_make_demo_data.py
# Encode every record once with HRR and once with MAP.
uv run src/02_encode.py
# Recreate the all-pairs metrics, retrieval audit, and comparison figure.
uv run src/03_evaluate.py
# Repeat the benchmark across six dimensions and five seeds.
uv run src/04_dimension_sweep.py
# Check the algebra, encoder, evaluation, and repository invariants.
uv run pytest -q
You can also repurpose this workflow for other datasets and use cases with the agent skill included in the repository.
Key findings and broader implications
The research question we began with asked whether HRR and MAP preserve the same relationships when the role-value encoder stays fixed. The results yielded four clear findings:
- The same encoder ran unchanged in both algebras. HRR and MAP supplied different field and value hypervectors and different binding operations within the same record-to-hypervector pipeline.
- Both algebras reproduced the intended pairwise structure. At 4,096 dimensions, each reached a correlation above
0.99with the encoder-defined source similarity, with mean absolute error close to0.01. - Capacity improved fidelity in both algebras (up to a point). Mean Pearson correlation with the encoder-defined source similarity exceeded
0.99from 2,048 dimensions onward. The trend flattens as dimensions approach 10,000, with a sweet spot of 8,192 dimensions in this fixture. - Retrieval preserved the same similarity levels. Across six top-four queries, HRR and MAP returned the same record ID in
22 / 24results. The other two records tied on source similarity, so the source-similarity score matched in 100% of the search results.
The hypotheses we began with were supported empirically. Even though HRR and MAP represent records in very different geometries, they can model the same compositional structure using different operators under the hood. For the encoder tested here, the algebra changed while the encoded relationships remained almost unchanged.
The broader result is methodological. We can use high-level abstractions in code to define an encoder’s intended relationships explicitly, implement the encoder, and test whether each representation preserves those relationships. Whether two different HDC algebras behave similarly moved from an intuition into a tangible, measured result that can be inspected, rerun, and adapted to different domains and datasets.
See the code that compares HRR and MAP similarity in our repository to explore this further.
Footnotes
-
Random cross-talk is unintended interference caused when unrelated bound and bundled hypervectors share a finite coordinate space. Their random components cancel only approximately, leaving residual contributions that perturb the cosine similarities the encoder was meant to produce. Too much cross-talk can blur genuine neighbors, create spurious similarity, and make rankings vary across random seeds. Increasing dimension averages those unrelated contributions across more components, so they cancel more reliably. See Kanerva’s introduction to hyperdimensional computing for the underlying high-dimensional geometry. ↩ ↩2
-
Exact entity semantics here means that two encoded terms match only when their normalized field and value are identical. For continuous numerical values (e.g., elevation), the encoder explicitly groups those into bins to capture ordinal relationships. The goal of this experiment is to measure only whether each algebra preserves the encoder’s declared data relationships, not whether those relationships match a human judgment of tea similarity. ↩
-
Each seed produces a different but reproducible set of random field and value hypervectors. Repeating the experiment across seeds shows whether a dimension preserves the source relationships consistently, rather than only under one favorable random initialization. ↩
-
These ties partly reflect the simple baseline: cosine similarity, not Jaccard, over eight equally weighted binary field-value terms. The score therefore reduces to shared-term count divided by eight and allows only a few values; real datasets may require weighted, continuous, learned, or domain-specific similarity. ↩