<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.4.1">Jekyll</generator><link href="/wordsalad/feed.xml" rel="self" type="application/atom+xml" /><link href="/wordsalad/" rel="alternate" type="text/html" /><updated>2026-08-26T22:59:10+00:00</updated><id>/wordsalad/feed.xml</id><title type="html">Words about math and machine learning</title><author><name>Alex Oberle</name></author><entry><title type="html">Analyzing Map</title><link href="/wordsalad/2025/09/26/analyzing-map.html" rel="alternate" type="text/html" title="Analyzing Map" /><published>2025-09-26T00:00:00+00:00</published><updated>2025-09-26T00:00:00+00:00</updated><id>/wordsalad/2025/09/26/analyzing-map</id><content type="html" xml:base="/wordsalad/2025/09/26/analyzing-map.html"><![CDATA[<h3 id="what-are-vector-symbolic-architectures">What are Vector Symbolic Architectures?</h3>

<p>Vector Symbolic Architectures (VSA) are a class of approaches which treat vectors as symbols and use mathematical operators to perform symbolic manipulation on them. Each VSA defines the following:</p>

<ul>
  <li>A vector sampling distribution $\Omega$</li>
  <li>A binding operator $B(\cdot, \cdot)$</li>
  <li>A bundling operator $+$ (usually addition)</li>
  <li>A retrieval (or unbinding) operator $B^*(\cdot, \cdot)$</li>
</ul>

<p>To encode information, symbols are bound in key/value (or role/filler) pairs, and then bound pairs are bundled together into a hypervector. Then, using any original key, we can use the retrieval operator to get its corresponding value vector back out of the hypervector.</p>

<p>As an example, consider the sentence <em>“Alex likes chocolate”</em>. We can assign vectors from the VSA’s distribution to the roles $\{First, Second, Third\}$ and values $\{Alex, likes, chocolate\}$.</p>

<p>We can then represent the entire sentence with:</p>

\[S = B(First, Alex) + B(Second, likes) + B(Third, chocolate)\]

<p>Then, we can later recover the $First$ word from the sentence with:</p>

\[B^*(S, First) = \widehat{Alex} \approx Alex\]

<p>In general, this retrieval process is subject to noise; a “good” VSA is one that is less noisy, in the sense that $\widehat{Alex}$ is very close to $Alex$.</p>

<h3 id="a-motivating-example-with-deep-learning">A Motivating Example with Deep Learning</h3>

<p>One application of VSAs in deep learning is to compress the size of the (very large) output layer in a neural net being trained for Extreme Multilabel Classification <a class="citation" href="#learning_hrr">[1], [2]</a>. In such a scenario, the total number of classes $d$ may be so large that the output layer comprises a significant portion of the total weights in the network, while typically only a few labels apply to any given training example <a class="citation" href="#xlm">[3]</a>. We can use VSAs to convert this into an $n$-dimensional vector regression task, where $n \ll d$.</p>

<p>The scheme proposed by <a class="citation" href="#learning_hrr">[1]</a> assigns 1 role vector for each class, and two unique filler vectors: $present$ and $absent$. Each training example then constructs a hypervector $S \in \mathbb{R}^n$:</p>

\[S = \underbrace{
        \sum_{\mathbf{c}_p \in Y_p} B(present,  \mathbf{c}_p)
    }_{\text{Labels present}} 
+ \underbrace{
        \sum_{\mathbf{c}_a \in Y_a} B(absent,  \mathbf{c}_a)
    }_{\text{Labels absent}}\]

<p>where $Y_p, Y_a$ are the sets of $present$ and $absent$ role vectors, respectively, for the training example.</p>

<p>The neural net is then trained to produce $S$, from which the predicted present and absent classes are extracted. There are two catches, though. The first is obvious — the scheme only works if you can reliably extract true class labels from $S$, so we’re incentivized to use the best VSA we can find. The second is that you need a way to pick $n$ intelligently — too large, and there’s no reason to use the technique; too small, and retrieval accuracy will suffer. A VSA’s capacity is the number of pairs of vectors it can store without losing retrieval accuracy for a given encoding dimension. Some, like the Holographic Reduced Representation, have theoretical bounds on capacity <a class="citation" href="#hrr">[4]</a>. Others, such as the Hadamard-derived Linear Binding (HLB), do not.</p>

