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 dialogues.
  • 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] Agent: Hello, thank you for calling the AB e-commerce platform. How can I help you?
[2] Customer: Hello, I bought a blender from your store last week, and it's making a strange noise when it runs.
[3] Agent: I'm sorry for the trouble. Does the noise start immediately after you turn it on, or after it has been running for a while?
  • 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] Agent: Hello, thank you for calling the AB e-commerce platform. How can I help you?
[2] Customer: Hello, I bought a blender from your store last week, and it's making a strange noise when it runs.
[3] Agent: I'm sorry for the trouble. Does the noise start immediately after you turn it on, or after it has been running for a while?
[4] Customer: It starts a few seconds after I turn it on, and the sound is very sharp.
[5] Agent: Understood. Could you please take a video of it running and send it to our technical staff for confirmation?
[6] Customer: Sure, I'll record it and send it to you in a bit.
[7] Agent: Great. After we receive the video, we will provide you with a solution within two hours.
[8] Customer: Okay, if it's confirmed to be a quality issue, can I get a direct replacement?
[9] Agent: Yes, if it is identified as a quality issue, we will replace it with a new machine for free and cover the shipping costs.
[10] Customer: Okay, I'll wait for your feedback then. Thank you for your patient answers.
"""

analysis_prompt = f"""
## Rules for Agent Quality Inspection and Satisfaction Analysis

### I. Objective
Based on the dialogue between the agent and the customer, accurately analyze the customer's emotions and feedback to determine their **satisfaction level** (Satisfied / Dissatisfied / Neutral) and provide the reason for the judgment. This is used for agent quality inspection and service improvement.

### II. Decision Flow (Must be followed from top to bottom. Stop immediately when a matching rule is met.)

1. **No Customer Input**
   - Condition: The entire dialogue contains no content from the customer.
   - Result: Judge as **Neutral**.

2. **Complaint or Strong Dissatisfaction**
   - Condition: The customer directly or indirectly expresses a desire to complain (about a delivery driver, courier, merchant, agent, etc.), or shows clear negative emotions such as anxiety, questioning, or complaining when inquiring about progress.
   - Examples:
     - "I want to complain about your delivery driver."
     - "Why hasn't this been handled yet? When will it be resolved?"
   - Result: Judge as **Dissatisfied** and end the analysis immediately.

3. **Negative Emotion in the Last Sentence**
   - Condition: The customer's last sentence contains negative emotion.
   - Result: Judge as **Dissatisfied**.

4. **No Expression of Thanks**
   - Condition: The customer does not express clear thanks, such as "thank you," throughout the entire dialogue.
   - Result: Judge as **Neutral**.

5. **Customer Actively Expresses Satisfaction or Praise**
   - Condition: The customer explicitly expresses satisfaction with the agent or gives praise during the dialogue.
   - Result: Ignore Rule 4 and judge as **Satisfied**.

6. **Thanks After a Solution is Provided**
   - Condition: Before the service ends, after the agent provides a solution like compensation, order cancellation, or a refund, the customer clearly and positively expresses thanks.
   - Notes:
     - "Okay" or "Alright" do not count as thanks.
     - No reply does not count as approval.
   - Result: Judge as **Satisfied**.

7. **Other Situations**
   - Condition: None of the above situations apply, and there are no complaints or obvious dissatisfaction.
   - Result: Judge as **Neutral**.

### III. Dialogue Content
```text
{dialogue}
```

### IV. Output Format
The judgment result must include two parts:
1. **Satisfaction Label**: Satisfied / Dissatisfied / Neutral
2. **Reason for Judgment**: A brief explanation based on the rules above.

Format:
```
Satisfaction Label#Reason for Judgment
```
Example:
```
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.
```
"""

# Get an API Key: https://help.aliyun.com/en/model-studio/get-api-key
# If the environment variable is not set, replace the following line with your Model Studio API Key: api_key="sk-xxx"
client = OpenAI(
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # The URL for the China (Beijing) region. Replace {WorkspaceId} with your workspace 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:
Extract key information from the following dialogue and output it in JSON format.

Dialogue content:
```
[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 information
6. Problem description
7. Scenario where the problem was found

Output format (JSON):
```json
{{
  "Purchase time": "...",
  "Purchase store": "...",
  "Product name": "...",
  "Order number": "...",
  "Customer contact information": "...",
  "Problem description": "...",
  "Scenario where the problem was found": "..."
}}
```

Note: If a piece of information is not mentioned in the dialogue, fill in "Not mentioned".

API reference

For the input and output parameters of the model, see Text generation.
Token Plan
Fine-tuning
Model Compression
Statistics and Monitoring
Support