Embeddings don't seem to work. #71

Closed
opened 2026-02-15 16:27:51 -05:00 by yindo · 3 comments
Owner

Originally created by @luigi052005 on GitHub (Apr 24, 2024).

I attempted to utilize the embedding model following the example provided on https://ollama.com/blog/embedding-models, yet each time, it returns: "Llamas are vegetarians and possess highly efficient digestive systems."

main.txt
image

Originally created by @luigi052005 on GitHub (Apr 24, 2024). I attempted to utilize the embedding model following the example provided on https://ollama.com/blog/embedding-models, yet each time, it returns: "Llamas are vegetarians and possess highly efficient digestive systems." [main.txt](https://github.com/ollama/ollama-python/files/15097631/main.txt) ![image](https://github.com/ollama/ollama-python/assets/101733154/b39f2f1c-e26e-4ca7-97a3-b5ee4285f925)
yindo closed this issue 2026-02-15 16:27:51 -05:00
Author
Owner

@luigi052005 commented on GitHub (Apr 25, 2024):

Am i doing something wrong here?

@luigi052005 commented on GitHub (Apr 25, 2024): Am i doing something wrong here?
Author
Owner

@chandansp27 commented on GitHub (Apr 26, 2024):

Hi,
The issue is from the n_results parameter set to 1, Chroma retrieves docs using the query, but the constraint with RAG is that the retrieved document might not always be the most relevant one to the query. When n_results is set to 1, only the 'Llamas are vegetarians.... ' was retrieved which caused the incorrect answer.

Upon increasing the n_resuts to 2, this is the top docs retrieved:

{'ids': '4', '5',
'distances': 177.4359130859375, 255.44308471679688,
'metadatas': None, None,
'embeddings': None,
'documents': [['Llamas are vegetarians and have very efficient digestive systems',
'Llamas live to be about 20 years old, though some only live for 15 years and others live to be 30 years old']],
'uris': None,
'data': None}

and this is the response:

"Based on the data provided, we can determine that llamas are vegetarians and have efficient digestive systems. This means that they are able to extract nutrients from their diet effectively and efficiently, which can contribute to their longevity.
The average lifespan of a llama is around 15-20 years in captivity, with some individuals living up to 30 years or more. This is relatively long for an animal of its size, as many larger animals tend to have shorter lifespans due to their increased metabolic demands and higher risk of health problems."

There are many techniques to improve retrieval accuracy like changing the parameters like n_results to a higher number, hybrid retrievers like BM25, re-ranking the retrieved docs using the prompt, and many more.

@chandansp27 commented on GitHub (Apr 26, 2024): Hi, The issue is from the n_results parameter set to 1, Chroma retrieves docs using the query, but the constraint with RAG is that the retrieved document might not always be the most relevant one to the query. When n_results is set to 1, only the 'Llamas are vegetarians.... ' was retrieved which caused the incorrect answer. Upon increasing the n_resuts to 2, this is the top docs retrieved: {'ids': [['4', '5']], 'distances': [[177.4359130859375, 255.44308471679688]], 'metadatas': [[None, None]], 'embeddings': None, 'documents': [['Llamas are vegetarians and have very efficient digestive systems', 'Llamas live to be about 20 years old, though some only live for 15 years and others live to be 30 years old']], 'uris': None, 'data': None} and this is the response: "Based on the data provided, we can determine that llamas are vegetarians and have efficient digestive systems. This means that they are able to extract nutrients from their diet effectively and efficiently, which can contribute to their longevity. The average lifespan of a llama is around 15-20 years in captivity, with some individuals living up to 30 years or more. This is relatively long for an animal of its size, as many larger animals tend to have shorter lifespans due to their increased metabolic demands and higher risk of health problems." There are many techniques to improve retrieval accuracy like changing the parameters like n_results to a higher number, hybrid retrievers like BM25, re-ranking the retrieved docs using the prompt, and many more.
Author
Owner

@luigi052005 commented on GitHub (Apr 26, 2024):

Thanks for the detailed explanation.

@luigi052005 commented on GitHub (Apr 26, 2024): Thanks for the detailed explanation.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ollama/ollama-python#71