This guide explains how to prepare a Wikipedia corpus for use with the Agentic-RAG system. Follow the steps below to download, extract, index, and (optionally) merge your corpus. You may refer to requirements.txt for environments building the corpus.
Download the English Wikipedia dump (We recommend the June 2021 version):
wget https://archive.org/download/enwiki-20210620/enwiki-20210620-pages-articles.xml.bz2Use the provided extract_wiki.py script to extract the dump into a directory (default: temp). This script uses WikiExtractor, which must be installed and available in your Python environment.
python extract_wiki.py --dump_path enwiki-20210620-pages-articles.xml.bz2 --output_dir temp --num_workers 8--dump_path: Path to the downloaded.bz2file--output_dir: Directory to store extracted files (default:temp)--num_workers: Number of parallel processes (adjust as needed)
Run the build_e5_corpus.py script to process the extracted files and build the E5 vector index. You can run this on the full corpus or in parallel splits.
python build_e5_corpus.py --data_dir temp --output_dir wikipedia_e5_index--data_dir: Directory with extracted wiki files (from step 2)--output_dir: Output directory for the E5 index
To process the corpus in parallel, specify --split_id and --total_splits (run one process per split):
python build_e5_corpus.py --data_dir temp --output_dir wikipedia_e5_index --split_id 0 --total_splits 4
python build_e5_corpus.py --data_dir temp --output_dir wikipedia_e5_index --split_id 1 --total_splits 4
python build_e5_corpus.py --data_dir temp --output_dir wikipedia_e5_index --split_id 2 --total_splits 4
python build_e5_corpus.py --data_dir temp --output_dir wikipedia_e5_index --split_id 3 --total_splits 4If you built the index in splits, merge them into a single index using merge_e5_splits.py:
python merge_e5_splits.py --output_dir wikipedia_e5_index --total_splits 4- The merged index will be saved in
wikipedia_e5_index/merged/
After building your corpus and index, you can run inference using main.py.
python main.py \
--retriever-type e5 \
--retriever-index-path wikipedia_e5_index/merged \
--e5-model-path /path/to/e5-large-v2 \
--reasoner-model Qwen/Qwen3-32B \
--summarizer-model Qwen/Qwen3-32B \
--dataset hotpotqa \
--output-dir output/search_e5- Adjust
--retriever-typeto shift to bm25 or other retrieval methods - Adjust
--retriever-index-pathto your merged E5 index directory - Set
--e5-model-pathto your E5 model location
- Use
--max-samplesto limit the number of questions processed - Use
--max-turnsto control the number of reasoning turns - Use
--save-intermediateto save intermediate results
See all options with:
python main.py --helpOptional, if need to run the pipeline easier, you can modify and run the bash file in the terminal by:
./test.sh