This section walks you through running ExpertLoop end-to-end with minimal setup.
git clone https://github.com/UAVLab-SLU/flight_log_knowledge_graph.git
cd flight_log_knowledge_graphExpertLoop uses a Python virtual environment to ensure dependency isolation.
macOS / Linux
python3 -m venv venv
source venv/bin/activateWindows (PowerShell)
python3 -m venv venv
venv\Scripts\ActivateWith the virtual environment activated:
pip install --upgrade pip
pip install -r requirements.txtExpertLoop relies on an external LLM for knowledge extraction and generation.
Set your API key as an environment variable:
macOS / Linux
export GEMINI_API_KEY="your_api_key_here"Windows (PowerShell)
export GEMINI_API_KEY="your_api_key_here"Or manually add API key to your .env file with the key GEMINI_API_KEY
Place PX4 forum thread data in the project root or data/ directory.
The pipeline expects forum threads in JSON format. Example files already included:
px4_threads.json
px4_posts.json
If you are adding your own data, ensure the structure follows the same schema used in px4_threads.json and px4_posts.json.
Run the knowledge graph construction pipeline using the provided scripts.
Step 6.1 — Merge Threads and Posts
python merge_threads_and_posts.pyThis produces merged thread representations used for knowledge extraction.
Step 6.2 — Run LLM-Assisted Knowledge Graph Extraction
python LLM-assisted-KG.pyThis step:
- Extracts entities and relations using the LLM
- Builds thread-level knowledge graphs
- Outputs intermediate graph files
python graph_linker.pyOutputs are written to:
output/
├── thread_graphs.json
├── thread_graphs_linked.json
├── all_threads_graphs.json
├── all_threads_graphs_linked.json
├── merged_threads.json
├── knowledge_graph.graphml
These files represent:
- Individual thread subgraphs
- Linked graphs across related threads
- A merged global view (optional)
ExpertLoop’s RAG pipeline lives in the rag_engine/ directory.
Example Query Execution
python rag_engine/rag_pipeline.py \
--query "Drone flips immediately on takeoff"The pipeline will:
- Retrieve relevant thread-level graphs
- Build structured context using prompt_builder.py
- Generate a grounded response via the LLM
Core RAG components:
- rag_engine/retriever.py
- rag_engine/prompt_builder.py
- rag_engine/embedded.py
Evaluation scripts and datasets live in rag_eval/ and eval/.
To run RAG evaluation:
python eval/evaluate_rag.pyEvaluation artifacts (scores, plots, summaries) are saved in:
rag_eval/data/gemini_eval/Including:
- metrics_summary.csv
- eval_results.json
- avg_scores.png
- pass_rates.png