Skip to content

Document that changing the embedding model breaks an existing chunk table - #58

Merged
mason-sharp merged 2 commits into
mainfrom
docs/model-change-warnings
Aug 11, 2026
Merged

Document that changing the embedding model breaks an existing chunk table#58
mason-sharp merged 2 commits into
mainfrom
docs/model-change-warnings

Conversation

@dpage

@dpage dpage commented Aug 11, 2026

Copy link
Copy Markdown
Member

Follows the discussion on #27, where we established that the code already guards against this properly and the gap is purely documentation.

What was missing

enable_vectorization() writes the provider's dimension into the chunk table's embedding vector(N) column when it creates the table, so the model choice is baked in permanently. Change pgedge_vectorizer.model to a model of a different size afterwards and the worker cannot write.

It handles that correctly: src/worker.c:1512 compares the two dimensions before writing, logs an actionable warning, and marks the batch failed with Dimension mismatch: model=N, table=M. Nothing is corrupted. But the documentation mentioned neither the constraint nor the recovery, and there was no mention of dimensions at all in configuration.md, best_practices.md or troubleshooting.md.

The part that matters most

recreate_chunks() is the function a reader would reach for, and best_practices.md currently recommends it for "a complete chunk regeneration". It cannot resolve a dimension change. It deletes the rows of the chunk table and leaves the column type untouched, so every requeued row fails in exactly the same way and the user goes round in a circle.

I verified this on a live table rather than reasoning about it:

step resulting column type
enable_vectorization(..., embedding_dimension => 3) vector(3)
after recreate_chunks() vector(3) — unchanged
after disable_vectorization(..., drop_chunk_table => TRUE) then enable_vectorization() vector(5), with every row requeued

So the docs now say plainly that recreate_chunks() is not the answer here, and give the rebuild that is.

Changes

configuration.md gains a warning admonition beneath the provider settings table, since that is where someone reads about the model in the first place. troubleshooting.md gains a section with the symptoms, a query to identify affected items, and both recovery routes: restoring the old model, which is right when the change was accidental, and rebuilding, which keeps the new model. best_practices.md gains three notes covering choosing the model up front, the rebuild, and budgeting for the provider cost of re-embedding.

Verification

Every claim was checked against the source rather than written from memory: all five functions named exist, disable_vectorization() really does take drop_chunk_table, the quoted Dimension mismatch: model=N, table=M text matches src/worker.c:1527 exactly, the queue columns used in the example query exist, and the documented default model matches src/guc.c. New prose wraps at 79 characters and carries no em-dashes; I also removed a pre-existing em-dash from a neighbouring paragraph.

mkdocs is not installed here, so the site build is unverified and CI or a local mkdocs build --strict should confirm the admonition renders. The admonition extension is enabled in mkdocs.yml, though this is the first use of it in these docs.

One observation, not addressed here: best_practices.md uses bold text as section headings throughout, which the house style warns against because MkDocs can misread it as a heading and add it to the navigation pane. I added to the existing Data Management section rather than introduce another one. Worth a separate tidy-up if you agree.

Nothing warned users that the embedding model fixes the dimension of a
chunk table. enable_vectorization() writes the provider's dimension into
the embedding vector(N) column when it creates the table, and changing
pgedge_vectorizer.model to a model of a different size afterwards leaves
the worker unable to write. It handles that correctly, comparing the two
dimensions before writing and marking the batch failed rather than
storing anything wrong, but the documentation mentioned neither the
constraint nor the recovery. There was no mention of dimensions at all in
configuration.md, best_practices.md or troubleshooting.md.

The correction matters more than the warning does. recreate_chunks() is
the function a reader would reach for, and best_practices.md recommends
it for "a complete chunk regeneration", but it cannot resolve a dimension
change: it deletes the rows of the chunk table and leaves the column type
untouched, so every requeued row fails exactly as before. Verified on a
live table, where the column stayed vector(3) across recreate_chunks()
and only became vector(5) after disable_vectorization() with
drop_chunk_table and a fresh enable_vectorization().

