HomeAI Tools
privateGPT

privateGPT

imartinez
1 liked
entry-slick
entry-slick
About privateGPT

Ask questions to your documents without an internet connection, using the power of LLMs. 100% private, no data leaves your execution environment at any point. You can ingest documents and ask questions without an internet connection!

Built with LangChain and GPT4All and LlamaCpp

demo

Environment Setup

In order to set your environment up to run the code here, first install all requirements:

``` pip install -r requirements.txt

```

Then, download the 2 models and place them in a directory of your choice.

  • LLM: default to ggml-gpt4all-j-v1.3-groovy.bin. If you prefer a different GPT4All-J compatible model, just download it and reference it in your .env file.
  • Embedding: default to ggml-model-q4_0.bin. If you prefer a different compatible Embeddings model, just download it and reference it in your .env file.

Rename example.env to .env and edit the variables appropriately.

``` MODEL_TYPE: supports LlamaCpp or GPT4All PERSIST_DIRECTORY: is the folder you want your vectorstore in LLAMA_EMBEDDINGS_MODEL: (absolute) Path to your LlamaCpp supported embeddings model MODEL_PATH: Path to your GPT4All or LlamaCpp supported LLM MODEL_N_CTX: Maximum token limit for both embeddings and LLM models

```

Note: because of the way langchain loads the LLAMA embeddings, you need to specify the absolute path of your embeddings model binary. This means it will not work if you use a home directory shortcut (eg. ~/ or $HOME/).

Test dataset

This repo uses a state of the union transcript as an example.

Instructions for ingesting your own dataset

Put any and all of your .txt, .pdf, or .csv files into the source_documents directory

Run the following command to ingest all the data.

``` python ingest.py

```

It will create a db folder containing the local vectorstore. Will take time, depending on the size of your documents. You can ingest as many documents as you want, and all will be accumulated in the local embeddings database. If you want to start from an empty database, delete the db folder.

Note: during the ingest process no data leaves your local environment. You could ingest without an internet connection.

Ask questions to your documents, locally!

In order to ask a question, run a command like:

``` python privateGPT.py

```

And wait for the script to require your input.

```

Enter a query:

```

Hit enter. You’ll need to wait 20-30 seconds (depending on your machine) while the LLM model consumes the prompt and prepares the answer. Once done, it will print the answer and the 4 sources it used as context from your documents; you can then ask another question without re-running the script, just wait for the prompt again.

Note: you could turn off your internet connection, and the script inference would still work. No data gets out of your local environment.

Type exit to finish the script.

How does it work?

Selecting the right local models and the power of LangChain you can run the entire pipeline locally, without any data leaving your environment, and with reasonable performance.

  • ingest.py uses LangChain tools to parse the document and create embeddings locally using LlamaCppEmbeddings. It then stores the result in a local vector database using Chroma vector store.
  • privateGPT.py uses a local LLM based on GPT4All-J or LlamaCpp to understand questions and create answers. The context for the answers is extracted from the local vector store using a similarity search to locate the right piece of context from the docs.
  • GPT4All-J wrapper was introduced in LangChain 0.0.162.

System Requirements

Python Version

To use this software, you must have Python 3.10 or later installed. Earlier versions of Python will not compile.

C++ Compiler

If you encounter an error while building a wheel during the pip install process, you may need to install a C++ compiler on your computer.

For Windows 10⁄11

To install a C++ compiler on Windows 10⁄11, follow these steps:

  1. Install Visual Studio 2022.
  2. Make sure the following components are selected:

    • Universal Windows Platform development
    • C++ CMake tools for Windows
  3. Download the MinGW installer from the MinGW website.
  4. Run the installer and select the “gcc” component.

Visit Official Website

https://github.com/imartinez/privateGPT

ivanmartit
🚀 Exciting news! Join @thanos_malkav and me for a deep dive into privacy-aware AI stacks powered by @PrivateGPT_AI. Let's build together! 🌐 Save your spot for this Wednesday at 9am PT / 6pm CEST 👉 LlamaIndex Webi...
link
LlamaIndex Webinar: Building Production RAG with Local Models (featuring PrivateGPT) · Zoom · Luma
Want to learn how to build a production-ready RAG stack using purely local models? We’re excited to be hosting a special webinar with Ivan and Daniel, creators of PrivateGPT - the leading...
Share
ivanmartit
Is it production ready? More than ready ;) Qdrant brings high performance semantic search to private AI apps through @PrivateGPT_AI
-------------
From @PrivateGPT:Happy to announce that @qdrant_engine has become the default #VectorDatabase for us 🚀

As a result, we incorporate high-performance vector similarity search into #private AI applications 💪

Cheers to a fantastic collaboration! 👏

👀 Integrations docs:
Share
Community Posts
ivanmartit
🚀 Exciting news! Join @thanos_malkav and me for a deep dive into privacy-aware AI stacks powered by @PrivateGPT_AI. Let's build together! 🌐 Save your spot for this Wednesday at 9am PT / 6pm CEST 👉 LlamaIndex Webi...
link
LlamaIndex Webinar: Building Production RAG with Local Models (featuring PrivateGPT) · Zoom · Luma
Want to learn how to build a production-ready RAG stack using purely local models? We’re excited to be hosting a special webinar with Ivan and Daniel, creators of PrivateGPT - the leading...
Share
ivanmartit
Is it production ready? More than ready ;) Qdrant brings high performance semantic search to private AI apps through @PrivateGPT_AI
-------------
From @PrivateGPT:Happy to announce that @qdrant_engine has become the default #VectorDatabase for us 🚀

