Closed lukeherron closed 9 months ago
🤖
Thank you for bringing this to our attention. It seems like there's indeed a discrepancy between the expected behavior and the actual behavior of the 'retriever_mode' parameter in the KnowledgeGraphIndex.as_retriever method in the v0.10.4 version of LlamaIndex.
As per the documentation and the codebase, the 'retriever_mode' parameter is supposed to determine the mode of operation for the retriever. It can take one of three values: "keyword", "embedding", or "hybrid". Depending on the 'retriever_mode' specified, the Knowledge Graph Index should return a KGTableRetriever that operates in the specified mode.
However, as you've pointed out, regardless of the 'retriever_mode' specified, the Knowledge Graph Index always returns a KGTableRetriever that operates in the 'keyword' mode. This is indeed a bug and not the intended behavior.
Unfortunately, as a technical support rep, I don't have the ability to create pull requests or issues. However, I would recommend you to create a new issue in the LlamaIndex repository detailing this bug. Please include the steps to reproduce the bug, the expected behavior, and the actual behavior. This will help the maintainers of the LlamaIndex repository to understand and fix the bug.
In the meantime, as a workaround, you might want to manually set the 'retriever_mode' of the KGTableRetriever after it has been returned by the KnowledgeGraphIndex.as_retriever method. Here's how you can do it:
kg_index = KnowledgeGraphIndex(...)
query_engine = kg_index.as_query_engine()
query_engine.retriever.retriever_mode = KGRetrieverMode.EMBEDDING
query_engine.query("Some query that really needs a good embedding")
Please note that this is just a temporary workaround and not a permanent solution. The maintainers of the LlamaIndex repository will need to fix the bug for a permanent solution.
I hope this helps! If you have any other questions or need further clarification, please don't hesitate to ask.
Thanks for raising @lukeherron. I believe the fix should just be to add the missing retriever_mode
param in the construction of the KGTableRetriever
. Just submitted a PR for this.
Bug Description
Prior to the v0.10.0 refactor, 'retriever_mode' parameter was being passed via kwargs to KGTableRetriever: https://github.com/run-llama/llama_index/blob/3823389e3f91cab47b72e2cc2814826db9f98e32/llama-index-legacy/llama_index/legacy/indices/knowledge_graph/base.py#L105-L114
'retriever_mode' is now a non-kwargs param and is not subsequently being passed to KGTableRetriever: https://github.com/run-llama/llama_index/blob/3823389e3f91cab47b72e2cc2814826db9f98e32/llama-index-core/llama_index/core/indices/knowledge_graph/base.py#L122-L142
The end result being retriever mode defaults to keyword and embeddings are ignored for any kg index queries.
Version
v0.10.4
Steps to Reproduce
Relevant Logs/Tracbacks
No response