The code is written in Python 3.8. Before running, you need to first install the required packages by typing following commands (Using a virtual environment is recommended):
conda create --name mora python==3.8
conda activate mora
pip3 install -r requirements.txt
You can access the datasets in MoRA/Dataset
Datasets:
MMLU_College_Physics.jsonMMLU_High_School_Physics.jsonPhysicsQA.jsonSciEval_Static_Physics.json
MoRA implementation can be found in MoRA/agent
Python Files:
agent.py: Contains theMoRAagent classprompts.py: Contains all the error identification & refinement promptsutils.py: Contains utilities functions for using GraphRAGmain.py: Containsevaluate()function for running MoRA on datasets
Download the GRAPH_RAG folder which contains Topic wise KBs from here: Google Drive
Replace empty MoRA/GRAPH_RAG folder with the downloaded one.
Using GraphRAG, local search is performed on these KBs to obtain conceptual contexts.
Steps:
-
Add your
TOGETHER_API_KEY&OPENAI_API_KEYinmain.py -
Add your
GRAPHRAG_API_KEYinutils.py, it's same as yourOPENAI_API_KEY -
Add
modelinmain.pyas base LLM:Llama-3-70B: "meta-llama/Llama-3-70b-chat-hf"Gemma-2-27B: " google/gemma-2-27b-it"
You can select any other LLM as well, refer to for model path: TogetherAI
-
Add
llm_modelinmain.pyas error identifier, for our experiments we used:gpt-4o -
Run
main.pywith following args: -
dataset_filename: The name of the dataset file to test, examplePhysicsQA.json, make sure dataset containsresponsefor each questions that needs to be refined. RunCoTinference first on the dataset (see the next section) and use that filename and path. -
max_steps: The maximum number of iteration steps for refinement -
graph_rag_dir: Directory path for GRAPH_RAG data -
dataset_dir: Directory path for datasets, should includeresponsefor each question that needs to be refined. -
result_dir: Directory path for saving results
Example:
python main.py PhysicsQA.json --max_steps 5 --graph_rag_dir 'MoRA/GRAPH_RAG' --dataset_dir 'MoRA/Dataset' --result_dir 'MoRA/Results'