You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fromllama_index.coreimportDocumentfromllama_index.core.node_parserimportSentenceSplitterfromllama_index.retrievers.bm25importBM25Retrieverdocuments= [
Document(text="Large Language Model"),
Document(text="LlamaIndex is a data framework for your LLM application"),
Document(text="How to use LlamaIndex")
]
splitter=SentenceSplitter(chunk_size=1024)
nodes=splitter.get_nodes_from_documents(documents)
retriever=BM25Retriever.from_defaults(nodes=nodes, similarity_top_k=2)
result_nodes=retriever.retrieve("llamaindex llm")
fornodeinresult_nodes:
print(node)
Relevant Logs/Tracbacks
Error Output:
Node ID: d9ed555e-bda4-4c45-aa21-dcd852e54d35
Text: LlamaIndex is a data framework for your LLM application
Score: 0.000
Node ID: 44962ba7-79f2-479c-a817-274290c6f626
Text: How to use LlamaIndex
Score: 0.498
Expected Output:
Node ID: e55c811f-94d9-444e-9ff1-518a5517238c
Text: LlamaIndex is a data framework for your LLM application
Score: 0.498
Node ID: 3645e578-a7fe-45e7-b139-311c54158bc4
Text: How to use LlamaIndex
Score: 0.121
The text was updated successfully, but these errors were encountered:
Hey @huanghao128! I'm here to help you with any bugs, questions, or contributions you have for the repository. Let me know how I can assist you!
The issue in the BM25Retriever class at line 92 of the file llama_index/retrievers/bm25/base.py can be fixed by modifying the loop to correctly match the retrieval nodes, top_n indexes, and scores. The suggested fix is correct. Here is the corrected code:
Bug Description
BM25Retriever retrieval nodes, top_n indexs and scores not match
llama_index/retrievers/bm25/base.py, line 92
fix like this:
Version
Steps to Reproduce
Relevant Logs/Tracbacks
The text was updated successfully, but these errors were encountered: