Adding an AI Assistant to a County-Level Media Client: A Technical Practice Guide

    This article walks through the technical practice of embedding an AI assistant into a county-level media client, using a real deployment as the reference case. It covers a five-layer architecture, the engineering details that make retrieval-augmented generation (RAG) reliable in a closed vertical knowledge domain, intent recognition and multi-turn task orchestration, content safety and compliance boundaries, and a four-tier measurement framework for continuous iteration. It also lists common pitfalls, such as treating model integration as a finished assistant. The core takeaway: the hard problem is not calling a language model, but keeping it trustworthy inside a bounded domain. The methodology is vendor-neutral and reusable by resource-constrained regional or vertical teams.

    1. Background and Problem Definition

    In March 2025, a media client serving an island county completed a key capability upgrade: an intelligent assistant entry named “Xiao Bang” was embedded on top of the existing news, government services, lifestyle services, and commerce features. Users tap the home screen icon to get round-the-clock answers to their questions. By 2025, the client had accumulated roughly 55,000 installations, with more than 7,000 new installations per year, and had become an important information channel between local government and residents. At the same time, its annual report candidly acknowledged three shortcomings: insufficient depth in government service handling, uneven coverage of livelihood services, and user interaction experience that needed improvement.

    Translated into technical language, these three points are three measurable engineering problems:

    • Insufficient service depth: the system can only “inform” and cannot “guide the user through a transaction,” meaning it lacks multi-turn task orchestration and form pre-filling.
    • Uneven coverage: there are structural gaps in knowledge supply, with some topics having abundant corpus and others nearly blank.
    • Interaction experience to improve: first-answer accuracy, response latency, and refusal strategy have not yet formed a closed loop.

    It is worth stressing that the technical difficulty of this kind of project has never been “calling a language model.” It is how to keep the model trustworthy within the closed knowledge boundary of a vertical domain. A general-purpose model can give a vague answer to a question like “where should I go in spring,” but as soon as a user asks “what are today’s departures from a specific ferry terminal” or “what is the list of documents required to apply for a certain subsidy,” any fabrication translates directly into a government trust cost.

    2. Overall Architecture Design

    A robust implementation is usually divided into five layers, top to bottom: an access layer, an orchestration layer, a capability layer, a data layer, and a governance layer.

    1. User taps "Intelligent Assistant"
    2. ↓
    3. Access layer: client SDK / gateway authentication / rate limiting
    4. ↓
    5. Orchestration layer: intent recognition → routing (chitchat / knowledge Q&A / handling guidance)
    6. ↓
    7. Capability layer: LLM inference + vector retrieval + rule engine + business API calls
    8. ↓
    9. Data layer: policy document store / vector index / session cache / log warehouse
    10. ↓
    11. Governance layer: content safety filtering / permission checks / monitoring and alerting / effectiveness evaluation

    The most critical design decision here is: do not let the model directly answer factual questions. Factual Q&A must follow a “retrieve first, then generate” path, where the model is only responsible for organizing the language and not for providing the facts. This constraint is the foundation for all subsequent safety design.

    3. Key Engineering Details of Retrieval-Augmented Generation

    The effectiveness of retrieval-augmented generation (RAG) depends 80% on data and chunking strategy, not on model selection.

    1. Document chunking must fit business semantics. Government texts commonly follow a “title—basis—conditions—materials—process” structure. If you split them hard by a fixed character count, you will separate “application conditions” from “required materials,” resulting in incomplete recalled fragments. A more reasonable approach is to split by structural tags and keep the section path at the head of each fragment as a context prefix.

    2. Hybrid retrieval beats single vector retrieval. Policy queries contain a large amount of exact-match demand, such as specific clause numbers, amount thresholds, and age limits. Pure semantic vectors are insensitive to numbers and identifiers, so keyword retrieval should be added and the results fused and reranked.

    Illustrative code (pseudo-implementation, expressing the flow only):

    1. def retrieve(query, top_k=5):
    2. dense = vector_index.search(query, top_k=top_k) # semantic recall
    3. sparse = keyword_index.search(query, top_k=top_k) # exact recall
    4. merged = rerank(fuse(dense, sparse), query) # fusion and rerank
    5. return [c for c in merged if c.score > THRESHOLD] # threshold filtering

    3. You must design an “empty retrieval” branch. When the overall recall similarity falls below the threshold, the correct behavior is to clearly tell the user that no basis was found and hand off to a human agent or provide a handling entry, rather than letting the model improvise. For government scenarios, this single rule often improves accuracy more than switching models does.

    4. Time layering. Policy knowledge has versioning issues, so documents should carry effective-time and expiry-time fields, and retrieval should filter by the current date to avoid old rules overriding new ones.

    4. Intent Recognition and Multi-Turn Task Orchestration

    User input is often short and omits the subject. Follow-up questions like “how do I do it” or “what do I need to bring” must rely on session state for completion. In practice, a combination of “lightweight classification + slot filling” works well: first use a small model or rules to complete intent classification, and once a handling intent is hit, enter a slot collection flow that confirms key parameters one by one before calling the corresponding business API.

    1. {
    2. "intent": "subsidy_apply",
    3. "slots": {"identity_type": "individual business", "missing": ["business start date"]},
    4. "action": "ask_next_slot",
    5. "fallback": "human_service"
    6. }

    A reminder: slot design should follow the principle of minimum necessity, collecting only the fields truly needed to complete the current task. This is both a user experience requirement and a personal information protection requirement.

    5. Content Safety and Compliance Boundaries

    The safety baseline for government Q&A can be summarized in three hard rules:

    1. Input-side filtering: detect prompt injection, unauthorized queries, and sensitive intents, and block “ignore previous instructions” style attacks.
    2. Output-side validation: policy basis in answers must be traceable to specific document fragments; without a basis, degrade to fallback phrasing.
    3. Permission-side isolation: when data such as personal handling progress or payment records is involved, authentication is completed on the server side, and the model side receives only the minimum de-identified context. Credential-type information must never be placed into the prompt.

    Before session data is used for effectiveness optimization, de-identification should be completed and a retention period should be clearly defined.

    6. Effectiveness Measurement and Continuous Iteration

    Do not look only at vanity metrics like “Q&A volume.” A four-tier metric system is recommended:

    • Usability: first-answer resolution rate, average interaction turns, response latency percentiles.
    • Accuracy: agreement rate between sampled human-labeled answers and their basis, and fabrication rate.
    • Business conversion: click-through and completion rates from Q&A to the handling entry.
    • Coverage: clustered distribution of unanswered questions, which directly indicates the priority for knowledge base backfill.

    The iteration loop is: cluster unresolved questions from online logs → add or revise knowledge entries → validate with a regression test set → roll out gradually. The regression test set should be accumulated over the long term to prevent fixing one problem from introducing another regression.

    7. Common Pitfalls

    • Pitfall 1: treating model integration as a finished assistant. Without retrieval, fallback, and operations mechanisms, it peaks at launch.
    • Pitfall 2: pursuing solving everything in a single Q&A. “Informing” and “handling” should be split into two capabilities: the former emphasizes accuracy, the latter emphasizes process completeness.
    • Pitfall 3: ignoring cold-start coverage. In the early launch period, proactively analyze high-frequency blank questions and fill them with rules and human agents, rather than waiting for data to accumulate naturally.
    • Pitfall 4: leaving evaluation to subjective feeling. Without a fixed test set and labeling standard, optimization cannot be falsified.

    8. Summary

    Back to the three shortcomings at the start: service depth is solved by task orchestration, balanced coverage is solved by knowledge governance and clustering of unanswered questions, and interaction experience is determined jointly by first-answer accuracy, latency, and fallback strategy. This methodology is vendor-neutral, and any team in a resource-constrained county-level or vertical scenario can reuse it. If you need elastic compute, vector retrieval, logging, and monitoring and alerting as foundational capabilities, combine general cloud service categories as needed, and avoid introducing complex components too early.