Intent recognition methods, electronic devices, storage media and application products
By introducing an intent category tree and constructing intent recognition prompts, the problem of insufficient accuracy in intent recognition in existing technologies is solved, achieving more efficient and accurate intent matching and processing, and improving the user interaction experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ANT BLOCKCHAIN TECHNOLOGY (SHANGHAI) CO LTD
- Filing Date
- 2026-02-27
- Publication Date
- 2026-06-02
AI Technical Summary
Existing intent recognition technologies lack accuracy in understanding the flexibility and ambiguity of users' natural language expressions, leading to biases in intent comprehension and impacting interaction efficiency and user experience.
Introducing an intent category tree related to the target application scenario, constructing intent recognition prompts, and using a hierarchical classification and differentiated processing strategy, utilizing a trained intent recognition model for accurate intent matching to generate follow-up questions or responses.
It improves the accuracy and efficiency of intent recognition, reduces dataset routing mismatch issues caused by intent misjudgment, and ensures the accuracy and reliability of subsequent processing.
Smart Images

Figure CN122132537A_ABST
Abstract
Description
Technical Field
[0001] This specification relates to the field of natural language processing technology, and more particularly to an intent recognition method, electronic device, computer-readable storage medium, and computer program product. Background Technology
[0002] In the field of natural language processing, intent recognition, as a core link in the interaction between user needs and service systems, is widely used in various scenarios such as intelligent customer service and intelligent question answering. Its core objective is to accurately parse the core needs expressed by users in natural language and then route them to the matching processing flow to complete the response.
[0003] However, the accuracy of existing intent recognition technologies still has significant room for improvement. Due to the flexibility, ambiguity, and inherent nature of users' natural language expressions, current intent recognition methods often struggle to accurately capture users' true intentions, leading to misunderstandings. These misunderstandings not only result in subsequent responses that do not meet user expectations but also reduce interaction efficiency, negatively impact user experience, and severely limit the effectiveness of intent recognition technology in real-world scenarios. Summary of the Invention
[0004] In view of the above, one or more embodiments of this specification provide the following technical solutions: According to a first aspect of one or more embodiments of this specification, an intent recognition method is proposed, comprising: The system receives questions input by users in a target application scenario and obtains a pre-configured intent category tree related to the target application scenario. The intent category tree includes at least two layers of nodes, where leaf nodes in the at least two layers of nodes represent specific intents in the target application scenario, and non-leaf nodes in the at least two layers of nodes represent summaries of the intents corresponding to their subordinate nodes. Based on the aforementioned question and the aforementioned intent category tree, intent recognition prompts are constructed; The intent recognition prompt is input into the trained intent recognition model so that the intent recognition model can determine the target intent category of the question from the intent category tree; If the target intent category belongs to a non-leaf node in the intent category tree, generate a follow-up question based on at least one leaf node corresponding to the non-leaf node and return it. If the target intent category belongs to a leaf node in the intent category tree, generate and return a response based on the target intent category.
[0005] According to a second aspect of the embodiments of this specification, an electronic device is provided, comprising: processor; Memory used to store processor-executable instructions; Wherein, when the processor executes the executable instructions, it is used to implement the method described in the first aspect.
[0006] According to a third aspect of the embodiments of this specification, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps of the method described in the first aspect.
[0007] According to a fourth aspect of the embodiments of this specification, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps of the method described in the first aspect.
[0008] As can be seen from the above embodiments, this specification introduces an intent category tree related to the target application scenario, providing a scenario-based and structured classification basis for intent recognition. This enables the intent recognition model to perform targeted intent matching based on the category tree, effectively improving the accuracy of intent recognition and reducing the problem of dataset routing mismatch caused by intent misjudgment. Furthermore, based on the hierarchical characteristics of the intent category tree, differentiated processing strategies are adopted for leaf nodes and non-leaf nodes, ensuring both the targeting of intent recognition and improving the efficiency and reliability of intent processing, thus guaranteeing the accuracy of subsequent processing.
[0009] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this specification. Attached Figure Description
[0010] Figure 1 This is a schematic diagram of the architecture of a question-and-answer service system provided in an exemplary embodiment.
[0011] Figure 2 This is a flowchart of an intent recognition method provided in an exemplary embodiment.
[0012] Figure 3 This is a schematic diagram of an intent category tree corresponding to a shopping question and answer system provided in an exemplary embodiment.
[0013] Figure 4 This is a schematic diagram of an intent recognition prompt word construction and intent recognition process provided in an exemplary embodiment.
[0014] Figure 5 This is a schematic diagram of an intent category tree containing specified leaf nodes, provided in an exemplary embodiment.
[0015] Figure 6 This is a schematic diagram of the structure of a device provided in an exemplary embodiment. Detailed Implementation
[0016] To enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this specification, and not all embodiments. Based on the embodiments in this specification, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of this specification.
[0017] The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this manual are all information and data authorized by the user or fully authorized by all parties. The collection, use and processing of related data shall comply with the relevant laws, regulations and standards of the relevant regions, and corresponding operation portals shall be provided for users to choose to authorize or refuse.
[0018] Figure 1 This is a schematic diagram of the architecture of a question-and-answer service system provided in an exemplary embodiment. Figure 1 As shown, the system may include a server 11, a network 12, and several terminals, such as a PC (Personal Computer) 13, a mobile phone 14, etc.
[0019] Server 11 can be a physical server containing a single host, or it can be a virtual server hosted in a host cluster. During operation, server 11 can run a question-and-answer service program, thus becoming a corresponding question-and-answer service platform.
[0020] PC13 and mobile phone14 are only some of the types of terminals that users can use. In reality, users can obviously also use terminals such as tablets, laptops, PDAs (Personal Digital Assistants), wearable devices (such as smart glasses, smartwatches, etc.), etc., and one or more embodiments in this specification do not limit this. During operation, the terminal can run a question-and-answer service program, acting as a client for the question-and-answer service. The client application for the aforementioned question-and-answer service can be launched and run on the terminal. This client-side program can be a native application installed on the terminal, or it can be a mini-program, quick app, or other similar form. Of course, when using web technologies such as HTML5, the relevant functions can be implemented through a browser-displayed page. This browser can be a standalone browser application or a browser module embedded in some applications.
[0021] As for the network 12 that enables interaction between terminals such as PC13 and mobile phone 14 and server 11, communication can be achieved using either wired or wireless networks based on the communication methods supported by the respective terminals. This specification does not impose any restrictions on this. For example, PC13 can support both wired and wireless communication, so it can use either wired or wireless networks as needed. Mobile phone 14 typically only supports wireless communication, so it can use a wireless network for communication.
[0022] For example, a question-and-answer service system can be a system specifically designed to serve a target application scenario. Such systems include, but are not limited to: ① a medical and health service question-and-answer system, providing patients with services such as symptom consultation, medication guidance, interpretation of examination reports, and appointment booking; ② an e-commerce shopping question-and-answer system, providing consumers with services such as product consultation, order inquiry, and after-sales support; ③ a financial management question-and-answer system, providing investors with services such as stock market information, fund product consultation, financial product analysis, and interpretation of financial policies; and ④ a government service question-and-answer system, providing citizens with services such as policy interpretation, service guides, online applications, and complaints and suggestions.
[0023] Please see Figure 2 This specification provides an intent recognition method, which can be executed by an electronic device, such as server 11 in the aforementioned question-and-answer service system, or other intent recognition devices connected to server 11; the method includes: In S200, the system receives questions input by the user in the target application scenario and obtains a pre-configured intent category tree related to the target application scenario. The intent category tree includes at least two layers of nodes. The leaf nodes in the at least two layers of nodes are used to represent specific intents in the target application scenario, and the non-leaf nodes in the at least two layers of nodes are used to represent a summary of the intents corresponding to the subordinate nodes.
[0024] The target application scenario refers to the specific service area preset by the question-and-answer service system, such as medical consultation, e-commerce customer service, and data query in enterprise operation scenarios. The question entered by the user in the target application scenario can be understood as the question entered using the client corresponding to the question-and-answer service system in the target application scenario, such as the consultation portal of a medical app or the customer service dialog box of an e-commerce platform.
[0025] Intent category trees are used to hierarchically represent multiple intents in a target application scenario. Please refer to [link / reference]. Figure 3This diagram illustrates the intent category tree corresponding to the shopping Q&A system. The intent category tree has a tree-like topology, with the root node at the top (representing an overview of the intent categories for the target application scenario), non-leaf nodes in the middle levels (containing first-level and second-level child nodes under the root node), and leaf nodes at the bottom. Non-leaf nodes serve as a general summary of their next-level nodes, representing a general intent category within the target scenario, but do not correspond to specific, directly responsive user needs. Leaf nodes are indivisible nodes, representing the user's specific intent within the target scenario—precise needs that can directly trigger a clear response. By classifying and organizing various intents within the target application scenario in a hierarchical manner, a progressive classification system from general intents to specific intents is formed, providing clear classification criteria and hierarchical judgment standards for intent recognition.
[0026] In S202, intent recognition prompts are constructed based on the question and intent category tree.
[0027] For example, a prompt word template can be pre-set. For instance, the structured prompt word template adopts a three-part template of "instruction + context + task". The instruction part is "Please analyze the core needs of the user's problem based on the following intent category tree and match the unique corresponding intent category"; the context part includes "User problem: ..." "Intent category tree: [hierarchical node list, labeled node type]"; and the task part is "Output format: intent identifier | node type | semantic matching degree".
[0028] Taking a business operation scenario as an example, the prompt template could include: "Based on the following intent category tree, analyze the core needs of the user's question and match the unique corresponding intent category. User question: I want to understand our company's revenue situation, focusing on customer data. Intent category tree: 1. Root node: Business operation query (non-leaf); 2. First-level child node: Revenue query (non-leaf) - 2.1 Second-level leaf node: Project revenue (intent identifier: Q001) - 2.2 Second-level leaf node: Customer revenue (intent identifier: Q002); 3. First-level child node: Business..." Performance Inquiry (Non-Leaf Node) - 3.1 Second-level Leaf Node: Team Performance (Intent Identifier: Q003) - 3.2 Second-level Leaf Node: Member Performance (Intent Identifier: Q004); 4. First-level Sub-node: Overall Business Inquiry (Non-Leaf Node) - 4.1 Second-level Leaf Node: Revenue by Line (Intent Identifier: Q005) - 4.2 Second-level Leaf Node: Synchronous Growth Rate (Intent Identifier: Q006) - 4.3 Second-level Leaf Node: Digital Technology Revenue Completion Rate (Intent Identifier: Q007). Output Format: Intent Identifier | Node Type | Semantic Matching Degree.
[0029] In this step, the electronic device can embed the question and intent category tree into the prompt word template to construct intent recognition prompt words. Intent recognition prompt words are a structured text that integrates user questions, intent category trees, and task instructions. They are used to guide the intent recognition model to complete the directional task of "matching the target intent from the intent category tree" rather than general semantic understanding, thereby achieving directional constraints on the model's reasoning process.
[0030] In some embodiments, before constructing intent recognition prompts based on the user-input questions and intent category trees corresponding to the target application scenario, the electronic device can also detect the current session state to determine whether the question is the first round of dialogue in the current session. In this embodiment, the same session refers to a multi-round question-and-answer interaction process that occurs continuously between the electronic device and the user around the same interaction context. The determination conditions for belonging to the same session may include, but are not limited to: (1) Each time the user initiates a new interaction process, the system will automatically generate a unique session identifier (SessionID) for the interaction. If the continuous user inputs are all associated with the same SessionID, they are considered to be in the same session. (2) If the user's multiple rounds of input occur within a preset time interval, such as configurable time windows such as 5 minutes or 10 minutes, they are considered to be in the same session. (3) If the user always stays on the same service function interface, such as the "Loan Consultation", "Reimbursement Form Filling", "Permission Application" interface, the system can infer that the user's intent is still around the same service scope and belongs to the same session.
[0031] If the question is in the initial dialogue stage, the electronic device generates intent recognition prompts based on the question and intent category tree. Otherwise, if the question is not in the initial dialogue stage, the electronic device can further utilize historical question-and-answer content related to the current conversation to enhance intent recognition.
[0032] When the question is not in the initial dialogue phase, the electronic device can obtain a set of historical question-and-answer pairs belonging to the current session. This set includes at least one historical question-and-answer pair, each consisting of the user's input question and the system's output response. Subsequently, the electronic device can filter out invalid historical question-and-answer pairs from the set and obtain valid ones, which serve as supplementary content for constructing intent recognition prompts.
[0033] The invalid historical question-and-answer pairs include follow-up or guiding questions. For example, when the system cannot uniquely determine the user's intent and requires further explanation, it may ask the user a follow-up question such as, "Do you want to inquire about XXX or subscribe to YYY?" Or, at the beginning of the conversation, to help the user understand the supported services, the system may ask guiding questions such as, "You can inquire about your balance, bill, or change your service plan." Because such responses do not represent a clear intentional response and do not contribute any real semantic meaning, they are considered invalid historical question-and-answer pairs and are removed.
[0034] After filtering, the electronic device generates intent recognition prompts based on the user's current input question, intent category tree, and valid historical question-answer pairs. This improves the intent recognition model's ability to understand contextual semantics, enabling the model to not only understand the current question itself but also reference the semantic history in the current session, thereby achieving more accurate intent recognition.
[0035] In this implementation, by distinguishing conversation stages, filtering invalid dialogue content, and retaining only valid historical question-and-answer pairs that reflect the user's true intent, redundant prompts, semantic noise accumulation, and model decision bias can be avoided. Simultaneously, by enabling prompts to carry coherent context, the intent understanding capability of the large language model in multi-turn dialogues can be improved, allowing the same question to achieve different recognition results in different contexts, thus better aligning with natural language interaction logic.
[0036] In one possible implementation, considering the input length limitation of intent recognition models, directly concatenating the user's question, intent category tree, and all historical question-answer pairs into the model might cause the input to exceed the model's processing capacity, leading to inference failure, model refusal to answer, or truncation of context, thus affecting recognition accuracy. Therefore, this implementation introduces a dynamic input content control strategy based on the number of tokens to ensure that the input size is controllable and the information is fully expressed.
[0037] Electronic devices can dynamically constrain and adjust the information required to construct prompts based on the smallest encoding unit (token unit) used by the intent recognition model. The token unit is the smallest encoding unit used by the intent recognition model during input processing and output generation. Electronic devices can use the token unit used by the intent recognition model as the smallest encoding granularity to encode the following and count the corresponding token counts: ① Concatenate the user's current input question with the intent category tree corresponding to the target application scenario, encode the result, and count the first token count; ② Concatenate the user's current input question, the intent category tree, and valid historical question-answer pairs, encode the result, and count the second token count. The second token count represents the actual input scale that the model needs to process while fully preserving contextual information.
[0038] If the number of the second token exceeds a preset token threshold, it means that the accumulated historical information of the current session has exceeded the model's ability to process it completely. Continuing to retain all content would lead to truncation or rejection of the model's input, thus affecting recognition quality. Therefore, the electronic device can generate summary content that meets preset conditions based on valid historical question-and-answer pairs. These conditions include: the number of tokens in the summary content is no greater than the difference between the preset token threshold and the number of the first token. In other words, key points of historical semantics are preserved through summarization, rather than discarding all history or only retaining the last few rounds of dialogue. Subsequently, the electronic device embeds the questions, intent category tree, and summary content into a preset prompt word template to construct intent recognition prompt words.
[0039] If the number of second tokens is not greater than the preset token threshold, it indicates that the current scale of historical question-and-answer information is still within the model's processing range, and retaining all historical dialogues will not cause input overload. Electronic devices can embed prompt word templates with questions, intent category trees, and valid historical question-and-answer pairs to construct intent recognition prompt words. This can preserve the continuity of context and the trajectory of user intent evolution to the greatest extent, thereby improving the stability and accuracy of intent recognition.
[0040] The preset token threshold can be determined based on the maximum number of input tokens supported by the intent recognition model. Furthermore, considering that the prompt word template itself reserves a fixed information structure, such as interaction format, guiding statements, and model role settings, which also occupy some tokens, the preset token threshold can be less than or equal to the difference between the maximum number of input tokens supported by the intent recognition model and the number of tokens occupied by the prompt word template.
[0041] This embodiment dynamically adjusts the input content based on the number of tokens, ensuring that the prompt words never exceed the upper limit of the model's input capacity, thus preventing the model from refusing to process or truncating semantics due to excessively long input.
[0042] In some embodiments, to improve the model's semantic understanding of user questions and the accuracy of intent recognition, the electronic device can perform word segmentation on the question before constructing intent recognition prompts based on the question and intent category tree, obtaining multiple words to be matched. These words typically reflect the core semantic features of the user's intent, such as entity names, key metrics, role titles, or specific operational terms. In different forms of natural language description, these words may have multiple expressions, including synonyms, abbreviations, or colloquial descriptions. Relying solely on user input for understanding may lead to model misjudgment or insufficient understanding.
[0043] Based on this, electronic devices can recall target proper nouns from a proper noun library related to the target application scenario based on multiple words to be matched. The similarity between the word vector corresponding to any target proper noun and the word vector corresponding to one of the words to be matched satisfies a first preset similarity condition. For example, when the word to be matched is "performance-based salary" and the word recalled by the model is "performance-based compensation system," if the similarity between their word vectors exceeds a set threshold, it can be considered that the user's question involves semantic concepts related to performance. The first preset similarity condition can be specifically set according to the actual application scenario, such as a similarity greater than 85% or 90%, but is not limited to this.
[0044] Through the recall process described above, a semantic mapping between user-expressed ideas and standard terminology can be achieved. Ultimately, electronic devices can write target proper nouns along with user input into prompts, enabling the intent recognition model to reason based on standardized expressions, rather than relying on the quality or standardization of the user's original expression, thereby improving the model's recognition accuracy.
[0045] In one possible implementation, considering the input length limitation problem of intent recognition models, if the prompt contains excessively long proper nouns, the input may be truncated, preventing the model from fully perceiving semantic information and thus affecting the accuracy of intent recognition. Therefore, this embodiment introduces a length control mechanism when recalling target proper nouns to achieve a dynamic balance between semantic supplementation and input length limitations.
[0046] In the process of recalling target proper nouns, electronic devices can recall multiple candidate proper nouns from a proper noun library related to the target application scenario based on multiple words to be matched. This recall process is implemented based on semantic similarity calculation. The similarity between the word vector corresponding to any candidate proper noun and the word vector corresponding to one of the words to be matched meets the first preset similarity condition. In this way, it can be ensured that the recalled terms maintain semantic consistency with the user's true intent, and there will be no redundant terms that are irrelevant to the user's needs.
[0047] Subsequently, to ensure that the final constructed prompt words do not exceed the acceptable input length of the model, the electronic device can use the token unit adopted by the intent recognition model as the smallest encoding granularity to encode the concatenation result of the question and intent category tree and count the first token quantity. This process is used to estimate the basic token space occupied by the necessary content when constructing the prompt words and to provide an accurate basis for calculating the remaining resources for subsequent addition of proper nouns. Next, the electronic device determines the available token quota based on the difference between the preset token threshold and the first token quantity, and selects the target proper noun set from multiple candidate proper nouns based on the token quantity corresponding to each candidate proper noun. The total number of tokens in the target proper noun set does not exceed the available token quota. The selection strategy can adopt a standard vocabulary priority selection, a length priority strategy, or a combination of both, so that more important and shorter proper nouns are included in the prompt words first. The determination of the preset token threshold can be found in the above description and will not be repeated here.
[0048] Finally, the selected target proper nouns are written into the constructed prompt words along with the user's input question, so that the model can not only understand the meaning of the user's original statement, but also obtain structured domain knowledge supplementation, thereby improving the depth of semantic understanding.
[0049] In some embodiments, before constructing intent recognition prompts based on the user-input question and the intent category tree corresponding to the target application scenario, the electronic device can also recall reference question-answer pairs from a question-answer library related to the target application scenario based on the question. Specifically, the electronic device can first use a pre-trained semantic vector model to vectorize the question to obtain the embedding vector corresponding to the question; then, it can search for multiple candidate question-answer pairs from the question-answer library and calculate the similarity between the embedding vector corresponding to any candidate question-answer pair and the embedding vector corresponding to the question. When the similarity meets a second preset similarity condition, it means that the candidate question-answer pair has a high semantic relevance to the question currently input by the user, and the candidate question-answer pair is recalled as a reference question-answer pair. Subsequently, when generating intent recognition prompts, the intent recognition prompts can further include reference question-answer pairs to improve the semantic expressiveness and contextual relevance of the prompts. The second preset similarity condition can be specifically set according to the actual application scenario, such as a similarity greater than 85% or 90%, but is not limited to this.
[0050] The reference question-answer pairs are typically derived from historical interaction corpora within the target application scenario. These corpora reflect typical expressions and high-frequency question patterns. Therefore, when the reference question-answer pairs exhibit high semantic consistency with the current question, using them as semantic supplementary content in prompt word construction can compensate for insufficient information in the user's current expression, enhance the semantic support capability of the prompt word content for the intent recognition model, and thus improve recognition accuracy.
[0051] In one possible implementation, also considering the input length limitation of the intent recognition model, during the recall of reference question-answer pairs, the electronic device can recall multiple candidate question-answer pairs from a question-answer library related to the target application scenario based on the question. The similarity between the embedding vector corresponding to the reference question-answer pair and the embedding vector corresponding to the question satisfies a second preset similarity condition. Then, using the token unit adopted by the intent recognition model as the smallest encoding granularity, the concatenation result of the question and intent category tree is encoded, and the first token quantity is counted. The difference between the preset token threshold and the first token quantity is used as the available token quota. Based on the token quantity corresponding to each candidate question-answer pair, a reference question-answer pair set is selected from multiple candidate proper nouns. The total number of tokens in the target proper noun set is not greater than the available token quota. This embodiment introduces a length control mechanism when recalling reference question-answer pairs to achieve a dynamic balance between semantic supplementation and input length limitation.
[0052] Understandably, electronic devices are not required to simultaneously include all valid historical question-and-answer pairs, target proper nouns, and reference question-and-answer pairs in the intent recognition prompt. Instead, they can select at least one of these three categories to add to the prompt structure based on the specific needs of the scenario, thereby improving the flexibility and adaptability of the prompts. For example, such as Figure 4 As shown, this example demonstrates the case where valid historical question-and-answer pairs, target proper nouns, and reference question-and-answer pairs are all added to the intent recognition prompts. In this case, the prompts are the most comprehensive and can provide a more complete semantic reference basis for the intent recognition model.
[0053] Since intent recognition models typically have a maximum input length limit, directly incorporating all the above content into the prompt word structure might cause the number of tokens to exceed the maximum input range allowed by the model, preventing it from performing inference correctly. Therefore, in this case, the electronic device can further consider the difference between a preset token threshold and the first token number, based on the already calculated first token number, to determine the total token quota currently available for supplementing content.
[0054] After determining the total available token quota, to prevent any one type of content from occupying too much token space and preventing other types of content from being included, electronic devices can divide the total token quota into three available token quotas according to a preset content allocation strategy. These quotas correspond to valid historical question-and-answer pairs, target proper nouns, and reference question-and-answer pairs, respectively. For example, a fixed ratio (such as 4:3:3) or a dynamic ratio (such as adaptive allocation based on the number of content recalled, semantic matching confidence, or priority) can be set for the above three types of content. Under this ratio constraint, target content with a token quantity not exceeding the respective quota can be selected sequentially from the set of recalled content.
[0055] By using the above method, even if there is a need to include multiple types of content in the prompt words at the same time, it is possible to achieve a balance and effective retention between the content under the condition of limited token quota. This ensures that the prompt words carry sufficient semantic information and that the structure of the generated prompt words meets the input constraints of the intent recognition model.
[0056] In S204, the intent recognition prompt is input into the trained intent recognition model so that the intent recognition model can determine the target intent category of the question from the intent category tree.
[0057] Among them, the trained intent recognition model can be a dedicated model obtained by fine-tuning the Large Language Model (LLM) in a specific context. The fine-tuning dataset consists of paired samples of "user question-intent category in target scenario", and the model output is the node matching result in the intent category tree.
[0058] For example, the intent recognition model can output the semantic matching degree between the question and the target intent category when outputting the target intent category. A semantic matching degree threshold (such as 0.7) can be set. If the semantic matching degree output by the intent recognition model is lower than the threshold, secondary inference is triggered.
[0059] In S206, if the target intent category belongs to a non-leaf node in the intent category tree, a follow-up question is generated and returned based on at least one leaf node corresponding to the non-leaf node.
[0060] Among them, follow-up questions are a type of guiding text that guides users to clarify their specific needs based on the intent of the leaf nodes under the non-leaf nodes. They have the characteristics of being targeted (only focusing on the leaf nodes under the non-leaf nodes) and concise (avoiding redundant information).
[0061] In this step, for ambiguous intents identified as non-leaf nodes, follow-up questions are generated to further clarify user needs, thereby achieving hierarchical refinement of intents. This can effectively reduce the recognition bias caused by ambiguous intents and further improve the accuracy of intent recognition.
[0062] For example, an electronic device can use a traversal algorithm, such as a depth-first search algorithm, to obtain all leaf nodes under a non-leaf node, forming a list of leaf nodes. The generation logic of "demand guidance + option listing" is adopted, completed by the Natural Language Generation (NLG) module. First, based on the user's original question and the target intent category corresponding to the non-leaf node, a guiding sentence is generated, such as "Your question pertains to order-related inquiries, what exactly is it?". Then, the intent category corresponding to the leaf node is simplified into options, such as "1. Check order status 2. Apply for a return 3. Modify delivery address". If there are multiple subordinate leaf nodes (e.g., M), all can be displayed, or the top N options with higher matching degree can be displayed first, where N < M, with the addition of "Please specify other needs". This embodiment focuses user needs on a clear range of leaf nodes through targeted option-based follow-up questions: on the one hand, it avoids users repeatedly inputting long text, improving interaction efficiency; on the other hand, by listing options, it reduces the ambiguity of user expression, providing clear input basis for the next accurate recognition, achieving efficient conversion from vague intent to clear intent.
[0063] In S208, if the target intent category belongs to a leaf node in the intent category tree, the response content is generated based on the target intent category and returned.
[0064] In this embodiment, by introducing an intent category tree related to the target application scenario, a scenario-based and structured classification basis is provided for intent recognition. This enables the intent recognition model to perform targeted intent matching based on the category tree, effectively improving the accuracy of intent recognition and reducing the problem of dataset routing mismatch caused by intent misjudgment. Furthermore, based on the hierarchical characteristics of the intent category tree, differentiated processing strategies are adopted for leaf nodes and non-leaf nodes, which not only ensures the targeting of intent recognition but also improves the efficiency and reliability of intent processing, ensuring the accuracy of subsequent processing.
[0065] For example, considering that user input may include questions related to the target application scenario, as well as casual conversation, general questions, or cross-domain requests unrelated to the target application scenario, to improve the accuracy of intent recognition and the rationality of interaction logic, please refer to [link to relevant documentation]. Figure 5 The intent category tree also includes specifying leaf nodes ( Figure 5 The gray nodes in the diagram represent leaf nodes used to indicate that the intent of the user's input is unrelated to the target application scenario, enabling electronic devices to distinguish between valid requests and invalid inputs, thus allowing for differentiated processing in different situations. Therefore, S208 can be further subdivided into the following two processing methods: In the first scenario, if the target intent category belongs to a specific leaf node in the intent category tree, it indicates that the user's input question has no direct semantic connection to the target application scenario. For example, the user might ask an entertainment-related, greeting-related, or cross-topic question during a service operation. Directly executing a standard response would neither meet the user's actual needs nor prevent service flow disruptions, thus reducing interaction efficiency. Therefore, electronic devices can generate guiding questions related to the target application scenario and return them to prompt the user to refocus on the service scope that the system can handle.
[0066] For example, an electronic device can determine at least one identity attribute associated with the user based on the user's login information in the current session, such as permission level, department, or role category. Then, based on the identity attribute, it retrieves multiple candidate guiding questions corresponding to the identity attribute from a pre-set guiding question database. The guiding question database records guiding questions that are valuable for user roles with different identity attributes in the target application scenario. Based on the semantic similarity between the question and each candidate guiding question, at least one guiding question to be returned is determined from the multiple candidate guiding questions, ensuring that the guiding content remains appropriately relevant to the current context, rather than abruptly jumping to another question. Through this method, the dialogue path can be automatically reclaimed when a user raises a question unrelated to the scenario, avoiding invalid interactions and allowing the user to gradually understand the system's processing scope, thereby improving the system's interactive experience and the overall stability of the intent recognition model.
[0067] In the second scenario, if the target intent category is a leaf node in the intent category tree but not a specified leaf node, the electronic device can generate and return response content based on the target intent category, such as specific operation instructions, specific service content results, or instructions for the next step.
[0068] This embodiment effectively distinguishes between valid and invalid cross-domain inputs by introducing designated leaf nodes, reducing the probability of model misidentification; and automatically generates scene-related guiding questions when irrelevant intentions are identified, avoiding getting bogged down in small talk or cyclical incorrect answers.
[0069] The various technical features in the above embodiments can be combined arbitrarily, as long as there is no conflict or contradiction between the combinations of features. However, due to space limitations, they are not described one by one. Therefore, the arbitrary combination of various technical features in the above embodiments is also within the scope of this specification.
[0070] Figure 6 This is a schematic structural diagram of a device provided in an exemplary embodiment. For example... Figure 6 As shown, device 600 mainly consists of a communication interface 602, a user interface 604, a processor 606, and a data storage 608. These components are interconnected and communicate with each other via a system bus, network, or other connection mechanism 610. The communication interface 602 enables device 600 to communicate with other devices, access networks, and transmission networks via analog or digital modulation. For example, the communication interface 602 may include processing components and an antenna for wireless communication with a radio access network or access point. Furthermore, the communication interface 602 can be a wired interface such as Ethernet, Token Ring, or a USB port, or a wireless interface such as Wi-Fi, Bluetooth, Global Positioning System (GPS), or a wide-area wireless interface (e.g., WiMAX or LTE). Of course, the communication interface 602 can also support other forms of physical layer interfaces and standard or proprietary communication protocols. The communication interface 602 may also include multiple physical communication interfaces, such as Wi-Fi interfaces, Bluetooth interfaces, and wide-area wireless interfaces.
[0071] User interface 604 includes receiving user input and providing output to the user. Therefore, user interface 604 may include input components such as a keypad, keyboard, touch-sensitive or presence-sensitive panel, computer mouse, trackball, joystick, microphone, still camera, and video camera, and output components such as a display screen (which may be combined with a touch-sensitive panel), CRT, LCD, LED, display using DLP technology, printer, and other similar devices known or developed in the future. User interface 604 may also generate auditory output via speakers, speaker jacks, audio output ports, audio output devices, headphones, and other similar devices known or developed in the future. In some embodiments, user interface 604 may include software, circuitry, or other forms of logic capable of transmitting and receiving data from external user input / output devices. Additionally or alternatively, device 600 may support remote access from other devices via communication interface 602 or another physical interface (not shown). User interface 604 may be configured to receive user input, the position and movement of which may be indicated by indicators or cursors described herein. User interface 604 may also be configured as a display device for rendering or displaying text fragments.
[0072] Processor 606 may contain one or more general-purpose processors and / or special-purpose processors.
[0073] Data storage 608 may include one or more volatile and / or non-volatile storage components and may be integrated wholly or partially with processor 606. Data storage 608 may include removable and non-removable components.
[0074] Processor 606 is capable of executing program instructions 618 (e.g., compiled or uncompiled program logic and / or machine code) stored in data storage 608 to perform the various functions described herein. Data storage 608 may contain a non-transitory computer-readable medium on which program instructions are stored, which, when executed by device 600, enable device 600 to perform any methods, processes, or functions disclosed in this specification and / or the accompanying drawings. Execution of program instructions 618 by processor 606 may result in processor 606 using data 612.
[0075] For example, program instructions 618 may include an operating system 622 (e.g., an operating system kernel, device drivers, and / or other modules) installed on device 600 and one or more applications 620 (e.g., a browser, social application, or game application). Similarly, data 612 may include operating system data 616 and application data 614. Operating system data 616 is primarily accessible to the operating system 622, while application data 614 is primarily accessible to one or more applications 620. Application data 614 may reside in a file system visible or hidden from the user of device 600.
[0076] Application 620 can communicate with operating system 622 through one or more application programming interfaces (APIs). These APIs help application 620 read and / or write application data 614, transmit or receive information via communication interface 602, receive or display information on user interface 604, etc.
[0077] In some terminology, application 620 may be simply referred to as "app". Furthermore, application 620 can be downloaded to device 600 through one or more online app stores or app markets. However, applications can also be installed on device 600 in other ways, such as through a web browser or a physical interface on device 600 (e.g., a USB port).
[0078] In some embodiments, the intent recognition device can be applied to, for example, Figure 6 The device shown implements the technical solution of this specification. The intent recognition device may include: The data acquisition module is used to receive questions input by users in the target application scenario and obtain a pre-configured intent category tree related to the target application scenario. The intent category tree includes at least two layers of nodes. The leaf nodes in the at least two layers of nodes are used to represent specific intents in the target application scenario, and the non-leaf nodes in the at least two layers of nodes are used to represent a summary of the intents corresponding to the subordinate nodes.
[0079] The intent recognition prompt word construction module is used to construct intent recognition prompt words based on questions and intent category trees.
[0080] The intent recognition module is used to input intent recognition prompts into the trained intent recognition model so that the intent recognition model can determine the target intent category of the question from the intent category tree.
[0081] The processing module is used to generate follow-up questions and return them based on at least one leaf node corresponding to the non-leaf node if the target intent category belongs to a non-leaf node in the intent category tree.
[0082] The processing module is also used to generate and return response content based on the target intent category if the target intent category belongs to a leaf node in the intent category tree.
[0083] In one implementation, the intent category tree also includes designated leaf nodes, which are used to indicate that the intent to which the user input question belongs is unrelated to the target application scenario.
[0084] The processing module is specifically used to generate and return guiding questions related to the target application scenario if the target intent category belongs to a specified leaf node in the intent category tree; and to generate and return response content based on the target intent category if the target intent category belongs to a leaf node in the intent category tree but is not a specified leaf node.
[0085] In one implementation, the processing module is specifically used to determine at least one identity attribute associated with the user based on the user's login information in the current session; based on the identity attribute, retrieve multiple candidate guidance questions corresponding to the identity attribute from a pre-set guidance question library; the guidance question library is used to record guidance questions for user roles with different identity attributes in the target application scenario; based on the semantic similarity between the question and each candidate guidance question, determine at least one guidance question to be returned from the multiple candidate guidance questions.
[0086] In one implementation, the intent recognition prompt construction module is further used to detect whether the question is in the first round of dialogue in the current session; if the question is not in the first round of dialogue, it obtains a set of historical question-answer pairs belonging to the current session, the set of historical question-answer pairs includes at least one historical question-answer pair, the historical question-answer pair includes an input question and an output answer; it filters out invalid historical question-answer pairs from the set of historical question-answer pairs to obtain valid historical question-answer pairs, wherein the output answers in invalid historical question-answer pairs include follow-up questions or guiding questions; and it constructs intent recognition prompts based on the question, the intent category tree, and the valid historical question-answer pairs.
[0087] In one implementation, the intent recognition prompt word construction module is specifically used to encode the concatenation result of the question and intent category tree and count the number of first tokens, using the token unit adopted by the intent recognition model as the smallest encoding granularity; and to encode the concatenation result of the question, intent category tree, and valid historical question-answer pairs and count the number of second tokens. Here, the token unit is the smallest encoding unit used when the intent recognition model inputs and outputs. If the number of second tokens is greater than a preset token threshold, summary content that meets preset conditions is generated based on the valid historical question-answer pairs. The preset conditions include: the number of tokens in the summary content is not greater than the difference between the preset token threshold and the number of first tokens; the question, intent category tree, and summary content are embedded into a preset prompt word template to construct intent recognition prompt words; if the number of second tokens is not greater than the preset token threshold, the question, intent category tree, and valid historical question-answer pairs are embedded into the prompt word template to construct intent recognition prompt words.
[0088] In one implementation, the intent recognition prompt word construction module is further used to perform word segmentation on the question to obtain multiple words to be matched, and to recall target proper nouns from a proper noun library related to the target application scenario based on the multiple words to be matched. The similarity between the word vector corresponding to any target proper noun and the word vector corresponding to one of the words to be matched satisfies a first preset similarity condition; wherein, the intent recognition prompt words also include target proper nouns; In one implementation, the intent recognition prompt word construction module is further used to recall reference question-answer pairs from a question-answer library related to the target application scenario based on the question, wherein the similarity between the embedding vector corresponding to the reference question-answer pair and the embedding vector corresponding to the question satisfies a second preset similarity condition; wherein the intent recognition prompt words also include reference question-answer pairs.
[0089] In one implementation, the intent recognition prompt word construction module is specifically used to recall multiple candidate proper nouns from a proper noun library related to the target application scenario based on multiple words to be matched. The similarity between the word vector corresponding to any candidate proper noun and the word vector corresponding to one of the words to be matched satisfies a first preset similarity condition. Using the token unit adopted by the intent recognition model as the smallest encoding granularity, the concatenation result of the question and intent category tree is encoded and the first token quantity is obtained. Based on the difference between the preset token threshold and the first token quantity, the available token quota is determined, and based on the token quantity corresponding to each candidate proper noun, the target proper noun set is selected from multiple candidate proper nouns. The total number of tokens in the target proper noun set is not greater than the available token quota.
[0090] For ease of description, the above devices are described by dividing them into various modules or units based on their functions. Of course, when implementing one or more of these specifications, the functions of each module or unit can be implemented in the same or different software and / or hardware, or a module that performs the same function can be implemented by a combination of multiple sub-modules or sub-units, etc. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division; in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed.
[0091] Based on the same concept as the methods described above, this specification also provides an electronic device, including: a processor; a memory for storing processor-executable instructions; wherein the processor performs the steps of the method as described in any of the above embodiments by executing the executable instructions.
[0092] Based on the same concept as the methods described above, this specification also provides a computer-readable storage medium having computer instructions stored thereon that, when executed by a processor, implement the steps of the methods as described in any of the above embodiments.
[0093] Based on the same concept as the methods described above, this specification also provides a computer program product, including a computer program / instructions that, when executed by a processor, implement the steps of the methods as described in any of the above embodiments.
[0094] What those skilled in the art will understand is: In this specification, the terms "comprising," "including," or any other variations thereof are intended to cover a non-exclusive inclusion, such that a process, method, product, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, product, or apparatus. Without further limitation, the presence of additional identical or equivalent elements in a process, method, product, or apparatus that includes said elements is not excluded.
[0095] In this specification, “a,” “an,” and “the” do not specifically refer to the singular, but may also include the plural.
[0096] In this specification, ordinal numbers such as "first," "second," etc., do not necessarily indicate order; they are often used to distinguish between objects. For example, "first server" and "second server" usually refer to two servers. To differentiate between these two servers, they are described as "first server" and "second server." Of course, sometimes these two servers may be the same server.
[0097] In this specification, unless explicitly stated otherwise, "receiving and sending data" does not necessarily mean direct receiving and sending; it can also mean indirect receiving and sending. For example, A receiving data sent by B can be understood as A directly receiving the data sent by B, or it can be understood as A indirectly receiving the data sent by B through other entities such as C. Similarly, B sending data to A can be understood as B sending the data directly to A, or it can be understood as B indirectly sending the data to A through other entities such as C. Here, C can be one entity, or it can be two or more entities.
[0098] In this specification, unless explicitly stated otherwise, the relationships between structures can be direct or indirect. For example, when describing "A is connected to B," unless it is explicitly stated that A and B are directly connected, it should be understood that A can be directly connected to B or indirectly connected to B. Similarly, when describing "A is on top of B," unless it is explicitly stated that A is directly above B (AB is adjacent and A is above B), it should be understood that A can be directly above B or indirectly above B (AB is separated by other elements, and A is above B). And so on.
[0099] This specification uses specific terms to describe embodiments thereof. Terms such as "an embodiment," "one embodiment," and / or "some embodiments" refer to a particular feature, structure, or characteristic associated with at least one embodiment of this specification. Therefore, it should be emphasized and noted that references to "an embodiment," "one embodiment," or "an alternative embodiment" in different locations throughout this specification do not necessarily refer to the same embodiment. Furthermore, those skilled in the art can combine and integrate the different embodiments or examples described herein, as well as the features of those different embodiments or examples, without contradiction.
[0100] Although one or more embodiments of this specification provide method steps as described in the embodiments or flowcharts, it is understood that the order of steps listed in the embodiments or flowcharts is only one of many possible execution orders and does not represent the only execution order. Therefore, when the claims involve method steps, any changes or adjustments to the order of such steps, or the parallelism between steps, are also within the scope of protection of the claims.
Claims
1. An intent recognition method, comprising: Receive questions input by users in the target application scenario and obtain a pre-configured intent category tree related to the target application scenario; The intent category tree includes at least two layers of nodes. The leaf nodes in the at least two layers of nodes are used to represent specific intents in the target application scenario, and the non-leaf nodes in the at least two layers of nodes are used to represent a summary of the intents corresponding to the subordinate nodes. Based on the aforementioned question and the aforementioned intent category tree, intent recognition prompts are constructed; The intent recognition prompt is input into the trained intent recognition model so that the intent recognition model can determine the target intent category of the question from the intent category tree; If the target intent category belongs to a non-leaf node in the intent category tree, generate a follow-up question based on at least one leaf node corresponding to the non-leaf node and return it. If the target intent category belongs to a leaf node in the intent category tree, generate and return a response based on the target intent category.
2. The method according to claim 1, wherein the intent category tree further includes a designated leaf node, the designated leaf node being used to indicate that the intent to which the user input question belongs is unrelated to the target application scenario; If the target intent category belongs to a leaf node in the intent category tree, generating and returning response content based on the target intent category includes: If the target intent category belongs to the specified leaf node in the intent category tree, generate and return a guiding question related to the target application scenario; If the target intent category belongs to a leaf node in the intent category tree but is not the specified leaf node, generate and return a response based on the target intent category.
3. The method according to claim 2, wherein generating guiding questions related to the target application scenario includes: Based on the user's login information in the current session, determine at least one identity attribute associated with the user; Based on the identity attribute, multiple candidate guidance questions corresponding to the identity attribute are retrieved from a pre-set guidance question library; the guidance question library is used to record guidance questions for user roles with different identity attributes in the target application scenario; Based on the semantic similarity between the question and each candidate guiding question, at least one guiding question to be returned is determined from the plurality of candidate guiding questions.
4. The method according to claim 1, further comprising, before constructing the intent recognition prompt based on the question and the intent category tree: Detect whether the question is in the first round of the current conversation; If the question is not in the first round of dialogue, obtain the set of historical question-answer pairs belonging to the current session. The set of historical question-answer pairs includes at least one historical question-answer pair, and the historical question-answer pair includes an input question and an output answer. Filter out invalid historical question-and-answer pairs from the set of historical question-and-answer pairs to obtain valid historical question-and-answer pairs, wherein the output responses in the invalid historical question-and-answer pairs include follow-up questions or leading questions; The construction of intent recognition prompts based on the question and the intent category tree includes: Based on the question, the intent category tree, and the valid historical question-answer pairs, intent recognition prompts are constructed.
5. The method according to claim 4, wherein constructing intent recognition prompts based on the question, the intent category tree, and the valid historical question-and-answer pairs includes: Using the token unit adopted by the intent recognition model as the smallest encoding granularity, the concatenation result of the question and the intent category tree is encoded and the first token count is obtained. Additionally, the concatenation result of the question, the intent category tree, and the valid historical question-answer pairs is encoded and the second token count is obtained. The token unit is the smallest encoding unit used when the intent recognition model is inputting and outputting. If the number of the second tokens is greater than the preset token threshold, a summary content that meets the preset conditions is generated based on the valid historical question and answer pair. The preset conditions include: the number of tokens in the summary content is not greater than the difference between the preset token threshold and the number of the first tokens. The question, the intent category tree and the summary content are embedded into a preset prompt word template to construct intent recognition prompt words. If the number of the second tokens is not greater than the preset token threshold, then the question, the intent category tree, and the valid historical question-and-answer pairs are embedded into the prompt word template to construct intent recognition prompt words.
6. The method according to any one of claims 1 to 5, further comprising, before constructing the intent recognition prompt based on the question and the intent category tree: The problem is segmented to obtain multiple words to be matched. Based on the multiple words to be matched, a target proper noun is recalled from a proper noun library related to the target application scenario. The similarity between the word vector corresponding to any target proper noun and the word vector corresponding to one of the words to be matched satisfies a first preset similarity condition. The intent recognition prompt word also includes the target proper noun. And / or, Based on the question, a reference question-answer pair is recalled from a question-answer library related to the target application scenario. The similarity between the embedding vector corresponding to the reference question-answer pair and the embedding vector corresponding to the question satisfies a second preset similarity condition. The intent recognition prompt also includes the reference question-answer pair.
7. The method according to claim 6, wherein the step of recalling target proper nouns from a proper noun database related to the target application scenario based on the plurality of words to be matched includes: Based on the multiple words to be matched, multiple candidate proper nouns are recalled from the proper noun library related to the target application scenario, and the similarity between the word vector corresponding to any of the candidate proper nouns and the word vector corresponding to one of the words to be matched satisfies the first preset similarity condition. Using the token unit adopted by the intent recognition model as the smallest encoding granularity, the concatenation result of the question and the intent category tree is encoded and the number of first tokens is counted. The available token quota is determined based on the difference between the preset token threshold and the first token quantity. Based on the token quantity corresponding to each candidate proper noun, a target proper noun set is selected from the multiple candidate proper nouns. The total token quantity of the target proper noun set is not greater than the available token quota.
8. An electronic device, characterized in that, include: processor; A memory for storing processor-executable instructions; wherein the processor implements the steps of the method as described in any one of claims 1-7 by executing the executable instructions.
9. A computer-readable storage medium, characterized in that, It stores computer instructions that, when executed by a processor, implement the steps of the method as described in any one of claims 1-7.
10. A computer program product, characterized in that, Includes a computer program / instructions that, when executed by a processor, implement the steps of the method as described in any one of claims 1-7.