More Deep Learning Articles…

PrivateGPT: A Free ChatGPT Alternative for Interacting with Your Documents Offline

A detailed step-by-step guide to installing privateGPT on your computer.

Currently, you can interact with documents such as PDFs using ChatGPT plugins, as I showed in a previous article, but this feature is exclusive to ChatGPT Plus subscribers.

Today, I will show you a free alternative to ChatGPT that will help you not only interact with your documents as if you were using ChatGPT, but also do so privately and offline, so you do not need to worry about data leaks.

This alternative is called privateGPT, and in this guide I will show you how to install it on your computer step by step.

The PrivateGPT demo

Before I show you the steps to install privateGPT, here is a demo of how it works.

For the test below, I use a research paper called SMS.pdf (other supported formats are .csv, .docx, .doc, .epub, .ppt and .txt). In the terminal, I run privateGPT with the command python privateGPT.py.

Then I can type a prompt just as we do with ChatGPT.

It is not as fast as ChatGPT, but remember that it is free and offline, and all your information stays 100% private, so let's try it!

How to install PrivateGPT

If you are familiar with a few terminal commands, installing privateGPT is very simple. If not, just follow each step listed below.

Step 1: Set up privateGPT

Go to the GitHub repo, click the green button that says “Code” and copy the link inside.

Now open the terminal and clone the repo by typing the git clone command and pasting the link we just copied.

git clone https://github.com/imartinez/privateGPT.git

Note: feel free to create a virtual environment and an extra folder to keep your files well organized.

We should now see a new folder called privateGPT. We need to go into this folder with the cd command.

cd privateGPT/

Inside this folder there should be a requirements.txt file. It contains all the dependencies we have to install for privateGPT to work.

Let's install all the dependencies in requirements.txt with the command below.

pip install -r requirements.txt

After running the command above, you will see a series of libraries being installed.

Once the installation is finished, we have to rename the example.env file to .env. You can do this manually or with the command below in the terminal.

mv example.env .env

You can edit the contents of the .env file if you want, but if you are following this tutorial, I recommend leaving it as it is.

Step 2: Download the LLM

Now it is time to download the LLM. To do this, we go to the GitHub repo again and download the file called ggml-gpt4all-j-v1.3-groovy.bin (under “Environment Setup”). The file is about 4 GB, so it may take some time to download.

Then we create a folder called “Models” inside the privateGPT folder and put the LLM we just downloaded inside the “Models” folder.

Finally, make sure that any file you want to analyse with privateGPT is inside the source_documents folder. All the supported extensions are listed below:

.csv .docx .doc .enex .eml .epub .html .md .msg .odt .pdf .pptx .ppt .txt

Step 3: Interact with your documents using privateGPT

Once you have put the files you want to interact with inside the source_documents folder, we have to ingest all our documents with the command below.

python ingest.py

After running the command, you will see the following image.

Now we can start asking our document questions with the command below.

python privateGPT.py

After a few seconds you should see the message “Enter a query”. This is the query I will use for this test:

> Enter a query: write a summary of the paper SMS.pdf

Great! PrivateGPT did a good job of summarizing my document.

Just note that privateGPT is not production-ready. The model selection is optimized for privacy, not performance.

Post links

Leave a comment

Your email address will not be published. Required fields are marked *