Skip to main content
Version: 0.0.4

agrag.ingestion.resolve.candidate_source.GraphCandidateSource

GraphCandidateSource(*, graph_store:GraphStore, embedder:Embedder, vector_store:VectorStore | None = None, vector_collection:str = '', entity_labels:Sequence[str] = (), top_k:int = 50) -> None

Bases: CandidateSource

Blocks by label in-batch; ANN-searches persisted entities globally.

Functions:

  • candidates_for – Return every other mention sharing the indexed mention's label.
  • global_candidates_for – Return persisted entities found by the shared vector-search route.

Attributes:

candidates_for​

candidates_for(index:int, entities:list[ExtractedEntity]) -> list[int]

Return every other mention sharing the indexed mention's label.

embedder​

embedder = embedder

entity_labels​

entity_labels = tuple(entity_labels)

global_candidates_for​

global_candidates_for(mention:ExtractedEntity) -> list[tuple[Entity, float]]

Return persisted entities found by the shared vector-search route.

The GraphStore-native path's payload already carries the real node properties and is validated directly. The VectorStore path's payload only carries label and text (the embedding source text), so candidates are hydrated from the graph by hit id instead; a hit that fails to hydrate, for example a tombstoned or deleted node, is skipped rather than reconstructed from text.

Each candidate is paired with the cosine similarity of the VectorHit it came from. The association is keyed by hit id, never by position: either branch can drop an entity (malformed payload, label mismatch, failed hydration) without dropping the corresponding score, so zipping the two lists positionally would silently shift scores onto the wrong entities.

Returns:

  • list[tuple[Entity, float]] – (Entity, score) pairs in hit order. score is 0.0 for
  • list[tuple[Entity, float]] – an entity whose id is absent from the hit map, which should not
  • list[tuple[Entity, float]] – happen since candidate ids come from those same hits.

graph_store​

graph_store = graph_store

top_k​

top_k = top_k

vector_collection​

vector_collection = vector_collection

vector_store​

vector_store = vector_store