Find answers from the community

Updated 2 years ago

when using query engine with streaming

At a glance
when using query engine with streaming = true and examining response.source_nodes.extra_info, all the values are None, although the text of the nodes contains extra_info at the top. what's the easiest way to retrieve extra_info of the nodes that were used to generate a response?

I am loading the index from storage like this:
Plain Text
load_index_from_storage(storage_context=self._get_storage_context(
                collection_name=self.id, persist_dir=os.path.join(self.base_persist_dir, self.id)), service_context=self._get_service_context())

and these are the supporting methods:

Plain Text
def get_query_engine(self, prompt_template=None, refine_template=None) -> BaseQueryEngine:
        return RetrieverQueryEngine(
            retriever=VectorIndexRetriever(
                index=self.index, similarity_top_k=math.floor((4097 - 300) / self.max_chunk_size)),
            response_synthesizer=ResponseSynthesizer.from_args(
                response_mode=ResponseMode.COMPACT,
                service_context=self._get_service_context(),
                streaming=self.streaming,
                text_qa_template=QuestionAnswerPrompt(prompt_template),
                refine_template=RefinePrompt(refine_template)))

    def _get_storage_context(self, collection_name, persist_dir=None):
        return StorageContext.from_defaults(
            vector_store=MilvusVectorStore(
                collection_name=collection_name, overwrite=self.overwrite),
            docstore=MongoDocumentStore.from_uri(...),
            persist_dir=persist_dir)

    def _get_service_context(self):
        llm_predictor = LLMPredictor(llm=ChatOpenAI(
            temperature=0, model="gpt-3.5-turbo", streaming=self.streaming))
        prompt_helper = PromptHelper()
        service_context = ServiceContext.from_defaults(
            chunk_size=self.max_chunk_size, llm_predictor=llm_predictor, prompt_helper=prompt_helper)
        return service_context
L
L
12 comments
milvus vector store doesn't support storing the metadata 😦
Although you can maybe remedy this since you are using a docstore as well
index = VectorStoreIndex.from_documents(..., store_nodes_override=True)

index = load_index_from_storage(...., store_nodes_override=True)
unsure if that will work or not though
milvus is a special case here
would using Pinecone instead of Milvus help?
definitely. Then you also don't need the docstore either
since everything goes into the vector store
don't even need to call persist then
to load a prevously created pinecone index, you would just do index = VectorStoreIndex.from_vector_store(vector_store, service_contex=service_context)
thank you, that is very helpful
will try using the override and if that fails, will think about using Pinecone instead
Add a reply
Sign up and join the conversation on Discord