Find answers from the community

Updated 10 months ago

Source Nodes

I want to log cosine similarity of RAG response while retrieving from chroma db ? Please refer below code for this: .vector_store = self.setup_chroma(collectionName)
storage_context = StorageContext.from_defaults(vector_store=vector_store)

documents = SimpleDirectoryReader(
input_files = files
).load_data()

node_parser = SentenceSplitter(chunk_size=512, chunk_overlap=50)
nodes = node_parser.get_nodes_from_documents(documents)
index = VectorStoreIndex(nodes, storage_context=storage_context)

query_engine = index.as_query_engine()
query_engine.query(query)
W
1 comment
You can get the similarity score of each retrieved nodes from the response.

Plain Text
response= query_engine.query(qry)
print(response.source_nodes)
Add a reply
Sign up and join the conversation on Discord