Skip to main content
Version: latest

agrag.ingestion.resolve.candidate_source.GraphCandidateSource

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

Bases: CandidateSource

Block by label in-batch. Search persisted entities globally with ANN.

Functions:

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 native vector search.

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 load) 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.

Raises:

  • Exception – The embedding, the vector search, or the graph read failed. An empty list means the search ran and found no candidate.

graph_store​

graph_store = graph_store

top_k​

top_k = top_k