Per-hop query refinement for the retrieval pipeline.
Tracks retrieval quality across hops and triggers LLM-based tag refinement when score improvement plateaus. Budget-limited to avoid excessive LLM calls.
Summary
Functions
Initializes refinement state from config and the pipeline's max hop count.
Budget is capped at max_hops to avoid exceeding the traversal depth.
Conditionally refines retrieval tags based on score plateau detection.
Functions
@spec init(Mnemosyne.Config.t(), non_neg_integer()) :: Mnemosyne.Pipeline.HopRefinement.State.t()
Initializes refinement state from config and the pipeline's max hop count.
Budget is capped at max_hops to avoid exceeding the traversal depth.
@spec maybe_refine( Mnemosyne.Pipeline.HopRefinement.State.t(), String.t(), [Mnemosyne.Pipeline.Retrieval.TaggedCandidate.t()], non_neg_integer(), map() ) :: {:refined, [String.t()], [[float()]], Mnemosyne.Pipeline.HopRefinement.State.t()} | {:skip, Mnemosyne.Pipeline.HopRefinement.State.t()}
Conditionally refines retrieval tags based on score plateau detection.
Returns {:refined, tags, vectors, new_state} when refinement is triggered
and succeeds, or {:skip, new_state} otherwise.
The ctx map must contain :llm, :embedding, :config, and :llm_opts.