"RAG-Anything: All-in-One RAG Framework"
Next-Generation Multimodal Intelligence
</div>
</div>
</div>
</div>
</div>
Initialize Your AI Journey
# Basic installation
pip install raganything
# With optional dependencies for extended format support:
pip install 'raganything[all]' # All optional features
pip install 'raganything[image]' # Image format conversion (BMP, TIFF, GIF, WebP)
pip install 'raganything[text]' # Text file processing (TXT, MD)
pip install 'raganything[image,text]' # Multiple features
…
[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:
# Verify installation
mineru --version
# Check if properly configured
python -c "from raganything import RAGAnything; rag = RAGAnything(); print('✅ MinerU installed properly' if rag.check_parser_installation() else '❌ MinerU installation issue')"
Models are downloaded automatically on first use. For manual download, refer to MinerU Model Source Configuration.
…
…
# Process multiple documents
await rag.process_folder_complete(
folder_path="./documents",
output_dir="./output",
file_extensions=[".pdf", ".docx", ".pptx"],
recursive=True,
max_workers=4
)
from raganything.modalprocessors import GenericModalProcessor
class CustomModalProcessor(GenericModalProcessor):
async def process_multimodal_content(self, modal_content, content_type, file_path, entity_name):
# Your custom processing logic
enhanced_description = await self.analyze_custom_content(modal_content)
entity_info = self.create_custom_entity(enhanced_description, entity_name)
return await self._create_entity_and_chunk(enhanced_description, entity_info, file_path)
RAG-Anything provides three types of query methods:
Pure Text Queries - Direct knowledge base search using LightRAG:
# Different query modes for text queries
text_result_hybrid = await rag.aquery("Your question", mode="hybrid")
text_result_local = await rag.aquery("Your question", mode="local")
text_result_global = await rag.aquery("Your question", mode="global")
text_result_naive = await rag.aquery("Your question", mode="naive")
# Synchronous version
sync_text_result = rag.query("Your question", mode="hybrid")
VLM Enhanced Queries - Automatically analyze images in retrieved context using VLM:
…
Multimodal Queries - Enhanced queries with specific multimodal content analysis:
…
…
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:
{"type": "text", "text": "content text", "page_idx": 0}{"type": "image", "img_path": "/absolute/path/to/image.jpg", "image_caption": ["caption"], "image_footnote": ["note"], "page_idx": 1}{"type": "table", "table_body": "markdown table", "table_caption": ["caption"], "table_footnote": ["note"], "page_idx": 2}{"type": "equation", "latex": "LaTeX formula", "text": "description", "page_idx": 3}{"type": "custom_type", "content": "any content", "page_idx": 4}{"type": "audio", "audio_path": "/absolute/path/to/talk.wav", "audio_caption": ["caption"], "page_idx": 5} — transcribed locally with faster-whisper (timestamped segments); long recordings are windowed into ordered chunks{"type": "video", "video_path": "/absolute/path/to/demo.mp4", "video_caption": ["caption"], "page_idx": 6} — SceneDetect scene boundaries + keyframe VLM description + audio-track transcription, merged by timestampImportant Notes:
img_path: Must be an absolute path to the image file (e.g., /home/user/images/chart.jpg or C:\Users\user\images\chart.jpg)page_idx: Represents the page number where the content appears in the original document (0-based indexing)This method is particularly useful when:
By default, process_document_complete and insert_content_list skip multimodal
(image/table/equation) processing for a document that is already marked as fully
processed, to avoid redundant LLM calls. If you switch to a new graph/vector
storage backend (e.g. migrating from the default file-based storage to Neo4j),
the new backend will not yet contain the multimodal entities/relations that were
written to the old one — see #154.
Pass force_multimodal_reprocess=True to explicitly re-run multimodal processing
and re-populate the current storage backend for an already-processed document:
# Re-run multimodal processing so the current storage backend has the
# image/table/equation entities and relations (default is False, i.e. no change
# to existing behavior for documents that have not switched backends)
await rag.process_document_complete(
file_path="path/to/your/document.pdf",
doc_id="doc-already-processed-id",
force_multimodal_reprocess=True,
)
# Same flag is available for direct content list insertion
await rag.insert_content_list(
content_list=content_list,
doc_id="doc-already-processed-id",
force_multimodal_reprocess=True,
)
This flag only affects multimodal content; it is opt-in and defaults to False,
so existing behavior is unchanged unless you explicitly set it.
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:
…
System Optimization Parameters
Create a .env file (refer to .env.example):
OPENAI_API_KEY=your_openai_api_key
OPENAI_BASE_URL=your_base_url # Optional
OUTPUT_DIR=./output # Default output directory for parsed documents
PARSER=mineru # Parser selection: mineru, docling, or paddleocr
PARSE_METHOD=auto # Parse method: auto, ocr, or txt
Note: For backward compatibility, legacy environment variable names are still supported:
MINERU_PARSE_METHOD is deprecated, please use PARSE_METHODNote: 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.
When ingestion runs on a server but your UI or another service needs HTTPS (or S3-style) links to figures, set:
# Base URL for assets (no trailing slash required)
RAGANYTHING_PUBLIC_ASSET_BASE_URL=https://my-bucket.s3.us-east-1.amazonaws.com/prefix
# Filesystem root that should be stripped from absolute paths under that tree
RAGANYTHING_PUBLIC_ASSET_STRIP_PREFIX=/var/rag/output
After parsing, each non-empty img_path, table_img_path, or equation_img_path may gain a sibling field *_public_url while the original path stays on disk for local processing. See #272.
Scope today: this mapping runs in the MinerU parser path only. Other parsers (e.g. Docling) keep working but will not produce
*_public_urlfields until the helper is wired into their content_list post-processing as well. If only one of the two env vars is set, RAG-Anything logs a warning and skips URL attachment.
RAGAnything now supports multiple parsers, each with specific advantages: