Reputation: 9
I have pretty much default settings but i keep getting this on initializing the VectorStore
caused by: org.postgresql.util.PSQLException: ERROR: expected 1596 dimensions, not 4096
spring:
ai:
ollama:
base-url: http://localhost:11434
embedding:
options:
model: llama3
vectorstore:
pgvector:
index-type: HNSW
distance-type: COSINE_DISTANCE
dimensions: 1596
My code to load is pretty simple if fails on the add. The vector_store table is created in the DB. Can't figure out why the .add is listing 4096 dimensions
for (File file : javaFiles) {
log.info("Loading document: {}", file.getName());
Resource resource = new FileSystemResource(file);
TextReader documentReader = new TextReader(resource);
List<Document> documents = documentReader.get();
TextSplitter textSplitter = new TokenTextSplitter();
List<Document> splitDocuments = textSplitter.apply(documents);
vectorStore.add(splitDocuments);
}
I am running this logic and it fails giving the 4096 when 1596 is expected. using these dependencies
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-ollama-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-pgvector-store-spring-boot-starter</artifactId>
</dependency>
Upvotes: -1
Views: 310
Reputation: 311
Actually there is a limitation on PgVector which allows at most 2000 dimensions for HNSW indexes (see spring-ai documentation).
And since you're using llama3 which got 4096 "embedding dimensions" accordingly to what I can see from this reference then it could explains your error.
I guess you could either:
Upvotes: 0