Prompt
What's the most cost-effective way to run semantic search using retrieval infrastructure at scale?
Latest observation
Nov 7, 2026
OpenAI APIWeb search: off
The most cost-effective way to run semantic search at scale is usually:
1) Use a two-stage retrieval architecture
- Stage 1: Cheap candidate generation
- Use sparse retrieval like BM25 / keyword search or a lightweight ANN index.
- Goal: pull back a few hundred or thousand candidates quickly and cheaply.
- Stage 2: Semantic reranking
- Apply embeddings + vector search only on the candidate set, not the entire corpus.
- Optionally rerank the top 50–200 with a more expensive model.
This is usually far cheaper than doing “full semantic search over everything” for every query.
2) Choose the right index type for your workload
For large-scale retrieval, a vector database or ANN index is standard, but cost depends heavily on the algorithm and hardware:
- HNSW
- Great latency/recall tradeoff
- Often higher memory usage
- Best when you can afford RAM for hot data
- IVF / PQ / ScaNN / disk-backed ANN
- Lower memory footprint
- Better when corpus is very large and cost matters
- Often the best cost/performance choice at scale
- Hybrid search
- Combine BM25 + vector search
- Improves quality so you can keep top-k smaller, reducing downstream cost
If cost is the priority, avoid overprovisioning a high-memory in-memory vector setup unless you truly need ultra-low latency.
3) Reduce embedding and storage costs
- Use a smaller embedding model if quality is acceptable.
- Normalize and deduplicate content before embedding.
- Embed only the fields that matter.
- Chunk documents carefully:
- Too many small chunks = higher storage and query cost
- Too large chunks = worse retrieval quality
- Use batch embedding and async pipelines to reduce compute cost.
4) Optimize query-time costs
- Cache frequent queries and results.
- Use adaptive top-k:
- Start with small candidate sets
- Expand only if confidence is low
- Add filters early (tenant, language, date, category) to shrink search space.
- Use ANN approximate search rather than exact brute-force vector similarity.
5) Pick infrastructure based on scale
Cheapest options for many teams:
- Postgres + pgvector for smaller to medium scale or simpler ops
- OpenSearch / Elasticsearch hybrid search if you already run it
- Managed vector DB only if you want to trade money for operational simplicity
More cost-effective at very large scale:
- Purpose-built ANN systems or custom retrieval stacks
- Sharded indexes, compressed vectors, disk-friendly ANN, and hot/cold tiering
6) Practical “best value” architecture
A common cost-effective setup is:
- BM25 / inverted index for initial retrieval
- Vector ANN index for semantic candidates
- Cross-encoder reranker only on top results
- Caching + filtering + deduplication to reduce repeated work
This gives strong quality without making every query expensive.
Rule of thumb
If you want the most cost-effective setup:
- Start with hybrid retrieval
- Use approximate ANN, not exact search
- Keep vectors compact and embeddings inexpensive
- Rerank only a small candidate set
- Avoid storing and searching unnecessary chunks/metadata
If you want, I can also give you:
- a reference architecture,
- a cost comparison of pgvector vs OpenSearch vs dedicated vector DBs, or
- a recommended stack for a specific scale (e.g. 1M, 100M, or 1B vectors).