Skip to main content

Conversation analysis (Tongyi-Xiaomi-Analysis)

Tongyi-Xiaomi-Analysis specializes in information extraction from dialogues, scenario classification, and satisfaction analysis. It excels at handling complex quality inspection rules, supports custom analysis standards, and provides powerful multi-turn dialogue understanding and semantic reasoning.

Core features

  • Information extraction: Automatically extracts key information from unstructured dialogues, such as time, location, product, issue description, and customer requests. Typical applications: Automating work order population, updating CRM customer information, and classifying and archiving issues.
  • Scenario classification: Identifies the business scenario of a dialogue and supports custom scenario categories. Typical applications: Automatically routing dialogues to specialized teams, tracking inquiry volume by scenario, and optimizing service processes for specific scenarios.
  • Satisfaction analysis: Determines customer satisfaction levels based on custom rules and supports multi-dimensional evaluation. Typical applications: Evaluating agent performance, monitoring service quality, and improving customer experience.
  • Complex quality inspection: Supports complex quality inspection rules, including nested conditions and logical reasoning, to accurately enforce enterprise-specific standards. Typical applications: Performing quality inspections in highly regulated industries like finance and healthcare, checking multi-step business processes, and verifying compliance with complex scripts.
  • Multi-turn dialogue understanding: Automatically connects context across turns to accurately resolve references and dependencies, grasping the user's true intent in a multi-turn exchange. Typical applications: Analyzing dialogues in complex business processes, understanding intent in long conversations, and extracting context-dependent information.
  • Deep semantic understanding: Accurately identifies implied meanings, emotional tones, and subtext in a conversation. Typical applications: Monitoring customer sentiment, detecting potential complaints, and identifying sales opportunities.
These features can be implemented by using custom prompts. For usage details, see Feature demos.

Scope

  • Supported regions: Only China (Beijing) is supported. You must use an API Key from this region.
  • Supported languages: The conversation analysis models only support Chinese dialogue analysis and do not support other languages.
  • Supported models:
    • tongyi-xiaomi-analysis-flash: Designed for structured analysis tasks such as information extraction and scenario classification. Suitable for low-latency online analysis and cost-sensitive offline tasks.
    • tongyi-xiaomi-analysis-pro: Designed for complex logical reasoning and deep semantic understanding. Suitable for scenarios such as quality inspection with multi-condition nested rules and multi-turn dialogue analysis with strong contextual dependencies. Compared to the Flash model, it offers stronger reasoning and understanding but at a higher cost and latency.
    For more information, see Model selection.
  • The models support implicit cache. Cache-hit tokens are billed according to the implicit cache billing rules.

Model selection

Use case

Recommended model

Model advantages

Recommendations

Fast information extraction and scenario classification

tongyi-xiaomi-analysis-flash

Low latency and cost. Suitable for high-frequency, real-time calls.

Use for standardized extraction and classification tasks that do not involve complex reasoning.

Standard quality inspection

tongyi-xiaomi-analysis-flash

Accurately understands dialogue semantics and sentiment, supports custom evaluation rules, and meets most quality inspection needs.

Use for quality inspection scenarios with clear rules. For complex business logic, use the pro model.

Complex logical quality inspection

tongyi-xiaomi-analysis-pro

Stronger reasoning capabilities, supporting complex business rules such as nested conditions and contextual dependencies.

Higher cost than the flash model. Use for scenarios that require extremely high accuracy, such as finance and healthcare.

In-depth multi-turn dialogue analysis

tongyi-xiaomi-analysis-pro

Stronger dialogue understanding capabilities, accurately understanding references and implied intent.

Use for scenarios that require a global understanding, such as post-sales ticket analysis and complaint root-cause analysis.

Quick start

Usage suggestions

  • Standardize dialogue content format: Organize dialogue content in the format of [Turn] Role: Content. Using a standard format helps the model parse the dialogue structure and accurately identify speaker roles, turn order, and contextual references. Example:
[1] 客服:您好,欢迎致电AB电商平台,请问有什么可以帮您?
[2] 客户:你好,我上周在你们店买了一台料理机,现在运行时有点异响。
[3] 客服:很抱歉给您带来困扰,请问异响是在开机后立刻出现还是运行一段时间后出现的呢?
  • Write clear rules: Clear analysis rules are key to the model's accuracy. Vague or contradictory rules can lead to unexpected analysis results. Tips for writing rules:
    • Be specific and actionable: Avoid vague descriptions. For example, instead of "good service attitude," use "responded promptly and used polite language."
    • Define priorities: When there are multiple rules, define their priorities and execution order to resolve potential conflicts and ensure the model can make a clear judgment.
    • Provide positive and negative examples: Include positive and negative examples in your rules to help the model accurately understand the evaluation criteria.
  • Use special markers for key terms: When a business term has a definition that differs from its common understanding, use a special marker (such as an abbreviation) to replace the term. This prevents the model from interpreting it based on general knowledge.
  • Set API parameters: Conversation analysis tasks typically require deterministic and accurate results. Use the following parameter settings:
    • temperature: Set to 0.0 so the model returns the same result for the same input every time, ensuring analysis consistency.
    • top_k: Set to 1 so the model always selects the highest-probability token, avoiding randomness.
  • Control the output format: To ensure parsable and controllable analysis results, specify the output format in the prompt. If necessary, provide an output example.

Code examples

Prerequisites: Obtain an API Key. If you use an SDK, install the latest version of the SDK.
  • OpenAI-compatible
  • DashScope
Python
from openai import OpenAI
import os

