dimension-tradeoffs.md

reference

← Back to skill

Content hash: 00890b142a62ab661d431e7f6582c923f3dcbafd87cc6816eb888c187c710ce8
# Dimension & Cost Tradeoffs

## Storage cost per 1M documents (float32)

| Dims | MB (raw) | GB (raw) | Typical model family |
|------|----------|----------|---------------------|
| 384  | 1,536    | 1.5      | MiniLM, all-MiniLM |
| 768  | 3,072    | 3.0      | BGE-base, E5-base, mpnet |
| 1024 | 4,096    | 4.0      | BGE-large, GTE-large |
| 1536 | 6,144    | 6.0      | OpenAI ada-002, text-embedding-3 |
| 3072 | 12,288   | 12.0     | OpenAI text-embedding-3-large |

Formula: `bytes = dims × 4 (float32) × N_docs`

## Matryoshka embedding support

Models supporting truncation to shorter dims with graceful degradation:
- OpenAI `text-embedding-3-small` and `text-embedding-3-large`
- `nomic-embed-text-v1.5`
- Several Sentence-Transformers models

Test at multiple dims with ONE model: embed at 1536, truncate to 768, benchmark recall.

## Retrieval quality vs dimensions

```
recall@10
  ^
  |     ***
  |   **
  | **          ← knee around 768-1024
  |*
  +--------------> dims
  128   384   768   1536  3072
```

For most RAG: 768-1024 is the practical sweet spot. Going beyond 1536 buys ~0-2% recall for 2-4× storage.

## API cost comparison (approximate per 1M tokens)

| Provider | Model | Dims | Cost (input) |
|----------|-------|------|-------------|
| OpenAI | text-embedding-3-small | up to 1536 | $0.02 |
| OpenAI | text-embedding-3-large | up to 3072 | $0.13 |
| Cohere | embed-english-v3 | 1024 | $0.10 |
| Voyage | voyage-2 | 1024 | $0.10 |
| Self-hosted | BGE-base | 768 | $0 (GPU/infra cost) |