Find answers from the community

Updated 2 months ago

i am using `QueryFusionRetriever` with

i am using QueryFusionRetriever with CondensePlusContextChatEngine, where i am having 2 retrievers BM25Retriever and VectorStoreIndex.from_vector_store and using langfuse for traces. When using condense plus context chat engine the traces are not well segrated like for multiple retriever, multiple queries and then fusion nodes. Just like well speperated as in index.as_chat_engine
p
k
6 comments
@kapa.ai i am using QueryFusionRetriever with CondensePlusContextChatEngine, where i am having 2 retrievers BM25Retriever and VectorStoreIndex.from_vector_store and using langfuse for traces. When using condense plus context chat engine the traces are not well segrated like for multiple retriever, multiple queries and then fusion nodes. Just like well speperated as in index.as_chat_engine
Let me check the knowledge base for you. One moment! :books:
----------------------
Based on the information provided in the knowledge sources, you can use the QueryFusionRetriever with multiple retrievers like BM25Retriever and VectorStoreIndex.from_vector_store. Here is an example of how you can set it up:

Plain Text
from llama_index.core import VectorStoreIndex, StorageContext
from llama_index.core.storage.docstore import SimpleDocumentStore
from llama_index.vector_stores.chroma import ChromaVectorStore
import chromadb

docstore = SimpleDocumentStore()
docstore.add_documents(nodes)

db = chromadb.PersistentClient(path="./chroma_db")
chroma_collection = db.get_or_create_collection("dense_vectors")
vector_store = ChromaVectorStore(chroma_collection=chroma_collection)

storage_context = StorageContext.from_defaults(
    docstore=docstore, vector_store=vector_store
)

index = VectorStoreIndex(nodes=nodes, storage_context=storage_context)

Plain Text
import nest_asyncio

nest_asyncio.apply()

from llama_index.core.retrievers import QueryFusionRetriever

retriever = QueryFusionRetriever(
    [
        index.as_retriever(similarity_top_k=2),
        BM25Retriever.from_defaults(
            docstore=index.docstore, similarity_top_k=2
        ),
    ],
    num_queries=1,
    use_async=True,
)

(Source: GitHub ())

For the CondensePlusContextChatEngine, you can initialize it from default parameters as shown below:

Plain Text
from llama_index.core.chat_engine import CondensePlusContextChatEngine

chat_engine = CondensePlusContextChatEngine.from_defaults(
    retriever=retriever,
    # other parameters as needed
)

(Source: LlamaIndex Docs ())
However, the knowledge sources do not provide specific information on how to segregate traces for multiple retrievers, multiple queries, and fusion nodes when using the CondensePlusContextChatEngine. It's recommended to refer to the official LlamaIndex documentation or the source code for more detailed information on this topic.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
@Logan M @WhiteFang_Jr
Add a reply
Sign up and join the conversation on Discord