Practices for Selecting Embedding and Reranking APIs

    Embeddings and reranking have become standard components in semantic search, recommendation systems, knowledge base QA, and content moderation. This article explores the key considerations for selecting embedding and reranking APIs, covering interface forms, evaluation dimensions, quota management, compliance, and recommended reference architectures. It provides actionable insights to help teams transition from prototypes to reliable, production-ready retrieval systems.

    In scenarios like semantic search, recommendations, knowledge base QA, and content moderation, embeddings and reranking have become standard components. The former maps objects like text and images into vector spaces to support approximate nearest neighbor (ANN) search, while the latter uses more refined relevance models to re-score candidate sets, improving the final ranking. Many teams initially seek services offering “free tiers, simple interfaces, and multimodal inputs.” However, a sustainable solution depends less on promotional quotas and more on whether capability boundaries match business needs, whether quotas and rate limits are predictable, and whether data governance meets compliance requirements.

    1. Clarify the Task Before Interface Forms

    Embedding interfaces typically accept one or more inputs and return fixed or variable-dimension floating-point vectors. Engineering-wise, it is essential to clarify: whether inputs support only text or also cover images, audio, and video; the maximum tokens or bytes per request; whether batch processing is supported; whether vector dimensions are configurable; and whether normalization and truncation strategies are provided. Reranking interfaces differ: inputs are generally a “query + candidate document list,” and outputs are relevance scores or reranked orders. The two are not interchangeable: embeddings solve “recall from a massive corpus,” while reranking solves “fine-ranking on a small set.” If the business only requires classification or clustering, embeddings alone suffice; for search and QA, the common pipeline is “embedding recall + rule filtering + reranking + generation.”

    Free quotas are attractive for individual prototypes, but the quota metrics must be clear: is it by token, call count, compute unit, or a dual limit of concurrency and QPS? Daily shared quotas, monthly amount limits, and rate limits for evaluation keys mean entirely different things for “occasional experiments” versus “continuous online traffic.” During selection, convert quotas into “daily processable queries × average document length” and compare against peak rather than average values. Any unpublished or irreproducible “performance numbers” should not be written into architecture decisions.

    1. General Evaluation Dimensions for Embedding Services

    2. Input Modality and Preprocessing: For text-only scenarios, focus on tokenization, multilingual support, and long document chunking. If the business includes screenshots, audio/video subtitles, or keyframes, verify whether the service natively accepts non-text or if it must be converted to text on the client side first. Client-side conversion introduces errors and latency but is often easier to audit; server-side multimodal reduces pipeline complexity but requires privacy assessments to be brought forward.

    3. Vector Space Consistency: Within the same business, fix the model version and dimension to avoid incomparable similarities caused by mixing. During version upgrades, perform full or sampled re-embedding and retain the old index for a period for grayscale rollout. Higher dimensions increase storage and retrieval costs and are not always better; compare recall rates and latency on a validation set rather than just looking at advertised dimensions.

    4. Engineering Implications of Billing and Quotas: When billing by million tokens, confirm via small-traffic testing whether prompts, document bodies, and metadata count as input, and whether output vectors are billed. If a free tier states that “content may be used to improve products,” this is typically unacceptable for scenarios involving personal data or trade secrets. Switch to commercial terms explicitly stating “not used for training” or a privatized deployment path.

    5. Stability and Isolation: Shared free pools may experience sudden rate limiting. Production environments should feature timeouts, retry backoff, degradation (e.g., keyword-only search), and local caching. Caching query vectors for high-frequency queries and performing offline batch embeddings for stable corpora can significantly reduce online costs.

    6. General Evaluation Dimensions for Reranking Services

    Reranking models model “query-document” interactions more thoroughly, but the computation increases approximately linearly with the number of candidates. In practice, reranking is typically only applied to the top few dozen to a couple of hundred recalled items. Evaluation focuses on: maximum candidate count, single document length, support for multi-field (title, body, tags) concatenation, and score calibration. If scores are not comparable, do not apply absolute threshold filtering across requests; use relative ranking instead.

    Reranking and business rules should be layered: compliance interception, inventory, and permissions should be completed before reranking to avoid sending unauthorized documents to the model. After reranking, click-through rates and freshness can be lightly fused, but fusion coefficients require offline experiments rather than guesswork.

    1. Use Free Quotas at the Right Stage

    During the prototype stage, limited free calls can verify chunking strategies, dimensions, and evaluation set metrics (like nDCG, Recall@K). Once metrics stabilize, migrate promptly to a contractable, auditable, and isolated environment. Evaluation keys often have strict rate and monthly call limits, suitable for protocol walkthroughs but not stress testing. Stress tests should use an isolated environment and comply with terms of service, avoiding using shared free tiers as stress testing machines.

    Data minimization is equally important: text sent to the interface should remove sensitive fields like ID numbers and internal tickets; logs should only retain hashes and truncated examples. If using general capabilities like vector search, object storage, logging, and monitoring/alerting on cloud platforms (e.g., Baidu AI Cloud), place keys in a Key Management Service (KMS) rather than hardcoding them into code repositories.

    1. Recommended Reference Architecture (Vendor-Agnostic)

    Offline: Document cleaning -> Chunking -> Embedding -> Write to vector index, metadata written to structured storage.
    Online: Query understanding -> Query embedding (cacheable) -> Approximate search -> Permission and rule filtering -> Reranking -> Truncate and return.
    Observability: Record latency for each stage, empty result rate, rate limit count, embedding failure rate; use a golden set for periodic regression to prevent silent performance drops due to model or chunking changes.

    Schematic calls (logical examples, not a specific vendor’s interface):

    1. POST /embeddings
    2. { "model": "text-embedding", "input": ["chunked text..."] }
    3. POST /rerank
    4. { "query": "user question", "documents": ["candidate1", "candidate2", "..."] }

    The client should split overly long inputs itself and record offsets to map hit chunks back to the original text. Reranking requests should limit the length of documents; truncate or summarize exceeding parts to avoid meaningless timeouts.

    1. Integration with Cloud Capabilities (e.g., Baidu AI Cloud)

    When requiring object storage for raw corpora, message queues for asynchronous embedding, container platforms for chunking and evaluation tasks, and logging services with monitoring for observing rate limits, use general-category products provided by cloud vendors to decouple model inference from the data plane. The focus is on interface version locking, controllable network egress, and traceable audit logs. Do not assume one cloud will provide undisclosed custom support for another company; architecture descriptions should be confined to standard capability combinations within your own account.

    1. Implementation Checklist
    • Is the task recall, fine-ranking, or both?
    • Do modalities, languages, and maximum length cover the real corpus?
    • Does the daily capacity after converting free/paid quotas cover the peak?
    • Is data allowed for service improvement; do contracts and regions meet compliance?
    • Are there versions, rollbacks, re-embedding, and evaluation sets?
    • Are rate limiting, timeouts, degradation, and caching designed?
    • Do reranking candidate scale and latency budget match the interaction scenario?

    The value of embedding and reranking APIs lies in standardizing semantic capabilities, not binding to quota numbers on a promotional page. Use tasks to define selection constraints, evaluation sets to constrain quality, and quotas and compliance to constrain cost and risk. This ensures a smooth transition from prototype to an operable retrieval system. For individual projects, limited free tiers suffice to verify chunking and metrics; for enterprise projects, switch early to services with predictable billing and clear data usage terms, designing them alongside retrieval, storage, and observability systems rather than chasing a specific interface name.