Parser Configuration#
The Parser component in RAGFlow's DSL chunker pipeline parses raw files into structured sections before downstream chunking. Its behavior is controlled by a ParserParam object whose defaults can be selectively overridden by the pipeline DSL configuration via param.update().
Key Files#
| File | Purpose |
|---|---|
rag/flow/parser/parser.py | ParserParam defaults, Parser dispatch logic, all file-type handlers |
rag/flow/base.py | ProcessParamBase (thin wrapper over ComponentParamBase) |
agent/component/base.py | ComponentParamBase.update() and all check_* validation helpers |
agent/canvas.py | Canvas loading: creates ParserParam, calls param.update() then param.check() |
rag/flow/tests/dsl_examples/general_pdf_all.json | Reference DSL with a fully configured Parser node |
ParserParam Structure#
ParserParam.__init__() defines two top-level dicts :
setups— per-file-type config dictionaries (one key per supported type:pdf,spreadsheet,doc,docx,markdown,text&code,html,slides,image,email,audio,video,epub)allowed_output_format— per-type lists of validoutput_formatvalues used exclusively during validation
Each entry in setups contains fields like:
| Field | Types that use it | Notes |
|---|---|---|
parse_method | pdf, spreadsheet, slides, image | Selects parsing backend |
output_format | All types | Constrained by allowed_output_format |
suffix | All types | File extensions that route to this handler |
lang | pdf, image | Language hint for OCR / VLM |
flatten_media_to_text | pdf, spreadsheet, docx, markdown | Treats images/tables as plain text |
remove_toc | pdf, doc, docx, markdown, html | Strips table-of-contents entries |
remove_header_footer | pdf, docx, html | Strips header/footer blocks |
vlm | pdf, docx, markdown | Optional VLM config for media sections |
DSL Override via param.update()#
When the canvas loads a pipeline, it runs this sequence for every component :
param = ParserParam() # creates defaults
param.update(dsl["params"]) # merges DSL overrides
param.check() # validates constraints
Parser(canvas, id, param) # instantiates component
ComponentParamBase.update() performs a recursive merge : it walks the DSL dict and, for each key, either sets the attribute directly (builtins and None) or recurses into the sub-object. Because setups is a plain dict (a builtin type), the entire setups value from the DSL replaces the default setups rather than merging individual file-type entries. A file type omitted from the DSL's setups will therefore lose its defaults entirely — include all file-type configs you need.
A minimal DSL override enabling a VLM method for PDF:
{
"setups": {
"pdf": {
"parse_method": "gpt-4o@openai",
"lang": "English",
"output_format": "json"
}
}
}
See general_pdf_all.json for a complete multi-type example.
Validation Constraints (param.check())#
ParserParam.check() validates each present file-type config . The main constraints are:
PDF (setups["pdf"])
parse_methodmust not be empty- If
parse_methodis not one ofdeepdoc,plain_text,mineru,docling,opendataloader,tcadp parser,paddleocr,somark, it is treated as a VLM model name andlangmust be non-empty output_formatmust be in["json", "markdown"]
Spreadsheet — output_format ∈ ["json", "markdown", "html"]
Doc / DOCX — output_format ∈ ["json", "markdown"]
Slides — output_format must be "json"
Image — if parse_method is not "ocr", lang must be non-empty
Audio / Video — vlm.llm_id must be non-empty
Email — output_format ∈ ["text", "json"]
EPUB — output_format ∈ ["text", "json"]
Validation helpers (check_empty, check_valid_value) are inherited from ComponentParamBase and raise ValueError on failure; Canvas.load() wraps this in a ValueError with the component name for clear error attribution .
Parse Method Selection (PDF)#
The PDF handler normalises parse_method at runtime :
| Method value | Backend |
|---|---|
deepdoc | RAGFlowPdfParser (layout-aware bbox extraction) |
plain_text | PlainParser (text lines only) |
mineru | MinerU OCR model via LLMBundle |
docling | DoclingParser |
opendataloader | OpenDataLoader OCR model |
tcadp parser | Tencent Cloud ADP (TCADPParser) |
paddleocr | PaddleOCR model via LLMBundle |
somark | SoMark model via LLMBundle |
<model_name>@<provider> | VLM image-to-text via VisionParser |
Suffix-based routing in _invoke() matches a file's extension against each setups[type]["suffix"] list and dispatches to the first matching handler .