<h3 id="map-i-and-hlb">MAP-I and HLB</h3>

<p>MAP – multiply-add-permute – is a family of VSAs which largely share operators, but differ in what distributions they sample vectors from <a class="citation" href="#map">[5], [6]</a>.</p>

<table>
  <thead>
    <tr>
      <th>VSA</th>
      <th>Sampling Distribution</th>
      <th>Binding Operator</th>
      <th>Bundling Operator</th>
      <th>Retrieval Operator</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>MAP-C</td>
      <td>$x_i ∼ U (−1, 1)$</td>
      <td>$\odot$ (component-wise multiplication)</td>
      <td>$+$ (with cutting)</td>
      <td>$\odot$</td>
    </tr>
    <tr>
      <td>MAP-B</td>
      <td>$x_i ∼ B(1, 0.5) · 2 − 1$</td>
      <td>$\odot$</td>
      <td>$+$ (with thresholding)</td>
      <td>$\odot$</td>
    </tr>
    <tr>
      <td>MAP-I</td>
      <td>$x_i ∼ B(1, 0.5) · 2 − 1$</td>
      <td>$\odot$</td>
      <td>$+$</td>
      <td>$\odot$</td>
    </tr>
  </tbody>
</table>

<p>MAP-I is of particular interest because it can be viewed as a discrete version of HLB as long as you restrict to only ever unbinding using vectors $v \in V^n = \{+1, -1\}^n$ — multiplying and dividing by $\pm 1$ are equivalent, after all.</p>

<table>
  <thead>
    <tr>
      <th>VSA</th>
      <th>Sampling Distribution</th>
      <th>Binding Operator</th>
      <th>Bundling Operator</th>
      <th>Retrieval Operator</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>HLB</td>
      <td>$x_i ∼ \{N(-\mu, 1/d), N(\mu, 1/d) \}$</td>
      <td>$\odot$</td>
      <td>$+$</td>
      <td>$\div$ (component-wise division)</td>
    </tr>
  </tbody>
</table>

<p>Since MAP-I is discrete, it has some helpful properties we can use to analyze it. For example, $V^n$ is closed under component-wise multiplication and division, so we have that binding $B: V^n \times V^n \to V^n$</p>

<h3 id="distance-and-dot-products">Distance and Dot Products</h3>

<p>$V^n$ is a finite set, so there are a finite number of values that dot products can take over its elements. In order to enumerate these dot products, we define the scaled Manhattan distance:</p>

\[d(x, y) = \frac{1}{2} \sum_{i=1}^n |x^{(i)} - y^{(i)}|\]

<p>This is equivalent to counting how many elements of $x$ and $y$ are different: if $x_i \neq y_i$, then $\frac{|x_i - y_i|}{2} = 1$. Immediately, we can use this distance formula to say something about dot products between elements of $V^n$:</p>

<p><strong>Lemma 1:</strong>
$x \cdot y$ is a function of $d(x, y)$ and $n$</p>

<p>$Proof$.</p>

\[x \cdot y = \sum_{i=1}^n x^{(i)}y^{(i)} 
= \sum_{x^{(i)} = y^{(i)}} x^{(i)}y^{(i)} + \sum_{x^{(i)} \neq y^{(i)}} x^{(i)}y^{(i)}
= p - q\]

<p>Where $p$ is the number of elements of $x$ and $y$ which are the same, and $q$ is the number of elements of $x$ and $y$ which are different. Therefore, we have $q = d(x, y)$, and $p = n - d(x,y)$. This gives the result</p>

\[x \cdot y = n - 2d(x, y) \tag*{$\blacksquare$}\]

<p>Using this lemma, we can describe the probability distribution of dot products over elements of $V^n$. This will be our primary tool for analyzing the capacity of MAP-I.</p>

<p><strong>Corollary 1 - Distribution of Random Dot Products over $V^n$:</strong>
If $x, y$ are sampled randomly and uniformly from $V^n$, then $x \cdot y = Z ∼ n - 2B(n, 0.5)$. Furthermore, $E[Z] = 0$ $Var[Z] = n$, and</p>

