Fix embedding vector dimension mismatch (768 -> 2560) #157
No reviewers
Labels
No labels
domain:backend
domain:devops
domain:frontend
status:approved
status:in-progress
status:needs-fix
status:qa
type:bug
type:devops
type:feature
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
forgejo_admin/pal-e-api!157
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "156-fix-embedding-vector-dimension-mismatch"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
The
qwen3-embedding:4bmodel produces 2560-dimensional vectors, but theblocks.embeddingcolumn was defined asvector(768)from the initial setup. This caused every embedding attempt to fail with "expected 768 dimensions, not 2560". This PR updates the column type and resets errored blocks for retry.Changes
alembic/versions/o5j6k7l8m9n0_fix_embedding_vector_dimension.py-- New Alembic migration that ALTERsblocks.embeddingfromvector(768)tovector(2560)and resets allembedding_status = 'error'blocks back to'pending'src/pal_e_docs/models.py-- UpdatedBlock.embeddingcolumn definition fromVector(768)toVector(2560)src/pal_e_docs/embedding_worker.py-- Updated docstring from "768 floats" to "2560 floats"Test Plan
pytest tests/ -v-- 497 passedruff check+ruff format --check-- all clean768insrc/andtests/-- none foundReview Checklist
Related
plan-pal-e-docs(Phase 5a)Closes #156
Self-Review: LGTM
Files reviewed: 3/3
down_revisionchain, safe ALTER (all embeddings NULL), errored blocks reset to pending. Downgrade documented.Vector(768)->Vector(2560), single-line change.Checks passed:
768references insrc/ortests/PR #157 Review
BLOCKERS
None.
NITS
embedding_status-- The upgrade resetsembedding_status = 'error'back to'pending', but the downgrade only reverts the column type without reversing this status change. This is non-blocking because (a) downgrades are rare, (b) the status reset is idempotent and harmless even if the column reverts, and (c) the downgrade already carries a NOTE about failure if 2560-dim data exists. But for completeness, the downgrade could includeUPDATE blocks SET embedding_status = 'error' WHERE embedding_status = 'pending'-- though this would incorrectly hit legitimately pending blocks, so leaving it out is arguably the right call. Noting for awareness only.SOP COMPLIANCE
156-fix-embedding-vector-dimension-mismatchreferences issue #156plan-pal-e-docs(Phase 5a)Closes #156present -- Will auto-close the issue on merge.envfiles, credentials, or tokens in the diffl2g3h4i5j6k7_add_vector_embeddings.pyis not modified (correct -- historical record)Verification Summary
models.pyline 207 now readsVector(2560), consistent with the migration target.src/andtests/returns zero hits for768. All remaining768occurrences are in Alembic migration files only (historical + downgrade), which is correct.down_revision = "n4i5j6k7l8m9"correctly points to the latest migration (n4i5j6k7l8m9_replace_sprints_with_boards.py).VERDICT: APPROVED