feat(qmd): switch to Qwen3 4B embedding and reranker models
Use Qwen3-Embedding-4B and Qwen3-Reranker-4B (both Q4_K_M) for QMD local search, and make the switch reach existing installations: - Rewrite the setup-owned models block on every install and update, while still recording the user's original block only once. - When the new embedding size no longer matches stored vectors, the daemon clears the old vectors and re-embeds the repository. - Delete setup-downloaded model files the current models no longer use. - Skip npm and pnpm lockfiles and minified bundles when indexing repositories, which saves embedding work and removes search noise. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3fcd7bcbfd
commit
ca4cb2a144
8 files changed
+113
-10
No files matched your search
@@ -5,7 +5,7 @@ import { execFileSync } from 'node:child_process';
|
||||
import { existsSync, mkdtempSync, rmSync, utimesSync, writeFileSync } from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join, resolve } from 'node:path';
|
||||
import { acquireStartLock, createServer, gitFingerprint, ignoreGlobs, keepModelsLoaded } from '../../shared/qmd/qmd-daemon.mjs';
|
||||
import { INDEX_EXCLUDES, acquireStartLock, createServer, gitFingerprint, ignoreGlobs, indexIgnores, keepModelsLoaded } from '../../shared/qmd/qmd-daemon.mjs';
|
||||
import { collectionName } from '../../shared/qmd/qmd-lib.mjs';
|
||||
|
||||
const defaultHits = () => [{ displayPath: `${collectionName('/r')}/src/a.ts`, body: 'x\nretry here', bestChunkPos: 2, bestChunk: 'retry here', score: 0.91 }];
|
||||
@@ -72,6 +72,19 @@ test('search adds the repo collection once, refreshes on change, and filters oth
|
||||
assert.equal(s.store.calls.filter((c) => c[0] === 'update').length, 1, 'unchanged fingerprint skips update');
|
||||
});
|
||||
|
||||
test('a changed embedding size clears old vectors and embeds again', async (t) => {
|
||||
const s = await start(t);
|
||||
let failures = 1;
|
||||
const embed = s.store.embed;
|
||||
s.store.embed = async (opts) => {
|
||||
if (failures-- > 0) throw new Error('Embedding dimension mismatch: existing vectors are 1024d but the current model produces 2560d.');
|
||||
return embed(opts);
|
||||
};
|
||||
s.store.internal = { clearAllEmbeddings: () => s.store.calls.push(['clear']) };
|
||||
assert.equal((await s.call('/search', { repo: '/r', query: 'q', limit: 1 })).status, 200);
|
||||
assert.deepEqual(s.store.calls.filter((c) => c[0] === 'clear' || c[0] === 'embed').map((c) => c[0]), ['clear', 'embed']);
|
||||
});
|
||||
|
||||
test('rejects a missing query', async (t) => {
|
||||
const s = await start(t);
|
||||
assert.equal((await s.call('/search', { repo: '/r' })).status, 400);
|
||||
@@ -182,6 +195,13 @@ test('ignoreGlobs turns git ignored paths into escaped QMD ignore globs', () =>
|
||||
assert.deepEqual(ignoreGlobs('', escape), []);
|
||||
});
|
||||
|
||||
test('index ignores add lockfiles and minified bundles to the git ignored paths', () => {
|
||||
const ignores = indexIgnores('/r', (path) => path, () => ['dist/**']);
|
||||
assert.deepEqual(ignores, [...INDEX_EXCLUDES, 'dist/**']);
|
||||
for (const pattern of ['**/package-lock.json', '**/pnpm-lock.yaml', '**/*.min.js']) assert.ok(ignores.includes(pattern));
|
||||
assert.deepEqual(indexIgnores('/r', (path) => path, () => []), INDEX_EXCLUDES, 'fixed excludes apply when git lists nothing');
|
||||
});
|
||||
|
||||
test('git ignored paths reach addCollection and are persisted only when they change', async (t) => {
|
||||
let ignore = ['dist/**'];
|
||||
let fingerprint = 'one';
|
||||
|
||||
Reference in new issue
Block a user