\[P(Z=z) = \frac{ \binom{n}{\frac{n - z}{2}} }{ 2^n }\]

<p>$Proof.$</p>

<p>Let $x, y$ be sampled randomly and uniformly from $V^n$, and define $D = d(x, y)$. Consider $x$ “fixed”, and a “successful trial” to be the case that $x^{(i)} = y^{(i)}$. The probability $x^{(i)} = y^{(i)}$ is $50\%$, and $x$ has $n$ elements, so there are $n$ trials. Therefore, $D ∼ B(n, 0.5)$.</p>

<p>Now, let $Z = x \odot y$. Then, by Lemma 1, we also have that</p>

\[Z = n - 2D\]

<p>Since $D$ is binomial, we can easily find $E[Z]$ and $Var[Z]$ as well:</p>

\[E[Z] = E[n - 2D] = n - 2E[D] = 0\]

\[Var[Z] = Var[n - 2D] = 4Var[D] = n\]

<p>Furthermore, we can write $Z$’s PMF explicitly with a simple change of variables:</p>

\[Z = n - 2D \iff D = \frac{n - Z}{2}
\implies P(Z=z) = P(D= \frac{n - z}{2}) = \frac{ \binom{n}{\frac{n - z}{2}}}{2^n} \tag*{$\blacksquare$}\]

<p>Finally, as our last bit of preparation, we define the vector concatenation operator $\oplus$ and connect it to dot products.</p>

\[\oplus: \mathbb{R}^n \times \mathbb{R}^m \to \mathbb{R}^{n+m}\]

\[x \oplus y =
\begin{bmatrix}
    x_1 \\
    x_2 \\
    \vdots \\
    x_n
\end{bmatrix} \oplus 
\begin{bmatrix}
    y_1 \\
    y_2 \\
    \vdots \\
    y_m
\end{bmatrix} = 
\begin{bmatrix}
    x_1 \\
    \vdots \\
    x_n \\
    y_1 \\
    \vdots \\
    y_m \\
\end{bmatrix}\]

<p><strong>Lemma 2:</strong> $x \cdot y + u \cdot v = x \oplus u \cdot y \oplus v$</p>

<p>$Proof:$</p>

\[x \cdot y + u \cdot v 
= \sum_{i=1}^n x^{(i)} y^{(i)} + \sum_{j=1}^m u^{(j)} v^{(j)}
= \sum_{k=1}^{n+m} (x \oplus u)^{(k)} (y \oplus v)^{(k)}\]

\[\text{by definition of vector concatenation.} \tag*{$\blacksquare$}\]

<h3 id="binding-and-bundling">Binding and Bundling</h3>

<p>Instead of considering binding and bundling as two distinct operations, we’ll consider them as a combined operation over two sets of “left” and “right” vectors.</p>

<p>Let $x_i$, $y_i \in \mathbf{R}^n$, $i=1, 2, \dots, \rho$ be left and right vectors. We’ll organize them into:</p>

\[X = 
\left(\begin{array}{c|c|c|c}
x_1 &amp; x_2 &amp; ... &amp; x_{\rho}
\end{array}\right), 
\quad
Y=
\left(\begin{array}{c|c|c|c}
y_1 &amp; y_2 &amp; ... &amp; y_{\rho}
\end{array}\right)
\in \mathbb{R}^{n \times \rho}\]

<p>Then we define the “bind then bundle” operation $\mathbf{BB}(\cdot, \cdot)$ as</p>

\[\mathbf{BB}(X, Y) = \text{diag}(XY^T) \in \mathbb{R}^n\]

<p>There’s a lot of equivalent ways to write that – it’s the same as a componentwise multiplication between the matrices, then summing along the rows. The important thing, however, is that each element of $\mathbf{BB}(X, Y)$ is itself a dot product:</p>

\[\mathbf{BB}(X, Y) =
\left(
    \begin{array}{c}
        X_1 \cdot Y_1 \\
        X_2 \cdot Y_2 \\
        \vdots \\
        X_n \cdot Y_n
    \end{array}
\right)
\quad
\text{$X_i,\ Y_i$ are the $i^{th}$ rows of $X$, $Y$, resp.}\]

<p>But $X_i$, $Y_i$ are elements of $V^{\rho}$, so their values are distributed according to Corollary 1.</p>

