Embeddings
An embedding is a list of numbers that represents the meaning of text. Text with similar meaning tends to have similar vectors, which lets you search by meaning instead of exact keywords. Use/v1/embeddings to create vectors:
| Parameter | Description |
|---|---|
model | Embedding model name |
input | A string or an array of strings |
encoding_format | Optional output format, usually float or base64 |
Python example
Batch embeddings
Similarity search
After you create vectors, store them in a vector database such as Milvus, Qdrant, Chroma, Pinecone, or pgvector. At query time, embed the user question and search for nearest vectors.Reranking
Reranking takes a query and candidate documents, then returns a relevance score for each candidate. It is commonly used after vector search to improve result quality.Typical RAG flow
- Split source documents into chunks.
- Create embeddings for each chunk.
- Store vectors and metadata in a vector database.
- Embed the user query.
- Retrieve the most similar chunks.
- Optionally rerank the retrieved chunks.
- Send the best context to a chat model for the final answer.
Practical guidance
- Choose an embedding model that matches your language and domain.
- Keep chunk sizes consistent and include useful metadata.
- Rerank only the top candidates to control cost and latency.
- Monitor token usage in dashboard and usage.
