jugesh
jugesh

Reputation: 82

Can I store vectors with more precision in pgvector?

I am trying to store deepface.DeepFace.represent image embedding in front_vector column with full precision. -0.7108331918716431 This is the actual precision but pgvector stores this as -0.7108332.

Here is the code:

from sqlalchemy import (Column,String,Integer,CHAR,
                        Date,Float, DECIMAL,LargeBinary,select)
from sqlalchemy.orm import declarative_base
from pgvector.sqlalchemy import Vector
Base= declarative_base()
class Student(Base):
    __tablename__="student_details"
    name = Column("name",String,nullable=False)
    dob = Column("dob",Date,nullable=False)
    gender = Column("gender",CHAR(10),nullable=False)
    front_vector = Column("front_vector",Vector(128))

pgvector official website suggests this,

CREATE TABLE items (id bigserial PRIMARY KEY, embedding double precision[]);

which I am not able to implement in sqlalchemy. Please provide a solution so I can store the vector with its full precision.

Upvotes: 0

Views: 372

Answers (0)

Related Questions