Skip to content

Embeddings & re-embedding

Every collection in a tenant shares one embedding model, the tenant’s default_embedding_model_id. Documents are embedded with it at ingest and questions are embedded with it at retrieval, which keeps the whole tenant in one vector space. There is no per-collection model.

Any embedding-capable model in the tenant’s catalog works (OpenAI, Ollama, vLLM, …). Both ingest and query embeddings are sent to the Core Proxy’s /v1/proxy/llm/embeddings, so they appear in proxy logs and usage like any other model call. New tenants get a default model at provisioning (text-embedding-3-small for a remote setup, nomic-embed-text for a local Ollama setup in the trial bundle).

Find an enabled embedding model, then PATCH the tenant:

Terminal window
curl -s "http://localhost:5050/v1/admin/llms?mode=embedding&enabled=true&limit=100" \
-H "Authorization: Bearer $ADMIN_JWT"
# → {"models": [{"id": "llm-01M61N23ES4KYJGVXVT9G8MNJB", "name": "Ollama Nomic Embed Text", "provider": "ollama", …}], "total": 2}
curl -s -X PATCH http://localhost:5050/v1/admin/tenants/default \
-H "Authorization: Bearer $ADMIN_JWT" -H "Content-Type: application/json" \
-d '{"default_embedding_model_id": "llm-01M61N23ES4KYJGVXVT9G8MNJB"}'

The response is the updated tenant record with default_embedding_model_id set. In the Admin UI: Administration → Settings → Tenant → Default Models; saving a changed model asks for an extra confirmation.

The same model is used by the semantic response cache (AI Estate → Resources → AI Models → Cache → Response Cache), so a switch affects both.

  1. Check the scope first:

    Terminal window
    curl -s http://localhost:5050/v1/admin/tenants/default/kb-stats \
    -H "Authorization: Bearer $ADMIN_JWT"
    {
    "tenant_id": "default",
    "document_count": 312,
    "chunk_count": 18450,
    "documents_by_status": {"ready": 309, "error": 3},
    "estimate": {
    "hosted_seconds": 123.0,
    "local_seconds": 1845.0,
    "note": "Wall-clock re-embed time depends on provider throughput, document size, and chunking. Hosted providers (OpenAI / Anthropic) typically run ~100-300 chunks/sec; a local Ollama instance closer to ~5-20 chunks/sec."
    }
    }
  2. Queue the re-embed:

    Terminal window
    curl -s -X POST http://localhost:5050/v1/admin/tenants/default/re-embed-kb \
    -H "Authorization: Bearer $ADMIN_JWT"
    {
    "message": "Queued 312 document(s) for re-embedding. The kb-uploader will process them in the background with the tenant's current embedding model.",
    "tenant_id": "default",
    "documents_queued": 312,
    "chunks_deleted": 18450,
    "qdrant_collection": "brutor_kb_default",
    "qdrant_dropped": true
    }

    This drops the tenant’s Qdrant collection (it is recreated with the new dimension on the first write), deletes the stored chunks, sets every document to pending and flushes the tenant’s semantic cache entries. Raw files and connector text stay in place, so nothing is re-uploaded or re-synced.

  3. Wait for the documents to return to ready (re-check kb-stats). Retrieval finds nothing until documents are re-indexed.

400 when the tenant has no default_embedding_model_id; 403 when a tenant admin targets another tenant. In the Admin UI, use Rebuild Index on AI Estate → Resources → Knowledge Base → Collections, or Re-embed all content under Administration → Settings → Tenant → Default Models, which shows the kb-stats estimate before confirming.

To re-process a single document instead, use POST /v1/admin/knowledge-base/documents/{document_id}/reembed (see Upload & ingestion).

When a query vector’s size does not match the tenant’s Qdrant collection, the Core Proxy skips retrieval for that call (the chat still goes through, ungrounded) and raises a per-tenant kb_vector_dim_mismatch system alert naming the expected and received dimensions. The fix is always the tenant re-embed above. See Alerts.

All tenants share one Qdrant instance, but each tenant’s vectors live in their own collection, brutor_kb_{tenant_id}, and every Qdrant call from the Control Plane, the KB Uploader and the Core Proxy carries a freshly minted HS256 JWT (300-second lifetime) that grants access to that one tenant’s collection only. Qdrant validates the token itself, so a cross-tenant read is refused at the vector store, independent of application filters. The signing secret is QDRANT_JWT_SIGNING_SECRET, shared by all three services and configured as Qdrant’s API key; a service without it disables its Qdrant operations rather than running unauthenticated.