DocPilot is a trainable interactive agent for multimodal long-document question answering. It is built around two core capabilities:
- π Evidence Seeking: Locate relevant evidence across documents, pages, and regions, and continue searching when evidence is insufficient.
- π§© Multimodal Understanding: Interpret text, tables, charts, figures, and layouts through fine-grained visual inspection and code-based reasoning.
The framework combines two components:
- Agent orchestration. A state-conditioned policy composes six document actions for adaptive evidence seeking, multimodal understanding, and iterative refinement.
- Curriculum-based agentic training. Compact models first learn individual document-solving abilities and then learn to coordinate those abilities from complete interaction trajectories.
Both WebUIs use the same backend and frontend. Install the project and demo dependencies from the repository root:
python -m pip install -e .
python -m pip install -r demo/chat/backend/requirements.txt
cd demo/chat/frontend
npm ci
cd ../../..Start both services from the repository root:
./demo/chat/start.sh- Agentic WebUI: open
http://127.0.0.1:5173. - Explainable WebUI: open
http://127.0.0.1:5173/flight.html. - Backend API: listens on
http://127.0.0.1:8008.
Configure the model provider, base URL, model name, and API key in the WebUI. Before uploading PDFs for preprocessing, complete the MinerU model setup described in Model Configuration below.
- Default agent runs the DocPilot pipeline and preprocesses uploaded PDFs with MinerU.
- Chat agent sends selected PDF pages, images, or text directly to a multimodal OpenAI-compatible model.
Runtime uploads, OCR output, workspace state, and conversation history remain local under demo/chat/backend/runs/ and demo/chat/workspace/. See the demo documentation for configuration details.
DocPilot-agentic-product.mp4
- This demo lets you upload documents, ask questions, and follow DocPilot's reasoning, tool execution, and source evidence in a chat interface.
- See demo/chat for setup, then run
./demo/chat/start.shand open the WebUI.
DocPilot-interaction-flight-product.mp4
- This demo visualizes DocPilot's evidence-seeking process as an animated flight across document pages, connecting agent actions to their supporting evidence.
- See Flight Lab in demo/chat for setup, then run
./demo/chat/start.shand open Flight Lab.
DocPilot represents each document through original page images, MinerU-derived structured elements, page thumbnails, and document overviews. Shared document and page identifiers connect these views for coarse-to-fine evidence access.
Six actions form a state-conditioned loop across three mechanisms:
| Mechanism | Action | Role |
|---|---|---|
| Evidence Seeking | Navigate |
Locate candidate pages from overviews and thumbnails. |
| Evidence Seeking | Extract |
Retrieve source-grounded text, table, and visual evidence. |
| Multimodal Understanding | Focus |
Crop, zoom, or isolate local visual regions. |
| Multimodal Understanding | Solve |
Execute code for aggregation, comparison, and numerical reasoning. |
| Iterative Refinement | Answer |
Generate a candidate answer from the evidence state. |
| Iterative Refinement | Analyze |
Verify grounding, identify gaps, and route the next action. |
Each observation updates the evidence state. Unsupported answers return to evidence seeking or multimodal reasoning.
DocAgent-Instruct-40K supports a two-stage curriculum:
- Single-ability fine-tuning learns individual document-solving capabilities from reasoning traces.
- Multi-ability agentic training learns their adaptive composition from complete interaction trajectories.
docpilot/
βββ app/
β βββ agent/ ReAct and trained-model agent implementations
β βββ tool/ Navigate, Extract, Focus, Solve, Answer, Analyze
β βββ workflow/ In-memory and MinerU-backed environments
β βββ prompt/ Action and role prompts
β βββ cli.py Inference and batch-QA entry point
β βββ llm.py OpenAI-compatible LLM client
β βββ schema.py State, evidence, observation, and answer schemas
β βββ vllm_protocol.py Parser for trained action-tag outputs
βββ pipelines/
β βββ document/ Indexing, MinerU execution, and page-object export
β βββ training/ Trace conversion and training-data utilities
βββ configs/
β βββ docpilot.example.yaml JSON-action agent configuration
β βββ docpilot-vllm.yaml Trained action-tag model configuration
β βββ document.example.yaml Document preprocessing configuration
βββ demo/chat/ React + FastAPI document-analysis interface
βββ assets/ README figures and a small example document graph
βββ pyproject.toml
βββ requirements.txt
DocPilot requires Python 3.11 or newer.
python -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -e .The core installation includes MinerU for document preprocessing. If only the preprocessed-document agent is needed, install the dependencies appropriate for that runtime from requirements.txt.
The main CLI reads model settings from YAML. Copy one of the example configurations and fill in the endpoint, key, and model name for your deployment:
llm:
provider: openai
protocol: json
model: YOUR_MODEL
base_url: YOUR_OPENAI_COMPATIBLE_BASE_URL
api_key: YOUR_API_KEYconfigs/docpilot.example.yamluses structured JSON actions with an OpenAI-compatible model.configs/docpilot-vllm.yamluses the action-tag protocol emitted by a trained DocPilot model served through vLLM.app/llm/.envcontains official provider endpoints for the provider-specific helper modules; every credential value is empty.
Before preprocessing documents or starting the interactive demo, download and verify the MinerU models for your runtime.
For a CUDA GPU (recommended):
mineru-kit models download \
--tier standard \
--small-backend torch \
--vlm-engine vllm \
--source modelscope \
--verbose
mineru-kit models verify \
--tier standard \
--small-backend torch \
--vlm-engine vllmFor CPU-only environments:
mineru-kit models download \
--tier standard \
--small-backend onnx \
--vlm-engine llama-cpp \
--source modelscope \
--verbose
mineru-kit models verify \
--tier standard \
--small-backend onnx \
--vlm-engine llama-cppThe models are cached under ~/.mineru/models/ and reused by subsequent runs
After configuring a model endpoint:
python -m app \
--config configs/docpilot.example.yaml \
--nodes-json assets/sample_nodes.json \
--question "What was the company's FY2015 revenue?" \
--show-stateSet the dataset paths in configs/document.example.yaml, then run:
python -m pipelines.document \
--config configs/document.example.yaml \
run --stages index,mineru-manifest,mineru-run,page-objectsThe available stages are:
python -m pipelines.document list-stagespython -m app \
--config configs/docpilot.example.yaml \
--mineru-dir runs/environment/mineru/DATASET/DOC_ID \
--question "Your document question" \
--show-statepython -m app \
--config configs/docpilot.example.yaml \
--question-file /path/to/questions.jsonl \
--max-samples 10 \
--num-workers 1By default, agent logs, result files, and temporary visual evidence are written under runs/logs/, runs/outputs/, and runs/.workspace/.
- Training Framework: ms-swift
- Sources of Training Data:
- Single-ability: DocSeeker, HotpotQA, FinQA, ChartQAPro, and InfographicVQA
- Multi-ability: LongDocURL, DUDE, MADQA, and MMDocRAG
If you find this repository useful, please cite:
@article{liang2026docpilot,
title={DocPilot: Interactive Agent Orchestration and Training for Long Visual Document Understanding},
author={Liang, Zhuowen and Lin, Xiaotian and Luo, Yuyu and Wang, Haixun and Tang, Nan},
journal={arXiv preprint arXiv:2610.21327},
year={2026}
}


