Fix embedding vector dimension mismatch (768 → 2560) #156

Closed
opened 2026-03-14 15:07:13 +00:00 by forgejo_admin · 0 comments

Lineage

plan-pal-e-docs → Phase 5 (Activate Semantic Search) → Phase 5a (Dimension Fix)

Repo

forgejo_admin/pal-e-docs

User Story

As the embedding worker
I want the vector column to match the model's output dimensions
So that embeddings can be stored and semantic search can function

Context

qwen3-embedding:4b produces 2560-dim vectors (ollama show confirms embedding length: 2560). The blocks.embedding column is vector(768) from when the model was first tested. The embedding worker is deployed (PR #155) but all blocks are erroring with: expected 768 dimensions, not 2560.

No embeddings have ever been stored (column was all NULL before activation), so this is a safe ALTER — no data loss.

File Targets

Files the agent should modify:

  • New Alembic migration file — ALTER TABLE blocks ALTER COLUMN embedding TYPE vector(2560)
  • src/pal_e_docs/models.py — update any vector(768) type hints or column definitions to vector(2560)
  • Any test files referencing 768 dimensions — update to 2560

Files the agent should search for 768:

  • src/pal_e_docs/embedding_worker.py — check if dimension is hardcoded anywhere
  • src/pal_e_docs/routes/notes.py — check search endpoint
  • src/pal_e_docs/services/search.py — check RRF search
  • tests/ — any test fixtures with 768-dim vectors

Files the agent should NOT touch:

  • k8s/embedding-worker.yaml — just merged, working fine
  • .woodpecker.yaml — just fixed

Acceptance Criteria

  • Alembic migration changes blocks.embedding from vector(768) to vector(2560)
  • All code references to 768 dimensions updated to 2560
  • Migration includes UPDATE blocks SET embedding_status = 'pending' WHERE embedding_status = 'error' to reset errored blocks
  • Tests pass with updated dimensions

Test Expectations

  • Run: pytest tests/ -v
  • Check no hardcoded 768 remains in source files

Constraints

  • This is an Alembic migration — use the existing migration framework in alembic/
  • No embeddings exist yet (all NULL), so the ALTER is safe and fast
  • After merge + deploy, the worker will automatically start processing the reset blocks
  • The config embedding_model in config.py is correct (qwen3-embedding:4b) — don't change it

Checklist

  • PR opened
  • Tests pass
  • No unrelated changes
  • pal-e-docs — project this affects
### Lineage `plan-pal-e-docs` → Phase 5 (Activate Semantic Search) → Phase 5a (Dimension Fix) ### Repo `forgejo_admin/pal-e-docs` ### User Story As the embedding worker I want the vector column to match the model's output dimensions So that embeddings can be stored and semantic search can function ### Context `qwen3-embedding:4b` produces 2560-dim vectors (`ollama show` confirms `embedding length: 2560`). The `blocks.embedding` column is `vector(768)` from when the model was first tested. The embedding worker is deployed (PR #155) but all blocks are erroring with: `expected 768 dimensions, not 2560`. No embeddings have ever been stored (column was all NULL before activation), so this is a safe ALTER — no data loss. ### File Targets Files the agent should modify: - New Alembic migration file — `ALTER TABLE blocks ALTER COLUMN embedding TYPE vector(2560)` - `src/pal_e_docs/models.py` — update any `vector(768)` type hints or column definitions to `vector(2560)` - Any test files referencing `768` dimensions — update to `2560` Files the agent should search for `768`: - `src/pal_e_docs/embedding_worker.py` — check if dimension is hardcoded anywhere - `src/pal_e_docs/routes/notes.py` — check search endpoint - `src/pal_e_docs/services/search.py` — check RRF search - `tests/` — any test fixtures with 768-dim vectors Files the agent should NOT touch: - `k8s/embedding-worker.yaml` — just merged, working fine - `.woodpecker.yaml` — just fixed ### Acceptance Criteria - [ ] Alembic migration changes `blocks.embedding` from `vector(768)` to `vector(2560)` - [ ] All code references to 768 dimensions updated to 2560 - [ ] Migration includes `UPDATE blocks SET embedding_status = 'pending' WHERE embedding_status = 'error'` to reset errored blocks - [ ] Tests pass with updated dimensions ### Test Expectations - [ ] Run: `pytest tests/ -v` - [ ] Check no hardcoded `768` remains in source files ### Constraints - This is an Alembic migration — use the existing migration framework in `alembic/` - No embeddings exist yet (all NULL), so the ALTER is safe and fast - After merge + deploy, the worker will automatically start processing the reset blocks - The config `embedding_model` in `config.py` is correct (`qwen3-embedding:4b`) — don't change it ### Checklist - [ ] PR opened - [ ] Tests pass - [ ] No unrelated changes ### Related - `pal-e-docs` — project this affects
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
forgejo_admin/pal-e-api#156
No description provided.