@@ -26,9 +26,7 @@ class Paper(Base):
2626
2727 __tablename__ = "paper"
2828
29- # ------------------
3029 # Columns
31- # ------------------
3230 paper_id : Mapped [int ] = mapped_column (BigInteger , primary_key = True , index = True )
3331 doi : Mapped [str ] = mapped_column (String (255 ), nullable = False , unique = True )
3432
@@ -54,16 +52,12 @@ class Paper(Base):
5452 DateTime (timezone = True ), nullable = False , server_default = func .now ()
5553 )
5654
57- # ------------------
5855 # Vector Embedding
59- # ------------------
6056 embedding : Mapped [Optional [List [float ]]] = mapped_column (
6157 Vector (768 ), nullable = True
6258 )
6359
64- # ------------------
6560 # Relationships
66- # ------------------
6761 project_links : Mapped [List ["ProjectPaper" ]] = relationship (
6862 "ProjectPaper" , back_populates = "paper" , cascade = "all, delete-orphan"
6963 )
@@ -72,15 +66,16 @@ class Paper(Base):
7266 "Project" , secondary = "project_paper" , back_populates = "papers"
7367 )
7468
75- # ------------------
7669 # Indexes (HNSW)
77- # ------------------
7870 __table_args__ = (
7971 Index (
8072 "ix_paper_embedding_hnsw" ,
8173 "embedding" ,
8274 postgresql_using = "hnsw" ,
83- postgresql_with = {"m" : 16 , "ef_search" : 40 , "lists" : 100 },
75+ postgresql_ops = {
76+ "embedding" : "vector_cosine_ops"
77+ },
78+ postgresql_with = {"m" : 16 , "ef_construction" : 64 },
8479 ),
8580 )
8681
0 commit comments