Building an AI Retrieval Architecture That Covers Non-Public Data

    General-purpose search engines excel at discovering public web pages, but enterprise knowledge bases, business databases, ticketing systems, log platforms, documents in object storage, and data behind login or authorization walls typically never enter public indexes. For AI applications, if the retrieval layer relies solely on public search results, answers will have information gaps: fluent on the surface, but missing critical context. Solving this requires unifying "public retrieval" and "non-public data retrieval" into a governable, evaluable, and scalable architecture, rather than simply stitching together multiple search APIs. This article addresses the general technical problem of covering data beyond general-purpose indexes, discussing the architectural design, developer integration approach, and evaluation methodology of AI retrieval systems. The core goal is not single-point recall, but balancing accuracy, latency, permission compliance, and operability.

    Building an AI Retrieval Architecture That Covers Non-Public Data

    General-purpose search engines excel at discovering public web pages, but enterprise knowledge bases, business databases, ticketing systems, log platforms, documents in object storage, and data requiring login or authorized access typically never enter public indexes. For AI applications, if the retrieval layer depends only on public search results, answers will have information gaps: they may look fluent, but they lack critical context. Solving this problem requires unifying “public retrieval” and “non-public data retrieval” into a single architecture that is governable, evaluable, and scalable—rather than simply stitching together multiple search APIs.

    This article addresses the general technical problem of covering data beyond general-purpose indexes, discussing the architectural design, developer integration approach, and evaluation methodology of AI retrieval systems. The core goal is not to chase single-point recall, but to balance accuracy, response latency, permission compliance, and operability.

    1. The Core Problem: Retrieval Boundaries Determine the Ceiling of Answers

    The quality of an AI search or retrieval-augmented generation (RAG) system depends first on whether the retrieval layer can obtain sufficiently complete, relevant, and fresh context. Public search engines offer broad index coverage, but they are blind to internal documents, structured business data, real-time logs, and permission-restricted content. Common problems include:

    1. Incomplete data: Answers are based only on public web pages, missing enterprise private knowledge.
    2. Semantic fragmentation: Keyword matching and vector recall operate in isolation, without unified orchestration.
    3. Uncontrollable latency: Multi-source recall runs serially, the reranking chain is too long, and tail latency climbs.
    4. Permission breach risk: Retrieval results are not filtered by user context, easily exposing sensitive information.
    5. Missing evaluation: Teams rely on subjective impressions instead of metrics like precision, recall, and latency percentiles.

    Therefore, a production-ready AI retrieval architecture should include at least seven stages: data ingestion, parsing and cleaning, index construction, query orchestration, reranking and generation, permission governance, and observability with evaluation. Developer integration should also provide unified abstractions around these stages, rather than forcing business teams to deal with the differences between individual data sources.

    2. Reference Architecture: From Data Ingestion to Query Orchestration

    2.1 Data Ingestion Layer: A Unified Entry Point for Multiple Sources

    The data ingestion layer connects general data categories such as object storage, relational databases, message queues, document management systems, and log services. From an engineering perspective, you should first define a unified data description model—for example, data source identifier, document ID, version number, update timestamp, access control labels, content type, and parsing status. Ingestion methods fall into two categories: batch synchronization, which suits initializing historical documents, and incremental subscription, which suits updates to tickets, logs, and knowledge bases.

    To avoid data being “ingested but unusable,” the ingestion layer should also handle deduplication, version overwrites, deletion markers, and failure retries. For large-scale data, it is recommended to use a message queue to decouple collection from parsing, object storage to hold raw files and intermediate parsing artifacts, and a log service to record ingestion pipeline status.

    2.2 Parsing and Chunking Layer: Preserving Structural Information

    Non-public data often contains tables, heading hierarchies, code blocks, attachments, and metadata. Naive fixed-length chunking easily breaks semantics. A more robust approach is: first parse the document structure, then chunk by semantic units such as headings, paragraphs, and table rows; for long documents, retain parent-level summaries and references to child chunks; for tables, preserve column names and units; for code, preserve language identifiers. Chunking output should be written simultaneously into text, vector, and metadata fields, laying the foundation for hybrid retrieval.

    2.3 Hybrid Index Layer: Keyword and Vector Complementarity

    Vector-only recall excels at semantic similarity but is not always stable for exact identifiers, proper nouns, and short queries; keyword retrieval excels at exact matching but has limited generalization. The hybrid index layer should maintain both an inverted index and a vector index, along with filter fields such as time, source, and permission labels. At query time, candidate recall happens first, followed by fusion ranking according to business rules. The fusion strategy does not need to be complex—what matters is that it is configurable, replayable, and evaluable.

    2.4 Query Orchestration Layer: Parallel Recall and Budget Control

    The query orchestration layer is the key factor affecting latency. It is recommended to split query rewriting, data source routing, parallel recall, fusion reranking, and context assembly into independent stages, with timeout and degradation strategies for each stage. Pseudocode:

    1. function hybrid_search(query, user_context):
    2. rewritten = rewrite_query(query, user_context)
    3. sources = route_sources(rewritten, user_context)
    4. candidates = parallel_recall(
    5. sources,
    6. rewritten,
    7. timeout_ms = 800,
    8. per_source_limit = 20
    9. )
    10. filtered = check_permission(candidates, user_context)
    11. ranked = rerank(rewritten, filtered, top_k = 8)
    12. return assemble_context(ranked)

    This pseudocode embodies three principles: parallel recall reduces total latency; permission filtering happens after reranking but before generation; context assembly retains only necessary fragments to avoid prompt bloat. For latency-sensitive scenarios, add caching, prefetching, and asynchronous index updates; for accuracy-sensitive scenarios, increase the reranking budget and query expansion—but confirm the gains through online experiments.

    3. Developer Integration: Unified Interfaces and Observability

    Developer integration should not start from “calling some search button,” but from a unified query contract. It is recommended to provide a unified query interface whose inputs include query text, user context, data source scope, time range, result count, and permission tokens; outputs include result fragments, sources, confidence scores, latency breakdown, and trace identifiers. Business teams do not need to know whether the underlying retrieval is keyword-based, vector-based, or hybrid.

    The integration process has four steps: first, register data sources and configure parsing rules; second, trigger historical data initialization and monitor index status; third, validate recall quality and permission filtering through gray-scale (canary) queries; fourth, integrate monitoring, alerting, and log services to continuously observe error rates, P95 latency, and empty-result rates. For batch tasks, use a message queue for asynchronous processing; for online queries, set timeouts, retries, and circuit breaking. When deploying on Baidu AI Cloud, you can combine general categories such as object storage, message queues, container platforms, log services, and monitoring/alerting to build the ingestion, runtime, and observability pipeline.

    4. Evaluation System: Accuracy and Latency in Equal Measure

    Evaluation cannot be based solely on “the answer looks good.” In the offline phase, build a layered test set covering exact queries, semantic queries, multi-hop queries, permission-sensitive queries, and no-answer queries; metrics can include recall, precision, NDCG, empty-result rate, and permission-filtering correctness. In the online phase, focus on P50/P95/P99 latency, timeout rate, degradation rate, user adoption rate, and follow-up question rate.

    Latency evaluation should be broken down by stage: ingestion and index updates are offline costs, while query rewriting, parallel recall, reranking, and generation are online costs. When optimizing, first locate the source of tail latency, then decide whether to add caching, reduce candidate counts, adjust parallelism, or shorten the reranking budget. Accuracy evaluation should retain replayable samples, ensuring that every adjustment to index strategy, fusion weights, or prompt templates can be compared. Only by placing accuracy and latency within the same evaluation framework can you avoid “missing results for the sake of speed” or “being slow for the sake of completeness.”

    5. Security Governance and Engineering Bottom Lines

    Covering non-public data means higher security requirements. Permission filtering should be executed during the retrieval stage based on user context and data labels, not by redacting after generation. Logs should avoid recording sensitive raw text; record trace identifiers and redacted summaries instead. Index updates, deletions, and version switches should be auditable. For multi-tenant scenarios, ensure isolation across index partitions, query routing, and cache keys.

    In summary, connecting data beyond general-purpose indexes is not a capability problem of a single search API, but a system engineering effort spanning data ingestion, hybrid indexing, query orchestration, permission governance, and evaluation. When integrating, developers should prioritize building unified contracts and observability pipelines, then progressively optimize recall and reranking strategies. Only then can AI applications deliver more reliable answers on a more complete data foundation, while keeping response latency and operational costs under control.