drewskidang / ChromaDB-Plugin-for-LM-Studio

Plugin that creates a ChromaDB vector database to work with LM Studio running in server mode!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

🚀 Supercharge your LM Studio with a Vector Database!

Ask questions about your documents and get an answer from LM Studio!

⚡GPU Acceleration⚡

GPU Windows Linux Requirements
Nvidia CUDA
AMD ROCm 5.6
Apple/Metal

🔥Requirements🔥

You must install these before following the installation instructions below:

‼️ 🐍Python 3.10 (I have not tested above this.).
‼️ Git
‼️ Git Large File Storage.
‼️ Pandoc (only if you want to process .rtf files).

🔥Installation🔥

‼️If you have Python 2 and Python 3 installed on your system, make sure and use "Python3" and "pip3" instead when installing.‼️

🪟WINDOWS INSTRUCTIONS🪟

Step 1

🟢 Nvidia GPU ➜ Install CUDA 11.8 or CUDA 12.1.
🔴 AMD GPU - Unfortunately, PyTorch does not currently support AMD GPUs on Windows. It's only supported on Linux. There are several ways to possibly get around this limitation, but I'm unable to verify since I don't have an AMD GPU. See HERE, HERE, and possibly HERE.

Step 2

Download the ZIP file from the latest "release," unzip anywhere on your computer, and go into the src folder.

Step 3

Within the src folder, open a command prompt and create a virtual environment:

python -m venv .

Step 4

Activate the virtual environment:

.\Scripts\activate

Step 5

python setup.py

And just follow the instructions.

Optional Step 6 - Double check GPU-Acceleration

Run this script if you want to doublecheck that you installed the Pytorch and gpu-acceleration software correctly:

python check_gpu.py
🐧LINUX INSTRUCTIONS🐧

Step 1

🟢 Nvidia GPUs ➜ Install CUDA 11.8
🔴 AMD GPUs ➜ Install ROCm version 5.6.

THIS REPO might also help if AMD's instructions aren't clear.

Step 2

Download the ZIP file from the latest "release," unzip anywhere on your computer, and go into the src folder.

Step 3

Within the src folder, open a terminal window and create a virtual environment:

python -m venv .

Step 4

Activate the virtual environment:

source bin/activate

Step 5

python -m pip install --upgrade pip

Step 6

🟢 Nvidia GPU:

pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

🔴 AMD GPU:

pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/rocm5.6

🔵 CPU only:

pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu

Step 7

sudo apt-get install portaudio19-dev

Step 8

sudo apt-get install python3-dev

Step 9

pip install -r requirements.txt

Optional Step 10

Run this script if you want to doublecheck that you installed the Pytorch and gpu-acceleration software correctly:

python check_gpu.py
🍎APPLE INSTRUCTIONS🍎

Step 1

All Macs with MacOS 12.3+ come with 🔘 Metal/MPS, which is Apple's implementation of gpu-acceleration (like CUDA for Nvidia and ROCm for AMD). I'm not sure if it's possible to install on an older MacOS since I don't have an Apple.

Step 2

Install Xcode Command Line Tools.

Step 3

Download the ZIP file from the latest "release," unzip anywhere on your computer, and go into the src folder.

Step 4

Within the src folder, open a terminal window and create a virtual environment:

python -m venv .

Step 5

Activate the virtual environment:

source bin/activate

Step 6

python -m pip install --upgrade pip

Step 7

pip install torch torchvision torchaudio

Step 8

brew install portaudio

Step 9

pip install -r requirements.txt

Optional Step 10

Run this script if you want to doublecheck that you installed the Pytorch and gpu-acceleration software correctly:

python check_gpu.py

🔥Transcription🔥

My program allows you to transcribe a question into the clipboard and paste it into LM Studio. It uses the powerful Ctranslate2 library and the state-of-the-art "Whisper" models.

⚡Transcription Acceleration⚡

Acceleration Support Requirements
Intel CPU
AMD CPU
Nvidia GPU CUDA
AMD GPU Will default to CPU
Apple CPU
Apple Metal/MPS Will default to CPU

Compatibility Checker

After following the installation instructions above, you can check which quantized versions of the Whisper models your CPU and GPU support. On Windows, use ctranslate2_compatibility.exe and on Linux or MacOS follow the instructions HERE.

As of Release v2.5, however, this is no longer mandatory because the program only displays compatible quantizations to choose from.

🔥Usage🔥

🔥USAGE INSTRUCTIONS🔥

Activate Virtual Environment

Make sure you are in theh src folder, have opened a command prompt/terminal, and activated the virtual environment (see installation instructions).

Run Program

python gui.py

Only systems running Windows with an Nvidia GPU will display metrics in the GUI. Feel free to request that I add AMD or Apple support.

Download Embedding Model

The download embedding model button lets you choose to download multiple embedding models. The command prompt/terminal will state when the download is complete and unpacked. Don't attempt to create the vector database before it's done.

Set Model Directory

The set model directory button allows you to choose which embedding model to create/query the vector database. You can choose any of the embedding models you previously downloaded by selecting the folder in which the model files were downloaded to.

Choose Documents for Database

The choose documents button allows you to select which documents you want in the database. Symbolic links to the files are put within the "Docs_for_DB" folder, not the actual files, but you can manually drag and drop files there as well if you want. Feel free to select multiple files or click the add files button multiple times. To delete any files you have to manually delete them from the "Docs_for_DB" folder, however.

Remember, anytime you add/remove files you must recreate the vector database.

The file types that are supported are .pdf, .docx, .txt, .json, .enex, .eml, .msg, .csv, .xls, .xlsx, .rtf, .odt.

‼️ However, PDF files must have had OCR done on them.

As of release 2.6.1, you can also transcribe audio files for the database. The transcription process will automatically create a .txt file within the "Docs_for_DB" folder.

Remember, anytime you add/remove documents you must re-create the database.

Create Databaase

The create database button...wait for it...creates the vector database! The command prompt will state when it's been "persisted." You should only conduct a search after you see this message.

Setup LM Studio

  1. Before searching, open LM Studio and load a model.

‼️ Remember, only models that use the Llama-2 prompt format are supported by default. You can change the "prefix" or "suffix" to test out other models, but for 99% of use cases a basic model that uses the Llama-2 prompt format is sufficient. Mistral models use the formate and are excellent.

  1. ...then click the server tab on the left side.
  2. ...then click "Start Server" in the server tab.

Search Database

Now type/transcribe your question and click "Submit Questions." The vector database will be queried. Your question along with any "contexts" from the database will be sent to the LLM within LM Studio for answer!

🔥Contact🔥

All suggestions (positive and negative) are welcome. "bbc@chintellalaw.com" or feel free to message me on the LM Studio Discord Server.

Example Image Example Image2 Example Image3 Example Image4 Example Image5 Example Image6 Example Image7

About

Plugin that creates a ChromaDB vector database to work with LM Studio running in server mode!


Languages

Language:Python 54.7%Language:CSS 29.1%Language:HTML 16.2%