-
Notifications
You must be signed in to change notification settings - Fork 82
Closed
Description
Hello,
Thanks for the work on this, @ankane and team! It's amazing to see more vector types and distance metrics being added continuously :) I am trying to insert a binary vector using SQLalchemy and my code looks like this:
from pgvector.sqlalchemy import BIT
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
class Entity(DeclarativeBase):
[...]
embedding: Mapped[np.array] = mapped_column(BIT(2048))
I am then trying to insert embedding
as a list[int]
of 0s and 1s only. However, this raises the following error:
RepositoryError: An exception occurred: (psycopg.errors.DatatypeMismatch) column "embedding" is of type bit but expression is of type smallint[]
^
HINT: You will need to rewrite or cast the expression.
A similar approach works fine using a list[float]
when inserting into an embedding of type pgvector.sqlalchemy.Vector
.
My question is: which Python type do I need to cast embedding
to before insertion?
Thanks for the help in advance!
Metadata
Metadata
Assignees
Labels
No labels