The final stage of the Wikantik search pipeline (Phase 3) is a Graph-Aware Reranker (GraphRerankStep). While Phase 1 and 2 focus on textual and vector similarity, Phase 3 utilizes the topology of the Knowledge Graph to surface related content that might lack direct keyword or vector overlap.
The reranker operates on a simple but powerful intuition: "If a page mentions entities that are closely connected in the Knowledge Graph to the user's intent, that page is likely highly relevant."
The process begins by resolving query terms into a set of seed entity IDs (Q). The system then performs a multi-source Breadth-First Search (BFS) through the kg_edges adjacency map up to a maximum radius (H_{max}, typically 2).
The proximity score S_{prox} for a candidate page is determined by the maximum proximity of its mentioned entities:
The implementation is designed for high-performance and Graceful Degradation.
Candidate Anchoring: The input to the step is the fused list from Phase 2 (RRF). No pages are added or removed; the candidate set is fixed.
Bulk Loading: The PageMentionsLoader fetches all entity mentions for the entire candidate set (e.g., top 100 pages) in a single SQL round-trip using the ANY(?) operator.
Base Rank Scaling: To ensure the boost is proportional to the initial relevance, each page is assigned a base score derived from its fused rank: B(p) = 1.0 - (\text{rank} / N).
The Boost Calculation:
Stable Reordering: The list is re-sorted by the final score. Because the sort is stable, pages with equal proximity scores retain their relative RRF ordering.
The reranker is a "non-critical" enhancement. The GraphRerankStep is wrapped in a fail-closed logic:
kg_edges table is being rebuilt or exceeds memory caps, returns input list.See Also: