Model | Dimensions | Max Tokens | Cost | MTEB Avg Score | Similarity Metric |
---|---|---|---|---|---|
text-embedding-3-small | 1536 (scales down) | 8191 | $0.02 / 1M tokens | 62.3 | cosine, dot product, L2 |
text-embedding-3-large | 3072 (scales down) | 8191 | $0.13 / 1M tokens | 64.6 | cosine, dot product, L2 |
pg_vector
.
When storing embeddings in Postgres, it is important that each vector will be stored in a row that fits in a single PG block (typically 8K). If this size is exceeded,
the vector will be stored in TOAST storage which can slow down queries. In addition vectors that are “TOASTed” are not indexed, which means you can’t reliably use vector indexes.
Both OpenAI’s embedding models were trained with a technique that allows developers to trade-off performance and cost of using embeddings. Specifically, developers can shorten embeddings
(i.e. remove some numbers from the end of the sequence) without the embedding losing its concept-representing properties by passing in the dimensions API parameter.
Using the dimensions parameter when creating the embedding (as shown above) is the preferred approach. In certain cases, you may need to change the embedding dimension after you generate it.
When you change the dimension manually, you need to be sure to normalize the dimensions of the embedding.