privateGPT icon

privateGPT

Interact with your documents privately using local LLMs, without the need for internet connection.

PrivateGPT: Secure, Local AI for Your Documents

Introduction

PrivateGPT is an open-source project, prominently hosted on GitHub by Zylon AI (repository: zylon-ai/private-gpt), designed to enable users to interact with their documents using the power of Large Language Models (LLMs) with complete privacy. Its core mission is to ensure that no data leaves the user's local execution environment at any point, making it an ideal solution for individuals and organizations dealing with sensitive or confidential information.

The project provides a production-ready AI setup that allows you to ingest documents and ask questions about them, leveraging local LLMs and embedding models, all without needing an internet connection (after initial setup and model downloads). It offers an API that follows OpenAI's schema, making it compatible with many existing tools and client libraries.

Key Features

PrivateGPT offers a suite of features focused on private, local AI document interaction:

  • 100% Private Document Q&A: The cornerstone of PrivateGPT. Ask questions about your local documents and receive answers generated by an LLM, with all processing happening on your own hardware. No data is sent to external servers.
  • Local LLM Execution: Runs various open-source LLMs directly on your machine.
    • Supported Model Formats: Primarily utilizes models in GGUF format (optimized for CPU and CPU+GPU execution).
    • Multiple LLM Backends: Supports various backends for running LLMs, including llama.cpp, Ollama, Hugging Face Transformers, and vLLM, offering flexibility in model choice and hardware utilization.
  • Local Embeddings Generation: Creates vector embeddings of your documents locally using sentence transformers or other supported embedding models. This is crucial for the Retrieval Augmented Generation (RAG) pipeline.
  • Vector Store Integration: Stores and queries document embeddings locally using various vector databases like Chroma, Qdrant, and LanceDB (with LlamaIndex providing abstractions for others).
  • OpenAI-Compatible API:
    • Built using FastAPI, it exposes an API that largely follows OpenAI's API schema.
    • This allows users to interact with their local models using existing OpenAI client libraries or tools like curl.
    • Supported endpoints typically include chat completions (/v1/chat/completions) and embeddings (/v1/embeddings).
  • Supported Document Formats:
    • Can ingest a wide variety of common document types, including PDF, TXT, DOCX, CSV, MD, EML, EPUB, HTML, PPTX, and more, leveraging LlamaIndex for document parsing.
  • User Interface (UI) Options:
    • Provides a functional Gradio UI client for testing the API and interacting with your documents.
    • As it offers an API, various community-developed UIs can also be connected.
  • Customizable & Extensible:
    • Open Source (Apache 2.0 License): Allows users to inspect, modify, and extend the codebase.
    • Configuration: Uses settings files (e.g., settings-local.yaml, settings-ollama.yaml, or custom profiles via PGPT_PROFILES environment variable) to manage LLM choices, embedding models, vector stores, and other parameters.
    • Modular Architecture: Built with components for ingestion, embedding, retrieval, and generation, primarily leveraging LlamaIndex.
  • Offline Capability: Once models and necessary dependencies are downloaded, PrivateGPT can run entirely without an internet connection.
  • Focus on Data Control & Privacy: The entire RAG pipeline (document parsing, embedding, storage, querying, LLM inference) can be executed locally.

Specific Use Cases

PrivateGPT is particularly valuable for scenarios where data privacy and local processing are paramount:

  • Securely Querying Sensitive Documents: Analyzing internal company documents, legal contracts, financial reports, medical records, or personal journals without exposing them to third-party AI services.
  • Building Private Knowledge Bases: Creating an internal, searchable knowledge base from a collection of documents that teams or individuals can query privately.
  • Offline Research & Analysis: Conducting research and asking questions about documents in environments without internet access.
  • Personalized AI Assistants for Local Data: Developing custom AI tools that are grounded in your own set of documents and information.
  • Cost-Effective LLM Interaction: Avoiding per-token API costs associated with cloud-based LLM services, especially for frequent or high-volume querying of static document sets (hardware and electricity costs are the main consideration).
  • Learning & Experimenting with RAG: Providing a hands-on environment to understand and experiment with Retrieval Augmented Generation pipelines using local models.
  • Compliance-Sensitive Environments: Suitable for industries with strict data residency and privacy requirements.

Usage Guide

