This project demonstrates how to build a powerful multimodal agent for document analysis using Docling for PDF extraction and LangChain for creating AI chains and agents. It showcases the seamless integration of tabular and textual data extracted from PDFs into a unified query system.
- PDF text and table extraction using Docling
- SQL-based querying of extracted tabular data
- RAG (Retrieval-Augmented Generation) for textual data analysis
- MultiModal Agent combining SQL and RAG capabilities
Docling is a state-of-the-art, open-source PDF conversion tool that offers several advantages:
- Accuracy: Powered by specialized AI models for layout analysis (DocLayNet) and table structure recognition (TableFormer).
- Efficiency: Runs on commodity hardware with a small resource budget.
- Comprehensive: Understands detailed page layout, reading order, locates figures, and recovers table structures.
- Metadata Extraction: Extracts metadata such as title, authors, references, and language.
- Flexibility: Configurable for batch-mode or interactive use.
- OCR Support: Optional OCR for scanned PDFs.
- Easy Integration: Simple, self-contained Python library with permissive MIT license.
- Clone this repository
- Navigate to the project directory:
cd MultiModal_RAG_Agent/- Install the required dependencies:
pip install -r requirements.txt- Create a .env file in the current folder
OPENAI_API_KEY=...
- Place your PDF files in the
data/directory. - Run the main.ipynb notebook.
- The notebook will:
- Extract text and tables from the PDFs using Docling
- Create an SQLite database with the extracted tables
- Set up a RAG system for the extracted text
- Initialize a multimodal agent that can answer questions using both SQL and RAG
- You can then query the agent with questions about the document content.
- PDF Extraction: Docling is used to extract both text and structured table data from PDF files.
- SQL Chain: Extracted tables are stored in an SQLite database, which can be queried using natural language through a LangChain SQL chain.
- RAG Chain: Extracted text is processed into a vector store for semantic search and query answering.
- MultiModal Agent: Combines the SQL and RAG chains into a unified agent that can route queries to the appropriate system based on the question type.
Contributions to improve the project are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.