<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Ollama Embedding Models Comparison on RockB</title><link>https://baeseokjae.github.io/tags/ollama-embedding-models-comparison/</link><description>Recent content in Ollama Embedding Models Comparison on RockB</description><image><title>RockB</title><url>https://baeseokjae.github.io/images/og-default.png</url><link>https://baeseokjae.github.io/images/og-default.png</link></image><generator>Hugo</generator><language>en-us</language><lastBuildDate>Tue, 24 Nov 2026 11:22:00 +0000</lastBuildDate><atom:link href="https://baeseokjae.github.io/tags/ollama-embedding-models-comparison/index.xml" rel="self" type="application/rss+xml"/><item><title>Agent Memory Multi-Hop Recall: One Retrieval Misses Half of a Two-Hop Answer</title><link>https://baeseokjae.github.io/posts/agent-memory-multi-hop-recall-2026/</link><pubDate>Tue, 24 Nov 2026 11:22:00 +0000</pubDate><guid>https://baeseokjae.github.io/posts/agent-memory-multi-hop-recall-2026/</guid><description>A 120-fact local store and three Ollama embedders: single-hop facts land in the top-5 for 19-20 of 20 questions, but both facts for a two-hop question land for only 3-5 of 20. Top-20 recovers 14 of 20, and one-shot decomposition recovers 4 of 20. Coverage is measured per question; reader accuracy is not claimed.</description><content:encoded><![CDATA[<p>Your agent memory store answers single-fact questions well enough to look healthy. Ask which region a service runs in and the right row comes back with a good similarity score. Then someone asks which database holds that service&rsquo;s data — a question the store can only answer by joining two rows — and the agent either returns half of it with no trace of doubt or says it has nothing.</p>
<p>Three different faults produce that same answer, and the stack usually cannot tell them apart: the second fact was never written; it was written but ranked outside the k rows you retrieve; or both rows reached the prompt and the model failed to join them. Each fault has a different fix, and the fix you pick first is usually the wrong one, because nothing in a normal retrieval log reports which of the three happened.</p>
<p>This article measures the middle fault on a small, fully published fixture: 120 short facts forming 40 two-hop chains, 20 two-hop and 20 single-hop questions, three local embedding models served by Ollama, exact cosine ranking with no ANN library, and a 0.5B model as the decomposition rewriter. The short version:</p>
<ul>
<li>Single-hop facts stayed in the top-5: 20/20 questions for <code>all-minilm:latest</code>, 19/20 for <code>snowflake-arctic-embed:33m</code> and 19/20 for <code>nomic-embed-text:latest</code>.</li>
<li>Both facts needed by a two-hop question reached the top-5 for only 3/20, 5/20 and 5/20 questions respectively.</li>
<li>Raising k to 20 recovered both facts for 14/20 questions on every one of the three encoders, at roughly four times the facts in the prompt.</li>
<li>The first hop was usually in the top-5 (17-18 of 20 questions) while the second hop&rsquo;s median rank was 11 to 14. The bridge is not missing from the store; it is below a five-slot cut.</li>
<li>One-shot decomposition — ask a 0.5B model to split the question, then retrieve each part — recovered both facts for 4 of 20, against 3 of 20 for a plain top-5: it restates the question because the intermediate entity is not in the input.</li>
<li>Reader-side accuracy is not claimed. The reader stage did not complete inside this run&rsquo;s budget: the run ended before <code>results-reader.json</code> was written, so no reader row exists for this run and no accuracy, token or per-call latency figure is reported. What is measured and published is coverage, which is deterministic and computed without a reader model.</li>
</ul>
<p>The fixture, the probe and the per-question rows are published; the raw files are listed at the end.</p>
<h2 id="what-multi-hop-means-here-operationally">What &ldquo;multi-hop&rdquo; means here, operationally</h2>
<p>MultiHop-RAG defines the problem as queries that &ldquo;require retrieving and reasoning over multiple pieces of supporting evidence&rdquo; and reports that existing retrieval-augmented systems answer them unsatisfactorily (<a href="https://arxiv.org/abs/2401.15391">arXiv:2401.15391</a>). That is an English news knowledge base with 2023-2024 systems, so its numbers are not this article&rsquo;s numbers — it is the definition that matters: the evidence is plural, and the pieces have to be joined.</p>
<p>LongMemEval splits long-term memory into information extraction, multi-session reasoning, temporal reasoning, knowledge updates and abstention, and its abstract reports a roughly 30% accuracy drop for commercial assistants and long-context models on information that must be remembered across sustained interactions (<a href="https://arxiv.org/abs/2410.10813">arXiv:2410.10813</a>). Multi-session reasoning is the capability area closest to this test. No LongMemEval or LoCoMo score is reused or re-derived here; the fixture is this site&rsquo;s own.</p>
<p>For this fixture the operational definition is narrower and easier to check. A question names one entity and asks for a property that is not stored on that entity. The store contains a chain: entity A → intermediate B, and B → answer. The question never names B. To answer, a retriever must return both rows; a reader must then apply the second to the first. &ldquo;Which database holds the data for orders-api?&rdquo; is answerable only if the store returns both &ldquo;orders-api runs in eu-west&rdquo; and &ldquo;eu-west stores primary data in aurora-eu-1&rdquo;. Nothing in the question mentions a region, so a single similarity search over the question text has to be lucky to rank both.</p>
<h2 id="the-fixture-120-facts-40-chains-40-questions">The fixture: 120 facts, 40 chains, 40 questions</h2>
<p>Everything is synthetic and deterministic, so the probe can be rerun and compared line by line.</p>
<ul>
<li>40 invented services (<code>orders-api</code>, <code>billing-worker</code>, …), 8 regions, 8 owning teams.</li>
<li>120 facts of 7 to 12 words (mean 9.2): 40 service→region, 40 service→team, 8 region→database, 8 team→on-call rotation, plus 24 distractors that sit on the same entities (cost centre per region, incident queue per team, language per service) so that &ldquo;region&rdquo; or &ldquo;team&rdquo; alone does not identify a unique row.</li>
<li>20 two-hop questions: 12 ask for a database through a service&rsquo;s region, 8 ask for an on-call rotation through a service&rsquo;s owning team. They are written in three phrasings (templated, natural, keyword-ish) to avoid measuring one prompt template.</li>
<li>20 single-hop controls on the same store: 10 &ldquo;which region does X run in&rdquo;, 10 &ldquo;which team owns X&rdquo;. A store or reader that fails these is broken in a way that has nothing to do with question shape.</li>
</ul>
<p>The store is a flat list of 120 vectors held in the probe process, ranked by exact cosine in pure Python (<code>math</code> only, no numpy, no ANN index, deterministic full sort). That choice is deliberate: an approximate index would add a second variable to a question about ranking.</p>
<h2 id="four-arms-and-what-each-isolates">Four arms, and what each isolates</h2>
<p>Every arm runs against the same store, the same facts and the same 40 questions.</p>
<ol>
<li><strong>top-5</strong> — embed the question, take five nearest facts. The default most local setups ship with.</li>
<li><strong>top-20</strong> — same, twenty facts. Tests whether k is the whole problem.</li>
<li><strong>decomposition</strong> — one call to the local reader model asking it to split the question into sub-questions, each sub-question embedded and retrieved separately at k=5, results unioned and deduplicated, capped at 10 facts. This is the fix most write-ups recommend.</li>
<li><strong>oracle</strong> — the two gold facts placed in the prompt, nothing else. This arm was designed to bound what the reader can do when retrieval is perfect. It is not reported here: the reader stage did not complete (see “Why there is no accuracy column”), so no accuracy column appears in this article.</li>
</ol>
<p>Arms 1 to 3 are retrieval measurements: they need no model beyond the embedder, they are deterministic, and every id is recorded. That is deliberately where this article puts its weight.</p>
<h2 id="bridge-coverage-before-accuracy">Bridge coverage before accuracy</h2>
<p>Accuracy mixes two failures. Coverage isolates one: does the retrieved set contain both facts the answer needs, regardless of what the reader says?</p>
<table>
	<thead>
			<tr>
					<th>Encoder (dimensions)</th>
					<th>Single-hop fact in top-5</th>
					<th>Both facts in top-5</th>
					<th>Both facts in top-20</th>
			</tr>
	</thead>
	<tbody>
			<tr>
					<td><code>all-minilm:latest</code> (384)</td>
					<td>20/20</td>
					<td>3/20</td>
					<td>14/20</td>
			</tr>
			<tr>
					<td><code>snowflake-arctic-embed:33m</code> (384)</td>
					<td>19/20</td>
					<td>5/20</td>
					<td>14/20</td>
			</tr>
			<tr>
					<td><code>nomic-embed-text:latest</code> (768)</td>
					<td>19/20</td>
					<td>5/20</td>
					<td>14/20</td>
			</tr>
	</tbody>