<h3 id="retrieval">Retrieval</h3>

<p>Let $S = \mathbf{BB}(X, Y)$. Given $y$ we want to retrieve $x$ from $S$. We check how good we are at doing this by comparing dot products between the value we unbind $\hat{x} = B^*(S, y)$ and the true result, $x$, giving us a retrieval score $R = \hat{x} \cdot x$. We can split this into two cases. In the “correct” case, we unbind with $y_i$ and take the dot product against $x_i$. Since $x_i$ and $y_i$ are bound together and contained within $S$, we expect the score to be high. In the “incorrect” case we unbind and test with non-matching $x$ and $y$. Since $x$ and $y$ are not bound within $S$, we expect the score to be low. Our goal is to find the PMFs for both of these cases.</p>

<p>First, we have a property of this retrieval process which will simplify things:</p>

<p><strong>Lemma 3:</strong>
\(B^*(S, y) \cdot x = B^*(S, x) \cdot y\)</p>

<p>$Proof:$</p>

\[B^*(S, y) \cdot x = \sum_{i=1}^n \frac{S^{(i)}}{y^{(i)}} x^{(i)} 
= \sum_{i=1}^n \frac{S^{(i)}}{x^{(i)}} y^{(i)} 
= B^*(S, x) \cdot y\]

\[\text{because } x^{(i)}, y^{(i)} \in \{-1, +1 \} \tag*{$\blacksquare$}\]

<h4 id="correct-case">Correct Case</h4>

<p>For the correct case, we can rewrite $S$:</p>

\[S = 
\left(
    \begin{array}{c}
        x_i^{(1)} \cdot y_i^{(1)} + \alpha_1 \\
        x_i^{(2)} \cdot y_i^{(2)} + \alpha_2 \\
        \vdots \\
        x_i^{(n)} \cdot y_i^{(n)} + \alpha_n
    \end{array}
\right)
=
\left(
    \begin{array}{c}
        x_i^{(1)} \cdot y_i^{(1)} \\
        x_i^{(2)} \cdot y_i^{(2)} \\
        \vdots \\
        x_i^{(n)} \cdot y_i^{(n)}
    \end{array}
\right)
+ 
\underbrace{
    \left(
        \begin{array}{c}
            \alpha_1 \\
            \alpha_2 \\
            \vdots \\
            \alpha_n
        \end{array}
    \right)
}_{=: \alpha}\]

<p>where each $\alpha_i$ is simply the other elements in the sum of the dot product for that entry.</p>

<p>Now, let’s examine $B^*(S, y_i)$:</p>

\[B^*(S, y_i) = S \div y = 
\left(
    \begin{array}{c}
        \frac{x_i^{(1)} \cdot y_i^{(1)}}{y_i} \\
        \frac{x_i^{(2)} \cdot y_i^{(2)}}{y_i} \\
        \vdots \\
        \frac{x_i^{(n)} \cdot y_i^{(n)}}{y_i}
    \end{array}
\right)
+ \alpha \div y_i
=
x_i + \alpha \div y_i =: \hat{x}_i\]

<p>Now, each $\alpha_k$ is equivalent to a dot product between two random vectors in $V^{\rho-1}$, which means they are random variables following our favorite distribution described above. Accordingly, their distribution is symmetric about $0$, and each $y_i^{(j)}$ is a Rademacher random variable. Therefore the distribution of the random variable $\alpha_k y_i^{(k)}$ is equivalent to $\alpha_k$. In other words, since we already didn’t know the sign of each element of $\alpha$, the fact that it may or may not be swapped by the component-wise division by $y_i^{(k)}$ is irrelevant.</p>

<p>Now, we need to compare $\hat{x}_i$ to $x_i$:</p>

\[\begin{aligned}
    &lt;\hat{x}_i,\ x_i&gt; &amp; =\  &lt;x_i + \alpha \div y_i,\ x_i&gt; \\
    &amp; = &lt;x_i, x_i&gt; + &lt;\alpha \div y_i,\ x_i&gt; \\ 
    &amp; = n + \underbrace{&lt;\alpha \div y_i,\ x_i&gt;}_{=: E}
\end{aligned}\]

