-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[Question]: query_engine.query("query") returns empty response... #11771
Comments
Hey @Sridevi17j, great to see you back! Hope you're doing well. 😊 Based on the code you've shared and the context provided, it seems like you're trying to query a document using the LlamaIndex framework. However, you're encountering an issue where the There are a few things you could try to resolve this issue:
new_index = load_index_from_storage(storage_context, service_context=service_context)
from llama_index import Document
docs=[Document(text=doc.page_content, metadata={"source":doc.metadata["source"]}) for doc in documents]
Remember, the The I hope this helps! If you're still encountering issues, please provide more details about the documents you're trying to index and the exact error messages you're seeing. This will help us better understand the problem and provide a more accurate solution. Sources
|
Hi @dosu-bot I added below code and i get below error so i am using like below from llama_index.embeddings.huggingface import HuggingFaceEmbedding Settings.embed_model = HuggingFaceEmbedding( also for StorageContext, i could not understand how to use this, and what are all the parameters to be passed in. |
Based on the information you've provided, it seems you're trying to use Here's a general example of how you might proceed based on the typical usage pattern: from llama_index.core.storage import StorageContext
# Assuming StorageContext requires parameters like 'storage_path' and 'config'
storage_path = "/path/to/storage"
config = {"option1": "value1", "option2": "value2"}
# Instantiate StorageContext with the required parameters
storage_context = StorageContext(storage_path, config)
# Use storage_context as needed For the exact parameters, you should refer to the As for the purpose and functionality of the I hope this helps! If you have any more questions or need further clarification, feel free to ask. Sources
|
@dosu-bot , I saved the index like below and i reloaded the index like below service_context = ServiceContext.from_defaults(llm=None, embed_model=embed_model) new_index = load_index_from_storage(storage_context, service_context=service_context) i get below error File ~\PycharmProjects\Test1.venv\Lib\site-packages\llama_index\core\indices\loading.py:33, in load_index_from_storage(storage_context, index_id, **kwargs) File ~\PycharmProjects\Test1.venv\Lib\site-packages\llama_index\core\indices\loading.py:64, in load_indices_from_storage(storage_context, index_ids, **kwargs) AttributeError: 'str' object has no attribute 'index_structs' pls provide your inputs.. |
Based on the error message you provided, it seems like the To resolve this issue, you need to create an instance of from llama_index.core.storage.index_store import JsonIndexStore
# Create an instance of JsonIndexStore
index_store_instance = JsonIndexStore("test/index_store.json")
# Pass the instance to the StorageContext constructor
storage_context = StorageContext(docstore=docstore, index_store=index_store_instance, vector_stores=vector_stores, graph_store=graph_store) This should resolve the For more information, you can refer to the StorageContext constructor in the LlamaIndex repository. Also, there was a similar issue reported in the LlamaIndex repository (issue #3426). The solution there involved manually fixing the Sources
|
@dosu-bot in the given links, i saw one line, and i used here for StorageContext for giving the persisten directory path, it did not throw error, but still it gives empty response, check it out service_context = ServiceContext.from_defaults(llm=None, embed_model=embed_model) storage_context = StorageContext.from_defaults(persist_dir="test") new_index = load_index_from_storage(storage_context, service_context=service_context) Query: what is this document about |
Based on the code you've shared and the context provided, there are a few potential issues that could be causing the
from llama_index import Document
docs=[Document(text=doc.page_content, metadata={"source":doc.metadata["source"]}) for doc in documents]
from llama_index import VectorStoreIndex, SimpleDirectoryReader
documents = SimpleDirectoryReader(input_files = ["test2.txt"]).load_data()
index = VectorStoreIndex.from_documents(documents)
query_engine = index.as_query_engine()
query_engine.query("what is my name?") Please try these suggestions and let me know if any of them resolve your issue. If not, could you provide more information about your setup, such as the version of LlamaIndex you're using, the type and format of the documents you're trying to query, and any error messages you're seeing? This will help me better understand the problem and provide more targeted assistance. Sources
|
@dosu-bot, have followed all your advise, after using custom LLM, instead of empty response, i am getting "My Response" as a response- which is a dummy response that is set in our LLM, see my code below index = VectorStoreIndex.from_documents(documents) from typing import Optional, List, Mapping, Any class OurLLM(CustomLLM):
from llama_index.embeddings.huggingface import HuggingFaceEmbedding Settings.embed_model = HuggingFaceEmbedding( service_context = ServiceContext.from_defaults(chunk_size=2048,llm=OurLLM(), embed_model=embed_model) storage_context = StorageContext.from_defaults(persist_dir="test") new_index = load_index_from_storage(storage_context, service_context=service_context) My response I tried setting the settings through Settings also, through ServiceContext... none of them working, tried setting the LLM to None also to CustomLLM, also changed chunk_size, context window... tried all possible way.. still no luck.. meanwhile, please also see my index_store.json below ( Note:- embedding dict is empty) What am i doing wrong here? |
Based on the code you've provided, it seems like the If you want the @llm_completion_callback()
def complete(self, prompt: str, **kwargs: Any) -> CompletionResponse:
return CompletionResponse(text=prompt) This will return the input query as the response. Regarding the content of your As for the similar issues in the LlamaIndex repository, it seems that some users have had success by checking the verbose output of the sub-questions generated by the Lastly, you might want to consider switching from Llama2 to a different LLM like Zephyr 7b beta for more reliable structured outputs. If necessary, you could also adapt the setup for use with llama-cpp for CPU hardware, but keep in mind that it will be slower. I hope this helps! If you have any other questions or need further clarification, feel free to ask. For more information, you can refer to the following sources:
Sources
|
@Sridevi17j have you tried using the chatgpt-3.5 api as LLM? |
@mlkorra I m trying to use Ollama , open source LLM |
I sorted this issue, by printing response in a stream. Below code gives response.
|
I'm sorry but this didn't helped!! |
Question Validation
Question
Please find my entire code here
from llama_index.core import VectorStoreIndex, SimpleDirectoryReader
documents = SimpleDirectoryReader("data1").load_data()
from llama_index.embeddings.huggingface import HuggingFaceEmbedding
from llama_index.core import Settings
Settings.embed_model = HuggingFaceEmbedding(
model_name="sentence-transformers/all-MiniLM-L6-v2"
)
Settings.llm = None
index = VectorStoreIndex.from_documents(documents)
query_engine = index.as_query_engine()
response = query_engine.query("what is this document about")
print(response)
Below is the output:
Query: what is this document about
Answer:
If i set Settings.llm = Some Huggingface LLM, then it returns "Empty Response" or "My Response"
so none of them worked.. Could someone pls advise, what am i doing wrong here, I have uploaded a pdf file to query it, i also tried with simple text files too..
But nothing worked..
The text was updated successfully, but these errors were encountered: