Add targeted comments explaining non-obvious behaviour
- embedder.py: lazy model load rationale, RGB conversion, shared vector space
- main.py: why vec appears twice, ::vector cast, 1-distance score formula
- main_oracle.py: why array.array("f") is required instead of plain list
- main_oracle_indb.py: no embedder import — embedding done inside Oracle SQL
- index_images_oracle.py: same array.array requirement on indexing path
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -29,6 +29,9 @@ def search(q: str = Query(...), limit: int = Query(12)):
|
||||
ORDER BY embedding <=> %s::vector
|
||||
LIMIT %s
|
||||
""",
|
||||
# vec appears twice: once for ORDER BY (uses HNSW index), once for the score column.
|
||||
# ::vector cast is required — psycopg2 passes the list as text without it.
|
||||
# 1 - distance converts cosine distance (0=identical) to similarity (1=identical).
|
||||
(vec, vec, limit),
|
||||
)
|
||||
rows = cur.fetchall()
|
||||
|
||||
Reference in New Issue
Block a user