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') : '';
|
||||
|
||||
Reference in new issue
Block a user