Optimizing Large-Scale Search Experience in Intelligent Q&A Systems

    This article explains how to improve the end-to-end retrieval pipeline of intelligent Q&A systems for large-scale web search scenarios. It covers query rewriting, controlled concurrency, webpage parsing, relevance ranking, deduplication, caching, context compression, and staged monitoring — helping practitioners move from serial search bottlenecks to fast, stable, and high-quality answer generation.

    When users complain that an intelligent Q&A system is slow, the cause is often not the model’s response time alone. For questions that require retrieving information across multiple web pages and data sources, the total latency is typically determined by a chain of stages: query decomposition, task scheduling, page fetching, content extraction, relevance ranking, context compression, and final generation.

    If the system still relies on an outdated retrieval channel, even a strong model may exhibit the following symptoms:

    • Simple questions respond quickly, but complex questions become noticeably slower.
    • As the search scope expands, waiting time grows almost linearly.
    • The system finds relevant pages but fails to extract meaningful body text.
    • Results contain duplicates, or important information is buried under low-quality pages.
    • Many search results are returned, but the final answer cites insufficient evidence.
    • Repeated queries at different times produce unstable results and inconsistent latency.

    Therefore, achieving an experience close to modern web search products is not primarily about increasing model parameter size — it is about restructuring the retrieval pipeline.

    1. Define the Complete Retrieval Pipeline

    A typical connected Q&A flow can be abstracted into the following stages:

    1. User Question
    2. ↓
    3. Intent Recognition and Query Rewriting
    4. ↓
    5. Multi-path Search Task Generation
    6. ↓
    7. Concurrent Retrieval and Web Page Fetching
    8. ↓
    9. Body Cleaning and Content Chunking
    10. ↓
    11. Relevance Ranking and Deduplication
    12. ↓
    13. Evidence Selection and Context Compression
    14. ↓
    15. Model Answer Generation

    If any stage is poorly designed, the overall experience degrades. For example, if the system first executes multiple search requests serially and then fetches each page one by one, the total time quickly adds up even when each request takes only a few seconds. Conversely, if independent search tasks run concurrently and results are merged and ranked after retrieval, total waiting time can be significantly reduced.

    However, concurrency does not mean increasing the number of requests without bound. Excessively high concurrency can cause target sites to refuse connections, exhaust the local connection pool, overload parsing services, or flood the downstream pipeline with low-quality results. A practical system must balance speed, stability, and result quality.

    2. Do Not Search with the Raw Question

    User input is often unsuitable as a direct search query. It may contain colloquial expressions, omitted context, multiple sub-questions, or subjective judgments. For example:

    1. Why do certain types of systems show large speed differences in large-scale search?

    A better approach is to first identify the intent and then decompose the question into multiple retrieval directions:

    1. 1. Typical performance bottlenecks in large-scale search
    2. 2. Latency differences between multi-path and serial retrieval
    3. 3. Optimization methods for webpage fetching and body parsing
    4. 4. Ranking and deduplication strategies for search results
    5. 5. Cache and timeout design in intelligent Q&A systems

    Query rewriting usually involves three steps:

    1. Extract Core Entities

    Identify the topic, objects, time range, geographic scope, and technical constraints in the question. Avoid passing irrelevant colloquial content directly to the search module.

    2. Break Down Compound Questions

    If a question contains cause analysis, solution comparison, and implementation suggestions, split it into independent sub-tasks. This improves recall and makes it easier to map each piece of evidence to a specific conclusion.

    3. Generate Queries from Different Angles

    For the same topic, use definition-based, principle-based, practice-based, and troubleshooting-based keywords. Multi-angle retrieval is more likely to cover high-value information than a single search, but the result scale must be controlled through deduplication and ranking.

    3. Replace Simple Serial Execution with Controlled Concurrency

    A common problem in old retrieval channels is:

    1. Search task 1 → wait → Search task 2 → wait → Search task 3

    A more reasonable approach is:

    1. Search task 1 ─┐
    2. Search task 2 ─┼→ Unified aggregation → Ranking and deduplication
    3. Search task 3 ─┘

    From an engineering perspective, you can use task queues, coroutines, or thread pools to manage concurrent tasks. The core principles include:

    • Set reasonable concurrency limits for different types of tasks.
    • Define connection timeouts, read timeouts, and total timeouts for each request.
    • Retry failed tasks a limited number of times.
    • Merge duplicate domains and pages.
    • Prioritize high-value tasks; low-priority tasks can be delayed or canceled.
    • Stop further searching when enough evidence has been collected to answer the question.

    The following pseudocode expresses the basic logic:

    1. async def retrieve_all(tasks, limit):
    2. semaphore = Semaphore(limit)
    3. async def run_one(task):
    4. async with semaphore:
    5. try:
    6. return await retrieve(task, timeout=8)
    7. except TimeoutError:
    8. return None
    9. results = await gather(*(run_one(task) for task in tasks))
    10. return [item for item in results if item is not None]

    The key is not the code format but “controlled concurrency.” Batch fetching without any concurrency limit may look faster in the short term, but in the long run it tends to cause timeouts and system instability.

    4. Search Results Are Not Equivalent to Valid Evidence

    The titles, snippets, and links returned by a search API only indicate that a page is possibly relevant — they are not sufficient as answer evidence. A high-quality system must fetch the page body and perform the following steps:

    1. Remove navigation bars, ads, comment sections, and repeated footers.
    2. Identify headings, paragraphs, lists, and tables within the body.
    3. Filter out pages that are too short, corrupted, or unparsable.
    4. Preserve the page source and fetch timestamp.
    5. Segment and limit content length.
    6. Mark whether a page has login restrictions or access failures.

    The quality of body cleaning directly affects the final answer. If large amounts of menus, recommended content, and script text are passed to the model, they increase context length and dilute the weight of key information.

    For longer pages, it is advisable to split them by heading hierarchy and semantic boundaries rather than by fixed character count. Overly large chunks reduce ranking precision; overly small chunks may break context. In practice, you can combine paragraphs, headings, and adjacent content windows, and save source information for each chunk.

    5. Add Secondary Ranking and Result Deduplication

    The goal of initial retrieval is to “find as much as possible,” while the goal of secondary ranking is to “keep the most useful content.” These two goals are not the same.

    When ranking, consider:

    • How well the query matches the page title.
    • Semantic relevance between the query and the body.
    • Whether the content directly answers the user’s question.
    • Whether the publication date meets the requirements.
    • Whether the source content is complete.
    • Whether multiple pages are highly duplicated.
    • Whether the page contains explicit data, definitions, or step-by-step instructions.

    Deduplication is also critical. Multiple pages may repost the same original article. Without aggregation, the model may mistakenly believe that multiple sources corroborate a conclusion. You can identify duplicate pages by normalizing titles, body summaries, link paths, and content fingerprints, and keep the most representative version during ranking.

    6. Build a Layered Cache to Reduce Repeated Search Costs

    Unstable search experiences often stem from a lack of caching strategies. Consider three types of caches:

    Query Cache

    Reuse search results for identical or highly similar questions within a short time frame. Suitable for hot topics and repeated inquiries.

    Page Cache

    Temporarily store successfully fetched and cleaned webpage bodies to avoid repeatedly downloading the same page.

    Intermediate Result Cache

    Cache intermediate outputs such as rewritten queries, page chunks, relevance scores, and summaries. This way, even when the answer must be regenerated, the full retrieval pipeline does not need to run from scratch.

    Caches need expiration policies. Content with strong time sensitivity, such as news, prices, and inventory, should not be reused for long periods. Stable content like technical documentation and standard definitions can use longer cache lifetimes.

    7. Control Context Size Instead of Blindly Expanding Search Scope

    More search pages do not guarantee a more accurate answer. Too much low-quality content creates an “information dilution” problem and can cause the model to miss key evidence.

    A more reasonable strategy is to first expand recall and then progressively compress:

    1. Initial recall: collect many candidate pages
    2. ↓
    3. Relevance ranking: filter out clearly irrelevant content
    4. ↓
    5. Body chunking: retain useful paragraphs
    6. ↓
    7. Evidence compression: merge duplicate viewpoints
    8. ↓
    9. Final generation: provide only high-value context

    For multiple sub-questions, retain a limited number of the most relevant evidence pieces for each sub-question, rather than letting all pages share an unlimited context pool. This improves answer coverage and avoids one sub-question consuming the entire context budget.

    8. Use Monitoring to Locate the Real Bottleneck

    Do not record only the total latency. Split and record the duration of each stage:

    1. Query rewriting time
    2. Search request time
    3. Web page connection time
    4. Body parsing time
    5. Ranking time
    6. Context compression time
    7. Answer generation time

    Also track metrics such as:

    • Timeout ratio
    • Retry ratio
    • Empty result ratio
    • Page parsing success rate
    • Duplicate content ratio
    • Average number of fetched pages
    • User-initiated abandonment ratio
    • Response time by question type

    If search request time is normal but page parsing is slow, the issue may be in the body extraction module. If fetching is fast but the model waits too long, check context size and generation strategy. If overall latency fluctuates widely, the cause may be concurrency control, external page stability, or low cache hit rates.

    For an existing system, you do not need to rewrite all modules at once. Proceed incrementally in the following order:

    First, confirm the current retrieval pipeline and identify serial requests, indefinite waits, or repeated fetches.

    Second, add timeouts, retries, and graceful degradation for all external requests to solve stability issues.

    Third, introduce controlled concurrency to run independent query tasks in parallel.

    Fourth, add body cleaning, content chunking, relevance ranking, and deduplication.

    Fifth, introduce query and page caches to reduce repeated request volume.

    Sixth, set up stage-by-stage monitoring and continue tuning concurrency limits, timeout values, and context sizes based on real data.

    In summary, differences in large-scale search experience are usually not determined by any single component but by the overall design of the retrieval pipeline. If the system still relies on legacy serial retrieval, crude page fetching, and indiscriminate context concatenation, it will struggle to balance speed and quality. By applying query decomposition, controlled concurrency, body extraction, secondary ranking, cache reuse, and staged monitoring, you can evolve the system from “can search” to “searches fast, filters well, and answers reliably.”