AI Intent Recognition Flow with LLMs

ML & AI · flowchart diagram · NOASSERTION

This flowchart illustrates the process of AI-driven intent recognition, including agent availability checks, prompt building, model invocation, and JSON pa

Source: https://github.com/lanzeweie/ASR-interview-coder-llm/blob/cad6297ac1dc16063215e57c175239b2019d44ab/README/Mermaid.md
Curated by lanzeweie
AI Machine Learning Natural Language Processing Chatbot System Design Flowchart Intent Classification

Mermaid source

flowchart TD
    Start([阶段2:意图识别启动<br/>前提:阶段1判定需要AI介入<br/>且用户开启意图识别]) --> CheckAgent{Agent可用?}

    CheckAgent -- 否 --> Fallback[使用默认意图<br/>技术讨论/决策咨询/问题解决]
    CheckAgent -- 是 --> BuildIntentPrompt[构建意图识别提示<br/>包含对话内容和主人公信息]

    BuildIntentPrompt --> CallIntentModel[调用小模型<br/>提取核心问题和讨论大纲]

    subgraph IntentDetails [意图识别详细流程]
        direction TB
        ExtractCore[1. 识别核心问题<br/>提取对话中的主要讨论话题]
        ExtractOutline[2. 生成讨论大纲<br/>列出关键要点和子话题]
        ExtractEntities[3. 提取实体信息<br/>涉及的技术、概念、决策点]
    end

    CallIntentModel --> ParseIntentJSON[解析JSON响应]

    subgraph ParseProcess [解析过程]
        direction TB
        ExtractJSON[提取JSON对象<br/>使用正则匹配]
        ValidateJSON[验证JSON格式<br/>检查必要字段]
        ReturnResult[返回结构化结果<br/>包含core_question和outline]
    end

    ParseIntentJSON --> Success{解析成功?}
    Success -- 是 --> ReturnIntent[返回意图识别结果<br/>传递给阶段3分发准备]
    Success -- 否 --> LogError[记录解析错误]

    ReturnIntent --> End([意图识别完成<br/>传递给智囊团/单模型])
    LogError --> Fallback
    Fallback --> End

    %% 配置参数
    subgraph IntentConfig [⚙️ 意图识别配置]
        direction LR
        Config1["启用开关:intent_recognition_enabled"]
        Config2["模型选择:本地/云端API"]
        Config3["上下文长度:最大50条消息"]
        Config4["输出格式:JSON (core_question + outline)"]
    end

    %% 样式定义
    style Start fill:#e1f5fe
    style CheckAgent fill:#e1f5fe
    style Success fill:#e1f5fe

    style ReturnIntent fill:#c8e6c9
    style Fallback fill:#fff3e0
    style LogError fill:#ffcdd2
    style End fill:#ffcdd2
    style CallIntentModel fill:#8B4513
    style IntentDetails fill:#f1f8e9,stroke:#4caf50,stroke-width:2px
    style ParseProcess fill:#f1f8e9,stroke:#4caf50,stroke-width:2px

What this diagram shows

The diagram outlines a multi-step process for intent recognition using an AI model. It begins with an initial check for AI intervention and user intent recognition enablement. It then determines agent availability, either falling back to default intents or proceeding to build a detailed prompt. The prompt is fed to a small language model for core question and discussion outline extraction. Detailed sub-processes for intent extraction (core question, outline, entities) and JSON response parsing (extraction, validation, structured result) are shown. The flow concludes with returning the structured intent or logging errors and falling back to default intents. Configuration parameters for the intent recognition system are also highlighted.

When to use it

Use this diagram when designing or documenting an AI-powered system that needs to understand user intent from conversational input, especially in applications like chatbots, virtual assistants, or intelligent routing systems. It's suitable for scenarios requiring structured intent extraction before further processing by other AI models or modules.

How to adapt it for your project

This diagram can be adapted by: 1. Adding more sophisticated fallback mechanisms, such as human handover or different default intent sets. 2. Integrating multiple intent models (e.g., a primary and a backup) or ensemble methods. 3. Expanding the "Extract Entities" section to include specific entity types relevant to the domain (e.g., product names, dates, locations). 4. Introducing a feedback loop for model improvement based on parsing success/failure or user corrections. 5. Detailing the "Agent可用?" check with specific criteria or a list of available agents.

Key concepts