What JPA + Hibernate data type should I use to support vector extension in postgres database, so that it allows me to create embeddings using a JPA Entity
CREATE TABLE items (id bigserial PRIMARY KEY, embedding vector(3));
https://github.com/pgvector/pgvector
2
Answers
You can use vladmihalcea hibernate types to convert vector type to List, so it is possible to save or query with JpaRepository.
you can use org.hibernate.type.descriptor.java.SerializableTypeDesc
like this example:
@Type: embedding field should use the serializable type, which is mapped to the SerializableTypeDescriptor class.
@Column : column definition for the embedding field, which is bytea.
then you can create embeddings using a JPA Entity and store them in a PostgreSQL database.any object that can be serialized to a byte array is acceptable!