Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The default settings result in an unworkable library #977

Open
ErykCh opened this issue Jun 28, 2024 · 2 comments · May be fixed by #2072
Open

The default settings result in an unworkable library #977

ErykCh opened this issue Jun 28, 2024 · 2 comments · May be fixed by #2072

Comments

@ErykCh
Copy link

ErykCh commented Jun 28, 2024

Bug description
I created everything on standard settings. Connection to OpenAI and the Neo4j vector database.

Environment

Steps to reproduce
Create connection to OpenAI and create Neo4j vector database.

public EmbeddingModel embeddingModel() {
    return new OpenAiEmbeddingModel(new OpenAiApi(embeddingBaseUrl, embeddingApiKey), MetadataMode.EMBED, OpenAiEmbeddingOptions.builder().withModel(embeddingModel).build());
}

public Neo4jVectorStore neo4jVectorStore(Driver driver, EmbeddingModel embeddingModel) {
    return new Neo4jVectorStore(driver, embeddingModel, Neo4jVectorStoreConfig.defaultConfig(), true);
}

public List<Document> findSimilarContent(SimilarContentRequest request) {
    SearchRequest searchRequest = SearchRequest.query(request.getQuery())
            .withTopK(request.getTopK())
            .withFilterExpression(buildFilterExpression(request.getMetadata()));
    return vectorStore.similaritySearch(searchRequest);
}

org.neo4j.driver.exceptions.ClientException: Failed to invoke procedure `db.index.vector.queryNodes`: Caused by: java.lang.IllegalArgumentException: Index query vector has 3072 dimensions, but indexed vectors have 1536.

I've check using Neo4j Console
there is index spring-ai-document-index
so created by spring ai
with following settings:
{
"indexProvider": "vector-2.0",
"indexConfig": {
"vector.dimensions": 1536,
"vector.similarity_function": "COSINE"
}
}

so spring ai set the wrong index even though he had the embedding model in hand and couldn't put it together properly, causing the solution not to work

Expected behavior
When I use EmbeddingModel to create VectoreStore everything should be created correctly.
Correct indexes and probably other errors that I will come across

@csterwa
Copy link

csterwa commented Sep 4, 2024

@ErykCh can you check latest M2 version to see if this is resolved?

meistermeier added a commit to meistermeier/spring-ai that referenced this issue Jan 15, 2025
In cases where no custom size is set, derive the size by the given
embedding model.

Had to migrate the embeddingDimension Spring Boot property from int to Integer
to introduce the null check for the fluent config. Everything else would
have been just noisy.

Closes spring-projects#977

Signed-off-by: Gerrit Meier <[email protected]>
@meistermeier
Copy link
Contributor

There is now a PR in place that targets this unexpected behaviour: #2072

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants