How huiel/grag works
File structure
• Top-level scripts and orchestration:
• train.py / inference.py / run.sh
• requirements.txt / LICENSE.txt
• Data layer:
• dataset/ (raw TSVs & WebQSP data + preprocessing)
• src/dataset/ (data loaders, preprocess modules for expla_graphs and webqsp)
• Model layer:
• src/model/gnn.py (graph encoder / retrieval model)
• src/model/graph_llm.py (Graph-LLM integration)
• src/model/llm.py (vanilla LLM wrapper and LoRA fine-tuning)
• Utilities:
• src/utils/ (checkpointing, config parsing, collate functions, evaluation, split-generation, retrieval helpers, scheduling, seeding, text-to-graph conversion)
README for additional insights
• Describes two main stages:
• Reference figures: “intro.png” (motivation) and “flow.png” (pipeline).
Main components & relationships
a. Dataset & Preprocessing
• Raw data (expla_graphs.tsv, WebQSP JSON/TSV) → Preprocessing modules → Serialized graph+text pairs
b. Graph Retrieval Engine
c. Language Model Module
• Optionally LoRA adapter for fine-tuning
d. Training Orchestrator
• Batches from DataLoader → Forward through GNN retriever & LLM → Loss calculation → Optimizer & LR scheduler → Checkpointing
e. Inference Pipeline
• Query input → Graph Retrieval → LLM generation → Output answer
f. Supporting Utilities
• Configuration loader, checkpoint manager, evaluator, collate & sampler, seed management, training split generator
Architectural patterns / design principles
• Strict separation of concerns (dataset vs. model vs. utils)
• Modular pipeline stages (preprocess → retrieve → generate → evaluate)
• Pluggable LLM backends (frozen vs. fine-tuned via LoRA)
• Decoupled retrieval (GNN) and generation (LLM) components
Detail
• Every essential module (all src/dataset/*, src/model/*, src/utils/*)
• How train.py ties everything together via config files and run.sh
• Evaluation and checkpoint paths back into the storage layer