# LocalAI Embeddings

## LocalAI Setup

[**LocalAI** ](https://github.com/go-skynet/LocalAI)is a drop-in replacement REST API that’s compatible with OpenAI API specifications for local inferencing. It allows you to run LLMs (and not only) locally or on-prem with consumer grade hardware, supporting multiple model families that are compatible with the ggml format.

To use LocalAI Embeddings within Flowise, follow the steps below:

1. ```bash
   git clone https://github.com/go-skynet/LocalAI
   ```
2. <pre class="language-bash"><code class="lang-bash"><strong>cd LocalAI
   </strong></code></pre>
3. LocalAI provides an [API endpoint](https://localai.io/api-endpoints/index.html#applying-a-model---modelsapply) to download/install the model. In this example, we are going to use BERT Embeddings model:

<figure><img src="https://823733684-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F00tYLwhz5RyR7fJEhrWy%2Fuploads%2Fgit-blob-117fabc699f34816d740e6a36a46ee76e7ec6112%2Fimage%20(27)%20(1).png?alt=media" alt=""><figcaption></figcaption></figure>

4. In the `/models` folder, you should be able to see the downloaded model in there:

<figure><img src="https://823733684-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F00tYLwhz5RyR7fJEhrWy%2Fuploads%2Fgit-blob-0cc470ce96972cc891da55a13d5e128f29cf6576%2Fimage%20(23)%20(1).png?alt=media" alt=""><figcaption></figcaption></figure>

5. You can now test the embeddings:

```bash
curl http://localhost:8080/v1/embeddings -H "Content-Type: application/json" -d '{
    "input": "Test",
    "model": "text-embedding-ada-002"
  }'
```

6. Response should looks like:

<figure><img src="https://823733684-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F00tYLwhz5RyR7fJEhrWy%2Fuploads%2Fgit-blob-9e7ddff44d91648ab0a9156a530a40f2a46f379c%2Fimage%20(29).png?alt=media" alt="" width="375"><figcaption></figcaption></figure>

## Flowise Setup

Drag and drop a new LocalAIEmbeddings component to canvas:

<figure><img src="https://823733684-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F00tYLwhz5RyR7fJEhrWy%2Fuploads%2Fgit-blob-e06028b369a136e3200d4b448a2a00bcb9ea2b91%2Fimage%20(21)%20(1)%20(2).png?alt=media" alt=""><figcaption></figcaption></figure>

Fill in the fields:

* **Base Path**: The base url from LocalAI such as <http://localhost:8080/v1>
* **Model Name**: The model you want to use. Note that it must be inside `/models` folder of LocalAI directory. For instance: `text-embedding-ada-002`

That's it! For more information, refer to LocalAI [docs](https://localai.io/models/index.html#embeddings-bert).
