When designing an intent recognition system, define the labels before choosing a model. If both “Will I be charged a cancellation fee?” and “Cancel it for me” are tagged as “Cancel order,” grouping them together makes perfect sense given the training data, but the business logic could then take the wrong action.
This article uses hotel booking and after-sales scenarios to present a reusable method for defining labels: choosing granularity, separating intents from slots, deciding when to use a hierarchy or multiple labels, and maintaining versions as the business changes. The accompanying files include definitions, positive and negative examples, permitted slots, and capability boundaries for seven labels.
Download the label specification, baseline code, and task-dependency examples. For an overview of the series, see Intent Recognition in Large Language Model Conversational Systems.
1. Divide intents according to the business process
When assigning intents, compare the processing flow, parameter requirements, access controls, and completion criteria for two requests. If the differences are substantial, they usually warrant separate labels; if only the city or date differs, use slots within the same intent instead.
For example:
| Utterance | What the system needs to do | Label |
|---|---|---|
| Will there be a cancellation fee for my booking? | Look up the policy and explain it | policy_query |
| Please cancel order DEMO-A | Verify the order and eligibility, then initiate the cancellation process | cancel_booking |
| How long does a refund take after cancellation? | Look up the refund timeline or process | refund_query |
| Don't cancel it; just check my order | Look up an existing order | order_query |
You cannot simply classify intents by topic keyword. All four utterances above may contain “cancel,” but looking up a policy, executing a cancellation, answering a refund question, and checking an order serve different purposes.
Nor should every API become a separate user intent. When a user wants to “check the status of an order,” the backend may query the order, then the payment, then fulfillment. Those are implementation steps. Using internal API names directly as labels would force the taxonomy to change whenever the backend interface does.
2. Distinguish intents from slots
“Book a hotel in Beijing” and “Book a hotel in Shanghai” typically share book_room, with the city represented as a slot. If every city became a label, introducing a new city would require adding a class, relabeling the data, and reevaluating the model.
A slot does more than identify an entity in the text; it also defines the entity's role in the task. “Travel from Beijing to Shanghai” contains two cities, but only the task definition determines which is the origin and which is the destination. In the hotel example, it must specify which city's room availability is being searched.
A label can be defined as follows:
Here, “change the check-in date before a booking is submitted” is treated as part of booking. Only a request to modify an existing order falls under change_booking. A label therefore cannot be determined by the current utterance alone; you also need to know what stage the task has reached.
The attachment's teaching_required_slots field is used only by the teaching state machine to calculate missing parameters. A real booking may also require a specific product, guest information, price, payment method, and similar details. The example's required fields being complete simply means it can proceed to subsequent business validation.
3. Choose the right level of granularity
Overly broad labels mix different business branches, leaving downstream systems to perform a second classification. For example, “after-sales” may cover cancellations, date changes, refund inquiries, and complaints. If the downstream system does not know which workflow to use, the classification does not provide enough information.
When labels are too fine-grained, similar categories can be difficult to distinguish, and annotation consistency becomes harder to maintain. If “What time is breakfast?” and “What time is checkout?” are handled by the same policy-retrieval module, they can initially share policy_query, with the subject represented as topic. Consider splitting them only if their capabilities later depend on different data, compliance requirements, or business metrics.
When deciding whether to split a category, consider:
- Whether there is a stable, explainable difference in the user's goal.
- Whether downstream systems can use the distinction to reduce ambiguity or select different capabilities.
- Whether annotators can distinguish the classes consistently based on evidence in the conversation.
- Whether each class has enough examples, and whether the benefit of maintaining a new class is clear.
“The model can't separate them” does not automatically mean you should merge them; there may simply not be enough data. Conversely, “the model can separate them” does not automatically mean they need separate business labels. Establish the processing requirements first, then evaluate the model's capabilities.
4. Write label definitions
Besides the label name, document its scope, negative examples, and how to handle conflicts:
| Item | What to document |
|---|---|
| Stable ID | The identifier used in code and historical data; it does not change when the display name does |
| Definition | The goal the user wants to achieve |
| Positive examples | A variety of natural expressions and any necessary context |
| Exclusions | Similar requests most likely to be misclassified |
| Allowed slots | The parameters the task can accept |
| Stage constraints | Whether an existing order is required and whether an unfinished task may continue |
| Capability boundary | Query only, modification allowed, or not currently supported by the system |
| Uncertainty handling | What additional information to collect and when to ask for clarification when the evidence is insufficient |
| Version | When the definition takes effect and which historical data needs review |
Positive and negative examples work best in pairs: “Cancel DEMO-A” and “Don't cancel DEMO-A yet,” and “Check the price” and “Book it at that price.” Typical positive examples alone do not explain how similar requests should be distinguished.
Do not write facts that are absent from the input or context into the answer. If annotators have to guess to label an example, turn it into a clarification example or supply genuinely available context.
5. Example label taxonomy for hotels
| ID | Goal | Key exclusions |
|---|---|---|
policy_query | Ask about amenities, check-in, and cancellation rules | Actual operations, dedicated refund workflows |
room_search | Search available rooms, room types, and rates | Submitting a booking, looking up an existing order |
book_room | Create a new booking and edit its parameters before submission | Modifying an existing booking |
order_query | Look up information or the status of an existing order | Modifying the order, dedicated refund tracking |
change_booking | Modify an existing booking | Creating a separate new booking |
cancel_booking | Request cancellation of an existing booking | Rules inquiries, negated cancellation requests |
refund_query | Ask about the refund process, amount, and arrival time | Making a payment directly, initiating a refund |
Treating refund inquiries as a separate category here is a business-design choice in this example. Another system might classify them as a subclass of order queries. Either design can work, provided its definitions are consistent and its processing paths make sense; this table should not be treated as a universal standard for all hotel systems.
6. Hierarchical and multi-label classification
Hierarchies organize concepts from broad to narrow. For example, information/order, information/policy, and transaction/cancellation. They can support navigation, layered error analysis, and assigning team responsibilities.
Whether to use two-stage classification must be tested empirically. If a request is first misclassified as information, the second stage can only select a leaf label within the information category, carrying the initial error forward. For a small taxonomy, predict leaf IDs directly and use the hierarchy only as a management structure.
Multi-label classification means that a single input expresses multiple goals: “Check my order and tell me what time breakfast is served.” This is not a deeper hierarchy; it means that two tasks coexist.
Another case is multiple tasks of the same type: “Book one room in Beijing and another in Shanghai.” If a set holds {book_room}, the number of tasks is lost. Assign each task an independent ID and store its parameters separately. See Multi-Label, Conditions, and Task Dependencies.
7. Distinguish unknown intents, ambiguity, and missing parameters
“I want to book a room” has a clear goal but is missing the city and dates, so continue filling slots. “Cancel that one” is referentially ambiguous when there are two orders, so ask which order is meant. “Issue an invoice” is out of scope for a system without invoicing capability.
These cases should be represented with separate status fields. If they are all grouped under unknown, the downstream program cannot determine whether to collect missing parameters, clarify the intended object, or explain that the capability is unsupported.
It is also necessary to distinguish semantic scope from temporary availability. If the system supports order lookup but the order service is currently timing out, the intent is still order_query; this is a service failure, not grounds for relabeling the request as out of scope. Conversely, if the system has never supported invoicing, it should report that the capability is unsupported even if the model recognizes the request.
For “Call me a hero from now on,” a general-purpose assistant can pass the request to a preferences module, while a hotel-specific recognizer can report that it is unsupported under its current scope. Different capability catalogs lead to different but equally reasonable labels.
8. Label changes and data migration
Suppose the invoicing feature is launched later. The old-data utterance “Issue a hotel invoice” was previously out of scope; in the new version, it should become invoice_request. The correct approach is to create a new label version, identify the affected samples, and switch routing only after the new capability is available.
If a coarse label is split into two fine-grained labels, the old label often cannot be mapped automatically to a single new label. You must revisit the original text and context rather than simply replacing strings. Although merging labels makes mapping easy, it can also change the denominator and business meaning of historical metrics.
Use the following migration steps: first establish the new definitions and document the differences, then relabel a sample; next, replay a fixed dataset under both the old and new definitions and check for routing changes; then update the label, model, prompt, data, and interface versions, retaining the old versions needed for rollback. Also record which label version historical reports use.
9. Unify label definitions in code
The attachment's batch2/data/taxonomy.json contains the complete taxonomy, with leaf IDs consistent with those in the first batch of core.py. You can verify this from the project root:
Use a single taxonomy for the label specification, model inputs, and service validation to prevent different modules from working with inconsistent definitions. For example, after adding a slot and updating the specification, generate the prompt and validation rules from it as well, rather than maintaining three separate strings.
Label definitions should support data annotation, model recognition, and business processing alike. Turn easily confused requests into positive and negative examples, then use them to expand the corpus and compare models; only then can you determine whether an improvement is effective.
Continue reading: Complex Intent Corpora, Benchmarking Three Basic Recognition Approaches, and Unknown Intents and Clarification Strategies.