As a result, we incorporate high-performance vector similarity search into #private AI applications 💪

Cheers to a fantastic collaboration! 👏

👀 Integrations docs:
Share
ivanmartit
Sources contain ALL the info about the chunks being used during LLM inference, making it extremely useful to give better feedback to the user.

Sources are modeled using the context.chunk object:
-------------
From @PrivateGPT:📃 Sources in Completions API:

Get info (text + metadata) about the Chunks used during inference by the contextual Completions APIs by adding:

{"include_sources": true }

to the request Body.

Sources are enabled by default in the UI.

👩‍💻 Docs:
image
Share
ivanmartit
RT @PrivateGPT_AI: 📃 Sources in Completions API:

Get info (text + metadata) about the Chunks used during inference by the contextual Compl…
Share
ivanmartit
Less than a month after releasing the new revamped version, @PrivateGPT_AI is back to being the Top Trending repository on GitHub 🥇, and has passed the 40K stars 🌟.

Thanks everyone in the AI Community for the support!

👀 Stay tuned for the exciting updates coming next!
image
Share
ivanmartit
Thanks @MatthewBerman for this great video review of the revamped @PrivateGPT_AI! Check out the setup process explained and the next steps unveiled 👀
-------------
From @MatthewBerman:PrivateGPT was the first project to enable "chat with your docs."

They are back with TONS of updates and are now completely local (open-source).

Chat with csv, pdf, txt, html, docx, pptx, md, and so much more!

Here's a full tutorial and review:
Share
ivanmartit
RT @PrivateGPT_AI: 📺 @MatthewBerman just published a new great video describing all the new features we have recently launched t.co / Twitter
t.co / Twitter
Share
ivanmartit
RT @MatthewBerman: So many awesome videos coming soon!

Up next: PrivateGPT 2.0 and Ollama "Let's Build"
Share
ivanmartit
RT @MatthewBerman: Amazon fine-tuned a version of Mistral to allow for 32k tokens.

Welcome to the open-source community, @amazon

https:…
Share
ivanmartit
RT @ClibrainAI: Introducing LINCE Mistral 7B, Spanish adaptation of the most efficient open-source LLM to date by @MistralAI.
The result: i…
Share
ivanmartit
RT @PrivateGPT_AI: 🧠PrivateGPT's Ingest API returns the *doc_id* and the extracted *doc_metadata* - btw, it works great with @llama_index's…
Share
ivanmartit
RT @nomic_ai: Releasing GPT4All v2.5.0 with GGUF Support

- Runs @MistralAI 7B Locally with Vulkan GPU Support
- Universal GPU Inference: M…
Share
ivanmartit
Building production apps not only requires Completions, but a full AI toolset. @PrivateGPT_AI is bridging the gap one step at a time.

Context Chunks API is a simple yet useful tool to retrieve context in a super fast and reliable way.

Check it out!
-------------
From @PrivateGPT:Check out our new Context Chunks API:

🔎Given a text, returns the most related chunks from the ingested documents.
➕Includes previous and next chunks for extended context retrieval.
⏱️Uses only the embeddings model, so it is hyper fast!

Docs:
Share
ivanmartit
RT @jerryjliu0: Defining the right API primitives for RAG is hard.

What I like about the new release of PrivateGPT is that it is not only…
Share
ivanmartit
RT @llama_index: Check out @PrivateGPT_AI (@ivanmartit) 🔥

Lets you easily spin up a RAG pipeline as a 1️⃣ *prod-ready* API + 2️⃣ in a full…
Share
ivanmartit
We've worked really hard on this full revamp of PrivateGPT, and we think you are going to love it ❤️

✅ Plug & Play UI+API+RAG.
👩‍💻 Extensible architecture: bring your own RAG.
🔒 Local and Private Cloud deployment.

Docs: PrivateGPT Docs
Discord: Join the Privat...
-------------
From @PrivateGPT:PrivateGPT is a production-ready service offering Contextual Generative AI primitives like document ingestion and contextual completions through a new API that extends OpenAI’s standard.
Talk to your documents privately using the default UI and RAG pipeline or integrate your own.
PrivateGPT Docs
Share
ivanmartit
Tfw you wake up totally refreshed and ready to take on the week! 😄✨🌤️ Bed Pillows: Co... #laylasleep #sleepbetter #sleepbetterlivebetter #investinrest #fyp #fypシ #bed #bedding #bedroom #boho #bedroomdecor #interiordesign #cozy #cozyvibes #fall #explore #explorepage
image
Share
ivanmartit
I've seen some people struggle to get @FastAPI to stream back the response from a local LLM. Here is a simple working gist using @llama_index and llamacpp to stream from Llama 2 13b GGUF. FastAPI streami...
link
FastAPI streaming local Llama 2 GGUF LLM using LLamaIndex
FastAPI streaming local Llama 2 GGUF LLM using LLamaIndex - fastapi_streaming_local_llama2.py
Share
ivanmartit
I don’t even want to share some of these, in case they run out.
Share
ivanmartit
If you want to understand RAG, I strongly recommend @llama_index docs. After going through "High Level Concepts" and "Basic Usage Pattern", spend some time in "Building RAG from scratch" (link). It is extremely educational! Thanks @jerryjliu0 and team! Building RAG fr...
Building RAG from Scratch (Lower-Level) - LlamaIndex 🦙 0.8.29.post1
Share