A Practical Guide to Generative Conversational LLMs for Vertical Scenarios

    This article presents a reusable engineering framework for building generative conversational systems that move beyond casual chat to executing multi-step, vertical-domain tasks. It covers pre-trained model scale selection and capability boundaries, the pre-training to alignment pipeline, multi-turn dialogue engineering, retrieval-augmented generation (RAG), hallucination detection and answer trustworthiness, capability orchestration across vertical scenarios, and evaluation, safety, and operations. The content is vendor-neutral and focuses on common industry practices that developers can adapt to deliver controllable, production-ready conversational AI.

    1. Introduction: From General Chat to Scenario-Based Task Execution

    Generative conversational agents are shifting from “being able to chat” to “being able to get work done.” Early products were mostly built around single-turn question answering: the user asks, the model replies, and the task ends when the interaction ends. In real business settings, however, user requests often consist of multiple steps: first clarifying the requirement, then retrieving information, then generating a structured document, and finally validating and revising it. This demands a conversational system with combined capabilities for multi-turn context retention, task decomposition, tool invocation, and result validation.

    This article takes a generative conversational agent released in March 2023 as its technical background (this class of product is typically driven by a self-developed generative large model and opened to public service after regulatory filing), abstracts its technical approach, and provides a reusable engineering practice framework. Note that this article does not involve any specific vendor’s product and only discusses common industry practices.

    2. Technical Foundation: Model Scale Selection and Capability Boundaries

    2.1 Trade-offs in Parameter Scale

    In engineering practice, model size is usually concentrated in the tens-of-billions parameter range (roughly 10B to 100B). This range is an important balance point between capability and cost:

    • Lightweight billion-scale models: low inference cost and low latency, suitable for high-concurrency, privacy-sensitive, on-device, or private deployments; they can already achieve competitive results on Chinese language understanding benchmarks and zero-shot and few-shot learning tasks.
    • Standard tens-of-billions models: stronger complex reasoning, long-form generation, and instruction-following capabilities, suitable for main-path scenarios such as knowledge Q&A and report writing.
    • Domain fine-tuned models: continued training on a general base with vertical corpora such as finance and coding can significantly improve terminology accuracy and code correctness.

    2.2 From Pre-training to Alignment

    A usable conversational model typically goes through three stages: pre-training (learning language and world knowledge), supervised fine-tuning (learning instruction formats and task paradigms), and preference alignment (making outputs better match human expectations and reducing harmful and low-quality content). When selecting a model, developers should focus on its stability in Chinese long-text processing, structured output (such as JSON), and multi-turn coreference resolution, rather than looking only at a single leaderboard score.

    3. Engineering Multi-Turn Dialogue

    The core of multi-turn dialogue is not “remembering all history” but “remembering the useful parts.” Common approaches include:

    1. Context window management: apply sliding-window truncation to historical messages, keeping the system prompt, the most recent several turns, and key entities.
    2. Session state summarization: when the number of turns exceeds a threshold, compress early dialogue into a structured summary (user goal, confirmed constraints, pending items).
    3. Slot and entity tracking: extract slots such as time, amount, and product name to avoid making users repeat descriptions.
    4. Coreference resolution rewriting: rewrite “it” or “the one above” into a complete semantic form before feeding it to the model to reduce ambiguity.

    Illustrative pseudocode:

    1. def build_prompt(system, history, summary, slots, query):
    2. ctx = [{"role": "system", "content": system}]
    3. if summary:
    4. ctx.append({"role": "system", "content": f"Session summary: {summary}"})
    5. if slots:
    6. ctx.append({"role": "system", "content": f"Known slots: {slots}"})
    7. ctx.extend(history[-6:]) # keep only the last 3 turns
    8. ctx.append({"role": "user", "content": query})
    9. return ctx

    4. Retrieval-Augmented Generation: Grounding Answers in Evidence

    Purely parametric knowledge has two inherent problems: lagging knowledge updates and hallucination. Retrieval-augmented generation (RAG) mitigates these through “retrieve first, then generate.” A typical full-stack pipeline includes:

    • Document parsing: support layout restoration and table and paragraph segmentation, preserving heading hierarchy as semantic anchors.
    • Chunking and vectorization: split by semantic boundaries; chunk size and overlap ratio need tuning by document type.
    • Hybrid retrieval: vector recall handles semantic similarity, keyword recall handles exact matching of proper nouns, followed by fusion ranking.
    • Reranking and context assembly: control the number and order of injected fragments to avoid “lost in the middle.”
    • Answer generation and citation: output conclusions along with source fragments for easy manual verification.

    For enterprise deployment, permission filtering (users can only retrieve documents they are authorized to access) and incremental indexing (changes take effect in near real time after document updates) should also be introduced.

    5. Hallucination Detection and Answer Trustworthiness

    Hallucination governance should be a first-class citizen of the product, not an after-the-fact patch. Combinable measures include:

    1. Evidence consistency checking: determine whether a generated conclusion is supported by retrieved fragments; if not, trigger clarification or refuse to answer.
    2. Confidence thresholds: when confidence is low, degrade to “providing candidates and evidence” rather than making direct assertions.
    3. Structured constrained output: require returning fixed fields to make it easy for programs to validate field completeness and value ranges.
    4. Secondary review pipeline: have another model or a rule engine perform fact-checking and compliance checks.
    1. {
    2. "answer": "...",
    3. "evidence": ["fragment-ID-12", "fragment-ID-27"],
    4. "confidence": 0.82,
    5. "need_clarify": false
    6. }

    6. Capability Orchestration for Vertical Scenarios

    When the same base model serves different scenarios, differences should be met through “composing capability modules” rather than retraining the model:

    • Finance: market and wealth-management knowledge Q&A, writing analytical articles and research reports, and in-depth information processing; requires strengthened externalized numerical computation (calling calculation tools rather than having the model do mental math) and compliance phrasing constraints.
    • Customer service: integration with ticketing, order, and knowledge base systems, emphasizing low latency and high determinism, with rules as a fallback when necessary.
    • Intelligent investment research and industry search: retrieval-primary and generation-secondary, outputting summaries and comparison tables with citations.
    • Writing and marketing assistance: emphasis on style control, templating, and multi-version generation.
    • Coding assistance: combining code retrieval and static checks; generated code must be verified through compilation and testing.

    7. Evaluation, Safety, and Production Operations

    Evaluation should cover three categories of metrics: task completion rate (whether the user’s problem is actually solved), answer quality (accuracy, completeness, readability), and system metrics (time to first token, throughput, cost per request). It is recommended to build scenario-specific evaluation sets that include multi-turn, ambiguous, no-answer (should refuse), and adversarial samples.

    For security and compliance, implement bidirectional content moderation for inputs and outputs, sensitive information masking, and operation auditing and logging; before offering services to the public, complete the algorithm and generative service related filing requirements. On the operations side, it is recommended to decouple model serving, vector retrieval, logging, monitoring and alerting, and message queues, and to continuously iterate on prompts, retrieval strategies, and model parameters through canary releases and A/B experiments.

    8. Conclusion

    The competitiveness of a generative conversational agent ultimately comes down to “controllability”: controllable knowledge sources, controllable output formats, and controllable cost and latency. If developers can establish a complete engineering loop across five layers—pre-trained base model selection, multi-turn state management, retrieval augmentation, hallucination detection, and scenario orchestration—they can turn general conversational capability into stable, deliverable business productivity.