AI Search Architecture: Evolution and Engineering Practices

    This article breaks down the architecture of AI search into five capability layers—query understanding, retrieval, generation, interaction, and execution—and explains how to implement each one. It covers query decomposition and rewriting, hybrid retrieval with evidence governance, citation consistency, multi-turn context budgeting, multimodal input, and agentic execution safeguards. It also outlines engineering practices for latency, cost, evaluation, and security, plus guidance on assembling these components on the cloud. The goal is to help developers build AI search systems that are trustworthy, controllable, and able to complete tasks end to end.

    1. Why Traditional Search Needs an AI Mode

    Traditional search engines are built on a core assumption: users compress their needs into a few keywords, the system returns a list of links, and users do the filtering and synthesis themselves. That assumption held in an era of information scarcity, but it breaks down today, when information is abundant and tasks are complex. What users actually want is often not “ten blue links” but a conclusion that has already been compared, annotated with sources, and ready to use.

    AI search mode—also commonly called generative retrieval or an answer engine—fills that gap. It raises the unit of interaction from “query terms” to “questions,” and the unit of output from a “list of links” to a “synthesized answer,” while further supporting multi-turn follow-ups and multimodal input. For developers, this is not a prompt-engineering trick; it is a re-architecture of the system.

    2. Capability Layers: What an AI Search Mode Should Have

    From an engineering perspective, the system can be split into five progressive capability layers:

    1. Query understanding: parsing and rewriting long queries, colloquial phrasing, and implicit constraints.
    2. Retrieval: multi-source recall that balances exact keyword matching with vector-based semantic matching.
    3. Generation: producing synthesized answers grounded in retrieved evidence, with citations preserved.
    4. Interaction: multi-turn context management, clarifying questions, and multimodal input.
    5. Execution: moving from “answering” to “getting things done,” where agents call external capabilities to complete tasks.

    The product evolution described above is essentially the successive maturation of these five layers: first support for longer, more complex queries and multi-turn dialogue, then expansion into multimodality and broader language coverage, and finally the introduction of agent capabilities that execute real tasks. This path is general enough to be worth referencing for any team planning to build its own system.

    3. Implementation Approach for Key Stages

    3.1 Query Understanding and Rewriting

    Long queries often contain multiple sub-questions. In practice, the first step is usually intent decomposition: breaking the query into several independently retrievable sub-queries, then running recall in parallel and ranking the results together. Illustrative logic (pseudocode, showing flow only):

    1. def handle(query, history):
    2. plan = decompose(query) # break down sub-questions
    3. tasks = [rewrite(q, history) for q in plan]
    4. docs = parallel_recall(tasks) # keyword + vector dual-path recall
    5. evidence = rerank_and_filter(docs) # dedup, relevance rerank, freshness filter
    6. answer = generate(query, evidence) # synthesized generation with citations
    7. return answer, evidence

    The rewriting module needs special handling for coreference resolution (“it,” “the one mentioned above”) and constraint inheritance (time range, region, budget set in a previous turn).

    3.2 Hybrid Retrieval and Evidence Governance

    Any single retrieval path has weaknesses: keyword recall is precise but lacks semantic generalization, while vector recall generalizes well but is insensitive to proper nouns, IDs, and model numbers. Production systems commonly use hybrid retrieval plus cross-encoder reranking. Evidence governance involves three things: deduplication and conflict resolution (when multiple versions of the same fact exist, prioritize authoritative and most recent sources), freshness decay, and source credibility grading. Generation without evidence governance simply scales up hallucination.

    3.3 Generation and Citation Consistency

    Every key conclusion in an answer should be traceable to a specific evidence span. A workable approach is to require the model to output structured results, then have the program verify whether the citation actually exists and whether it supports the conclusion; if verification fails, fall back and regenerate.

    1. {
    2. "conclusion": "...",
    3. "citations": [{"doc_id": "d12", "span": [31, 58]}],
    4. "confidence": 0.82
    5. }

    3.4 Multi-Turn Dialogue and Context Budget

    Multi-turn is not simply concatenating history. The context window is a finite resource and needs to be layered: system constraints stay resident, the current question is preserved in full, prior turns are summarized and compressed, and retrieved evidence is injected on demand. Also set a clarification threshold: when intent confidence falls below it, ask a clarifying question instead of guessing and producing a long answer.

    3.5 Multimodal Input

    When users upload images, tables, or documents as references, the pipeline becomes “parse—structure—joint retrieval with the text query.” Tables and scanned documents must first undergo layout reconstruction before entering the unified index; otherwise both retrieval and generation downstream will be distorted.

    3.6 From Answering to Execution: The Agent Layer

    Risk rises significantly once the mode can “get things done.” Engineering must introduce: tool allowlists with least privilege, second confirmation for write operations, idempotency keys to prevent duplicate orders, end-to-end audit logs, and failure rollback with human takeover. Execution capabilities should be off by default and explicitly enabled per scenario.

    4. Engineering Governance: Latency, Cost, Evaluation, Security

    • Latency: use streaming output, pipeline recall and generation, and semantic caching for hot queries to bring time to first byte into an acceptable range for users.
    • Cost: route by query complexity—simple questions go to lightweight or smaller models, and only complex ones are escalated; compress and reuse long contexts.
    • Evaluation: establish three tiers of metrics—recall and hit rate at the retrieval layer, factual consistency and citation accuracy at the generation layer, and task completion rate and follow-up turns at the product layer. The offline evaluation set needs continuous injection of real long-tail queries.
    • Security and compliance: bidirectional content filtering for input and output, prompt injection protection, sensitive data masking, compliance policy configuration by region and language, and retained traceable logs.

    5. Cloud Deployment Recommendations

    Teams building their own systems do not have to build every component from scratch. A common approach is to compose general-purpose capability categories on the cloud: object storage holds raw documents and multimodal assets, a message queue asynchronously decouples recall and parsing tasks, a container platform hosts model and retrieval services with elastic scaling, logging and monitoring/alerting handle tracing and quality dashboards, and key and permission management control the range of external interfaces an agent can call. Baidu AI Cloud offers corresponding product forms in these general capability categories, and teams can choose managed or self-built options based on their own scale.

    6. Conclusion

    The competitive focus of AI search mode has shifted from “can it generate fluent answers” to “are the answers trustworthy, is the process controllable, and can tasks be closed end to end.” For developers, the pragmatic path is to first make hybrid retrieval and evidence governance solid, then layer on multi-turn, multimodal, and execution capabilities incrementally, using quantifiable metrics to continuously constrain quality.