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
@@ -33,6 +33,13 @@ export function ignoreGlobs(output, escape) {
|
||||
return output.split('\0').filter(Boolean).map((path) => (path.endsWith('/') ? `${escape(path.slice(0, -1))}/**` : escape(path)));
|
||||
}
|
||||
|
||||
// Tracked lockfiles and minified bundles are large and generated: embedding them costs time and only adds noise to results.
|
||||
export const INDEX_EXCLUDES = ['**/package-lock.json', '**/npm-shrinkwrap.json', '**/pnpm-lock.yaml', '**/*.min.js'];
|
||||
|
||||
export function indexIgnores(repo, escape, git = gitIgnored) {
|
||||
return [...INDEX_EXCLUDES, ...git(repo, escape)];
|
||||
}
|
||||
|
||||
export function gitIgnored(repo, escape) {
|
||||
try {
|
||||
return ignoreGlobs(execFileSync('git', ['-C', repo, 'ls-files', '-z', '--others', '--ignored', '--exclude-standard', '--directory'],
|
||||
@@ -126,7 +133,15 @@ export function createServer({ store, token, idleMs, now = Date.now, onIdle, ext
|
||||
}
|
||||
}
|
||||
await store.update({ collections: [name] });
|
||||
await store.embed({ collection: name, chunkStrategy: 'auto' });
|
||||
try {
|
||||
await store.embed({ collection: name, chunkStrategy: 'auto' });
|
||||
} catch (error) {
|
||||
// QMD keeps one vector table, so a new embedding model with another size needs a full clear; other collections re-embed on their next refresh.
|
||||
if (!/Embedding dimension mismatch/.test(error?.message ?? '')) throw error;
|
||||
console.error('qmd-daemon: embedding model changed; clearing old vectors and re-embedding.');
|
||||
store.internal.clearAllEmbeddings();
|
||||
await store.embed({ collection: name, chunkStrategy: 'auto' });
|
||||
}
|
||||
fingerprints.set(name, fingerprint);
|
||||
return { collection: name, updated: true };
|
||||
}
|
||||
@@ -223,7 +238,7 @@ async function main() {
|
||||
};
|
||||
const daemon = createServer({
|
||||
store, token, idleMs: idleMinutes() * 60_000, onIdle: stop, extractSnippet,
|
||||
ignored: (repo) => gitIgnored(repo, fastGlob.escapePath),
|
||||
ignored: (repo) => indexIgnores(repo, fastGlob.escapePath),
|
||||
persistIgnore: async (name, ignore) => {
|
||||
const path = qmdConfigPath();
|
||||
const text = existsSync(path) ? readFileSync(path, 'utf8') : '';
|
||||
|
||||
@@ -8,8 +8,8 @@ import { dirname, join, resolve } from 'node:path';
|
||||
import { pathToFileURL } from 'node:url';
|
||||
|
||||
export const MODELS = {
|
||||
embed: 'hf:Qwen/Qwen3-Embedding-0.6B-GGUF/Qwen3-Embedding-0.6B-Q8_0.gguf',
|
||||
rerank: 'hf:ggml-org/Qwen3-Reranker-0.6B-Q8_0-GGUF/qwen3-reranker-0.6b-q8_0.gguf',
|
||||
embed: 'hf:Qwen/Qwen3-Embedding-4B-GGUF/Qwen3-Embedding-4B-Q4_K_M.gguf',
|
||||
rerank: 'hf:giladgd/Qwen3-Reranker-4B-GGUF/Qwen3-Reranker-4B.Q4_K_M.gguf',
|
||||
generate: 'hf:tobil/qmd-query-expansion-1.7B-gguf/qmd-query-expansion-1.7B-q4_k_m.gguf',
|
||||
};
|
||||
export const MASK = '**/*.{md,py,cs,ts,tsx,js,jsx,mjs,go,rs,java,ps1,sh,json,yml,yaml,xml,sql}';
|
||||
|
||||
Reference in new issue
Block a user