How context can change a retrieval ranking
Why shared bipolar binding preserves a ranking, how weighted similarity can change it, and what remains to be tested for useful retrieval.
On this page
When we search through information, we usually have a purpose in mind. A record that’s useful for one task may be less useful for another, even when both tasks concern the same subject. How can a retrieval system take that purpose into account when deciding which records to bring back?
Consider a collection of past equipment incidents. A maintenance task might call for cases with similar symptoms, while planning a replacement might favor cases with similar operating constraints. Both searches use the same records. What changes is which similarities we want the system to emphasize.1
For HDC, this raises two connected questions: what information about an incident does its hypervector retain, and how should we use that information when comparing incidents for a particular task?
In the previous installment, we saw why a wider hypervector can’t restore distinctions lost during encoding. Here we’ll call a stored hypervector encoding facts or features from a record a memory. For our equipment example, it represents an incident using information such as its symptoms and operating conditions.
We’ll keep these stored hypervectors fixed and ask how the task can change the way we compare them. We’ll call the active context a lens: state that controls a defined retrieval operation, rather than a special kind of hypervector with automatic semantic powers.
Filtering sets eligibility
Suppose a system retrieves the 10 closest records under a fixed similarity function, then removes records from the wrong machine type. The filter changes eligibility within the returned set. It doesn’t change the scores or recover a relevant record that never reached the shortlist.
Filtering remains useful for permissions, date ranges, and other explicit constraints. It can also run before search. Suppose two incidents both pass those constraints: one matches the current symptoms more closely, while the other matches the operating conditions. Maintenance and replacement planning might order those same eligible cases differently. Removing either case can change the winner, but leaves the comparison between them unanswered. We need a scoring rule if we want both to remain candidates and their relative scores to reflect the task.
| Context acts on… | What can change |
|---|---|
| The comparison rule | Relative scores and rankings among the same memories. |
| The candidate set | Which memories are eligible to compete. |
| The acceptance threshold | Whether the best available match is accepted at all. |
These are distinct controls. Raising a common similarity threshold can turn a match into an abstention without changing the order of the candidates. Only a change to the comparison rule changes how the same pair of representations is scored.
When binding preserves rankings
Binding is useful in HDC precisely because it can preserve structure under a reversible transformation.2 In bipolar multiplicative binding (using the MAP method), binding multiplies the components in an element-wise manner. Suppose we represent context by a bipolar hypervector and bind it to a query and every stored memory :
Every context component squares to one. The transform preserves norms too, so cosine similarities remain unchanged for nonzero inputs. It cannot reorder the memories. For binary XOR binding, the corresponding observation is that flipping the same positions on both sides preserves Hamming distance.
Binding can also express a structured query. If a memory binds a role such as “machine type” to its value, a compatible role query can recover evidence about that value, as in our comparison of HDC algebras. But binding an arbitrary context only to the query doesn’t guarantee a useful ranking either. The memory encoding must give that query transformation a meaning.
Weighting can change rankings
A useful precedent comes from Robert Nosofsky’s generalized context model of categorization. It models selective attention by weighting psychological dimensions, changing distances between exemplars as the categorization task changes.3 The useful connection is that a task can alter similarity by changing what a comparison emphasizes. Its weighted-distance model uses psychological dimensions; it doesn’t establish that weighting individual HDC coordinates will be useful.
We’ll use coordinate weighting because it makes the contrast with shared sign flips easy to inspect: weights change the size of each contribution to the score. The construction lets us examine that change directly, while leaving the choice of a useful retrieval method open. Let task state select nonnegative weights ; here names the task, rather than a hypervector to bind. A weighted cosine score is:
The score is defined when both weighted norms are nonzero. Unlike a shared sign flip, unequal weights can change the relative importance of agreements and disagreements. Equivalently, we scale each coordinate on both sides by before taking ordinary cosine. This transformation generally doesn’t preserve the original angles.
In a distributed hypervector, coordinate 42 is not normally “maintenance relevance.” A coordinate weighting would need evidence that emphasizing those components improves comparisons for the task; the algebra alone supplies none. If meaningful features are available before encoding, weighting or selecting those features may offer a more interpretable intervention. It also raises a different question: will the changed query encoding remain compatible with the stored memories?
Same memories, different winners
Take an eight-component query containing only . Memory A agrees with its first four components and disagrees with the last four; B does the reverse; C disagrees everywhere. The blocks are deliberately constructed to make the arithmetic visible, not to suggest that production hypervectors have one semantic field per block.
| Pattern | Components 1-4 | Components 5-8 |
|---|---|---|
| Query | ||
| A | ||
| B | ||
| C |
Uniform weights give A and B a tie at zero. Context 1 weights each of the first four coordinates by three and each remaining coordinate by one. Context 2 reverses those weights. With the query and memories fixed, the scores become:
| Comparison | A | B | C |
|---|---|---|---|
| Uniform | 0.00 | 0.00 | -1.00 |
| Context 1 | 0.50 | -0.50 | -1.00 |
| Context 2 | -0.50 | 0.50 | -1.00 |
For A under Context 1, the numerator is and the denominator is 16, giving 0.50. Changing the context makes B the winner without changing any stored component. C stays below both competitors.
The scoring operation only reads the query and memories. Our reproducible script checks both the table and that the implementation leaves those inputs unchanged. We also enumerated all 256 bipolar context patterns for this eight-component example: symmetric binding preserved all three baseline scores in every case. This is an exact constructed demonstration, not evidence that a learned lens improves a real application.
Where context enters retrieval
So far, we’ve used context to change how we score a query against stored memories. Context can also influence what the query represents, which memories we search, or whether we accept a match. The table maps these choices to their effects and the conditions they depend on. You can read each row as a pair: what does each mechanism let us change, and what conditions does it need to work?
| Mechanism | What it changes | What must be checked |
|---|---|---|
| Feature gating before encoding | Which input distinctions reach the query representation. | Compatibility with stored encodings and loss of useful evidence. |
| Context-conditioned similarity | The contributions used to compare fixed hypervectors. | Useful weights, nonzero norms, and candidate recall. |
| Temporary prototype construction | The category representative used for the current comparison. | Stable source memories and the cost of constructing the prototype. |
| Context-specific memory routing | Which memory bank or partition supplies candidates. | Relevant cases excluded by a mistaken route. |
| Asymmetric query composition | The structured association the query asks the memory to recover. | Agreement between query algebra and stored role-value encoding. |
| Cleanup thresholds | How much evidence is needed to accept a retrieved match. | False matches and abstentions; a common threshold does not reorder scores. |
These mechanisms can work together, but a new scoring rule is only useful if candidate retrieval brings it the relevant records to compare.
Retrieving the right candidates
For a builder, the first implementation question is whether the desired case reaches the comparison at all. Suppose the original index returns only A, but the new context would rank B higher. Rescoring A can’t recover B. A context-dependent score may therefore require a change to candidate retrieval as well as a new scoring function.
A full scan compares every eligible memory and avoids shortlist exclusion, with work that grows with the number of memories. Broader shortlists increase comparison work; separate indexes for known contexts add storage and maintenance. These choices determine how much of the new ranking a deployed system can actually recover. Useful weights and adequate candidate recall are separate requirements.
Does the ranking help?
At HDC Labs, our reading is that a lens should be evaluated as a retrieval policy with observable behavior. If changing the task brings a different record to the top, we know context is affecting the search. We still need to ask whether that record is more relevant for the task. The toy example succeeds because we chose both the patterns and the contexts to make the intended ordering explicit.
It should be possible to design application tests using independently specified relevance judgments for each task. We’d hold query content and durable memory fixed, vary the task context, and compare fixed retrieval with filtering, symmetric binding, and the proposed lens. Measure relevant-neighbor recall, irrelevant matches, abstentions, query cost, and whether stored memory changes. Include a return to the original context to check that the original retrieval behavior returns too.
The promising separation is between what a system remembers and how it consults that memory. Context can change the latter through explicit, testable operations. In the next post, we’ll examine another way to make that separation: constructing a temporary category prototype from durable memories.
Footnotes
-
Lisa Feldman Barrett and Earl K. Miller, “Categorization is ‘baked’ into the brain”, Nature Reviews Neuroscience (2026). Open author PDF. Their account of context-dependent categorization prompted the question we explore here. We introduced that connection in our opening review. The retrieval operations and HDC constructions in this post are our engineering analysis, not mechanisms proposed in the Perspective. ↩
-
Pentti Kanerva, “Hyperdimensional Computing: An Introduction to Computing in Distributed Representation with High-Dimensional Random Vectors”, Cognitive Computation 1 (2009): 139-159. Open author manuscript, sections 5.3 and 6.4-6.9. The invariance proof, weighted comparison, and constructed example here are our mathematical exposition, not a reported experiment from the paper. ↩
-
Robert M. Nosofsky, “Attention, similarity, and the identification-categorization relationship”, Journal of Experimental Psychology: General 115 (1986): 39-61. Open author-hosted paper, especially p. 41, equation 6, and the selective-attention discussion. The algebra and eight-component example in this post are our own, not results from this study. ↩