Question classifier

Updated at:

Definition

The question classifier uses a large language model (LLM) to infer a matching category based on user input and predefined category descriptions. The classifier then outputs the result to provide more precise information to descendant nodes.

Prerequisites

Create an AI Studio service

Example scenarios

Common scenarios include classifying customer service intents, categorizing product reviews, and sorting emails in batches.

In a typical product support Q&A scenario, the question classifier can be used as a preliminary step before knowledge base retrieval to classify the user's intent. After classification, the query is directed to different downstream knowledge bases to find relevant content and provide an accurate answer.

The following figure shows an example workflow template for a product support scenario.

image

This scenario uses three category labels.

  • Category 1: Questions related to logistics

  • Category 2: Questions related to products

  • Category 3: Other questions

When a user enters a question, the question classifier automatically classifies it based on the configured category labels.

  • "How do I set up contacts in the address book on an iPhone 14?" —> "Questions related to products"

  • "When will my order arrive?" —> "Questions related to logistics"

  • "What is the weather like today?" —> "Other questions"

Node configuration

Click the image icon after Start to add a Question Classifier node.

Click the node and configure its settings in the Question Classifier panel.

Configuration steps:

  1. Select an input variable. This is the content to classify.

  2. Select a reasoning model. The question classifier uses the natural language classification and reasoning capabilities of an LLM. Selecting a suitable model improves classification accuracy.

  3. Add category labels and descriptions. Manually add multiple categories. For each category, provide keywords or descriptive statements to help the LLM better understand the classification criteria.

  4. Select a descendant node for each category. This defines the workflow path for each classification result.

Advanced Settings

Instruction: In the Instruction field under Advanced Settings, you can add supplementary instructions, such as more detailed classification criteria, to improve the classifier's performance.

Output variable

The class_name variable stores the prediction result from the classification model. After classification is complete, this variable contains the specific category label. You can reference this result in subsequent nodes to execute the corresponding logic.