Wednesday, February 7, 2024

Setup PrivateGPT on a Fresh Ubuntu 22.04



TLDR; We'll set up PrivateGPT on a brand new Ubuntu 22.04 Install. 

I want to preface and warn you, that I am not a savvy user, much less an expert in Artificial Intelligence (AI) or Large Language Models ( LLMs). I am pretty sure I am going to say/type some wrong things :). 

I warned you, here's my write-up:

With all of the hype around AI and ChatGPT, I figured I'd join the bandwagon. A co-worker of sorts pointed out an interesting Github project 'PrivateGPT' that he has been using. His work is private in nature and while he could benefit from the advantages that a toolset like ChatGPT brings it is not feasible/permissible/frowned upon to give OpenAI or any other company the data you are working with( which is usually your clients' data.

That's where PrivateGPT comes to the rescue. The GitHub Repo "PrivateGPT is a production-ready AI project that allows you to ask questions about your documents using the power of Large Language Models (LLMs), even in scenarios without an Internet connection. 100% private, no data leaves your execution environment at any point." Please visit and support the repo located here: https://github.com/imartinez/privateGPT. The readme mentions that for the latest info, we should visit https://docs.privategpt.dev/.

What are my motivations? 
  • I briefly tried to set it up and failed, I gave up. Now I am back and forcing myself to get it working. 
  • AI is here to stay and what better way to learn than to play around with it. 
  • You never know if your business might be able to use it. 
Use Cases:

  • Well, I'll leave that up to your imagination. Think of PrivateGPT as a ChatGPT alternative that you can feed your documents( DOCS, TXT, PDF) and interact with them, 
    • We'll go over some test scenarios. 
We'll be using the installation instructions here: https://docs.privategpt.dev/installation. If the instructions are there, why do you need to read this? Because I failed once, I'll probably fail again as I am writing this as I go through the steps. I failed so you can learn from my mistakes, the idea is to give you a better starting point. With all of that being said let's get into the installation.

  • We'll start with a VM with a fresh install of Ubuntu 22.04. I had the Desktop Edition handy which will do the job and allow us to run a browser within the machine. 
    • I won't bore you with screenshots of this process. 
    • Make sure you update and upgrade your box. 
    • Take Snapshot before we begin, that way you can revert back to a clean slate.
  • I ran into some issues with dependencies, let's get these out of the way before we get started:
    • sudo apt install git curl gcc g++ pkg-config
    • sudo apt install build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev
      libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
  • Let's create a directory, then Clone the Repo
    • mkdir /home/MYUSER/PrivateGPT
      • cd /home/MYUSER/PrivateGPT
    • git clone https://github.com/imartinez/privateGPT 
Install pyenv and Python 3.11
  • Now we have to install Python 3.11 using a Python version manager.
    • We'll install pyenv
    • Let's use this writeup: https://medium.com/@therazmatrix/how-to-install-and-use-pyenv-in-ubuntu-22-04-fa7c28ca0b67
      • curl https://pyenv.run | bash
        • Then I added this to my /home/MYUSER/.bashrc file
        • # Pyenv
          export PYENV_ROOT="$HOME/.pyenv"
          command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
          eval "$(pyenv init -)"
          eval "$(pyenv virtualenv-init -)"
      • You'll need to restart the shell.( just close it and re-open it)
      • pyenv install 3.11
        • It worked :) 
  • Now Install Poetry
    • https://python-poetry.org/docs/#installing-with-the-official-installer
      • curl -sSL https://install.python-poetry.org | python3 -
      • That worked fine the first time, were on a roll. 
    • So I did not put the PATH for poetry in my .bashrc, because reasons but I can run it calling /home/MYUSER/.local/bin/poetry 
  • We need to create a virtual environment for our project to use the 3.11.7 Python install
  • in /home/MYUSER
    •  pyenv virtualenv 3.11.7 privategpt
  • then go to /home/MYUSER/privateGPT
    • pyenv local privategpt
    • pip install llama-cpp-python
    • poetry install --with ui
      • This will take a while
    • poetry install --with local
      • This will take another while
    • poetry run python scripts/setup
  • Finally
    • /home/MYUSER/.local/bin/poetry run python -m private_gpt
    • You'll see a message similar to:
    • You can now browse to https://127.0.0.1:8001
      • Upload a File, and ask it some questions. 

Baofeng UV5R Simplex Repeater (VOX)

Let's start off with the list of it items that we'll need:  Materials: Computer: Laptop/Desktop Running Windows Radio Piece: 1X Baof...