# How to Configure Multiple Document Parsers (MinerU, Docling, PaddleOCR) in RAG‑Anything

> Easily configure multiple document parsers like MinerU Docling and PaddleOCR in RAGAnything by setting the parser option or environment variable.

- Repository: [✨Data Intelligence Lab@HKU✨/RAG-Anything](https://github.com/HKUDS/RAG-Anything)
- Tags: how-to-guide
- Published: 2026-04-22

---

**Configure multiple document parsers in RAG‑Anything by setting the `parser` option in `RAGAnythingConfig` or the `PARSER` environment variable, with support for MinerU, Docling, and PaddleOCR.**

RAG‑Anything is an open‑source RAG framework that abstracts document parsing behind a unified interface. The `parser` configuration determines which backend extracts text, tables, and images from your documents. This guide covers global configuration, per‑document overrides, direct API usage, and custom parser registration based on the actual source code in `HKUDS/RAG‑Anything`.

## Global Parser Configuration

The parser selection flows through three layers: environment variables, configuration objects, and runtime state.

### Environment Variable Method

Set `PARSER` before launching your application:

```bash
export PARSER=docling
python -m raganything my_document.docx

```

The `RAGAnythingConfig` class reads this via `get_env_value` in [`raganything/config.py`](https://github.com/HKUDS/RAG-Anything/blob/main/raganything/config.py) at lines 28–31:

```python

# From raganything/config.py

class RAGAnythingConfig:
    parser: str = field(default_factory=lambda: get_env_value("PARSER", "mineru"))
    # ...

```

### Python Configuration Method

Instantiate `RAGAnythingConfig` directly for programmatic control:

```python
from raganything import RAGAnything, RAGAnythingConfig

config = RAGAnythingConfig(parser="paddleocr")
rag = RAGAnything(
    config=config,
    llm_model_func=your_llm,
    vision_model_func=your_vision,
    embedding_func=your_embedding
)

```

The `RAGAnything` class constructs the parser from `self.config.parser` at lines 118–131 in [`raganything/raganything.py`](https://github.com/HKUDS/RAG-Anything/blob/main/raganything/raganything.py):

```python

# From raganything/raganything.py

def _get_document_parser(self):
    from raganything.parser import get_parser
    return get_parser(self.config.parser)

```

## Per‑Document Parser Override

While `process_document_complete` does not accept a `parser` argument, you can temporarily mutate the configuration:

```python

# Global default: MinerU

rag = RAGAnything(config=RAGAnythingConfig(parser="mineru"), ...)

# Process PDF with MinerU

await rag.process_document_complete("paper.pdf")

# Override for Office document

rag.config.parser = "docling"
await rag.process_document_complete("contract.docx")

# Restore for remaining documents

rag.config.parser = "mineru"
await rag.process_document_complete("another.pdf")

```

This pattern is stateful—mutations persist until explicitly changed.

## Direct Low‑Level Parser API

For fine‑grained control with parser‑specific parameters, bypass the `RAGAnything` wrapper:

```python
from raganything.parser import get_parser

# PaddleOCR with custom language and GPU device

ocr = get_parser("paddleocr")
content = ocr.parse_document(
    file_path="receipt.jpg",
    method="ocr",
    lang="en",
    device="cuda:0",
    backend="pipeline"
)

```

The `get_parser` factory validates names against `SUPPORTED_PARSERS` and custom registrations at lines 2260–2270 in [`raganything/parser.py`](https://github.com/HKUDS/RAG-Anything/blob/main/raganything/parser.py):

```python

# From raganything/parser.py

SUPPORTED_PARSERS = ("mineru", "docling", "paddleocr")

def get_parser(name: str) -> Parser:
    if name in _CUSTOM_PARSERS:
        return _CUSTOM_PARSERS[name]()
    if name not in SUPPORTED_PARSERS:
        raise ValueError(f"Unknown parser: {name}")
    # ... instantiate built-in parser

```

## Installing Optional Parser Dependencies

| Parser | Installation Command | Additional Requirements |
|--------|----------------------|------------------------|
| **MinerU** (default) | `pip install raganything` | None—uses `mineru` CLI |
| **Docling** | `pip install raganything[docling]` or `pip install raganything[all]` | Requires **LibreOffice** for Office → PDF conversion |
| **PaddleOCR** | `pip install raganything[paddleocr]` or `uv sync --extra paddleocr` | Requires **paddlepaddle** (CPU or GPU build). See [paddlepaddle.org.cn/install/quick](https://www.paddlepaddle.org.cn/install/quick) |

Dependencies are declared in [`setup.py`](https://github.com/HKUDS/RAG-Anything/blob/main/setup.py) as optional extras. After installation, no additional configuration is needed—`get_parser` automatically discovers the new backend.

## Registering Custom Parsers

Extend RAG‑Anything with your own parser implementation:

```python
from raganything.parser import Parser, register_parser, get_parser

class SimpleTextParser(Parser):
    def parse_document(self, file_path, **kwargs):
        with open(file_path) as f:
            return [{"type": "text", "text": f.read()}]

# Register once per process

register_parser("simpletext", SimpleTextParser)

# Use like built-in parsers

rag.config.parser = "simpletext"
await rag.process_document_complete("notes.txt")

```

The registry is an in-process dictionary `_CUSTOM_PARSERS` defined at lines 2260–2270 in [`raganything/parser.py`](https://github.com/HKUDS/RAG-Anything/blob/main/raganything/parser.py). Registration is global and persists for the process lifetime.

## Summary

- **Global configuration**: Set `PARSER` environment variable or `RAGAnythingConfig(parser="...")` to choose MinerU, Docling, or PaddleOCR
- **Per-document override**: Mutate `rag.config.parser` before calling `process_document_complete`
- **Direct API access**: Use `get_parser(name)` for parser-specific parameters and custom kwargs
- **Dependency management**: Install optional extras with `pip install raganything[parsername]`; Docling requires LibreOffice, PaddleOCR requires paddlepaddle
- **Extensibility**: Register custom parsers via `register_parser(name, ParserClass)` for bespoke document processing

## Frequently Asked Questions

### Can I use different parsers for different documents in the same script?

Yes. Mutate `rag.config.parser` before each call to `process_document_complete`. The configuration is stateful, so remember to reset it for subsequent documents if needed.

### Why does Docling require LibreOffice?

Docling converts Office documents (DOCX, PPTX, XLSX) to PDF before parsing. This conversion relies on LibreOffice's headless mode. Install LibreOffice via your system package manager—see the RAG‑Anything offline setup documentation for distribution-specific commands.

### How do I verify which parsers are installed and available?

Call `list_parsers()` to see the built-in list, or attempt `get_parser(name)` which raises `ValueError` for invalid names. Successful instantiation confirms the parser's dependencies are installed.

### Can I pass GPU device settings to PaddleOCR?

Yes. When using the low-level API via `get_parser("paddleocr")`, pass `device="cuda:0"` (or your GPU identifier) to `parse_document`. The high-level `RAGAnything` interface does not expose device selection directly—use the low-level API for hardware-specific configuration.