This module adds a multi-hop retrieval agent to CognitiveRAG. The agent:
03_embedding/multihop_agent.py03_embedding/run_multihop_agent.pyrun_pipeline.py03_embedding/output/multihop_traces/03_embedding/output/multihop_artifacts/run_pipeline.py now runs the multi-hop agent by default. To run the legacy single-hop flow, use --single-hop.
Example:
python run_pipeline.py --strategy hybrid
Legacy single-hop:
python run_pipeline.py --strategy dense --single-hop
python 03_embedding/run_multihop_agent.py \
--query "What written claims made by Theranos executives were later contradicted by courtroom testimony?" \
--strategy hybrid \
--max-hops 3 \
--per-hop-top-k 8 \
--total-doc-budget 24 \
--sufficiency-threshold 0.75 \
--time-limit-sec 60
The agent uses the same backends as the rest of the pipeline:
NVIDIA_API_KEYIf you already run run_pipeline.py, your env is already set up.
Each run produces a trace JSON:
03_embedding/output/multihop_traces/multihop_trace_YYYYMMDD_HHMMSS_<id>.jsonThe trace includes:
The agent is configured via MultiHopConfig:
max_hops: Maximum hopsper_hop_top_k: Documents per hoptotal_doc_budget: Overall retrieval budgetsufficiency_threshold: Combined sufficiency thresholdtime_limit_sec: Hard time limit per querystrategy: dense, sparse, or hybridExample inputs and trace samples are stored here:
03_embedding/output/multihop_artifacts/sample_queries.json03_embedding/output/multihop_artifacts/trace_example.json03_embedding/output/multihop_artifacts/early_termination_example.json03_embedding/output/multihop_artifacts/failure_example.json