How boliupro/rag2-mp works
RAG²-MP predicts a user’s next grid location by combining retrieved historical mobility patterns, gravity-based spatial candidates, and LLM reasoning. The documented workflow runs from trajectory preprocessing and sample loading through prediction; separate preparation utilities build the retrieval index and fit gravity weights. The graph retains both standard and detailed evaluation entry points and shared spatial utilities. Relationships for unsampled implementation details are omitted; documented capability links use the README as evidence.
Main entry points: Predictor.py Mobility predictor · LLM.py LLM decision · mobility_process.py Trajectory preprocessing · dataset.py Sample loading
Components 17
Mobility data
- Trajectory preprocessing
raw_data/mobility_process.py - POI preprocessing
raw_data/poi_process.py - Sample loading
dataset/dataset.py
Knowledge preparation
- RAG index builder
util/build_rag_database.py - Retrieval index
util/rag_database - Gravity weight fitting
util/fit_gravity_weight.py - City gravity weights
util/gravity_weight
Prediction engine
- Mobility predictor
model/Predictor.py - Mobility retrieval
model/RAG.py - Gravity candidates
model/Gravity.py - LLM decision
model/LLM.py
Experiment workflows
- Train and evaluate
trainer/trainer.py - Detailed analysis
trainer/detailed_trainer.py - Experiment configuration
config/config.yaml
Shared spatial layer
- Spatial utilities
util/utils.py
Other components
- Trajectory data
- Next-location predictions
Connections 21
- Trajectory data → Trajectory preprocessing: supplies traces
README.md - Trajectory preprocessing → Sample loading: prepares trajectories
README.md - POI preprocessing → Gravity candidates: prepares POI data
- Sample loading → Train and evaluate: provides samples
README.md - Sample loading → Detailed analysis: provides samples
README.md - Trajectory preprocessing → RAG index builder: provides history
README.md - RAG index builder → LLM decision: generates embeddings
util/build_rag_database.py - RAG index builder → Retrieval index: writes index
util/build_rag_database.py - Gravity weight fitting → City gravity weights: fits weights
README.md - Mobility predictor → Mobility retrieval: initializes retrieval
model/Predictor.py - Mobility predictor → Gravity candidates: coordinates candidates
README.md - Mobility predictor → LLM decision: initializes decision
model/Predictor.py - Mobility retrieval → Retrieval index: queries index
README.md - Mobility retrieval → LLM decision: summarizes patterns
README.md - Gravity candidates → Spatial utilities: uses distances
model/Gravity.py - LLM decision → Next-location predictions: reasons next location
README.md - Train and evaluate → Mobility predictor: runs prediction
README.md - Detailed analysis → Mobility predictor: runs prediction
README.md - Train and evaluate → Experiment configuration: loads settings
README.md - Detailed analysis → Experiment configuration: loads settings
README.md - Spatial utilities → Mobility predictor: supports formatting
model/Predictor.py