MCPcopy Index your code
hub / github.com/aiming-lab/MDocAgent

github.com/aiming-lab/MDocAgent @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
95 symbols 337 edges 23 files 2 documented · 2%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

MDocAgent

Overview

We propose MDocAgent, a novel multi-modal multi-agent framework for document question answering. It integrates text and image retrieval through five specialized agents — general, critical, text, image, and summarizing agents — enabling collaborative reasoning across modalities. Experiments on five benchmarks show a 12.1% improvement over state-of-the-art methods, demonstrating its effectiveness in handling complex real-world documents.

main_fig

Requirements

  1. Clone this repository and navigate to MDocAgent folder
git clone https://github.com/aiming-lab/MDocAgent.git
cd MDocAgent
  1. Install Package: Create conda environment
conda create -n mdocagent python=3.12
conda activate mdocagent
bash install.sh
  1. Data Preparation

  2. Create a data directory: bash mkdir data cd data

  3. Download the dataset from huggingface and place it in the data directory. The documents of PaperText are same as PaperTab. You can use symbol link or make a copy.

  4. Return to the project root: bash cd ../

  5. Extract the data using: bash python scripts/extract.py --config-name <dataset> # (choose from mmlb / ldu / ptab / ptext / feta) The extracted texts and images will be saved in tmp/<dataset>.

Retrieval

  • Text Retrieval

    Set the retrieval type to text in config/base.yaml: yaml defaults: - retrieval: text Then run: bash python scripts/retrieve.py --config-name <dataset>

  • Image Retrieval

    Switch the retrieval type to image in config/base.yaml: yaml defaults: - retrieval: image Run the retrieval process again: bash python scripts/retrieve.py --config-name <dataset>

The retrieval results will be stored in:

data/<dataset>/sample-with-retrieval-results.json

Multi-Agent Inference

Run the following command:

python scripts/predict.py --config-name <dataset> run-name=<run-name>

Note: <run-name> can be any string to uniquely identify this run (required).

The inference results will be saved to:

results/<dataset>/<run-name>/<run-time>.json

To specify the top-4 retrieval candidates, use:

python scripts/predict.py --config-name <dataset> run-name=<run-name> dataset.top_k=4

Evaluation

  1. Add your OpenAI API key in config/model/openai.yaml.

  2. Run the evaluation (make sure <run-name> matches your inference run): bash python scripts/eval.py --config-name <dataset> run-name=<run-name> The evaluation results will be saved in:

results/<dataset>/<run-name>/results.txt

Note: Evaluation will use the newest inference result file with same <run-name>.

Citation

@article{han2025mdocagent,
  title={MDocAgent: A Multi-Modal Multi-Agent Framework for Document Understanding},
  author={Han, Siwei and Xia, Peng and Zhang, Ruiyi and Sun, Tong and Li, Yun and Zhu, Hongtu and Yao, Huaxiu},
  journal={arXiv preprint arXiv:2503.13964},
  year={2025}
}

Core symbols most depended-on inside this repo

load_data
called by 7
mydatasets/base_dataset.py
load_processed_content
called by 4
mydatasets/base_dataset.py
clean_up
called by 4
models/base_model.py
predict
called by 4
agents/ablations.py
sum
called by 4
agents/multi_agent_system.py
predict_dataset
called by 4
agents/multi_agent_system.py
dump_data
called by 3
mydatasets/base_dataset.py
process_message
called by 3
models/base_model.py

Shape

Method 68
Class 16
Function 11

Languages

Python100%

Modules by API surface

mydatasets/base_dataset.py18 symbols
agents/base_agent.py9 symbols
agents/ablations.py9 symbols
models/qwen.py8 symbols
agents/multi_agent_system.py8 symbols
models/openai.py7 symbols
retrieval/image_retrieval.py6 symbols
models/base_model.py6 symbols
retrieval/text_retrieval.py5 symbols
models/llama.py5 symbols
retrieval/base_retrieval.py4 symbols
agents/mdoc_agent.py3 symbols

For agents

$ claude mcp add MDocAgent \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact