How icamd/karpa works
KARPA takes KGQA questions and topic entities, asks an LLM to plan relevant relation paths, retrieves and ranks graph paths using either heuristic-value or pathfinding retrieval, then produces answers and evaluates predictions. The README documents both retrieval variants and automatic evaluation. Sampled code supports the main drivers’ LLM, graph-helper, and evaluation relationships; the detailed internal stages of unsampled code are represented at subsystem level rather than inferred. The repository also includes a separate CoT/IO prompting workflow.
Main entry points: KARPA_H.py Heuristic Retrieval · KARPA_D.py Pathfinding Retrieval · cot.py CoT Runner · data QA Datasets
Components 15
KARPA Reasoning
- Heuristic Retrieval
KARPA/KARPA_H.py - Pathfinding Retrieval
KARPA/KARPA_D.py - Relation Prompts
KARPA/prompt_list.py
Knowledge Graph Access
- Graph Helpers
KARPA/freebase_func.py - Wikidata Client
KARPA/client.py
Shared Services
- QA Datasets
data - Runtime Utilities
KARPA/utils.py - Prediction Evaluation
KARPA/evaluate_results.py - Predictions
predictions
CoT Baseline
- CoT Runner
CoT/cot.py - CoT/IO Prompts
CoT/prompt_list.py - CoT Utilities
CoT/utils.py
Other components
- Questioner
- Freebase SPARQL
- LLM Service
Connections 22
- Questioner → Heuristic Retrieval: submits question
README.md - Questioner → Pathfinding Retrieval: submits question
README.md - QA Datasets → Heuristic Retrieval: loads questions
- QA Datasets → Pathfinding Retrieval: loads questions
- Heuristic Retrieval → Relation Prompts: uses prompts
KARPA/KARPA_H.py - Pathfinding Retrieval → Relation Prompts: uses prompts
KARPA/KARPA_D.py - Heuristic Retrieval → Graph Helpers: calls helpers
KARPA/KARPA_H.py - Pathfinding Retrieval → Graph Helpers: calls helpers
KARPA/KARPA_D.py - Graph Helpers → Freebase SPARQL: queries graph
KARPA/freebase_func.py - Heuristic Retrieval → LLM Service: requests completions
KARPA/KARPA_H.py - Pathfinding Retrieval → LLM Service: requests completions
KARPA/KARPA_D.py - Heuristic Retrieval → Runtime Utilities: imports utilities
KARPA/KARPA_H.py - Pathfinding Retrieval → Runtime Utilities: imports utilities
KARPA/KARPA_D.py - Heuristic Retrieval → Prediction Evaluation: evaluates results
KARPA/KARPA_H.py - Pathfinding Retrieval → Prediction Evaluation: evaluates results
KARPA/KARPA_D.py - Heuristic Retrieval → Predictions: writes predictions
README.md - Pathfinding Retrieval → Predictions: writes predictions
README.md - Questioner → CoT Runner: runs baseline
- CoT Runner → QA Datasets: loads questions
- CoT Runner → CoT/IO Prompts: selects prompts
CoT/cot.py - CoT Runner → CoT Utilities: calls utilities
CoT/cot.py - CoT Utilities → LLM Service: requests completion
CoT/utils.py