-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
[Bug]: Starter Tutorial (Local Models) - model response incorrect #13542
Comments
The issue you're encountering with irrelevant sections of text being retrieved and responded to in the LlamaIndex library could be due to a few key factors related to the configuration of the
By reviewing and potentially adjusting these aspects of the
|
@gmatteuc it works fine for me, ran this a few times and the results were consistent Code: from llama_index.core import VectorStoreIndex, SimpleDirectoryReader, Settings
from llama_index.embeddings.ollama import OllamaEmbedding
from llama_index.llms.ollama import Ollama
documents = SimpleDirectoryReader("data").load_data()
# nomic embedding model
Settings.embed_model = OllamaEmbedding(model_name="nomic-embed-text")
# ollama
Settings.llm = Ollama(model="llama3", request_timeout=360.0)
index = VectorStoreIndex.from_documents(
documents,
)
query_engine = index.as_query_engine()
response = query_engine.query("What did the author do growing up?")
print(response)
print(response.source_nodes[0].score)
print(response.source_nodes[1].score)
print(response.source_nodes[0].text[:100])
print(response.source_nodes[1].text[:100]) Output:
Maybe make sure you have the latest version of Ollama's server installed, and the latest version of the models pulled?
|
Yes, pulled llama3 and nomic-embed-text in Ollama (that I just reinstalled) as described. "c:/Users/matteucc/Desktop/Playground/LlamaIndex/data/newtest.py |
That's pretty weird. I see you are on windows, i wonder if it's an Ollama + windows thing |
Weird ideed. I will retry on another computer and/or using gpt-3.5-turbo to see if I get the same issue... |
@logan-markewich Hi! Small update on the issue. I tried with gpt-3.5-turbo and it works. I also tried with LangChain + Ollama and got the same issue. I think the problem is not with the language model itself but with the similarity search in the vector store. In both case the retrieved documents don't always fit the query not all parts of the documents seems to be accessible for retrival... Indeed, with LangChain, if I swap the embedding generator from the Ollama one to the OpenAI one while keeping Ollama as LLM the probem is fully solved (I didn't try the same in LlamaIndex yet). |
Bug Description
I followed the installation and setup steps described in the documentation page. Everything seems to be correctly setup but when I run the starter tutorial code the model doesn't seem process correctly the document ("paul_graham_essay.txt") or the request because instead of responding "The author wrote short stories and tried to program on an IBM 1401." it responds: "Based on the context provided in the essay, the author did not directly mention what they did growing up. However, we can infer some information about their background from the text. [...]". From the logging it seems that the top 2 nodes retrieved are actually not the most relevant parts of the text to answer the question. What could the issue be?
Version
0.10.37
Steps to Reproduce
Installing and setting up as described here: https://docs.llamaindex.ai/en/stable/getting_started/installation/ and running the following code as "starter.py": "
from llama_index.core import VectorStoreIndex, SimpleDirectoryReader, Settings
from llama_index.embeddings.ollama import OllamaEmbedding
from llama_index.llms.ollama import Ollama
import logging
import sys
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
logging.getLogger().addHandler(logging.StreamHandler(stream=sys.stdout))
documents = SimpleDirectoryReader("data").load_data()
Settings.embed_model = OllamaEmbedding(model_name="nomic-embed-text")
Settings.llm = Ollama(model="llama2", request_timeout=360.0)
index = VectorStoreIndex.from_documents(
documents,
)
query_engine = index.as_query_engine()
response = query_engine.query("What did the author do growing up?")
print(response)
"
Relevant Logs/Tracbacks
The text was updated successfully, but these errors were encountered: