Comments (2)
To emit similarity scores along with the retrieved results using the VectorIndexRetriever
, you need to ensure that the _retrieve
method returns a list of NodeWithScore
objects, which include both the nodes and their corresponding similarity scores.
Here's how you can modify the _retrieve
method:
def _retrieve(
self,
query_bundle: QueryBundle,
) -> List[NodeWithScore]:
query_result = self._index.query(
query_str=query_bundle.query_str,
top_k=self._similarity_top_k,
**self._kwargs,
)
# Assuming query_result is a VectorStoreQueryResult object
nodes_with_scores = self._build_node_list_from_query_result(query_result)
return nodes_with_scores
In this modification, it is assumed that the self._index.query
method returns a VectorStoreQueryResult
object, which contains the nodes and their similarity scores. The nodes_with_scores
list is then created using the _build_node_list_from_query_result
method, which processes the VectorStoreQueryResult
to include the similarity scores.
The VectorStoreQueryResult
object typically contains the following attributes:
nodes
: A list of nodes.ids
: A list of node IDs.similarities
: A list of similarity scores corresponding to the nodes or node IDs.
The _build_node_list_from_query_result
method processes these attributes to build a list of NodeWithScore
objects, which include both the nodes and their similarity scores [1][2].
This approach ensures that the retrieved results include the similarity scores.
To continue talking to Dosu, mention @dosu.
from llama_index.
Each node has the score
nodes = retriever.retrieve("query")
print(nodes[0].score)
from llama_index.
Related Issues (20)
- [Question]: nlsql table query engine keep the conversation going ( chat history) HOT 7
- [Feature Request]: Moving from Completions to Chat Completions in the OpenAILike API HOT 2
- [Question]: Getting a list of Document content from SimpleDirectoryReader HOT 2
- [Bug]: Input length exceeds maximum allowed token size when using Nvidia NIMs HOT 2
- [Question]: Getting Document ID from Document Text HOT 1
- How can llamaindex point multiple ElasticSearchStores to the same index_name when using Elasticsearch for storage? HOT 1
- How to use 'Azure Cosmos DB for MongoDB account (RU)' instance as DocStore to store document nodes HOT 4
- First Retrieval on Chroma Vector Store is Significantly Slow[Bug]: HOT 3
- [Bug]:Perplexity LLM integration list outdated HOT 1
- [Bug]: Workflow steps appear to be blocking? HOT 2
- PandasAIReader.__init__() got an unexpected keyword argument 'llm'[Bug]: HOT 2
- DuckDB vector database Tutorial HOT 1
- [Feature Request]: Store-agnostic interface for retrieving document embeddings from vector index HOT 5
- [Question]: AzureChatStore: Ensuring Asynchronous Requests and Understanding _atable_service_client Usage HOT 2
- [Feature Request]: FaissVectorStore with metadata support
- [Question]: Value Prop of LlamaIndex Workflows over LangGraph? HOT 1
- [Bug]: WARNING:llama_index.embeddings.openai.utils:Retrying llama_index.embeddings.openai.base.get_embeddings in 0.7360705661705746 seconds as it raised APIConnectionError: Connection error.. HOT 1
- [Question]: How to handle complex PDFs HOT 2
- [Feature Request]: Support for locally hosted LLM API HOT 1
- [Bug]: MistralAI chat_completion API broken HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from llama_index.