</table>
<p>Three encoders spanning two widths and three training recipes agree on the shape: single-hop retrieval is close to saturated, two-hop coverage at k=5 is 15-25%, and one deeper cut fixes most of it. This is the first number an operator should produce for their own store, because it decides whether the next hour is spent on retrieval or on prompting.</p>
<p>The 14/20 at k=20 is not a rounding artifact of one encoder: all three land on 14, and the overlap is real but partial — two encoders share 12 of those 14 questions, <code>snowflake-arctic-embed</code> and <code>nomic-embed-text</code> share 11, and only 11 questions are covered by all three. Six questions stay uncovered on each encoder even at 20 facts, and the six are not the same six, which is a different problem: the second fact is ranked below 20, or, in one case on <code>all-minilm</code>, was not returned in the top 50 at all.</p>
<h2 id="where-the-second-fact-actually-sits">Where the second fact actually sits</h2>
<p>The median rank of the second hop was 11 for <code>all-minilm</code> and <code>snowflake-arctic-embed:33m</code>, and 14 for <code>nomic-embed-text</code>. Across the three encoders the second hop&rsquo;s ranks spread from 2 to 45 — 2-41, 2-40 and 3-45 per encoder. In the same questions, the first hop was in the top-5 for 18, 17 and 18 of 20 respectively.</p>
<p>That asymmetry is the mechanism. The question text resembles the first fact closely — the service name is in both — so the first hop ranks high. The second fact never mentions the service; it says which database the <em>region</em> uses. Its similarity to the question is carried only by the shared concept &ldquo;database&rdquo;, which is why it lands in the teens rather than nowhere. If your store never returns the bridge at any depth, the failure is upstream — chunking, write path or encoder — and the <a href="https://baeseokjae.github.io/posts/agent-memory-chunk-granularity-recall-2026/">chunk granularity fixture</a> and the <a href="https://baeseokjae.github.io/posts/agent-memory-embedding-swap-recall-2026/">embedding swap test</a> cover those separately. The <a href="https://baeseokjae.github.io/posts/agent-memory-architecture-guide-2026/">architecture guide</a> puts the same class of weakness in one line about pure vector stores: &ldquo;Fails for temporal queries and entity relationship tracking.&rdquo; The <a href="https://baeseokjae.github.io/posts/persistent-agent-memory-on-elasticsearch-building-0-89-recall/">Elasticsearch hybrid walkthrough</a> is the cluster-scale answer: fuse a lexical channel with a dense one so that a row sharing only a keyword can still surface.</p>
<h2 id="why-there-is-no-accuracy-column">Why there is no accuracy column</h2>
<p>The planned reader arms (<code>qwen2.5:0.5b</code> at temperature 0, seed 42, an <code>UNKNOWN</code> escape and a published normalised-substring grading rule) did not complete inside this run&rsquo;s budget. The probe writes <code>results-reader.json</code> after every finished row and again at the end of the reader stage; neither happened here, so no reader row exists for this run and there is nothing to report — not an accuracy, not a prompt-token count, not a per-call time. Rather than publish a subset of cells as if it were the table, the article reports no reader accuracy at all.</p>
<p>The one generation workload this run did record is the 20 decomposition rewrites, one per two-hop question: 0.88 to 4.6 seconds each and 47.2 seconds in total at 60 max tokens (<code>decomposition.json</code>). Those are rewrites, not answers over retrieved facts, so they do not bound the cost of a 40-question, four-arm reader grid, and no such bound is claimed here. The probe takes <code>--deadline-epoch</code> for exactly this reason: its default budget is 900 seconds, it skips any remaining decomposition calls 240 seconds before the deadline, and the reader loop stops 120 seconds before it — a reserve too small for a four-arm reader grid on a shared 2-vCPU host.</p>
<p>So of the three causes in the introduction, this article measures one: the bridging fact ranked below the cut. It does not measure &ldquo;both facts reached the prompt and the model failed to join them&rdquo;, and it does not separate a store that never wrote the second fact from a store that writes it and ranks it badly — the published fixture contains both facts, which is what makes the coverage numbers meaningful in the first place.</p>
<p>What the reader arms would have added is the oracle-versus-top-5 gap: how much of the accuracy loss is retrieval and how much is joining. The probe in the evidence directory implements all four arms, so that gap is reproducible on a host that is not contended. The grading rule is in the probe, not in the prose: lowercase, replace non-alphanumerics with spaces, remove whitespace, and check whether the gold value appears in the answer.</p>
<h2 id="why-one-shot-decomposition-did-not-fix-coverage">Why one-shot decomposition did not fix coverage</h2>
<p>The decomposition arm was the one meant to answer &ldquo;raise k or split the question&rdquo; in accuracy terms, and it bought almost nothing. The union of its sub-query retrievals contained both required facts for 4 of the 20 two-hop questions, against 3 of 20 for a plain top-5 on the same encoder — one question out of twenty, on a subset that averaged 6.5 facts instead of 5.</p>
<p>The reason is visible in the rewrites themselves. All 20 questions produced parseable sub-query lines (none failed to parse; 44 sub-queries in total, 2.2 per question, capped at 4), but <strong>0 of the 20 sets named the intermediate entity</strong> the second hop needs — no region, no team. A one-shot rewriter sees only the question, and the question never contains the bridge, so the most it can do is restate the question in two ways or ask what the entity is:</p>
<pre tabindex="0"><code>Q:  I need to find the database behind inventory-api - if it went down, which cluster would I look at?
1. Which cluster is associated with the inventory-api?
2. What is the inventory-api?
3. How can I check if the inventory-api has gone down?
4. Which cluster should I look at if the inventory-api goes down?
</code></pre><p>All four sub-queries point at the same fact. The second hop never gets a query of its own, because nothing in the input suggests one. On one question the model refused outright — &ldquo;orders-api is not mentioned in the question&rdquo; — when the service name was, in fact, the whole question.</p>
<p>That is a structural limit rather than a complaint about a 0.5B model. Decomposition fixes multi-hop coverage only when the split is iterative: retrieve hop 1, put the intermediate entity into the next query, retrieve again. A single rewrite pass cannot introduce a value it has never seen. If you are evaluating &ldquo;decomposition&rdquo; as a fix for a two-hop failure, the first thing to check is whether your implementation is a loop or a single pass; this fixture says a single pass at this model size changes the coverage count by one question while costing one rewrite call and 2.2 retrieval calls per question (44 sub-queries over 20 questions, capped at 4).</p>
<h2 id="ten-lines-to-audit-your-own-store">Ten lines to audit your own store</h2>
<p>The measurement above is a fixture result; the transferable part is the check. This snippet is not the probe — it is the smallest version you can paste next to your own store, and it answers only the coverage question: for a question you already know needs two rows, are both rows in the set you would have sent?</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-python" data-lang="python"><span style="display:flex;"><span><span style="color:#f92672">import</span> json<span style="color:#f92672">,</span> math<span style="color:#f92672">,</span> urllib.request
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">def</span> <span style="color:#a6e22e">embed</span>(texts):  <span style="color:#75715e"># swap for your store&#39;s embedding client; shape stays the same</span>
</span></span><span style="display:flex;"><span>    req <span style="color:#f92672">=</span> urllib<span style="color:#f92672">.</span>request<span style="color:#f92672">.</span>Request(<span style="color:#e6db74">&#34;http://127.0.0.1:11434/api/embed&#34;</span>,
</span></span><span style="display:flex;"><span>        json<span style="color:#f92672">.</span>dumps({<span style="color:#e6db74">&#34;model&#34;</span>: <span style="color:#e6db74">&#34;all-minilm&#34;</span>, <span style="color:#e6db74">&#34;input&#34;</span>: texts})<span style="color:#f92672">.</span>encode(),
</span></span><span style="display:flex;"><span>        {<span style="color:#e6db74">&#34;Content-Type&#34;</span>: <span style="color:#e6db74">&#34;application/json&#34;</span>})
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">return</span> json<span style="color:#f92672">.</span>loads(urllib<span style="color:#f92672">.</span>request<span style="color:#f92672">.</span>urlopen(req)<span style="color:#f92672">.</span>read())[<span style="color:#e6db74">&#34;embeddings&#34;</span>]
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">def</span> <span style="color:#a6e22e">cos</span>(a, b):
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">return</span> sum(x <span style="color:#f92672">*</span> y <span style="color:#66d9ef">for</span> x, y <span style="color:#f92672">in</span> zip(a, b)) <span style="color:#f92672">/</span> math<span style="color:#f92672">.</span>sqrt(sum(x <span style="color:#f92672">*</span> x <span style="color:#66d9ef">for</span> x <span style="color:#f92672">in</span> a) <span style="color:#f92672">*</span> sum(y <span style="color:#f92672">*</span> y <span style="color:#66d9ef">for</span> y <span style="color:#f92672">in</span> b))
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># store_vectors: [(fact_id, vector)] for your own rows; question: the text you already know needs two rows</span>
</span></span><span style="display:flex;"><span>q <span style="color:#f92672">=</span> embed([question])[<span style="color:#ae81ff">0</span>]
</span></span><span style="display:flex;"><span>ranked <span style="color:#f92672">=</span> sorted(((cos(q, v), fact_id) <span style="color:#66d9ef">for</span> fact_id, v <span style="color:#f92672">in</span> store_vectors), reverse<span style="color:#f92672">=</span><span style="color:#66d9ef">True</span>)[:<span style="color:#ae81ff">5</span>]
</span></span><span style="display:flex;"><span>print([fact_id <span style="color:#66d9ef">for</span> _, fact_id <span style="color:#f92672">in</span> ranked])   <span style="color:#75715e"># are both required fact ids in this list?</span>
</span></span></code></pre></div><p>Run it on twenty questions whose answers you already know need two rows. Two outputs matter. If both ids are absent from the top-5 for most questions, k is your first lever and the table above says roughly how much it buys. If both ids are present and the answer is still wrong, retrieval is not your problem and raising k will not fix it — the <a href="https://baeseokjae.github.io/posts/agentic-workflow-context-management-2026/">context management write-up</a> covers what the prompt does with facts it already has.</p>
<p>Two cautions on reading the output. First, the check is per fact id, not per text: if your store writes two near-duplicate rows for the same fact, coverage will look better than the join does. Second, a five-slot cut is not a free parameter — raising it to 20 multiplied the facts in the prompt by four in this fixture, and this run records no token or latency measurement for that trade, so the count is the only part of it in evidence here.</p>
<h2 id="what-this-fixture-does-not-tell-you">What this fixture does not tell you</h2>
<ul>
<li>The store holds 120 facts and is scanned exactly. A production store with 10^5 to 10^6 vectors usually runs an approximate index, and recall of the index is a second, unmeasured loss on top of the ranking measured here.</li>
<li>The rewriter is 0.5B parameters and the reader grid is not reported at all. A larger model may join the two facts more reliably once both are present, but that is an accuracy claim this run does not make; the coverage columns are the part that transfers.</li>
<li>The fixture&rsquo;s questions are synthetic, three phrasings per shape. Real user questions carry more surface variation and, sometimes, the intermediate entity itself.</li>
<li>Single run, one 2-vCPU aarch64 host, no retries: these are mechanism results with per-question rows published, not benchmark scores. One pair of arms is a reading, not a trend.</li>
<li>Decomposition is tested as a single rewrite pass. A two-stage loop — retrieve, then ask again with the intermediate entity in hand — is not measured here and is the obvious next test.</li>
<li>No monetary cost is stated. Everything ran locally; unknown cost is unknown, and no paid API was used.</li>
</ul>
<h2 id="evidence-and-reproduction">Evidence and reproduction</h2>
<p>First-party artifacts, all published under this repository&rsquo;s <code>research/evidence/agent-memory-multi-hop-recall-2026/</code> directory:</p>
<ul>
<li><a href="https://raw.githubusercontent.com/baeseokjae/baeseokjae.github.io/main/research/evidence/agent-memory-multi-hop-recall-2026/multihop_probe.py"><code>multihop_probe.py</code></a> — stdlib-only probe: fixture builder, Ollama embedding calls, exact cosine ranking, arms, grading.</li>
<li><a href="https://raw.githubusercontent.com/baeseokjae/baeseokjae.github.io/main/research/evidence/agent-memory-multi-hop-recall-2026/fixture.json"><code>fixture.json</code></a> — the 120 facts, 20 two-hop and 20 single-hop questions with gold values and the fact ids each answer needs.</li>
<li><a href="https://raw.githubusercontent.com/baeseokjae/baeseokjae.github.io/main/research/evidence/agent-memory-multi-hop-recall-2026/results-retrieval.json"><code>results-retrieval.json</code></a> — per-question ranks, top-5 and top-20 id lists for all three encoders, and the measured embedding dimensions.</li>
<li><a href="https://raw.githubusercontent.com/baeseokjae/baeseokjae.github.io/main/research/evidence/agent-memory-multi-hop-recall-2026/decomposition.json"><code>decomposition.json</code></a> — the raw rewrite each question produced and the sub-queries parsed from it.</li>
<li><a href="https://raw.githubusercontent.com/baeseokjae/baeseokjae.github.io/main/research/evidence/agent-memory-multi-hop-recall-2026/METHOD.md"><code>METHOD.md</code></a> — host, model digests, grading rule, deviations.</li>
</ul>
<p>Reproduce on any host with Ollama and the three models pulled:</p>
<pre tabindex="0"><code>python3 multihop_probe.py --out ./out --reader qwen2.5:0.5b --deadline-epoch $(( $(date +%s) + 5400 ))
</code></pre><p><code>--deadline-epoch</code> is not decorative: the probe&rsquo;s default budget is 900 seconds, it stops decomposing 240 seconds before the deadline, and its reader loop breaks 120 seconds before it — not enough for a four-arm reader grid on a contended 2-vCPU host. The probe writes <code>fixture.json</code>, <code>results-retrieval.json</code>, <code>decomposition.json</code>, <code>results-reader.json</code> and <code>summary.json</code>; this run ended before the reader stage, which is why the last two are missing here rather than withheld. Embedding dimensions are recorded under <code>dims</code> in <code>results-retrieval.json</code> — 384, 384 and 768, measured by the probe — and the model digests in <code>METHOD.md</code> and <code>ollama-tags.json</code>. <a href="https://docs.ollama.com/api/embed">Ollama&rsquo;s <code>/api/embed</code> documentation</a> is the endpoint contract. The two library pages (<a href="https://ollama.com/library/all-minilm"><code>all-minilm</code></a>, <a href="https://ollama.com/library/nomic-embed-text"><code>nomic-embed-text</code></a>) give footprint and context window — 46 MB with 512 tokens, 274 MB with 2K tokens — but no embedding dimensions; the nomic page additionally repeats the vendor&rsquo;s own claim that it surpasses OpenAI&rsquo;s <code>text-embedding-ada-002</code> and <code>text-embedding-3-small</code>, a comparison this article does not test.</p>
<p>The useful conclusion is not &ldquo;local stores cannot do multi-hop&rdquo;. It is that coverage and accuracy fail separately, that the bridge usually sits just past a five-slot cut, and that the audit which tells you which failure you have is ten lines long.</p>
]]></content:encoded></item></channel></rss>