code-index eval model-comparison.md
8.2 kB · 158 lines
Markdown
at main

Model comparison: nomic-embed-text-v1.5 vs Qwen3-Embedding-0.6B #

Recorded 2026-08-21. Two indexes over the same 9-repository subset of the workspace, one per model, scored with the same queries. This measures whether a larger embedding model is worth adopting; it does not adopt one — see eval/baseline.md for the full-corpus numbers this subset is meant to test a fix against.

Setup #

Subset: nine repositories — code-index itself plus eight private ones, mixed JavaScript, TypeScript and Python — 270 files, 4367 chunks each, identical file sets in both indexes (confirmed via bin/code-index status). Because the corpus is private, the rows below describe a repository by language and kind rather than by name.

Query count correction: the original estimate was 22 of the query set's 25 queries falling in this subset. The actual count, filtered by repo, is 20 — between one and three per repository, of which one is code-index's own. eval/score.py --repos <comma-list> does the filtering without touching the query file.

nomic-embed-text-v1.5 Qwen3-Embedding-0.6B
Parameters 137M 600M
Dimensions (as loaded) 768 1024
Pooling mean last
Document prefix search_document: none
Query prefix search_query: Instruct: Given a code search query, retrieve relevant source code and documentation that answer the query\nQuery:
GGUF quantisation f16 Q8_0

Correction to README.md's "Choosing a different model" section: it lists only EMBED_DIM and the two prefix constants as what a swap touches. Qwen3- Embedding is decoder-only and needs last-token pooling, not the mean pooling --pooling mean the section's instructions imply keeping. Porting only the two things that section names would have run this whole comparison on a meaningless embedding, with no error to show for it — llama-server accepts --pooling mean against any architecture and produces a vector of the right shape regardless of whether the pooling matches how the model was trained. Fixing the README itself belongs to whichever track adopts a model; this one only records the correction.

Indexing rate #

Both builds ran on the same machine in the same conditions (not idle — do not compare against README.md's "Measured on this machine" table, which recorded ~5 chunks/s for nomic under different load). Rate is wall-clock: index.lock creation to build.log's last write, divided by the 4367 chunks embedded.

elapsed chunks/s vs nomic
nomic-embed-text-v1.5 29m 51s 2.44 1x
Qwen3-Embedding-0.6B 51m 22s 1.42 1.7x slower

README.md's reasoning ("a 600M-parameter model... is roughly 4x slower to index") predicted about a 4x slowdown; the measured slowdown in this run is 1.7x. Both numbers come from the same conditions, so the discrepancy is a property of the model or the CPU path, not measurement noise — worth rechecking before quoting the 4x figure elsewhere.

Full-corpus extrapolation (37,704 chunks, from eval/baseline.md), using this run's rates rather than README.md's:

chunks/s extrapolated full rebuild
nomic-embed-text-v1.5 2.44 ~4.3 hours
Qwen3-Embedding-0.6B 1.42 ~7.4 hours

Hit rate #

20 queries, identical set for both models and both scoping modes. "Discounted" excludes any hit whose path contains eval/queries before ranking (eval/score.py --exclude-path) — the query file sat inside the code-index repo, part of the subset, and contains every query's own text verbatim, so it can win on text similarity for reasons that have nothing to do with a model's retrieval quality. It has since moved out of the tree, which removes the problem rather than only discounting it.

nomic top-1 nomic top-5 Qwen top-1 Qwen top-5
unscoped, raw 8/20 (40%) 14/20 (70%) 17/20 (85%) 20/20 (100%)
unscoped, discounted 8/20 (40%) 14/20 (70%) 17/20 (85%) 20/20 (100%)
repo-scoped, raw 11/20 (55%) 16/20 (80%) 18/20 (90%) 20/20 (100%)
repo-scoped, discounted 11/20 (55%) 16/20 (80%) 18/20 (90%) 20/20 (100%)

Discounting the query file changes nothing in either model's aggregate count on this subset: it did occupy the wrong top-1 slot for two nomic unscoped misses (a regex-validation query and one reporting-pipeline query), but the file the model actually reaches once it is excluded is a different wrong file, not the correct one — so those were already misses either way. It inflates neither model, on this subset.

The four failures eval/baseline.md called out by name #

Four of eval/baseline.md's six full-corpus "misses that survive repo scoping" fall inside this subset, and this subset build reproduces them exactly under nomic, confirming the subset didn't change nomic's characteristic failures:

  • The chat bot's message-scrubbing query, still beaten by that repo's main entry point.
  • The identity service's record-key hashing query, still beaten by its main server file.
  • The reporting pipeline (x2) — the stalled-feature detector and the README's pipeline description, both still beaten by the same dashboard-generation script.

Under Qwen, repo-scoped, all four reach the top 5 (none of Qwen's misses are these). The two single-file queries reach top-1. The two reporting-pipeline queries do not reach top-1 (both still lose to the dashboard-generation script) but do land in the top 5, a change from a genuine retrieval failure (answer nowhere near the query in embedding space) to a ranking nuance (right neighbourhood, wrong ordering). This is the case eval/baseline.md's rejected-ranking section says matters most: these misses were retrieval failures the raw score couldn't fix by re-ranking a top-5 pool, because the correct answer wasn't in reach of one. Qwen puts it in reach.

Remaining Qwen misses (top-1 only; top-5 is 20/20 in both scoping modes) #

  • A TypeScript sync app (2/3 top-1 both scoped and unscoped) — one of its three queries loses top-1 to another chunk of the same repository; all three are correctly in-repo and in the top 5, so this is same-repository ranking noise rather than a retrieval gap. Nomic has the same shape here (1/3 top-1, 3/3 top-5), so this isn't something the larger model introduced.
  • The reporting pipeline (as above).

Recommendation #

This is a clear win, not a marginal one, and it is concentrated exactly where eval/baseline.md said a ranking fix couldn't reach: unscoped top-1 more than doubles (40% -> 85%), unscoped top-5 goes from 70% to a clean 100%, and every one of the four named cross-repository retrieval failures moves from "wrong neighbourhood" to "right neighbourhood, occasionally wrong order." The cost is a rebuild that this run measures at roughly 7.4 hours full-corpus against nomic's 4.3 — about 1.7x, not the 4x README.md's reasoning predicted — plus a one-time correctness trap (last-token pooling) that isn't obvious from that section and is worth fixing there before anyone else attempts this swap. Whether a ~3-hour-longer one-time rebuild is worth a jump from 70% to 100% unscoped top-5 on real workspace queries is a judgment call for whoever owns that migration, but the number to weigh it against is 7.4 hours, once, not a recurring cost — incremental re-indexing after the first build only touches changed files.

Reproducing #

CODE_INDEX_DATA=<worktree>/.index-nomic uv run python eval/score.py \
  --repos <the nine subset repositories, comma-separated>
CODE_INDEX_DATA=<worktree>/.index-nomic uv run python eval/score.py --repo-scoped \
  --repos <the nine subset repositories, comma-separated>

Same two commands against .index-qwen, plus --exclude-path eval/queries on any of the four for the discounted numbers. Either index is now built by setting CODE_INDEX_MODEL to the GGUF and nothing else: embed.PROFILES carries each model's dimensions, pooling and prefixes. At the time of this run it did not, and the values in the table above were applied to embed.py by hand — which is what the profile table exists to prevent.