You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Extract optional dependencies
* Separate local mode into llms-llama-cpp and embeddings-huggingface for clarity
* Support Ollama embeddings
* Upgrade to llamaindex 0.10.14. Remove legacy use of ServiceContext in ContextChatEngine
* Fix vector retriever filters
PrivateGPT is a service that wraps a set of AI RAG primitives in a comprehensive set of APIs providing a private, secure, customizable and easy to use GenAI development framework.
2
+
3
+
It uses FastAPI and LLamaIndex as its core frameworks. Those can be customized by changing the codebase itself.
4
+
5
+
It supports a variety of LLM providers, embeddings providers, and vector stores, both local and remote. Those can be easily changed without changing the codebase.
6
+
7
+
# Different Setups support
8
+
9
+
## Setup configurations available
10
+
You get to decide the setup for these 3 main components:
11
+
- LLM: the large language model provider used for inference. It can be local, or remote, or even OpenAI.
12
+
- Embeddings: the embeddings provider used to encode the input, the documents and the users' queries. Same as the LLM, it can be local, or remote, or even OpenAI.
13
+
- Vector store: the store used to index and retrieve the documents.
14
+
15
+
There is an extra component that can be enabled or disabled: the UI. It is a Gradio UI that allows to interact with the API in a more user-friendly way.
16
+
17
+
### Setups and Dependencies
18
+
Your setup will be the combination of the different options available. You'll find recommended setups in the [installation](/installation) section.
19
+
PrivateGPT uses poetry to manage its dependencies. You can install the dependencies for the different setups by running `poetry install --extras "<extra1> <extra2>..."`.
20
+
Extras are the different options available for each component. For example, to install the dependencies for a a local setup with UI and qdrant as vector database, Ollama as LLM and HuggingFace as local embeddings, you would run
Refer to the [installation](/installation) section for more details.
25
+
26
+
### Setups and Configuration
27
+
PrivateGPT uses yaml to define its configuration in files named `settings-<profile>.yaml`.
28
+
Different configuration files can be created in the root directory of the project.
29
+
PrivateGPT will load the configuration at startup from the profile specified in the `PGPT_PROFILES` environment variable.
30
+
For example, running:
31
+
```bash
32
+
PGPT_PROFILES=ollama make run
33
+
```
34
+
will load the configuration from `settings.yaml` and `settings-ollama.yaml`.
35
+
-`settings.yaml` is always loaded and contains the default configuration.
36
+
-`settings-ollama.yaml` is loaded if the `ollama` profile is specified in the `PGPT_PROFILES` environment variable. It can override configuration from the default `settings.yaml`
37
+
38
+
## About Fully Local Setups
39
+
In order to run PrivateGPT in a fully local setup, you will need to run the LLM, Embeddings and Vector Store locally.
40
+
### Vector stores
41
+
The vector stores supported (Qdrant, ChromaDB and Postgres) run locally by default.
42
+
### Embeddings
43
+
For local Embeddings there are two options:
44
+
* (Recommended) You can use the 'ollama' option in PrivateGPT, which will connect to your local Ollama instance. Ollama simplifies a lot the installation of local LLMs.
45
+
* You can use the 'embeddings-huggingface' option in PrivateGPT, which will use HuggingFace.
46
+
47
+
In order for HuggingFace LLM to work (the second option), you need to download the embeddings model to the `models` folder. You can do so by running the `setup` script:
48
+
```bash
49
+
poetry run python scripts/setup
50
+
```
51
+
52
+
### LLM
53
+
For local LLM there are two options:
54
+
* (Recommended) You can use the 'ollama' option in PrivateGPT, which will connect to your local Ollama instance. Ollama simplifies a lot the installation of local LLMs.
55
+
* You can use the 'llms-llama-cpp' option in PrivateGPT, which will use LlamaCPP. It works great on Mac with Metal most of the times (leverages Metal GPU), but it can be tricky in certain Linux and Windows distributions, depending on the GPU. In the installation document you'll find guides and troubleshooting.
56
+
57
+
In order for LlamaCPP powered LLM to work (the second option), you need to download the LLM model to the `models` folder. You can do so by running the `setup` script:
- UI: whether or not to enable UI (Gradio) or just go with the API
37
+
38
+
In order to only install the required dependencies, PrivateGPT offers different `extras` that can be combined during the installation process:
33
39
34
40
```bash
35
-
poetry install --with ui
41
+
poetry install --extras "<extra1> <extra2>..."
36
42
```
37
43
38
-
Verify everything is working by running `make run` (or `poetry run python -m private_gpt`) and navigate to
39
-
http://localhost:8001. You should see a [Gradio UI](https://gradio.app/)**configured with a mock LLM** that will
40
-
echo back the input. Below we'll see how to configure a real LLM.
44
+
Where `<extra>` can be any of the following:
45
+
46
+
- ui: adds support for UI using Gradio
47
+
- llms-ollama: adds support for Ollama LLM, the easiest way to get a local LLM running, requires Ollama running locally
48
+
- llms-llama-cpp: adds support for local LLM using LlamaCPP - expect a messy installation process on some platforms
49
+
- llms-sagemaker: adds support for Amazon Sagemaker LLM, requires Sagemaker inference endpoints
50
+
- llms-openai: adds support for OpenAI LLM, requires OpenAI API key
51
+
- llms-openai-like: adds support for 3rd party LLM providers that are compatible with OpenAI's API
52
+
- embeddings-ollama: adds support for Ollama Embeddings, requires Ollama running locally
53
+
- embeddings-huggingface: adds support for local Embeddings using HuggingFace
54
+
- embeddings-sagemaker: adds support for Amazon Sagemaker Embeddings, requires Sagemaker inference endpoints
55
+
- embeddings-openai = adds support for OpenAI Embeddings, requires OpenAI API key
56
+
- vector-stores-qdrant: adds support for Qdrant vector store
57
+
- vector-stores-chroma: adds support for Chroma DB vector store
58
+
- vector-stores-postgres: adds support for Postgres vector store
59
+
60
+
## Recommended Setups
61
+
62
+
There are just some examples of recommended setups. You can mix and match the different options to fit your needs.
63
+
You'll find more information in the Manual section of the documentation.
64
+
65
+
> **Important for Windows**: In the examples below or how to run PrivateGPT with `make run`, `PGPT_PROFILES` env var is being set inline following Unix command line syntax (works on MacOS and Linux).
66
+
If you are using Windows, you'll need to set the env var in a different way, for example:
67
+
68
+
```powershell
69
+
# Powershell
70
+
$env:PGPT_PROFILES="ollama"
71
+
make run
72
+
```
73
+
74
+
or
75
+
76
+
```cmd
77
+
# CMD
78
+
set PGPT_PROFILES=ollama
79
+
make run
80
+
```
81
+
82
+
### Local, Ollama-powered setup - RECOMMENDED
83
+
84
+
**The easiest way to run PrivateGPT fully locally** is to depend on Ollama for the LLM. Ollama provides local LLM and Embeddings super easy to install and use, abstracting the complexity of GPU support. It's the recommended setup for local development.
41
85
42
-
### Settings
86
+
Go to [ollama.ai](https://ollama.ai/) and follow the instructions to install Ollama on your machine.
43
87
44
-
<Calloutintent="info">
45
-
The default settings of PrivateGPT should work out-of-the-box for a 100% local setup. **However**, as is, it runs exclusively on your CPU.
46
-
Skip this section if you just want to test PrivateGPT locally, and come back later to learn about more configuration options (and have better performances).
47
-
</Callout>
88
+
After the installation, make sure the Ollama desktop app is closed.
48
89
49
-
<br />
90
+
Install the models to be used, the default settings-ollama.yaml is configured to user `mistral 7b` LLM (~4GB) and `nomic-embed-text` Embeddings (~275MB). Therefore:
50
91
51
-
### Local LLM requirements
92
+
```bash
93
+
ollama pull mistral
94
+
ollama pull nomic-embed-text
95
+
```
96
+
97
+
Now, start Ollama service (it will start a local inference server, serving both the LLM and the Embeddings):
98
+
```bash
99
+
ollama serve
100
+
```
101
+
102
+
Once done, on a different terminal, you can install PrivateGPT with the following command:
Once installed, you can run PrivateGPT. Make sure you have a working Ollama running locally before running the following command.
54
108
55
109
```bash
56
-
poetry install --with local
110
+
PGPT_PROFILES=ollama make run
57
111
```
58
112
59
-
For PrivateGPT to run fully locally GPU acceleration is required
60
-
(CPU execution is possible, but very slow), however,
61
-
typical Macbook laptops or window desktops with mid-range GPUs lack VRAM to run
62
-
even the smallest LLMs. For that reason
63
-
**local execution is only supported for models compatible with [llama.cpp](https://github.com/ggerganov/llama.cpp)**
113
+
PrivateGPT will use the already existing `settings-ollama.yaml` settings file, which is already configured to use Ollama LLM and Embeddings, and Qdrant. Review it and adapt it to your needs (different models, different Ollama port, etc.)
> It's highly encouraged that you fully read llama-cpp and llama-cpp-python documentation relevant to your platform.
84
-
> Running into installation issues is very likely, and you'll need to troubleshoot them yourself.
136
+
PrivateGPT will use the already existing `settings-sagemaker.yaml` settings file, which is already configured to use Sagemaker LLM and Embeddings endpoints, and Qdrant.
137
+
138
+
The UI will be available at http://localhost:8001
139
+
140
+
### Non-Private, OpenAI-powered test setup
141
+
142
+
If you want to test PrivateGPT with OpenAI's LLM and Embeddings -taking into account your data is going to OpenAI!- you can run the following command:
143
+
144
+
You need an OPENAI API key to run this setup.
145
+
146
+
Edit the `settings-openai.yaml` file to include the correct API KEY. Never commit it! It's a secret! As an alternative to editing `settings-openai.yaml`, you can just set the env var OPENAI_API_KEY.
147
+
148
+
Then, install PrivateGPT with the following command:
PrivateGPT will use the already existing `settings-openai.yaml` settings file, which is already configured to use OpenAI LLM and Embeddings endpoints, and Qdrant.
85
160
86
-
#### Customizing low level parameters
161
+
The UI will be available at http://localhost:8001
87
162
88
-
Currently, not all the parameters of `llama.cpp` and `llama-cpp-python` are available at PrivateGPT's `settings.yaml` file.
89
-
In case you need to customize parameters such as the number of layers loaded into the GPU, you might change
90
-
these at the `llm_component.py` file under the `private_gpt/components/llm/llm_component.py`.
163
+
### Local, Llama-CPP powered setup
91
164
92
-
##### Available LLM config options
165
+
If you want to run PrivateGPT fully locally without relying on Ollama, you can run the following command:
93
166
94
-
The `llm` section of the settings allows for the following configurations:
-`max_new_tokens`: this lets you configure the number of new tokens the LLM will generate and add to the context window (by default Llama.cpp uses `256`)
171
+
In order for local LLM and embeddings to work, you need to download the models to the `models` folder. You can do so by running the `setup` script:
172
+
```bash
173
+
poetry run python scripts/setup
174
+
```
98
175
99
-
Example:
176
+
Once installed, you can run PrivateGPT with the following command:
100
177
101
-
```yaml
102
-
llm:
103
-
mode: local
104
-
max_new_tokens: 256
178
+
```bash
179
+
PGPT_PROFILES=local make run
105
180
```
106
181
107
-
If you are getting an out of memory error, you might also try a smaller model or stick to the proposed
108
-
recommended models, instead of custom tuning the parameters.
182
+
PrivateGPT will load the already existing `settings-local.yaml` file, which is already configured to use LlamaCPP LLM, HuggingFace embeddings and Qdrant.
183
+
184
+
The UI will be available at http://localhost:8001
185
+
186
+
#### Llama-CPP support
187
+
188
+
For PrivateGPT to run fully locally without Ollama, Llama.cpp is required and in
0 commit comments