A comprehensive AI-powered system for extracting, analyzing, and synthesizing knowledge from PDF documents using Ollama's local AI models.
- π PDF Processing: Extract text, tables, and images from PDF documents
- π€ AI-Powered Analysis: Uses Ollama with Llama 3.1 for intelligent content analysis
- π Table Extraction: Automatically detects and extracts tables from PDFs
- π¨ Flowchart Analysis: Analyzes flowcharts and diagrams using AI vision capabilities
- π Citation Mapping: Maps citations to reference documents
- π Similarity Search: Finds relevant content across documents using FAISS
- π Knowledge Synthesis: Creates comprehensive knowledge documents
- π» Streamlit Interface: User-friendly web interface for document processing
- Python 3.8 or higher
- Ollama installed locally
- Git
-
Clone the repository
git clone <repository-url> cd knowledge-document-creation
-
Create and activate virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Download NLTK data
python -c "import nltk; nltk.download('punkt_tab'); nltk.download('punkt'); nltk.download('averaged_perceptron_tagger'); nltk.download('stopwords')" -
Setup Ollama
# Install Ollama from https://ollama.ai/ ollama serve ollama pull llama3.1:8b -
Run the application
streamlit run main.py
-
Open your browser to
http://localhost:8501
- Upload Main PDF: Upload the primary document you want to analyze
- Upload Reference PDFs: Upload reference documents for comparison and citation mapping
- Generate Knowledge Document: Click "Generate" to process all documents
- View Results: Review the generated knowledge document with statistics and organized content
- Download: Download the document in Word or text format
PDF Input β Text Extraction β Table Detection β Flowchart Analysis β AI Processing β Knowledge Synthesis β Output
knowledge-document-creation/
βββ main.py # Main Streamlit application
βββ requirements.txt # Python dependencies
βββ setup_environment.py # Environment setup script
βββ .gitignore # Git ignore file
βββ README.md # This file
βββ Paragraph_extraction_from_pdf.py # Text extraction module
βββ Table_to_text/ # Table extraction module
β βββ Detect_table_redact.py
βββ Flowchart_to_text/ # Flowchart analysis module
β βββ flowchart_to_text.py
β βββ Detect_flowchart_redact.py
βββ csv/ # Generated CSV files (ignored by git)
The application uses the following environment variables:
LLM_PROVIDER=ollamaOLLAMA_MODEL=llama3.1:8b
These are automatically set by the setup script.
The system is configured to use llama3.1:8b by default. You can use other models by:
- Pulling the desired model:
ollama pull <model-name> - Setting the environment variable:
export OLLAMA_MODEL=<model-name>
- Extracts text from PDFs using multiple libraries (PyMuPDF, pdfplumber)
- Handles various PDF formats and layouts
- Preserves text structure and formatting
- Automatically identifies tables in PDF documents
- Extracts table content to Excel format
- Maps table references in the main document
- Extracts images and diagrams from PDFs
- Uses Ollama's vision capabilities to analyze flowcharts
- Generates textual descriptions of visual content
- Identifies citation patterns in academic documents
- Maps citations to corresponding reference documents
- Performs similarity search to find relevant content
- Combines extracted content from all sources
- Creates organized knowledge documents
- Provides download options in multiple formats
- New Document Types: Extend the extraction modules in
Table_to_text/orFlowchart_to_text/ - AI Models: Modify the Ollama integration in
flowchart_to_text.py - UI Components: Add new Streamlit components in
main.py
# Test imports
python -c "from main import *; print('β
All imports successful')"
# Test specific modules
python -c "from Paragraph_extraction_from_pdf import create_csv; print('β
Text extraction works')"-
Ollama Connection Error
# Check if Ollama is running ollama list # Start Ollama service ollama serve
-
NLTK Data Missing
python -c "import nltk; nltk.download('punkt_tab')" -
PyMuPDF Import Error
pip uninstall PyMuPDF pip install pymupdf
-
Permission Errors
- Ensure write permissions in the project directory
- Check if antivirus software is blocking file operations
- Check the Issues page
- Review the troubleshooting section above
- Ensure all dependencies are properly installed
This project is licensed under the MIT License - see the LICENSE file for details.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Ollama for local AI model serving
- Streamlit for the web interface
- PyMuPDF for PDF processing
- LangChain for document processing
- FAISS for similarity search
For support, email your-email@example.com or create an issue in the repository.
Made with β€οΈ for knowledge discovery and document analysis