<p>Since $n$ is constant, all we have to do is find the PMF for $E$:</p>

\[E = \sum_{j=1}^n \frac{\alpha_j x_i^{(j)}}{y_i^{(j)}}\]

<p>We still have that $x_i^{(j)}$ and $y_i^{(j)}$ are Rademacher random variables, so the PMF of $E$ is equivalent to the PMF of</p>

\[\bar{E} = \sum_{j=1}^n \alpha_j = \sum_{j=1}^n u \cdot w \ \ \ \ \ u, w \in V^{(\rho - 1)}\]

<p>Since $\bar{E}$ is the sum of $n$ dot products of vectors in $V^{\rho-1}$, so we can apply Lemma 2 (vector concatenation) to view it as a single $n(\rho-1)$-dimensional dot product over elements of $V^{n(\rho-1)}$. Using Corollary 3, we therefore have that $\bar{E} ∼ B(n (\rho - 1), 0.5)$.</p>

<p>However, we don’t just want the PMF of $E$, we want the PMF of $T = n + E$. Fortunately, this is relatively simple:</p>

\[\begin{aligned}
    P(T=c) = P(n + E = c) = P(E = c-n) &amp; = \frac{\binom{n(\rho-1)}{(n(\rho-1) - (c-n) ) /2}}{2^{n(\rho-1)}} \\
    &amp; = \frac{\binom{n(\rho-1)}{(n\rho -c ) /2}}{2^{n(\rho-1)}}
\end{aligned}\]

<h4 id="incorrect-case">Incorrect Case</h4>

<p>The incorrect case is easier. Let $F = B^*(S, y) \cdot x_i$, $y \neq y_i$.</p>

\[B^*(S, y) = S \div y = 
\left(
    \begin{array}{c}
        X_1 \cdot Y_1 \div y^{(1)} \\
        X_2 \cdot Y_2 \div y^{(2)} \\
        \vdots \\
        X_n \cdot Y_n \div y^{(n)}
    \end{array}
\right)
= \beta\]

<p>Then, like previously, we write $F = \langle \beta, x_i \rangle$ as a sum:</p>

\[F = \sum_{j=1}^n \beta^{(j)} x_i^{(j)} = \sum_{j=1}^n \frac{x_i^{(j)}}{y^{(j)}} X_j \cdot Y_j\]

<p>We apply the exact same argument here as we did for $E$ and $\bar{E}$ – the only difference is that we have a sum of $n$ dot products of $\rho$ vectors from $V^\rho$, instead of $\rho-1$. As a result, we get:</p>

\[P(F=c) = \frac{\binom{n\rho}{(n\rho-c)/2}}{2^{n\rho}}\]

<h3 id="charts--experimental-results">Charts &amp; Experimental Results</h3>

<p>To check the above results, have some charts! For each chart, I computed samples of $T$ and $F$ for a fixed value of $n$ and $\rho$ and plotted the results as a histogram. Separately, I computed the PMFs for $T$ and $F$ using the formulas described above, and overlaid the curves over the histogram.</p>

<p><img src="/wordsalad/assets/images/2025-09-26/map-100-8.png" alt="n=100,rho=8" /></p>

<p>We can see the discrete nature of MAP-I on full display – the histogram has an “empty” space in between each bar. In fact, this is because the parity of $t \sim T$ and $f \sim F$ is determined fully by $n$ and $\rho$. The maximum value of either distribution is $n p$ (in the case that all elements of all vectors bound and bundled into $S$ were equal to $1$), and all possible other values count down by $2$ from there. This does mean the plotted PMFs are slightly dishonest – in reality, they’re not smooth either. However, the plot looks much nicer by pretending they are instead of having them dip back down to $0$ on every other integer, or plotting them as discontinuous line segments.</p>

<p><img src="/wordsalad/assets/images/2025-09-26/map-700-20.png" alt="n=700,rho=20" /></p>

<h3 id="separation-of-distributions">Separation of Distributions</h3>

<p>We can see from the graphs that the distributions for $T$ and $F$ are separated, but that does not tell us by how much. Nor does it tell us in practice how big of a dimension $n$ we need to choose to accurately retrieve from a bundle of $\rho$ pairs. We can use the following inequality to describe what “well separated” means for $T$ and $F$ in terms of their standard deviations:</p>

