This repository is an official PyTorch implementation of MoR in Mixture of Structural-and-Textual Retrieval over Text-rich Graph Knowledge Bases
To set up the environment, you can install dependencies using Conda or pip:
conda env create -f mor_env.yml
conda activate your_env_name # Replace with actual environment namepip install -r requirements.txtBefore running the inference, please go to https://drive.google.com/drive/folders/1ldOYiyrIaZ3AVAKAmNeP0ZWfD3DLZu9D?usp=drive_link
(1) download the "checkpoints" and put it under the directory MoR/Planning/
(2) download the "data" and put it under the directory MoR/Reasoning/
(2) download the "model_checkpoint" and put it under the directory MoR/Reasoning/text_retrievers/
To run the inference script, execute the following command in the terminal:
bash eval_mor.shThis script will automatically process three datasets using the pre-trained planning graph generator and the pre-trained reranker.
bash train_planner.shStep2: Train mixed traversal to collect candidates (note: there is no training process for reasoning)
bash run_reasoning.shbash train_reranker.shWe provide codes to generate your own training data to finetune the Planner by using different LLMs.
python get_llm_data.py --model "model_name" \
--dataset_name "dataset_name" \
--azure_api_key "your_azure_key" \
--azure_endpoint "your_azure_endpoint" \
--azure_api_version "your_azure_version"
python get_llm_data.py --model "model_name" \
--dataset_name "dataset_name" \
--openai_api_key "your_openai_key" \
--openai_endpoint "your_openai_endpoint"