graphragzen.query.get_context.semantic_similar_entities
- graphragzen.query.get_context.semantic_similar_entities(embedding_model, vector_db, query, k, entity_types=['node', 'edge'], features_to_match=['description'], score_threshold=0.0)[source]
Get entities with the highest semantic similarity to the query.
- Parameters:
embedding_model (BaseEmbedder) – The embedding model used to compute the query vector.
vector_db (VectorDatabase) – The vector database to search for similar entities.
query (str) – The query string to find similar entities.
k (int) – Maximum number of entities (nodes and edges) to return.
entity_types (List[str], optional) – Which entities to search. Defaults to [‘node’, ‘edge’].
features_to_match (List[str], optional) – Entity features to perform semantic similarity search on with regards to the query. Defaults to [“description”].
score_threshold (float, optional) – Exclude all vector search results with a score worse than this. Defaults to 0.0.
- Returns:
A list of dictionaries containing ‘entity_type’, ‘entity_name’, ‘score’.
- Return type:
List[dict]