dialogue = """
[1] 客服:您好,欢迎致电AB电商平台,请问有什么可以帮您?
[2] 客户:你好,我上周在你们店买了一台料理机,现在运行时有点异响。
[3] 客服:很抱歉给您带来困扰,请问异响是在开机后立刻出现还是运行一段时间后出现的呢?
[4] 客户:差不多开机几秒钟后就有了,而且声音很尖锐。
[5] 客服:了解了,请问您方便拍一段运行过程的视频发给我们技术人员确认吗?
[6] 客户:可以,我一会儿拍好发给你们。
[7] 客服:好的,我们收到视频后会在两小时内给您回复处理方案。
[8] 客户:那如果确定是质量问题,是可以直接换新的吧?
[9] 客服:是的,如果检测为质量问题,我们将为您免费更换新机并承担运费。
[10] 客户:好的,那我等你们的反馈,谢谢你们的耐心解答。
"""

analysis_prompt = f"""
## 客服质检满意度判定规则

### 一、目标
根据客服与客户的对话内容,准确解析客户的情绪与反馈,判定其**满意度等级**(满意 / 不满意 / 一般),并提供判定理由,用于客服质检与服务改进。

### 二、判定流程(必须自上而下匹配,遇到符合条件的规则时立即终止后续判断)

1. **无客户发言**
   - 条件:整段对话中没有客户的内容。
   - 结果:判定为 **一般**。

2. **投诉或强烈不满**
   - 条件:客户直接或间接表示要投诉(对象包括骑手、快递员、商家、客服等),或者在催促问题进度时带有明显焦急、质问、抱怨等消极情绪。
   - 示例:
     - "我要投诉你们的配送员"
     - "怎么还没处理?到底什么时候能好?"
   - 结果:判定为 **不满意**,并立即结束判定。

3. **最后一句负面情绪**
   - 条件:客户的最后一句话中出现负面情绪。
   - 结果:判定为 **不满意**。

4. **无感谢记录**
   - 条件:如果整个对话中客户没有表达"谢谢"等明确感谢语。
   - 结果:判定为 **一般**。

5. **客户主动表示满意或好评**
   - 条件:对话中客户明确表示对客服满意或给予好评。
   - 结果:忽略第4条直接判定为 **满意**。

6. **方案后感谢**
   - 条件:服务结束前,客服提供了赔付、退单、退款等解决方案后,客户明确积极地表示感谢。
   - 注意点:
     - "好的"、"行"不算感谢
     - 没有回复不算认可
   - 结果:判定为 **满意**。

7. **其他情况**
   - 条件:非上述任何情况,且无投诉或明显不满。
   - 结果:判定为 **一般**。

### 三、对话内容
```text
{dialogue}
```

### 四、输出格式
判定结果需包含两个部分:
1. **满意度标签**:满意 / 不满意 / 一般
2. **判定理由**:基于上述规则的简要说明。

格式:
```
Satisfaction Label#Reason for Judgment
```
示例:
```
Neutral#The customer did not express thanks, nor did they show any complaints or dissatisfaction during the dialogue, so the judgment is neutral.
Dissatisfied#The customer showed clear dissatisfaction and questioning when asking about the progress, matching Rule 2, so the judgment is dissatisfied.
```
"""

# 获取API Key:https://help.aliyun.com/zh/model-studio/get-api-key
# 若没有配置环境变量,请用阿里云百炼API Key将下行替换为:api_key="sk-xxx"
client = OpenAI(
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # 华北2(北京)地域的URL。调用时将 {WorkspaceId} 替换为真实的业务空间ID。
    base_url="https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
)

completion = client.chat.completions.create(
    model="tongyi-xiaomi-analysis-flash",
    messages=[
        {
            'role': 'user',
            'content': analysis_prompt
        }
    ],
    temperature=0,
    extra_body={
        "top_k": 1
    }
)

print(completion.choices[0].message.content)

Feature examples

Each feature example provides runnable content. To try out a feature, replace the content in the code sample.
  • Dialogue information extraction
  • Scenario classification
  • Satisfaction analysis
  • Complex quality inspection
  • Multi-turn dialogue understanding
  • Deep semantic understanding
Feature description: Automatically extracts key information from unstructured dialogues, such as time, location, product, problem description, and customer requests.Use cases:
  • Automatic ticket system population
  • CRM customer information updates
  • Problem classification and archiving
content example:
请从以下对话中提取关键信息,并按照 JSON 格式输出。

对话内容:
```
[1] Customer Service: Hello, this is Wang. How can I help you?
[2] Customer: Hello, I bought an iPhone 15 at your Nanjing Xinjiekou store last Wednesday. The order number is 123456789. The screen is now a bit yellow.
[3] Customer Service: Okay, let me check for you. Could you please provide your phone number?
[4] Customer: 138****5678
[5] Customer Service: Got it. I see your order. Regarding the yellow screen issue, under what circumstances did you notice it?
[6] Customer: I noticed it during normal use. It's especially obvious when looking at a white background.
```

Information to extract:
1. Purchase time
2. Purchase store
3. Product name
4. Order number
5. Customer contact
6. Issue description
7. Issue discovery context

Output format (JSON):
```json
{{
  "purchase_time": "...",
  "purchase_store": "...",
  "product_name": "...",
  "order_number": "...",
  "customer_contact": "...",
  "issue_description": "...",
  "issue_discovery_context": "..."
}}
```

Note: If an item is not mentioned in the dialogue, fill in "Not mentioned".

API reference

For the input and output parameters of the model, see Text generation.