Skip to content

How to pass the nodes for BM25Retriever from VectorStoreIndex #18155

Closed Answered by dosubot bot
Alnasser0 asked this question in Q&A
Discussion options

You must be logged in to vote

To resolve the "Please pass exactly one of index, nodes, or docstore" error when passing nodes to BM25Retriever, ensure that you are providing only one of the index, nodes, or docstore arguments. Here's how you can correctly pass the nodes:

from llama_index.retrievers.bm25 import BM25Retriever
import Stemmer

# Assuming you have a list of nodes from your VectorStoreIndex
nodes = vector_index.docstore.docs.values()

# Initialize the BM25Retriever with the nodes
bm25_retriever = BM25Retriever.from_defaults(
    nodes=nodes,
    similarity_top_k=similarity_top_k,
    stemmer=Stemmer.Stemmer("english"),
    language="english",
)

Make sure that you are not passing both nodes and any other arg…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Alnasser0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant