Chat with your documents privately, locally, and securely β¨
Features β’ Installation β’ Usage β’ Architecture β’ Contributing
PrivateGPT transforms your personal documents into an intelligent, conversational AI assistant. Unlike cloud-based solutions, everything runs locally on your machine, ensuring your sensitive data never leaves your control.
- π Complete Privacy: Your documents never leave your machine
- π Smart Document Understanding: Chat with PDFs, Word docs, and text files
- β‘ Real-time Responses: Streaming responses for better user experience
- π― Context-Aware: Provides accurate answers based on your documents
- π οΈ Easy Setup: Simple installation and intuitive interface
- Supports multiple formats: PDF, DOCX, DOC, TXT
- Automatic text chunking for optimal retrieval
- Vector embeddings for semantic search
- Streamlit-based chat interface with design first philosophy
- Real-time streaming responses
- Context-aware conversations
- Emoji support for better readability
- RAG (Retrieval-Augmented Generation) pipeline
- ChromaDB for vector storage
- Ollama for local LLM inference
- Modular and extensible design
Before getting started, ensure you have the following installed:
- Python 3.8+ π
- Ollama (for local LLM inference) π€
- Homebrew (for macOS users) πΊ
# macOS
brew install ollama
# Linux
curl -fsSL https://ollama.ai/install.sh | sh
# Windows (using WSL)
curl -fsSL https://ollama.ai/install.sh | sh
# Download the embedding model
ollama pull nomic-embed-text
# Download the language model
ollama pull mistral
# Clone the repository
git clone https://github.com/dangkv/privateGPT.git
cd privateGPT
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
streamlit>=1.28.0
langchain>=0.0.350
langchain-community>=0.0.10
chromadb>=0.4.15
ollama>=0.1.0
pypdf>=3.17.0
python-docx>=0.8.11
docx2txt>=0.8
Understanding the data folder structure is crucial for setting up PrivateGPT:
data/
βββ raw/ # π Your unstructured documents go here
β βββ document1.pdf
β βββ report.docx
β βββ notes.txt
β βββ subfolder/
β βββ more_docs.pdf
βββ processed/ # π§ Processed document chunks (auto-generated)
βββ chroma_db/ # ποΈ Vector database storage (auto-generated)
βββ chroma.sqlite3
βββ index/
-
Create the data directory (if it doesn't exist):
mkdir -p data/raw
-
Add your documents to the
data/raw/
folder:- Supported formats:
.pdf
,.docx
,.doc
,.txt
- You can organize documents in subfolders
- No size limit (within reason)
- Supported formats:
-
Example structure:
data/raw/ βββ company_policies/ β βββ employee_handbook.pdf β βββ code_of_conduct.docx βββ research_papers/ β βββ ai_trends_2024.pdf β βββ machine_learning_guide.pdf βββ personal_notes/ βββ meeting_notes.txt βββ project_ideas.docx
-
Start the services:
make start
-
Ingest your documents:
make db-ingest
-
Open your browser and go to
http://localhost:8501
-
Start chatting with your documents! π¬
-
Shut down bot:
make stop
PrivateGPT comes with a comprehensive Makefile for easy management:
# π― Main Commands
make start # Start all services
make stop # Stop all services
make status # Check service status
# π Streamlit Management
make streamlit-start # Start Streamlit app
make streamlit-stop # Stop Streamlit app
make streamlit-reset # Restart Streamlit
# π€ Ollama Management
make llm-start # Start Ollama service
make llm-stop # Stop Ollama service
make llm-status # Check Ollama status
# ποΈ Database Management
make db-ingest # Process and ingest documents
make db-reset # Reset database
make db-backup # Create database backup
make db-check # Check database status
# π§Ή Cleanup
make clean # Clean temporary files
make clean-all # Deep clean everything
If you prefer to run the ingestion manually:
python scripts/ingest_documents.py
PrivateGPT follows a modular RAG (Retrieval-Augmented Generation) architecture:
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β π Documents β ββ β π Ingestion β ββ β ποΈ Vector DB β
β (PDF, DOCX, β β (Chunking & β β (ChromaDB) β
β TXT files) β β Embedding) β β β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β π¬ Streamlit β ββ β π§ RAG β ββ β π Retrieval β
β Interface β β Pipeline β β (Semantic β
β β β β β Search) β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β
βββββββββββββββββββ
β π€ Generation β
β (Ollama + β
β Mistral) β
βββββββββββββββββββ
- π Ingestion Pipeline: Processes documents and creates vector embeddings
- π Retrieval System: Finds relevant document chunks using semantic search
- π€ Generation Engine: Uses Ollama with Mistral model for response generation
- π¬ Chat Interface: Streamlit-based UI with real-time streaming
- ποΈ Vector Database: ChromaDB for efficient similarity search
Customize PrivateGPT by modifying config.py
:
# Model configurations
EMBEDDING_MODEL = "nomic-embed-text" # Change embedding model
LLM_MODEL = "mistral" # Change language model
OLLAMA_BASE_URL = "http://localhost:11434"
# Chunking parameters
CHUNK_SIZE = 1000 # Adjust chunk size
CHUNK_OVERLAP = 200 # Adjust overlap
# Retrieval parameters
TOP_K_RETRIEVAL = 5 # Number of documents to retrieve
- Follow PEP 8 style guidelines
- Add docstrings to all functions and classes
- Include type hints where appropriate
- Write unit tests for new features
- Update documentation as needed
This project is licensed under the MIT License - see the LICENSE file for details.
- LangChain for the RAG framework
- Ollama for local LLM inference
- ChromaDB for vector storage
- Streamlit for the web interface
- Mistral for the language model
π Ready to chat with your documents privately?
Made with β€οΈ by the PrivateGPT Team