|
| 1 | +# Embeddings Service |
| 2 | + |
| 3 | +This directory configures a local embedding server using Hugging Face Text Embeddings Inference (TEI) with the `sentence-transformers/all-MiniLM-L6-v2` model. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The embeddings service provides an OpenAI-compatible API for generating text embeddings locally. |
| 8 | + |
| 9 | +- **Model**: sentence-transformers/all-MiniLM-L6-v2 |
| 10 | +- **Embedding Dimension**: 384 |
| 11 | +- **API Endpoint**: http://embeddings:80/v1 (internal), http://localhost:8081/v1 (external) |
| 12 | + |
| 13 | +## Prerequisites |
| 14 | + |
| 15 | +To use embeddings for search and agent features, add these to your `.env` file (see `.env.example`): |
| 16 | + |
| 17 | +```env |
| 18 | +AGENT_ENABLED=True |
| 19 | +SEARCH_ENABLED=True |
| 20 | +OPENAI_API_KEY=your-api-key-here # Optional: only needed for agent features or when using OpenAI embeddings |
| 21 | +``` |
| 22 | + |
| 23 | +## Local Embeddings (Default) |
| 24 | + |
| 25 | +This setup uses a local embedding service with no external API required. The default configuration in `embeddings.env` is: |
| 26 | + |
| 27 | +- `OPENAI_BASE_URL=http://embeddings:80/v1` |
| 28 | +- `EMBEDDING_DIMENSION=384` |
| 29 | + |
| 30 | +### Start the orchestrator |
| 31 | + |
| 32 | +Start the orchestrator with the local embeddings service: |
| 33 | + |
| 34 | +```bash |
| 35 | +docker compose --profile embeddings up orchestrator |
| 36 | +``` |
| 37 | + |
| 38 | +## Alternative: Using OpenAI Embeddings |
| 39 | + |
| 40 | +If you prefer to use OpenAI's embedding service instead of running a local model: |
| 41 | + |
| 42 | +### Configuration |
| 43 | + |
| 44 | +Override the embedding settings by editing `docker/overrides/embeddings/embeddings.env`: |
| 45 | + |
| 46 | +```env |
| 47 | +OPENAI_BASE_URL=https://api.openai.com/v1 |
| 48 | +EMBEDDING_DIMENSION=1536 |
| 49 | +``` |
| 50 | + |
| 51 | +### Start the orchestrator |
| 52 | + |
| 53 | +Start only the orchestrator (skips the local embeddings service): |
| 54 | + |
| 55 | +```bash |
| 56 | +docker compose up orchestrator |
| 57 | +``` |
| 58 | + |
| 59 | +## Post-Setup Steps |
| 60 | + |
| 61 | +After starting the services and making sure you have data for the entity you want to index: |
| 62 | + |
| 63 | +### 1. Apply the schema change |
| 64 | + |
| 65 | +This will resize the vector dimension to match your embedding configuration (384 for local, 1536 for OpenAI) and delete existing records: |
| 66 | + |
| 67 | +```bash |
| 68 | +docker compose exec orchestrator /home/orchestrator/.venv/bin/python main.py embedding resize |
| 69 | +``` |
| 70 | + |
| 71 | +⚠️ **Note**: This command will delete all existing embedding records. |
| 72 | + |
| 73 | +### 2. Re-index your data |
| 74 | + |
| 75 | +Example Index subscriptions: |
| 76 | + |
| 77 | +```bash |
| 78 | +docker compose exec orchestrator /home/orchestrator/.venv/bin/python main.py index subscriptions |
| 79 | +``` |
| 80 | + |
| 81 | +## Advanced Configuration |
| 82 | + |
| 83 | +The following configurations use conservative defaults for local/unknown models: |
| 84 | + |
| 85 | +- `EMBEDDING_FALLBACK_MAX_TOKENS=512`: Maximum tokens per embedding request |
| 86 | +- `EMBEDDING_MAX_BATCH_SIZE=32`: Maximum batch size for embedding requests |
| 87 | + |
| 88 | +**Note**: These settings are only used as fallbacks for local or unknown models (like the example in this setup). For known providers and models, the system automatically retrieves the correct values via LiteLLM. The fallback values are already configured safely for local models, but can be adjusted if needed in `docker/overrides/embeddings/embeddings.env`. |
0 commit comments