Evaluating Embedding and Reranking APIs: A Practical Selection Guide
This guide explains how to evaluate embedding and reranking API providers for retrieval-augmented generation without relying on vendor claims. It covers free-tier limits, token budgeting, index rebuild rules when switching models, recall and latency checks, and enterprise production requirements.
In retrieval-augmented generation (RAG), vector retrieval and reranking form the core path for improving large language model answer accuracy. With many API providers offering embedding and rerank models, developers and enterprises must balance cost, performance, multimodal support, and data privacy. This article stays clear of vendor marketing and explains, from an engineering and neutral technical perspective, how to evaluate API providers and what practices to follow in production.
1. Common API service models and free-tier pitfalls
During knowledge-base prototyping, developers often look first at free quotas. Mainstream API offerings generally fall into a few categories: multimodal embedding APIs from major international AI vendors (text, images, audio, and similar inputs), open-source models hosted on edge computing platforms, and inference APIs provided directly by open-source communities.
When assessing free quotas, watch for these common pitfalls:
- Data privacy and product-improvement terms. Many free tiers state that user inputs may be used to improve the provider’s own products or to train future models. For knowledge bases that contain trade secrets or sensitive information, sending content to such free APIs for embedding can create serious compliance risk.
- Rate limits and quota resets. Free tiers usually come with strict concurrency limits and monthly call caps. Some evaluation keys are intended only for prototypes. Daily free quotas often reset in UTC, so convert that time to the local time zone to avoid miscalculating availability during peak business hours.
- Free does not mean production guarantees. A free quota only reduces compute cost within a limited capacity. It does not provide a service-level agreement (SLA). If an underlying node fails or the network is unstable, a retrieval path without automatic retry and fallback can fail outright.
2. Token budgeting and capacity estimation
APIs are usually billed by tokens consumed. A common mistake with Chinese knowledge bases is treating character count as token count. Because tokenizers differ, the ratio of Chinese characters to tokens typically ranges from about 1.5:1 to 1:2. To judge whether a free quota is enough, build a strict token budget.
Suppose an edge platform converts usage into billing units per million input tokens, and the account shares a fixed daily free quota. If the initial index contains 10,000 text chunks averaging 500 tokens each, and the system then receives 1,000 queries averaging 50 tokens each, same-day consumption is:
Indexing: 10,000 chunks × 500 tokens/chunk = 5,000,000 tokensQueries: 1,000 queries × 50 tokens/query = 50,000 tokensTotal: 5,050,000 tokens
Multiply that total by the billing rate to estimate the day’s billed units. This is only a static budget under ideal conditions. In real systems, also account for:
- Chunk overlap. Overlap used to preserve context typically increases processed tokens by 10% to 20%.
- Failed retries. Network issues or timeouts can consume two or more times the expected tokens.
- Incremental rebuilds. Full rebuilds when documents change can cause periodic spikes in token use.
3. Engineering rules for model switches and index rebuilds
As a knowledge base grows or accuracy requirements rise, teams often move to a newer embedding model. A model switch must follow index rebuild rules.
1. Do not mix vector spaces
Even if the old and new models both output the same dimension (for example, 1024), never store vectors from different models in the same vector index. Their feature spaces differ in fundamental ways. Mixing them makes cosine similarity lose semantic meaning and can cause severe recall errors.
2. Keep separate indexes and versions
When introducing a new model, create a new vector index and keep the old one until the new index is fully validated. Running both in parallel supports a smooth migration and a fast rollback if quality drops.
3. Standardize request bodies and migration checks
Use a consistent API request body during migration. A standard embedding request looks like this:
{"model": "your-embedding-model-id","input": ["Text that needs to be embedded", "Another piece of text"],"encoding_format": "float"}
Check whether the new API supports the existing batching logic, custom truncation length, and error codes expected by the current exception-handling middleware.
4. Recall quality and rerank coordination
The embedding model performs the first-stage retrieval; the rerank model performs fine ranking. Selection should come back to retrieval quality. Do not rely on subjective impression. Use a quantitative evaluation.
- Build a benchmark set. Manually label 20 to 50 real user questions from the business domain, and define the expected correct document chunk for each question.
- Measure top-k recall. Generate vectors with the candidate model and search the knowledge base. Typically check whether the expected document appears in the top 5 results. If top-5 accuracy from the embedding model is too low, a rerank model is unlikely to recover the miss.
- Keep document and query embeddings aligned. In most cases, the embedding model used at indexing time and the one used at query time must be exactly the same. Models that support asymmetric encoding are an exception, but their parameter requirements must be followed strictly.
- Measure rerank API latency. Rerank models are usually cross-encoders and are far more expensive to compute than embeddings. Besides the accuracy gain, test P99 latency across candidate-set sizes (for example, top 20 through top 100) so the reranker does not become the throughput bottleneck.
5. Recommendations for enterprise deployment
For personal projects or low-frequency prototypes, free quotas from open-source communities or edge platforms can be enough. In enterprise production, data compliance, high concurrency, and stability become hard requirements.
For enterprise deployment, choose a cloud provider with solid compliance credentials and infrastructure. For example, model hosting and vector database services on Baidu AI Cloud can provide dedicated compute and data isolation, and can integrate with cloud-native components such as object storage, logging, and monitoring and alerting. That supports an end-to-end path from data ingestion and chunking through embedding and fine ranking. This model avoids third-party API rate limits and privacy risk and is better suited to long-term, stable operation of large knowledge bases.
In short, choosing embedding and rerank APIs is not a simple price comparison. It is a technical decision covering cost, engineering practice, quality evaluation, and compliance risk. Only a systematic evaluation framework can support an efficient and reliable retrieval foundation for RAG applications.
