HKUDS/RAG-Anything
๐ News
- [2025.08.12]๐ฏ๐ข ๐ RAG-Anything now features VLM-Enhanced Query mode! When documents include images, the system seamlessly integrates them into VLM for advanced multimodal analysis, combining visual and textual context for deeper insights.
- [2025.07.05]๐ฏ๐ข RAG-Anything now features a context configuration module, enabling intelligent integration of relevant contextual information to enhance multimodal content processing.
- [2025.07.04]๐ฏ๐ข ๐ RAG-Anything now supports multimodal query capabilities, enabling enhanced RAG with seamless processing of text, images, tables, and equations.
- [2025.07.03]๐ฏ๐ข ๐ RAG-Anything has reached 1k๐ stars on GitHub! Thank you for your incredible support and valuable contributions to the project.
๐ System Overview
Next-Generation Multimodal Intelligence
Modern documents increasingly contain diverse multimodal contentโtext, images, tables, equations, charts, and multimediaโthat traditional text-focused RAG systems cannot effectively process. RAG-Anything addresses this challenge as a comprehensive All-in-One Multimodal Document Processing RAG system built on LightRAG.
As a unified solution, RAG-Anything eliminates the need for multiple specialized tools. It provides seamless processing and querying across all content modalities within a single integrated framework. Unlike conventional RAG approaches that struggle with non-textual elements, our all-in-one system delivers comprehensive multimodal retrieval capabilities.
Users can query documents containing interleaved text, visual diagrams, structured tables, and mathematical formulations through one cohesive interface. This consolidated approach makes RAG-Anything particularly valuable for academic research, technical documentation, financial reports, and enterprise knowledge management where rich, mixed-content documents demand a unified processing framework.
๐ฏ Key Features
- ๐ End-to-End Multimodal Pipeline - Complete workflow from document ingestion and parsing to intelligent multimodal query answering
- ๐ Universal Document Support - Seamless processing of PDFs, Office documents, images, and diverse file formats
- ๐ง Specialized Content Analysis - Dedicated processors for images, tables, mathematical equations, and heterogeneous content types
- ๐ Multimodal Knowledge Graph - Automatic entity extraction and cross-modal relationship discovery for enhanced understanding
- โก Adaptive Processing Modes - Flexible MinerU-based parsing or direct multimodal content injection workflows
- ๐ Direct Content List Insertion - Bypass document parsing by directly inserting pre-parsed content lists from external sources
- ๐ฏ Hybrid Intelligent Retrieval - Advanced search capabilities spanning textual and multimodal content with contextual understanding
๐๏ธ Algorithm & Architecture
Core Algorithm
RAG-Anything implements an effective multi-stage multimodal pipeline that fundamentally extends traditional RAG architectures to seamlessly handle diverse content modalities through intelligent orchestration and cross-modal understanding.
1. Document Parsing Stage
The system provides high-fidelity document extraction through adaptive content decomposition. It intelligently segments heterogeneous elements while preserving contextual relationships. Universal format compatibility is achieved via specialized optimized parsers.
Key Components:
-
โ๏ธ MinerU Integration: Leverages MinerU for high-fidelity document structure extraction and semantic preservation across complex layouts.
-
๐งฉ Adaptive Content Decomposition: Automatically segments documents into coherent text blocks, visual elements, structured tables, mathematical equations, and specialized content types while preserving contextual relationships.
-
๐ Universal Format Support: Provides comprehensive handling of PDFs, Office documents (DOC/DOCX/PPT/PPTX/XLS/XLSX), images, and emerging formats through specialized parsers with format-specific optimization.
2. Multi-Modal Content Understanding & Processing
The system automatically categorizes and routes content through optimized channels. It uses concurrent pipelines for parallel text and multimodal processing. Document hierarchy and relationships are preserved during transformation.
Key Components:
-
๐ฏ Autonomous Content Categorization and Routing: Automatically identify, categorize, and route different content types through optimized execution channels.
-
โก Concurrent Multi-Pipeline Architecture: Implements concurrent execution of textual and multimodal content through dedicated processing pipelines. This approach maximizes throughput efficiency while preserving content integrity.
-
๐๏ธ Document Hierarchy Extraction: Extracts and preserves original document hierarchy and inter-element relationships during content transformation.
3. Multimodal Analysis Engine
The system deploys modality-aware processing units for heterogeneous data modalities:
Specialized Analyzers:
-
๐ Visual Content Analyzer:
- Integrate vision model for image analysis.
- Generates context-aware descriptive captions based on visual semantics.
- Extracts spatial relationships and hierarchical structures between visual elements.
-
๐ Structured Data Interpreter:
- Performs systematic interpretation of tabular and structured data formats.
- Implements statistical pattern recognition algorithms for data trend analysis.
- Identifies semantic relationships and dependencies across multiple tabular datasets.
-
๐ Mathematical Expression Parser:
- Parses complex mathematical expressions and formulas with high accuracy.
- Provides native LaTeX format support for seamless integration with academic workflows.
- Establishes conceptual mappings between mathematical equations and domain-specific knowledge bases.
-
๐ง Extensible Modality Handler:
- Provides configurable processing framework for custom and emerging content types.
- Enables dynamic integration of new modality processors through plugin architecture.
- Supports runtime configuration of processing pipelines for specialized use cases.
4. Multimodal Knowledge Graph Index
The multi-modal knowledge graph construction module transforms document content into structured semantic representations. It extracts multimodal entities, establishes cross-modal relationships, and preserves hierarchical organization. The system applies weighted relevance scoring for optimized knowledge retrieval.
Core Functions:
-
๐ Multi-Modal Entity Extraction: Transforms significant multimodal elements into structured knowledge graph entities. The process includes semantic annotations and metadata preservation.
-
๐ Cross-Modal Relationship Mapping: Establishes semantic connections and dependencies between textual entities and multimodal components. This is achieved through automated relationship inference algorithms.
-
๐๏ธ Hierarchical Structure Preservation: Maintains original document organization through “belongs_to” relationship chains. These chains preserve logical content hierarchy and sectional dependencies.
-
โ๏ธ Weighted Relationship Scoring: Assigns quantitative relevance scores to relationship types. Scoring is based on semantic proximity and contextual significance within the document structure.
5. Modality-Aware Retrieval
The hybrid retrieval system combines vector similarity search with graph traversal algorithms for comprehensive content retrieval. It implements modality-aware ranking mechanisms and maintains relational coherence between retrieved elements to ensure contextually integrated information delivery.
Retrieval Mechanisms:
-
๐ Vector-Graph Fusion: Integrates vector similarity search with graph traversal algorithms. This approach leverages both semantic embeddings and structural relationships for comprehensive content retrieval.
-
๐ Modality-Aware Ranking: Implements adaptive scoring mechanisms that weight retrieval results based on content type relevance. The system adjusts rankings according to query-specific modality preferences.
-
๐ Relational Coherence Maintenance: Maintains semantic and structural relationships between retrieved elements. This ensures coherent information delivery and contextual integrity.
๐ Quick Start
Initialize Your AI Journey
Installation
Option 1: Install from PyPI (Recommended)
|
|
Option 2: Install from Source
|
|
Optional Dependencies
[image]- Enables processing of BMP, TIFF, GIF, WebP image formats (requires Pillow)[text]- Enables processing of TXT and MD files (requires ReportLab)[all]- Includes all Python optional dependencies
โ ๏ธ Office Document Processing Requirements:
- Office documents (.doc, .docx, .ppt, .pptx, .xls, .xlsx) require LibreOffice installation
- Download from LibreOffice official website
- Windows: Download installer from official website
- macOS:
brew install --cask libreoffice- Ubuntu/Debian:
sudo apt-get install libreoffice- CentOS/RHEL:
sudo yum install libreoffice
Check MinerU installation:
|
|
Models are downloaded automatically on first use. For manual download, refer to MinerU Model Source Configuration.
Usage Examples
1. End-to-End Document Processing
|
|
2. Direct Multimodal Content Processing
|
|
3. Batch Processing
|
|
4. Custom Modal Processors
|
|
5. Query Options
RAG-Anything provides three types of query methods:
Pure Text Queries - Direct knowledge base search using LightRAG:
|
|
VLM Enhanced Queries - Automatically analyze images in retrieved context using VLM:
|
|
Multimodal Queries - Enhanced queries with specific multimodal content analysis:
|
|
6. Loading Existing LightRAG Instance
|
|
7. Direct Content List Insertion
For scenarios where you already have a pre-parsed content list (e.g., from external parsers or previous processing), you can directly insert it into RAGAnything without document parsing:
|
|
Content List Format:
The content_list should follow the standard format with each item being a dictionary containing:
- Text content:
{"type": "text", "text": "content text", "page_idx": 0} - Image content:
{"type": "image", "img_path": "/absolute/path/to/image.jpg", "image_caption": ["caption"], "image_footnote": ["note"], "page_idx": 1} - Table content:
{"type": "table", "table_body": "markdown table", "table_caption": ["caption"], "table_footnote": ["note"], "page_idx": 2} - Equation content:
{"type": "equation", "latex": "LaTeX formula", "text": "description", "page_idx": 3} - Generic content:
{"type": "custom_type", "content": "any content", "page_idx": 4}
Important Notes:
img_path: Must be an absolute path to the image file (e.g.,/home/user/images/chart.jpgorC:\Users\user\images\chart.jpg)page_idx: Represents the page number where the content appears in the original document (0-based indexing)- Content ordering: Items are processed in the order they appear in the list
This method is particularly useful when:
- You have content from external parsers (non-MinerU/Docling)
- You want to process programmatically generated content
- You need to insert content from multiple sources into a single knowledge base
- You have cached parsing results that you want to reuse
๐ ๏ธ Examples
Practical Implementation Demos
The examples/ directory contains comprehensive usage examples:
raganything_example.py: End-to-end document processing with MinerUmodalprocessors_example.py: Direct multimodal content processingoffice_document_test.py: Office document parsing test with MinerU (no API key required)image_format_test.py: Image format parsing test with MinerU (no API key required)text_format_test.py: Text format parsing test with MinerU (no API key required)
Run examples:
|
|
๐ง Configuration
System Optimization Parameters
Environment Variables
Create a .env file (refer to .env.example):
|
|
Note: For backward compatibility, legacy environment variable names are still supported:
MINERU_PARSE_METHODis deprecated, please usePARSE_METHOD
Note: API keys are only required for full RAG processing with LLM integration. The parsing test files (
office_document_test.pyandimage_format_test.py) only test parser functionality and do not require API keys.
Parser Configuration
RAGAnything now supports multiple parsers, each with specific advantages:
MinerU Parser
- Supports PDF, images, Office documents, and more formats
- Powerful OCR and table extraction capabilities
- GPU acceleration support
Docling Parser
- Optimized for Office documents and HTML files
- Better document structure preservation
- Native support for multiple Office formats
MinerU Configuration
|
|
You can also configure parsing through RAGAnything parameters:
|
|
Note: MinerU 2.0 no longer uses the
magic-pdf.jsonconfiguration file. All settings are now passed as command-line parameters or function arguments. RAG-Anything now supports multiple document parsers - you can choose between MinerU and Docling based on your needs.
Processing Requirements
Different content types require specific optional dependencies:
- Office Documents (.doc, .docx, .ppt, .pptx, .xls, .xlsx): Install LibreOffice
- Extended Image Formats (.bmp, .tiff, .gif, .webp): Install with
pip install raganything[image] - Text Files (.txt, .md): Install with
pip install raganything[text]
๐ Quick Install: Use
pip install raganything[all]to enable all format support (Python dependencies only - LibreOffice still needs separate installation)
๐งช Supported Content Types
Document Formats
- PDFs - Research papers, reports, presentations
- Office Documents - DOC, DOCX, PPT, PPTX, XLS, XLSX
- Images - JPG, PNG, BMP, TIFF, GIF, WebP
- Text Files - TXT, MD
Multimodal Elements
- Images - Photographs, diagrams, charts, screenshots
- Tables - Data tables, comparison charts, statistical summaries
- Equations - Mathematical formulas in LaTeX format
- Generic Content - Custom content types via extensible processors
For installation of format-specific dependencies, see the Configuration section.
๐ Citation
Academic Reference
If you find RAG-Anything useful in your research, please cite our paper:
|
|
๐ Related Projects
Ecosystem & Extensions
โญ Star History
Community Growth Trajectory
๐ค Contribution
Join the Innovation