Skip to content

Decode embeddings returned by pgvector Python 0.5 - #1752

Merged
serengil merged 1 commit into
serengil:masterfrom
Afloat16:fix/pgvector-vector-decoder-20261116
Nov 16, 2026
Merged

serengil merged 1 commit into
serengil:masterfrom
Afloat16:fix/pgvector-vector-decoder-20261116

Conversation

@Afloat16

Copy link
Copy Markdown
Contributor

Tickets

Self-contained pgvector driver compatibility fix.

What has been done

pgvector Python 0.5 changed Psycopg's decoded vector value from a NumPy array to a Vector object. That object is not iterable, so the existing list(value) calls raise TypeError: 'Vector' object is not iterable. This breaks single-identity reads, full-gallery reads, exact searches, and identification with the current driver.

Use the driver's to_list() method when available and retain the existing conversion for older array-returning drivers. The production change is two return-value conversions.

The driver change is recorded in pgvector Python's 0.5.0 changelog.

How to test

Validation run, using real PostgreSQL 16.16, pgvector extension 0.8.7, and Psycopg 3.3.9:

  • Python 3.12 / pgvector Python 0.5.1: original source has 8 failures and 3 passing controls; patched source plus adjacent regressions has 50 passes.
  • Python 3.10 / pgvector Python 0.4.2: all 11 new cases already pass on the original source, and all 50 selected cases pass after the change.
  • Repository-pinned Pylint: 10.00/10; MyPy: 145 source files passed; test formatting passed.

The tests read actual database values through both decoder generations, verify single-row and streamed batch results, exercise public exact search and identification, and preserve missing-identity, empty-gallery, and native ANN-search behavior. Recognition is replaced at the embedding boundary; database reads, decoded values, and distance calculations are real.

@serengil
serengil merged commit c8bc91e into serengil:master Nov 16, 2026
3 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