\[E[T] - a\sqrt{Var[T]} \geq E[F] + a\sqrt{Var[F]} \quad \text{where $a$ is an arbitrary positive constant}\]

<p>We can plug in the expected values and variances of $T$ and $F$ using the results from Corollary 1, and solve for $n$ to describe the minimum dimension needed to keep $T$ and $F$ separated by $a$ standard deviations with up to $\rho$ bundled pairs per hypervector:</p>

\[\begin{aligned}
        &amp; n - a\sqrt{n(\rho-1)} \geq 0 + a\sqrt{n \rho} \\
        &amp; \iff n \geq a(\sqrt{n(\rho-1)} + \sqrt{n \rho}) \\
        &amp; \iff n^2 \geq a^2(n(\rho-1) + 2\sqrt{n (\rho-1)} \sqrt{n \rho} + n\rho \\
        &amp; \iff n^2 \geq a^2(n(\rho-1) + 2n\sqrt{\rho(\rho-1)} + n\rho) \\
        &amp; \geq na^2((\rho-1) + 2(\rho-1) + \rho) \\
        &amp; \implies n \geq a^2(4\rho - 3)
    \end{aligned}\]

<p>Then solving for $a$, we get the maximum number of standard deviations between the two distributions with given dimension and bundle size:</p>

\[\begin{aligned}
    &amp; n \geq a^2(4\rho - 3) \\
    &amp; \iff a^2 \leq \frac{n}{4\rho-3} \\
    &amp; \iff a \leq \sqrt{ \frac{n}{4\rho-3}  }
\end{aligned}\]

<p>These inequalities provide a handy rule of thumb for practitioners seeking to choose an encoding size for their VSAs – choosing $a$ is less explicit than choosing a probability of success, but it is still fairly interpretable. With $a = 3$ or $4$, you can be confident that the distributions will be well separated, and the probability of an incorrect retrieval being mistaken for a correct one is quite low. Additionally, these results align with those recently published in <a class="citation" href="#lessons">[7]</a>. They experimentally show the same linear relationship between $n$ and $\rho$ for MAP-I, HRR, and HLB that these inequalities prove for MAP-I.</p>

<h2 id="works-cited">Works Cited</h2>
<ol class="bibliography"><li><span id="learning_hrr">[1]A. Ganesan <i>et al.</i>, “Learning with holographic reduced representations,” <i>Advances in neural information processing systems</i>, vol. 34, pp. 25606–25620, 2021.</span></li>
<li><span id="hlb">[2]M. M. Alam, A. Oberle, E. Raff, S. Biderman, T. Oates, and J. Holt, “A walsh hadamard derived linear vector symbolic architecture,” <i>Advances in Neural Information Processing Systems</i>, vol. 37, pp. 2711–2733, 2024.</span></li>
<li><span id="xlm">[3]K. Bhatia <i>et al.</i>, “The extreme classification repository: Multi-label datasets and code.” 2016. Available at: http://manikvarma.org/downloads/XC/XMLRepository.html</span></li>
<li><span id="hrr">[4]T. A. Plate, “Holographic reduced representations,” <i>IEEE Transactions on Neural networks</i>, vol. 6, no. 3, pp. 623–641, 1995.</span></li>
<li><span id="map">[5]R. W. Gayler, “Multiplicative Binding, Representation Operators &amp; Analogy (Workshop Poster).” 1998. Available at: http://cogprints.org/502/</span></li>
<li><span id="schlegel">[6]K. Schlegel, P. Neubert, and P. Protzel, “A comparison of vector symbolic architectures,” <i>Artificial Intelligence Review</i>, vol. 55, no. 6, pp. 4523–4555, Aug. 2022, doi: 10.1007/s10462-021-10110-3.</span></li>
<li><span id="lessons">[7]F. S. Carzaniga, M. Hersche, K. Schindler, and A. Rahimi, “Practical Lessons on Vector-Symbolic Architectures in Deep Learning-Inspired Environments,” 2025.</span></li></ol>]]></content><author><name>Alex Oberle</name></author><summary type="html"><![CDATA[What are Vector Symbolic Architectures?]]></summary></entry></feed>