Skip to content

Return Item objects in the SQLAlchemy binary reranking example - #180

Open
AlexShen-Oguri wants to merge 1 commit into
pgvector:masterfrom
AlexShen-Oguri:codex/docs-orm-binary-reranking
Open

AlexShen-Oguri wants to merge 1 commit into
pgvector:masterfrom
AlexShen-Oguri:codex/docs-orm-binary-reranking

Conversation

@AlexShen-Oguri

Copy link
Copy Markdown

Summary

Select the mapped Item alias for the subquery in the SQLAlchemy binary reranking example. Selecting the raw subquery and calling session.scalars() returned its first column, which is the ID in the documented model. The mapped alias returns the complete reranked items.

Evidence

  • Executed the exact example queries using SQLAlchemy 2.0.43 and an in-memory SQLite session with test functions for the vector operators. The original returned integers. The revised query returned Item instances in the same cosine order with their attributes and session identity intact.
  • Compiled both queries with SQLAlchemy's PostgreSQL dialect. The Hamming candidate selection, cosine reranking, and limits matched. PostgreSQL execution was outside this verification.

Merge Danger

The change is confined to the SQLAlchemy README example.

OpenAI Codex helped reproduce the incorrect result shape, edit the example, and verify the result mapping.

Co-authored-by: OpenAI Codex <codex@openai.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant