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

Results for SimilaritySearch in RAG Application with Ollama always return 0 documents #1625

Open
cjullien opened this issue Oct 29, 2024 · 2 comments
Labels
ollama question Further information is requested RAG Issues related to Retrieval Augmented Generation

Comments

@cjullien
Copy link

Bug description
When I create a RAG Application with SimilaritySearch, the search returns similar documents when using Azure OpenAI, but always returns zero documents with Ollama. The issue occurs specifically when I use the withSimilarityThreshold parameter with Ollama.

Environment
last version of spring-ai BOM
ollama with llama 3.2
Azure OpenAI
PGVector

Steps to reproduce
When I use withSimilarityThreshold with Ollama, I always have 0 Document in my similarDocuments (it's ok with Azure OpenAI)

   var similarity = 0.8; 
    var topk =20;
    var searchRequest = SearchRequest.query(question.question())
            .withTopK(topk)
            .withSimilarityThreshold(similarity);
     List<Document> similarDocuments = vectorStore.similaritySearch(searchRequest);

Expected behavior
The search should return similar results between Azure OpenAI and Ollama. However, Ollama consistently returns zero similar documents.

Observed Behavior

Azure OpenAI: Returns a list of documents that meet the similarity threshold.
Ollama: Returns zero documents, regardless of the similarity threshold set.

Additional Information

Configuration Consistency: The vectorStore configuration is identical for both platforms.
Error Logs: No explicit error messages are thrown; however, the empty response from Ollama does not align with the expected output.
[spring-ai-bootstraping] [nio-8080-exec-1] c.c.s.s.controller.AskRagController : Found 0 similar documents

@asaikali
Copy link

What embedding model are you using with ollama?

@asaikali asaikali added RAG Issues related to Retrieval Augmented Generation ollama question Further information is requested labels Oct 30, 2024
@cjullien
Copy link
Author

I tested with the following models

#spring.ai.ollama.embedding.options.model=nomic-embed-text
#spring.ai.ollama.embedding.options.model=mxbai-embed-large
spring.ai.ollama.embedding.options.model=chroma/all-minilm-l6-v2-f32
#spring.ai.ollama.embedding.options.model=hellord/e5-mistral-7b-instruct:Q4_0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ollama question Further information is requested RAG Issues related to Retrieval Augmented Generation
Projects
None yet
Development

No branches or pull requests

2 participants