Install E²GraphRAG dependencies
masterTo set up your environment for E²GraphRAG, install the required Python packages using the provided requirements.txt file.
pip install -r requirements.txtrepository·master·Indexed 41 days ago
https://github.com/yibozhao624/e-2graphragA lightweight, modular framework for Graph-based Retrieval-Augmented Generation (RAG) that utilizes structured graph reasoning. The pipeline manages text splitting, tree construction, graph extraction, and answer generation via a configurable YAML-based system. It supports datasets such as NovelQA and InfiniteBench and provides a resumable processing workflow via main.py.
To set up your environment for E²GraphRAG, install the required Python packages using the provided requirements.txt file.
pip install -r requirements.txtTo use the InfiniteBench dataset, you need two specific files: longbook_choice_eng.jsonl and longbook_qa_eng.jsonl.
You can obtain them in two ways:
./data/InfiniteBench directory.download.sh script located in the repository.The E²GraphRAG pipeline automates document tree construction, graph structure extraction, and answer generation. The entry point is main.py.
To run the pipeline, you must provide a YAML configuration file that defines the key parameters for the process.
Example configuration path: ./configs/example_config.yaml
python main.py --config <path_to_config_file>The NovelQA dataset is partially available via Hugging Face. To obtain the available portion, you must install the huggingface_hub library, log in via the CLI, and clone the repository. Note that some books in NovelQA are not publicly available; for the full dataset, you must contact the original authors of the NovelQA paper.
pip install huggingface_hub
huggingface-cli login
git clone https://huggingface.co/datasets/NovelQA/NovelQAThe complete pipeline (tree construction, graph extraction, and answer generation) is managed by main.py.
Before running, you must prepare a YAML configuration file to define your parameters. An example configuration can be found at ./configs/example_config.yaml.
python main.py --config <path_to_config_file>E²GraphRAG supports the following datasets:
Usage Note: After downloading your data, you must specify the data path when initializing the Dataloader class. Detailed instructions for data acquisition can be found in ./data/README.md.
The E²GraphRAG pipeline is executed by running main.py with a configuration file. The pipeline orchestrates text splitting, tree building, graph extraction, and Question Answering (QA) using a retrieved graph structure.
By default, the script looks for a config.yaml file. You can specify a different configuration file using the --config flag.
Workflow Overview:
dataset_name and dataset_path in the config.sequential or nn (newline) methods.build_tree_task and extract_graph_task in parallel using multiprocessing.Retriever to find relevant graph components and an LLM to generate answers or select multiple-choice options.python main.py --config your_config.yamlThe pipeline is designed to be resumable. If a crash occurs during dataset processing, you can skip the failed items by updating the resumeIndex in your configuration file.
Error Handling:
multiprocessing.set_start_method("spawn") to ensure safe parallel execution on CUDA devices.clean_cuda_memory and torch.cuda.empty_cache().The pipeline behavior is controlled by a YAML configuration file. Key sections include:
llm: Defines llm_path (model location) and llm_device (e.g., cuda:0).dataset: Specifies dataset_name (e.g., NovelQA, InfiniteChoice, InfiniteQALoader) and dataset_path.cluster: Controls text chunking with length, overlap, and merge_num.extractor: Defines the method and language for graph extraction.retriever: Contains kwargs passed to the Retriever class.paths: Defines cache_path for intermediate files and answer_path for results.resume: Uses resumeIndex to skip already processed items in a dataset.split_method: Options are sequential or nn.