Choosing Embedding and Rerank Model APIs: A Practical Guide

    This guide explains how to choose between Embedding and Rerank model APIs for RAG, semantic search, and knowledge base systems. It covers the capability boundaries of both model types, key selection criteria, how to convert free-tier quotas into a realistic budget, a lightweight evaluation method starting with 20 real questions, and architecture practices for caching, observability, and fallback. Readers will learn how to make rational tradeoffs among effectiveness, cost, and compliance.

    1. Background: Why Embedding and Rerank Should Be Discussed Separately

    In systems such as retrieval-augmented generation, semantic search, and knowledge base question answering, Embedding and Rerank serve two different stages. Embedding maps unstructured content such as text, images, audio, and video into a dense vector space. It solves the recall problem and emphasizes throughput and coverage. Rerank performs fine-grained ordering on the recalled results. It solves the ranking problem and emphasizes discrimination accuracy under small batches and low latency. Treating the two as the same thing is a root cause of budget overruns and underwhelming results for many teams.

    The multiple vendors and specific model names mentioned in the original material essentially reflect the same technical fact: the market offers a large number of hosted APIs for both types of model capabilities, and most of them provide free or trial quotas for developers. This article therefore does not focus on any specific product. Instead, it abstracts them into “a cloud vendor,” “a hosted inference platform,” or “a common industry approach,” and focuses on transferable selection methods and engineering practices. If your organization uses general-purpose capabilities from Baidu AI Cloud (such as container platforms, object storage, logging services, and monitoring and alerting), you can map the architecture recommendations in this article directly onto the corresponding product categories.

    2. Capability Boundaries and Selection Criteria

    2.1 Embedding: Input Modality, Dimensions, and Batching

    When selecting an Embedding model, verify at least four things: the supported input modalities (plain text, mixed text and images, audio, video, formatted documents such as PDF), the vector dimensions, and the maximum batch size and maximum length per request. Multimodal support means you can perform cross-modal retrieval in the same vector space, but it also means the semantic distributions of different modalities differ more, requiring more careful evaluation.

    2.2 Rerank: Candidate Set Size and Latency Budget

    A Rerank model typically takes paired input of “query plus several candidate documents” and outputs relevance scores. Its cost grows linearly with the number of candidates. A common engineering practice is therefore “retrieve the top 50 to 100 in the coarse recall stage, and only process the top 20 to 50 in fine ranking.” If the recall stage quality is too poor, even the strongest reranking cannot save it.

    2.3 A Selection Comparison Table

    Dimension Embedding Rerank
    Primary goal High recall, high throughput High-precision ranking
    Input form Single piece of content Query-candidate pairs
    Cost sensitivity Total input tokens Number of candidates × number of queries
    Typical failure mode Mixing vector spaces Truncating the candidate set too aggressively

    3. Free Quotas Are Not Unlimited Calls: Converting Quota into Budget

    The core reminder in the original material is critical: a free quota is a dual constraint on rate and total volume. It is neither a capacity commitment nor a service guarantee. Taking a billing model that “shares a certain number of compute units per day and consumes a fixed number of compute units per million input tokens” as an example, you can build a general estimation formula:

    1. Daily compute units consumed = (indexing tokens + query tokens + retry tokens) × unit token cost
    2. Indexing tokens ≈ number of chunks × average tokens per chunk × (1 + chunk overlap rate)

    Consider an illustrative example: suppose the initial index has 10,000 chunks averaging 500 tokens each, and 1,000 queries of 50 tokens each are added that day. The total is about 5.05 million tokens. If each million tokens consumes 1,075 compute units, that day requires about 5,429 compute units. If the account’s shared daily quota is 10,000 compute units, there appears to be ample headroom, but it will quickly become tight once you add the following factors:

    • Extra input from chunk overlap (20% overlap adds about 1 million tokens);
    • Failed retries and timeout resends;
    • Shared consumption from other model calls under the same account;
    • Full recomputation during index rebuilds;
    • Chinese character counts do not map one-to-one to token counts, so actual tokens are often higher than intuitive estimates.

    The conclusion is clear: any judgment that “it is enough for a personal project” must be validated against your own real usage curve, and you should reserve at least 30% headroom for peaks and retries. In addition, the daily quota usually resets at a fixed time zone (such as UTC 00:00). Cross-timezone teams need to convert the reset point to local time to avoid hitting quota exhaustion during business peaks.

    4. Evaluation Method: 20 Real Questions Are Enough to Start

    Do not pursue a large-scale evaluation set from the outset. A more pragmatic path is:

    1. Pick 20 representative questions from real business logs, covering short queries, long queries, synonymous rewrites, proper nouns, and negations;
    2. Manually label whether the top 5 recalled results for each question are relevant;
    3. Fix the document set and change only one variable (model or parameter), then observe changes in the number of top-5 hits;
    4. Record the model version, dimensions, and chunking parameters for each evaluation to form a traceable evaluation log.

    Illustrative evaluation script skeleton:

    1. def evaluate(questions, index, top_k=5):
    2. hit = 0
    3. for q in questions:
    4. results = index.search(q, top_k=top_k)
    5. if any(r.relevant for r in results):
    6. hit += 1
    7. return hit / len(questions)

    The key discipline is: documents and queries must be encoded with the same model. When switching models, do not reuse old vectors. Even if the dimensions are the same, rebuild an independent index and keep the old version, because the vector spaces of different models are not interchangeable. Mixing them causes a cliff-like drop in recall quality that is hard to diagnose.

    5. Architecture Implementation: Layering, Caching, and Observability

    A robust production architecture typically has four layers: content ingestion and cleaning, chunking and vectorization, vector indexing and retrieval, and reranking and generation. Engineering recommendations include:

    • Manage the chunking strategy and overlap rate as configuration items; changes should trigger a rebuild process;
    • Cache Embedding results for high-frequency queries to significantly reduce repeated consumption;
    • Use a message queue to smooth peaks and isolate batch indexing from online queries, preventing them from competing for quota;
    • Track the daily consumption curve, rate-limit trigger counts, and recall hit rate through logging services and monitoring alerts;
    • Set a candidate count limit and timeout fallback strategy for Rerank, falling back to the coarse ranking order on timeout.

    6. Common Pitfalls and Compliance Reminders

    First, treating the free quota as a capacity guarantee while ignoring rate limits and reset time zones; second, estimating tokens by character count, causing budget deviations; third, switching models without rebuilding the index; fourth, only testing recall without testing reranking, or only testing reranking without fixing recall; fifth, ignoring data compliance. Some free tiers may use input content for product improvement. For sensitive data, use a channel explicitly not used for training or self-deploy open-weight models—but note that the compute cost of self-deployment is not zero.

    7. Conclusion

    Choosing Embedding and Rerank model APIs is essentially an engineering tradeoff among effectiveness, cost, and compliance. First clarify the task layering, then convert the quota into a verifiable budget, use 20 real questions for a minimum viable evaluation, and finally backstop the risks with an architecture that is rebuildable, rollback-capable, and observable. This lets you make a rational decision between free quotas and paid plans.