Setting up and using PrivateGPT involves several steps, typically performed in a Python environment:

  1. Prerequisites:
    • Python (version 3.11 is often recommended).
    • Poetry for dependency management (recommended, or use pip with requirements.txt).
    • A C++ compiler (like GCC or Visual Studio with C++ tools) for some dependencies (e.g., llama-cpp-python).
    • make (optional, but helpful for running scripts).
  2. Clone the Repository:
    git clone [https://github.com/zylon-ai/private-gpt.git](https://github.com/zylon-ai/private-gpt.git)
    cd private-gpt
    
  3. Install Dependencies:
    • Using Poetry (Recommended):
      # Ensure Poetry is installed (see official Poetry website)
      # Upgrade Poetry to a tested version if needed (e.g., poetry self update 1.8.3)
      poetry install --with ui,local # Installs core, UI, and local LLM dependencies
      # Or for specific backends/features:
      # poetry install --extras "ui llms-ollama embeddings-huggingface vector-stores-qdrant"
      
    • Using Pip: A requirements.txt is usually available for pip-based installation.
  4. Download Models:
    • PrivateGPT requires an LLM for generation and an embedding model for document processing.
    • Run the setup script to download default local models (this usually includes a GGUF LLM like gpt4all-j or a similar small model, and a sentence-transformer embedding model):
      poetry run python scripts/setup
      
    • These models will be downloaded to a models directory. You can also manually download other GGUF models and configure PrivateGPT to use them.
  5. Configure Settings (Profiles):
    • PrivateGPT uses profiles (e.g., local, openai, ollama) managed by YAML files (e.g., settings-local.yaml).
    • You can set the active profile using the PGPT_PROFILES environment variable (e.g., export PGPT_PROFILES=local).
    • Edit the relevant settings-*.yaml file or create a settings.yaml to customize:
      • llm: Specify the LLM mode (llamacpp, ollama, openai, huggingface), model path or name, context window, temperature, etc.
      • embedding: Specify the embedding mode (huggingface, openai, ollama), model name.
      • vectorstore: Choose the vector store (chroma, qdrant, lancedb) and its settings.
  6. Ingest Documents:
    • Place your documents (PDF, TXT, DOCX, MD, etc.) into the source_documents directory (or a custom directory configured in your settings).
    • Run the ingestion script:
      make ingest
      # Or poetry run python -m private_gpt ingest
      
    • This process will parse the documents, create embeddings, and store them in your chosen local vector database. This only needs to be done once for new documents or when documents are updated.
  7. Run PrivateGPT:
    • With Gradio UI & API Server:
      PGPT_PROFILES=local make run
      # Or poetry run python -m private_gpt run
      
      This typically starts a FastAPI server (e.g., on http://localhost:8001) providing OpenAI-compatible API endpoints and a Gradio web UI accessible through your browser.
    • Query via API (Example with curl for chat):
      curl -X POST "http://localhost:8001/v1/chat/completions" \
           -H "Content-Type: application/json" \
           -d '{
                 "model": "your-configured-llm-name",
                 "messages": [{"role": "user", "content": "What are the main points in my documents about [topic]?"}],
                 "use_context": true
               }'
      
    • Query via UI: Open the Gradio UI in your browser (the URL will be shown when you run make run) and ask questions about your ingested documents.

Hardware Requirements

Hardware needs depend significantly on the size of the LLM and embedding models used:

  • CPU: A modern multi-core CPU is essential.
  • RAM:
    • Minimum: 8GB might work for very small models and limited document sets, but 16GB is generally recommended as a starting point.
    • Recommended: 32GB or more for running larger 7B+ parameter GGUF models smoothly alongside document processing.
  • Storage:
    • SSD is highly recommended for faster loading of models and vector stores.
    • Space for PrivateGPT itself, Python environment, downloaded models (LLMs can be several GBs to tens of GBs; embedding models are smaller), and the vector database. Plan for at least 20-50GB free space plus room for your documents and models.
  • GPU (Optional but Recommended for Larger Models):
    • While PrivateGPT can run CPU-only (especially with GGUF models via llama.cpp), a compatible NVIDIA GPU (CUDA) or AMD GPU (ROCm on Linux) or Apple Silicon (Metal) can significantly accelerate LLM inference if the chosen LLM backend and model support it.
    • Sufficient VRAM is crucial if using a GPU (e.g., 6-8GB VRAM for smaller models, 12GB+ for larger ones).

Pricing & Plans

PrivateGPT is a free and open-source project, licensed under the Apache 2.0 License.

  • There are no subscription fees or charges for using the PrivateGPT software itself.
  • Users are responsible for the costs associated with their own hardware (CPU, GPU, RAM, storage) and electricity.
  • The open-source LLMs and embedding models used with PrivateGPT also typically have their own open (often permissive) licenses.

Frequently Asked Questions (FAQ)

Q1: What is PrivateGPT? A1: PrivateGPT is an open-source AI project that allows you to ingest your documents and ask questions about them using Large Language Models (LLMs) that run entirely on your local machine. This ensures 100% privacy as no data leaves your execution environment.

Q2: How does PrivateGPT ensure privacy? A2: All components of PrivateGPT, including document parsing, embedding generation, vector storage, and LLM inference, are designed to run locally on your hardware. It does not require an internet connection to function (after initial setup and model downloads) and does not send your documents or queries to any third-party cloud services.

Q3: What types of documents can I use with PrivateGPT? A3: PrivateGPT, through its integration with LlamaIndex, supports a wide range of document formats, including PDF, TXT, DOCX (Microsoft Word), CSV, MD (Markdown), EML (Email), EPUB, HTML, and PPTX (PowerPoint).

Q4: What AI models does PrivateGPT use? A4: PrivateGPT is flexible and can be configured to use various open-source LLMs (primarily in GGUF format via llama.cpp or models via Ollama/Hugging Face Transformers) and embedding models (typically sentence-transformers from Hugging Face). Default setup often includes a smaller, generally capable model like GPT4All-J or a Mistral variant for the LLM, and a common sentence-transformer for embeddings.

Q5: Do I need a powerful GPU to run PrivateGPT? A5: While a GPU (NVIDIA, AMD, Apple Metal) will significantly improve performance for larger LLMs, PrivateGPT is designed to be runnable on CPU-only setups, especially with quantized GGUF models. Sufficient RAM is crucial regardless of GPU availability.

Q6: Is PrivateGPT free? A6: Yes, PrivateGPT is free and open-source software, licensed under the Apache 2.0 license.

Q7: How do I interact with PrivateGPT? A7: You can interact with PrivateGPT through its FastAPI-based API (which is OpenAI compatible, allowing use with various client libraries) or through the provided Gradio web UI for a more user-friendly chat experience with your documents.

Q8: Can I use PrivateGPT for commercial purposes? A8: The PrivateGPT software itself is Apache 2.0 licensed, which generally permits commercial use. However, you must also comply with the licenses of the specific LLMs and embedding models you choose to run with PrivateGPT, as these models have their own separate licenses (e.g., Llama 2 has specific commercial use conditions).

Here are examples of the types of articles and guides you can find online to help you get started and explore advanced uses of PrivateGPT:

  • Official PrivateGPT Documentation: The primary source for setup, configuration, and advanced usage. (https://docs.privategpt.dev/)
  • "How to Set Up PrivateGPT on Windows/Mac/Linux": Many tech blogs and individual developers have created detailed step-by-step installation guides for various operating systems. (Search for these titles).
    • Example (Conceptual - actual links will vary based on recency and quality):
      • A Medium article titled "Your Own Private ChatGPT: A Local Setup Guide for PrivateGPT."
      • A YouTube tutorial demonstrating the Docker setup for PrivateGPT.
  • "Chat With Your Documents Locally Using PrivateGPT and [Specific LLM]": Tutorials focusing on using popular models like Llama 3, Mistral, or Phi with PrivateGPT.
    • Example: "Query Your PDFs Offline: A Deep Dive into PrivateGPT with Llama 3" by a tech blogger.
  • "Building a Private RAG System with PrivateGPT": More advanced articles discussing the Retrieval Augmented Generation pipeline within PrivateGPT and how to optimize it.
    • Example: "Advanced RAG Techniques with PrivateGPT for Enterprise Knowledge Bases" on a data science blog.
  • "PrivateGPT API: Integrating Local Document Q&A into Your Applications": Guides for developers on how to use the FastAPI endpoints.
  • "Comparing Local LLM Solutions: PrivateGPT vs. Ollama vs. [Other Tool]": Blog posts that compare different local AI solutions, highlighting PrivateGPT's strengths.
  • "Enhancing PrivateGPT with Custom Models and Embeddings": Advanced tutorials for users wanting to go beyond the default model configurations.

(To find current and relevant articles, search for terms like "PrivateGPT tutorial," "PrivateGPT setup guide," "PrivateGPT [your OS] install," "PrivateGPT [specific LLM] guide" on Google, Medium, DEV.to, YouTube, and other tech communities.)

Community & Support

  • GitHub Repository: The primary hub for the project, including code, issue tracking, and discussions. (https://github.com/zylon-ai/private-gpt)
  • Discord Server: PrivateGPT has an official Discord community for user support, sharing experiences, and discussions with developers. (Link usually available on the GitHub README).
  • GitHub Discussions: For more in-depth questions and community interaction related to development and features.

Ethical Considerations & Safety

  • Data Privacy: This is the core strength of PrivateGPT. By design, all data processing and AI inference occur locally, ensuring that sensitive documents and queries do not leave the user's environment.
  • Model Responsibility: Users are responsible for the LLMs and embedding models they choose to download and use with PrivateGPT. This includes understanding any inherent biases in these models and using their outputs critically.
  • License Compliance: Users must adhere to the licenses of the individual models they use within the PrivateGPT framework.
  • Accuracy: While powerful, LLMs can sometimes "hallucinate" or provide inaccurate information. Answers generated by PrivateGPT should be verified against the source documents, especially for critical applications.

Last updated: May 16, 2025

Found an error in our documentation?Email us for assistance