Adds a warning admonition to the provider settings, a troubleshooting
section giving the symptoms and both recovery routes, and three practice
notes covering model choice, the rebuild and its provider cost. The
quoted error text and every function and column named were checked
against the source rather than written from memory.

Also drops an em-dash from a neighbouring paragraph, per the house style.
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 34 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b5c473a1-d1c3-4a25-892c-dd7d320f9007

📥 Commits

Reviewing files that changed from the base of the PR and between a8069b0 and 7a905cc.

📒 Files selected for processing (2)
  • docs/best_practices.md
  • docs/troubleshooting.md
📝 Walkthrough

Walkthrough

The documentation adds guidance for selecting embedding models before vectorization and accounting for re-embedding costs. It explains that model changes can create vector-dimension mismatches because existing chunk tables are not migrated. It documents worker validation, failed queue items, diagnostic SQL, model restoration, retries, and vectorization recreation. It also clarifies worker startup detection and exponential backoff.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main documentation change about changing embedding models and its effect on existing chunk tables.
Description check ✅ Passed The description directly explains the documented dimension mismatch, affected behavior, recovery procedures, and verification status.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/model-change-warnings

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/best_practices.md`:
- Around line 40-43: Update the vectorizer rebuild instructions to pass
drop_chunk_table => TRUE when calling disable_vectorization() before
enable_vectorization(), ensuring the existing chunk table and embedding
vector(N) column are dropped before rebuilding with a different model dimension.

In `@docs/troubleshooting.md`:
- Around line 105-131: Clarify in the rebuilding instructions that
pgedge_vectorizer.model is global, while chunk tables are maintained per
vectorized column. State that the docs/body example repairs only that column and
the disable/enable steps must be repeated for every affected vectorized column.
- Line 16: Update the background-worker discovery statement in the
troubleshooting documentation to avoid guaranteeing detection within seconds.
State that configured databases are checked using the current
exponential-backoff interval, which can be up to five minutes after creating the
pgedge_vectorizer extension.
- Around line 80-89: Update the diagnostic SQL query in the troubleshooting
section to retain the failed-status filter while adding a condition on
error_message that matches dimension-mismatch failures. Keep the existing
grouping and selected columns so the query identifies only the failures
described by this section.
- Around line 96-103: Update the restore SQL example near the troubleshooting
guidance to use a placeholder such as previous-model-name instead of hard-coding
text-embedding-3-small, and state that it must be replaced with the model
configured before the change. Keep the retry_failed() flow unchanged.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 36f2b06b-e559-49f5-a9a2-6d1a8ad7615e

📥 Commits

Reviewing files that changed from the base of the PR and between 24d0611 and a8069b0.

📒 Files selected for processing (3)
  • docs/best_practices.md
  • docs/configuration.md
  • docs/troubleshooting.md

Comment thread docs/best_practices.md Outdated
Comment thread docs/troubleshooting.md Outdated
Comment thread docs/troubleshooting.md
Comment thread docs/troubleshooting.md
Comment thread docs/troubleshooting.md
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Four corrections from CodeRabbit's review, all of them fair.

The best practices bullet said to rebuild with disable_vectorization()
and enable_vectorization() without naming drop_chunk_table. Left out,
the chunk table survives, the column keeps its old dimension and the
mismatch continues, so the bullet described a rebuild that does not
work. The troubleshooting steps had the argument; the summary did not.

The restore example hardcoded text-embedding-3-small while the prose said
to restore the previous model. Anyone whose table was built by a
different model would have followed it and stayed mismatched. It now
carries a placeholder and points at the table=M figure in the error as
the way to identify which model to go back to.

The rebuild was written around a single docs/body example, but the model
is one global setting while chunk tables are independent per column, so
changing it strands every vectorizer whose dimension no longer matches.
The steps now say to repeat them for each, and give a query listing them.

The worker discovery paragraph promised detection "within seconds", which
the backoff does not support once it has reached its five minute ceiling.
It now states the real bound and mentions that a reload brings the check
forward. That paragraph is also wrapped to the house width, having been
one long line before.
@mason-sharp
mason-sharp merged commit cf2a891 into main Aug 11, 2026
9 checks passed
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.

2 participants