Comments (1)
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.
Related Issues (20)
- [Bug]: pipeline arun does not parallelize query pipeline HOT 3
- Json +pdf engine HOT 1
- [Question]: SentenceNodeParser ignores max_length of embed model HOT 4
- [Bug]: Unable to run UnstructuredElementNodeParser with OpenAILike LLM HOT 2
- [Feature Request]: Async support for Qdrant Vector store HOT 2
- [Question]: when break complex problem into sub-problems raise “JSONDecodeError" HOT 5
- [Question]: is default in VectorIndexRetriever semantic search HOT 2
- [Question]: Cannot import name 'DEFAULT HUGGING FACE EMBEDDING MODEL from 'llama_index.embeddings' (/usr/local/lib/python3.11/site-packages/llama_index/embeddings/__init__.py) HOT 3
- [Feature Request]: Adding Azure Cosmos DB NoSql as a new vector store
- [Feature Request]: Upgrade llama-index-embeddings-text-embeddings-inference package dependency requirements
- [Question]: Storing agent HOT 5
- [Bug]: Gemini.stream_chat is missing @llm_chat_callback() HOT 1
- [Bug]: Qwen2 compete error HOT 1
- [Bug]: SQLTableRetrieverQueryEngine response metadata not correctly formatted HOT 1
- [Question]: Big problem on saving and retrieve KnowledgeGraphIndex (Neo4j) HOT 4
- [Bug]: Text match filter doesn't work with PostgreSQL filter search and gives unknown operator error. HOT 2
- [None page in Documentation]: Sub category shows None under data connectors page, reroutes to blank. HOT 5
- [Bug]: ModuleNotFoundError: No module named 'llama_index.utilities' HOT 2
- [Feature Request]: Knowledge Graph Index generation parallelized (multiple LLM calls and embeddings generation at the same time) HOT 2
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.