Files
hibernate-demo/hibernate-vector/output/01-mapping.txt
T

32 lines
1.3 KiB
Plaintext

# float[] <-> vector(4): the DDL Hibernate generates, the round trip, the failure modes
# Hibernate ORM 7.4.17.Final (on the classpath), PostgreSQL 16.15, pgvector 0.8.7, JDK 25
== Versions seen at runtime
Hibernate ORM (org.hibernate.Version): 7.4.17.Final
server: PostgreSQL 16.15 (Ubuntu 16.15-0ubuntu0.24.04.1) on x86_64-pc-linux-gnu
== Column type Hibernate created for Doc.embedding (pg_attribute)
doc.embedding : vector(4)
== Insert and read back
-- insert
insert into doc (category,embedding,title) values (?,cast(? as vector),?)
read back float[]: [0.7, 0.7, 0.0, 0.0]
same values: true
how pgvector prints it: [0.7,0.7,0,0]
== Failure: a three-element array for a vector(4) column
DataIntegrityViolationException -> PSQLException: ERROR: expected 4 dimensions, not 3
== In-place change of the float[] is detected by dirty checking
-- update sent at commit
update doc set category=?,embedding=cast(? as vector),title=? where id=?
== Half precision: SqlTypes.VECTOR_FLOAT16 maps the same float[] to halfvec
half_doc.embedding : halfvec(4)
stored (embedding::text): [0.099975586,0.19995117,0.30004883,0.7001953]
read back float[]: [0.099975586, 0.19995117, 0.30004883, 0.7001953]
== Failure: cosine distance against the zero vector
select '[0,0,0,0]'::vector <=> '[1,2,3,4]'::vector -> NaN