Skip to content

fix(search): re-embed lexical vectors after IDF changes - #27

Merged
JohnXu22786 merged 4 commits into
mainfrom
bug/search-reembed-after-incremental-idf-change
Sep 12, 2026
Merged

JohnXu22786 merged 4 commits into
mainfrom
bug/search-reembed-after-incremental-idf-change

Conversation

@JohnXu22786

@JohnXu22786 JohnXu22786 commented Sep 12, 2026

Copy link
Copy Markdown
Owner

What this PR does

Before this PR:

Incremental corpus changes could leave unchanged lexical vectors on stale IDF weights. Persisted pre-fix indexes could reload those vectors. If a remote provider failed during targeted re-embedding, only changed chunks switched to lexical fallback, leaving mixed provider and dimension vectors. Removing the final file with autosave enabled left stale persisted index files. Reindexing a file removed the old record before reading its replacement; when the path disappeared or became unreadable, the failure path persisted stale surviving lexical vectors.

After this PR:

Re-embed all lexical document vectors after corpus changes and invalidate pre-fix persisted indexes with format v2. If targeted remote embedding falls back, re-embed the entire corpus with the IDF-aware lexical provider. Persist an empty index when the final file is removed. When reindexing fails after removing an existing file, refresh IDF and re-embed surviving lexical vectors before autosave. Add focused regression coverage for all affected paths.

Type of change

Bug fix

Breaking changes (if any)

Existing persisted indexes are intentionally rebuilt once after upgrade.

Incremental corpus changes update the IDF weights used for queries. Recompute every lexical document vector after those changes so unchanged chunks use the same weights as the query while remote providers retain targeted re-embedding.
The previous format can contain lexical document vectors built with stale corpus IDF weights. Bump the persisted index version so those files are rebuilt before they can be searched.
When a targeted remote embedding fails, replace every stored vector with IDF-aware fallback vectors so provider and dimension state cannot mix. Persist empty indexes after removing the final file so autosaved deletions survive reload.
@JohnXu22786
JohnXu22786 force-pushed the bug/search-reembed-after-incremental-idf-change branch from 897b428 to a90827a Compare September 12, 2026 14:51
Reindexing removes the old file before reading its replacement. Refresh the corpus IDF and surviving lexical vectors when that read fails so autosaved indexes remain consistent.
@JohnXu22786
JohnXu22786 marked this pull request as ready for review September 12, 2026 15:13
@JohnXu22786
JohnXu22786 merged commit 55d4838 into main Sep 12, 2026
2 checks passed
@JohnXu22786
JohnXu22786 deleted the bug/search-reembed-after-incremental-idf-change branch September 12, 2026 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant