Intention recognition method and device
By combining a mixed recognition method of small intention recognition model and large language model in intention recognition, the problems of poor results and low accuracy caused by a single existing intention recognition method are solved, and higher accuracy and efficiency of intention recognition are achieved.
Patent Information
- Application Number
- CN202411979137.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-05-02
AI Technical Summary
The existing single intent recognition method leads to poor intention recognition effect and low accuracy.
Confidence is obtained by entering the target text to be identified into the intent recognition model; if the highest confidence is less than the preset threshold, a prompt text is constructed and a large language model is input to perform intent recognition to improve accuracy.
It improves the accuracy and efficiency of intention recognition, and enhances the processing ability of complex and variable user input through a hybrid recognition method of large and small models.
Smart Images

Figure CN119918668A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to an intent recognition method and device. Background Art
[0002] Intent recognition is an important part of realizing intelligent services. Whether it is smart home, car system or intelligent customer service, intent recognition can enable these systems to have the ability to "understand" and "judge", thereby providing more intelligent and humane services. Intent recognition technology can not only improve the user experience and interaction efficiency of application software, but also promote the diversification and intelligent development of software functions.
[0003] However, in related technologies, intent classification is usually performed only based on rule judgment or model prediction methods, and the method of intent recognition is relatively simple, resulting in poor intent recognition effect and low accuracy. Summary of the invention
[0004] The present application provides an intent recognition method and device to solve the problem that the existing intent recognition method is single, resulting in poor intent recognition effect and low accuracy.
[0005] In a first aspect, an embodiment of the present application provides an intent recognition method, the method comprising:
[0006] Inputting the target text to be recognized into the intent recognition model, and obtaining the confidence that the target text output by the intent recognition model belongs to each intent;
[0007] If the highest confidence level is less than a preset threshold, constructing a prompt text for performing intent recognition on the target text;
[0008] The prompt text is input into a large language model so that the large language model performs intent recognition on the target text, and a target intent corresponding to the target text output by the large language model is obtained.
[0009] In a second aspect, an embodiment of the present application further provides an electronic device, which includes at least a processor and a memory, and the processor is used to implement the steps of the intent recognition method as described above when executing a computer program stored in the memory.
[0010] In an embodiment of the present application, the target text to be identified is input into the intent recognition model, and the confidence that the target text output by the intent recognition model belongs to each intent is obtained; if the highest confidence is less than a preset threshold, a prompt text for intent recognition of the target text is constructed; the prompt text is input into the large language model, so that the large language model performs intent recognition on the target text, and the target intent corresponding to the target text output by the large language model is obtained. In an embodiment of the present application, the target text is firstly identified based on the intent recognition model to determine the confidence that the target text belongs to each intent. If the highest confidence is less than the preset threshold, it means that the intent recognition model cannot accurately identify the intent of the target text, and the electronic device will use the large language model to perform intent recognition on the target text. In an embodiment of the present application, the electronic device improves the accuracy and efficiency of intent recognition by hybrid recognition of large and small models. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] In order to more clearly illustrate the technical solution of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0012] Figure 1 A schematic diagram of an intent recognition process provided in an embodiment of the present application;
[0013] Figure 2 The intent recognition flow chart provided for the embodiment of the present application;
[0014] Figure 3 A schematic diagram of the structure of an intention recognition device provided in an embodiment of the present application;
[0015] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0016] In order to make the purpose, technical scheme and advantages of the present application clearer, the technical scheme in the embodiment of the present application will be clearly and completely described below in conjunction with the drawings in the embodiment of the present application. Obviously, the described embodiment is only a part of the embodiment of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application. In the absence of conflict, the embodiments in the present application and the features in the embodiments can be arbitrarily combined with each other. In addition, although the logical order is shown in the flow chart, in some cases, the steps shown or described can be performed in an order different from that here.
[0017] The terms "first" and "second" in the specification and claims of the present application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the term "comprising" and any of their variations are intended to cover non-exclusive protection. For example, a process, method, system, product or device comprising a series of steps or units is not limited to the listed steps or units, but optionally also includes steps or units that are not listed, or optionally also includes other steps or units inherent to these processes, methods, products or devices. "Multiple" in the present application can mean at least two, for example, two, three or more, and the embodiments of the present application are not limited.
[0018] The following is a description of exemplary embodiments of the present application in conjunction with the accompanying drawings, including various details of the embodiments of the present application to facilitate understanding, which should be considered as merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope of the present application. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description. It should be noted that in the embodiments of the present application, certain software, components, models and other existing solutions in the industry may be mentioned, which should be considered as exemplary, and their purpose is only to illustrate the feasibility of the implementation of the technical solution of the present application, but it does not mean that the applicant has or will necessarily use the solution.
[0019] Intent recognition is an important task in the field of natural language processing (NLP), which aims to understand the intent of the text or voice input by the user and classify it into predefined intent categories. This has a wide range of applications in the fields of intelligent customer service, voice assistants, search engines, etc. The key to intent recognition is to accurately understand the user's intent and map it to the corresponding action or response. Among the known technologies of intent recognition, common methods include using machine learning algorithms such as maximum entropy models, support vector machine models, xgboost models, or convolutional neural network models.
[0020] Intent recognition systems that rely purely on rule matching have limited performance when dealing with complex and changing user inputs, and cannot handle ambiguous, implicit, or multi-intent expressions. Methods based on small neural network models such as BERT and FastCNN also have some shortcomings. Small models often show poor generalization when there is insufficient training data or insufficient diversity. The accuracy of these models will be significantly reduced when faced with new and unseen data. Small models require a large amount of high-quality annotated data for training to ensure their performance. Collecting and annotating this data is time-consuming and expensive, especially for fields with complex and varied application scenarios. Large language models such as GPT perform well in generalization, but their high computational complexity leads to slow response speed. This can seriously affect the user experience in scenarios with high real-time requirements (such as car systems). Traditional intent recognition systems often lack flexible feedback mechanisms and cannot self-adjust and optimize based on user feedback.
[0021] Based on this, the embodiment of the present application provides an intent recognition method and device. In the embodiment of the present application, the electronic device inputs the target text to be recognized into the intent recognition model, and obtains the confidence that the target text output by the intent recognition model belongs to each intent; if the highest confidence is less than a preset threshold, a prompt text for performing intent recognition on the target text is constructed; the prompt text is input into the large language model, so that the large language model performs intent recognition on the target text, and obtains the target intent corresponding to the target text output by the large language model.
[0022] Embodiment 1:
[0023] Figure 1 A schematic diagram of an intent recognition process provided in an embodiment of the present application, the process includes:
[0024] S101: Input a target text to be recognized into an intent recognition model, and obtain the confidence level output by the intent recognition model that the target text belongs to each intent.
[0025] An intent recognition method provided in an embodiment of the present application is applied to an electronic device, which may be a PC, a server, etc.
[0026] In the embodiment of the present application, an intention recognition model is pre-configured in the electronic device, and the electronic device first uses the intention recognition model to recognize the intention of the target text to be recognized. The intention recognition model is a small model trained based on a large amount of historical data, which can calculate the confidence that the input text belongs to each intention according to semantics, that is, a neural network model, such as BERT, FastCNN, etc.
[0027] Specifically, the electronic device inputs the target text into the intent recognition model, and the intent recognition model analyzes the target text according to the semantics of the target text, determines and outputs the confidence that the target text belongs to each intent.
[0028] S102: If the highest confidence is less than a preset threshold, construct a prompt text for performing intent recognition on the target text; input the prompt text into a large language model so that the large language model performs intent recognition on the target text, and obtains a target intent corresponding to the target text output by the large language model.
[0029] In an embodiment of the present application, a preset threshold is pre-configured in the electronic device, and the electronic device determines whether the intent recognition model can accurately recognize the intent of the target text based on the relationship between the highest confidence level output by the electronic device and the preset threshold.
[0030] Among them, if the electronic device determines that the highest confidence output by the intent recognition model is lower than the preset threshold, it means that the confidence difference of each intent determined by the electronic device is not large, that is, it means that the intent recognition model cannot accurately recognize the intent of the target text. Based on this, the electronic device calls a large language model to perform intent recognition on the target text. The large language model can be GPT-4, etc., which is not limited here.
[0031] Specifically, the electronic device constructs a prompt text for performing intent recognition on the target text, and inputs the prompt text into the large language model so that the large language model performs intent recognition on the target text. The electronic device obtains the target intent corresponding to the target text output by the large language model.
[0032] In an embodiment of the present application, the target text is first identified based on the intent recognition model to determine the confidence that the target text belongs to each intent. If the highest confidence is less than a preset threshold, it means that the intent recognition model cannot accurately identify the intent of the target text, and the electronic device will use a large language model to identify the intent of the target text. In an embodiment of the present application, the electronic device improves the accuracy and efficiency of intent recognition by using a mixed recognition method of large and small models.
[0033] Embodiment 2:
[0034] In order to improve the effect and accuracy of intent recognition, based on the above embodiment, in the embodiment of the present application, before inputting the target text to be recognized into the intent recognition model, the method further includes:
[0035] Identifying target keywords contained in the target text;
[0036] Obtain a pre-saved correspondence between a keyword combination and an intent. If the correspondence does not store a target keyword combination consisting of the target keywords, execute a subsequent step of inputting the target text to be recognized into the intent recognition model.
[0037] During the application process, the content of the target text received by the electronic device may be very simple. Based on this, in order to improve the efficiency of intent recognition and reduce the time consumption of intent recognition, in an embodiment of the present application, the correspondence between keyword combinations and intents can be pre-configured in the electronic device, so that the electronic device can determine the intent of the target text based on rule matching.
[0038] Specifically, the electronic device identifies the target keywords contained in the target text, and determines whether a target keyword combination consisting of the target keywords is stored according to the correspondence between the pre-stored keyword combination and the intention. If it is determined that there is no target keyword combination, the intention recognition of the target text is performed based on the intention recognition model.
[0039] Among them, the electronic device can perform keyword recognition on the target text in a variety of ways, such as regular matching recognition based on a keyword dictionary, or recognition based on a trained keyword recognition model, etc., which are not limited here.
[0040] In a possible implementation, in the embodiment of the present application, the correspondence between a keyword combination and an intent means that if the text to be identified only contains all the keywords in the keyword combination, then the text to be identified is determined to be the intent corresponding to the keyword combination. A keyword combination may contain one keyword or multiple keywords, which is not limited here.
[0041] For example, the electronic device stores a correspondence between keyword combination A and intent A, and the keyword combination A includes keyword a and keyword b. Based on this, if the electronic device recognizes that the keywords included in the target text are keyword a and keyword b, the electronic device determines that the target intent of the target text is intent A based on the correspondence; if the electronic device recognizes that the keyword included in the target text is keyword a, the electronic device cannot determine the target intent of the target text based on the correspondence.
[0042] In order to improve the intent recognition effect and accuracy, based on the above embodiments, in the embodiment of the present application, the method further includes:
[0043] If a target keyword combination consisting of the target keywords is stored in the corresponding relationship, determining a first candidate intent corresponding to the target keyword combination in the corresponding relationship;
[0044] The first candidate intent is determined as the target intent corresponding to the target text.
[0045] In an embodiment of the present application, if the electronic device determines that a target keyword combination consisting of target keywords contained in the target text is stored in a pre-configured correspondence relationship, the electronic device determines the first candidate intention corresponding to the target keyword combination in the correspondence relationship, and determines the first candidate intention as the target intention corresponding to the target text.
[0046] Embodiment 3:
[0047] In order to improve the effect and accuracy of intent recognition, based on the above embodiments, in the embodiment of the present application, the prompt text for constructing the intent recognition of the target text includes:
[0048] Determine the target account for inputting the target text, and obtain the target user tag and target user information corresponding to the saved target account; wherein the user information includes the user's geographic location, time and operation record;
[0049] Obtain a preconfigured prompt template, wherein the prompt template includes a task definition, a first field for filling in the text to be recognized, a second field for filling in the user tag, a third field for filling in the user information, and a fourth field for filling in the intent to be selected;
[0050] Add the target text to the first field, add the target user tag to the second field, add the target user information to the third field, and add each stored intent to be identified to the fourth field;
[0051] The filled-in prompt template is determined as the prompt text.
[0052] In actual applications, the texts that require electronic devices to call large language models for intent recognition are generally long input, multi-category, complex user semantics or ambiguous texts. Based on this, in order to better enable the large language model to perform intent recognition, the electronic device needs to construct a prompt text and input the prompt text into the large language model for intent recognition.
[0053] Specifically, the prompt text constructed by the electronic device includes but is not limited to user tags, user information, text to be recognized, task definitions, and intentions to be selected that can be recognized by the large language model. In order to improve the efficiency of constructing the prompt text, in an embodiment of the present application, a prompt template is pre-configured in the electronic device, which includes but is not limited to task definitions, a first field for filling in text to be recognized, a second field for filling in user tags, a third field for filling in user information, and a fourth field for filling in intentions to be selected.
[0054] Based on this, in the embodiment of the present application, when the electronic device constructs the prompt text, the electronic device determines the target account for inputting the target text, and obtains the target user tag and target user information corresponding to the saved target account. Specifically, in the embodiment of the present application, a user tag is abstracted based on the user's historical habits and personal information. The user tag is a feature identifier abstracted based on the user's historical habits and personal information. These tags can be the user's hobbies, occupation, age group, device usage habits, etc.
[0055] User information refers to the current user environment and historical behavior data, such as the user's geographic location, time, recent operation records, etc. User information can help the system understand the user's current needs and intentions more accurately.
[0056] For example: Scenario perception: Based on the user's environment (such as at home, in the car, etc.), the large language model can infer the user's possible needs, thereby improving the accuracy of intent recognition; Historical behavior analysis: By analyzing the user's past behavior, the large language model can predict the user's possible operation path and make corresponding preparations and suggestions in advance.
[0057] Among them, in the embodiment of the present application, user information and user tags are used as user background information.
[0058] Based on this, the electronic device obtains a pre-configured prompt template, and adds the target text to the first field, the target user tag to the second field, the target user information to the third field, and each saved intent to be recognized to the fourth field. The electronic device determines the filled prompt template as the prompt text.
[0059] The user information may also include the user's geographic location, time and operation records.
[0060] In an embodiment of the present application, the task definition may be a sub-prompt text such as "As an intent classification assistant, you are now given some user information and input. Please output the intent that matches the question in the following intent and reply in the following format" to prompt the large language model which task is currently being performed.
[0061] In the embodiment of the present application, the electronic device adjusts and optimizes the task definition, output format description and other content organization methods through the Prompt offline optimization method, so as to generate an optimal prompt text. The electronic device inputs the prompt text into the large language model to obtain the target intent corresponding to the target text.
[0062] Embodiment 4:
[0063] In order to improve the intent recognition effect and accuracy, based on the above embodiments, in the embodiment of the present application, the prompt template also includes a fifth field for filling in the sample text and the corresponding sample intent;
[0064] Before determining the filled prompt template as the prompt text, the method further includes:
[0065] Obtain each text and the corresponding intention stored in the database, and determine the similarity between the target text and each text according to a preset similarity algorithm;
[0066] Determine a first preset number of texts with the highest corresponding similarity as candidate texts;
[0067] Sorting the candidate texts by using a Rerank sorting model;
[0068] Determine a second preset number of candidate texts ranked first as target example texts corresponding to the target text;
[0069] The target example text and the corresponding target intent are added to the fifth field.
[0070] In order to enable the large language model to perform intent recognition more accurately, in an embodiment of the present application, when the electronic device constructs a prompt text, the prompt text may also include an example text and a corresponding example intent, and the large language model may perform intent recognition on the target text based on the example text and the corresponding example intent. The example text and the corresponding example intent may be a previously determined question similar to the target text and the corresponding intent. That is, the example text is a historically similar question, and the example intent is the intent corresponding to the historically similar question.
[0071] Based on this, in an embodiment of the present application, the prompt template may also include a fifth field for filling in example text and corresponding example intent.
[0072] In a possible implementation, the electronic device obtains each text and the corresponding intent stored in the database, determines the similarity between the target text and each text according to a preset similarity algorithm, and determines the first preset number of texts with the highest corresponding similarity as candidate texts. The electronic device sorts each candidate text using a trained Rerank sorting model, wherein the higher the ranking of the candidate text, the more similar the candidate text is to the target text. The electronic device determines the second preset number of candidate texts with the highest ranking as the target example texts corresponding to the target text; and adds the target example text and the corresponding target intent to the fifth field.
[0073] In this embodiment of the present application, the first preset number is greater than the second preset number; the database may be a pre-configured intention case library for storing historical records.
[0074] Embodiment 5:
[0075] In order to improve the intent recognition effect and accuracy, based on the above embodiments, in the embodiment of the present application, the prompt template also includes a sixth field for filling in the replied text and the corresponding intent in the turn-to-turn dialogue;
[0076] Before determining the filled prompt template as the prompt text, the method further includes:
[0077] If it is determined that the target text is a non-first-round question in a multi-round dialogue, then obtaining the saved target question text and the corresponding intention that have been answered in the multi-round dialogue where the target text is located;
[0078] The target replied text and the corresponding intent are added to the sixth field.
[0079] The intent recognition method provided in the embodiment of the present application can be applied not only to single-round question-answering scenarios, but also to multi-round question-answering scenarios. However, in multi-round question-answering scenarios, there may be a problem of missing keywords for questions other than the first round, that is, keywords that have appeared in the previous rounds of questions are omitted in the current round of questions.
[0080] Based on this, in order to avoid inaccurate intent recognition due to missing keywords in multi-round question-and-answer scenarios, in an embodiment of the present application, for target texts that are not first-round questions in multi-round conversations, the electronic device adds questions from previous rounds and corresponding intents to the prompt words when constructing the prompt words.
[0081] Specifically, in the embodiment of the present application, the prompt template also includes a sixth field for filling in the replied text and the corresponding intent in the round-by-round dialogue. The electronic device determines whether the target text is a non-first-round question in the multi-round dialogue. If the electronic device determines that the target text is a non-first-round question in the multi-round dialogue, the target question text and the corresponding intent that have been replied in the multi-round dialogue where the saved target text is located are obtained, and the electronic device adds the target replied text and the corresponding intent to the sixth field of the prompt template.
[0082] Embodiment 6:
[0083] In order to improve the effect and accuracy of intent recognition, based on the above embodiments, in the embodiment of the present application, the process of determining each intent to be recognized includes:
[0084] Inputting the target text into an intent classification model, and obtaining a target intent category corresponding to the target text output by the intent classification model;
[0085] Obtain each saved intention belonging to the target intention category, and determine each intention as each intention to be identified.
[0086] When using a large language model for intent classification, the intent and the corresponding description information need to be added to the prompt text so that the large language model can input the appropriate intent based on the user's selection. However, if all intents and the corresponding description information are put into the prompt text, the input length of the large language model will increase, the response time will increase, and the accuracy of intent recognition by the large language model will also decrease.
[0087] Based on this, in an embodiment of the present application, all intents are pre-organized offline according to a hierarchical architecture, divided into major categories and minor categories from top to bottom, and an intent classification model is pre-trained so that the target intent category to which the target text belongs can be determined based on the intent classification model, and then each intent belonging to the target intent category and the corresponding description information are added to the prompt text.
[0088] Specifically, the electronic device inputs the target text into the intent classification model, and the intent classification model classifies the target text, determines and outputs the target intent category corresponding to the target text. The electronic device obtains the target intent category output by the intent classification model, obtains each saved intent belonging to the target intent category, and determines each intent as each intent to be recognized.
[0089] Implemented 7:
[0090] In order to improve the intent recognition effect and accuracy, based on the above embodiments, in the embodiment of the present application, the method further includes:
[0091] If the highest confidence is not less than the preset threshold, the intention corresponding to the highest confidence is determined as the target intention corresponding to the target text.
[0092] In an embodiment of the present application, if the electronic device determines that the highest confidence level output by the intent recognition model is not less than a preset threshold, the electronic device determines that the intent recognition model can accurately recognize the intent of the target text, and the electronic device directly determines the target intent of the target text based on the output of the intent recognition model.
[0093] Specifically, if the electronic device determines that the highest confidence is not less than a preset threshold, the intention corresponding to the highest confidence is determined as the target intention corresponding to the target text.
[0094] Embodiment 8:
[0095] In order to improve the intent recognition effect and accuracy, based on the above embodiments, in the embodiment of the present application, the method further includes:
[0096] Receiving a feedback operation input by a user for the target intention;
[0097] If the feedback operation is an operation indicating that the target intent is correctly identified, the target text and the target intent are correspondingly saved in a database.
[0098] In an embodiment of the present application, after the electronic device determines the target intent, the electronic device can also receive feedback operations input by the user for the target intent, and assist in intent recognition by analyzing the behavior pattern of the user's feedback operation, such as clicks, slides and other interactive behaviors. For example, if the user performs a certain operation or reply after receiving the target intent, such as a button click or "OK", the electronic device will use the operation or reply as a model feedback operation, and analyze the feedback operation offline through a large language model to see if it is a correct operation to identify the target intent, and save the correct intent in the database.
[0099] Specifically, the electronic device receives a feedback operation input by the user for the target intent, and calls the large language model to analyze the feedback operation. If the electronic device determines that the feedback operation is an operation indicating that the target intent is correctly identified, the electronic device stores the target text and the target intent in a database.
[0100] In a possible implementation, the electronic device may also adaptively learn at least one of the large language model, the intent recognition model, and the intent classification model based on the text and the corresponding intent stored in the database.
[0101] Specifically, the electronic device calls the large language model to generate a large number of training data sets based on the database, starts model training and automatically evaluates it, and notifies relevant personnel to replace and publish the model. At the same time, the electronic device uses the large language model to continuously improve and expand the prompt template to improve the accuracy of prompt template matching.
[0102] Figure 2 The intent recognition flow chart provided in the embodiment of the present application is as follows: Figure 2 As shown, the process of intent recognition can be divided into three stages.
[0103] Phase 1: rule matching, electronic devices match simple and clear intents such as "turn on the light" and "play music" through predefined rules. After receiving the target text input by the user, the electronic device first uses regular expressions or conditional logic to match the keywords or phrases in the target text. Rule matching is the most efficient, but the rules are limited. If the rule is matched, the corresponding intent is directly returned. If it is not matched, the second phase is carried out.
[0104] The second stage: small model intent recognition. When the rule matching cannot determine the intent, the intent recognition model (small model) is used for intent recognition. The intent recognition model (small model) can use models such as Bert and FastCNN. Based on a large amount of historical data training, it can calculate the confidence that the target text belongs to each intent based on the semantics of the target text input by the user. When the output execution degree of the intent recognition model (small model) is high, the result is returned directly. If the confidence of all intents is relatively low, it enters the third stage.
[0105] Phase 3: When the output of the intent recognition model (small model) is low, the target text is handed over to the large language model (LLM) for processing, such as GPT-4, to provide high-accuracy results. Considering that the third phase usually has long input, multiple categories, complex user semantics, and ambiguous problems, it can only be processed based on the large language model.
[0106] In an embodiment of the present application, a hybrid intent recognition engine combining rule matching, small models and large models is proposed, which can dynamically select the most appropriate processing method according to the complexity of user questions, thereby improving efficiency and accuracy. At the same time, it involves a set of feedback mechanisms that can continuously update the rule base and small models, optimize the matching logic of the rule base and the accuracy of the small model, and expand new intents.
[0107] Embodiment 9:
[0108] Based on the above embodiments, Figure 3 A schematic diagram of the structure of an intention recognition device provided in an embodiment of the present application, the device includes:
[0109] The intention recognition module 301 is used to input the target text to be recognized into the intention recognition model, and obtain the confidence that the target text output by the intention recognition model belongs to each intention;
[0110] The processing module 302 is used to construct a prompt text for performing intent recognition on the target text if the highest confidence level is less than a preset threshold;
[0111] The intention recognition module 301 is further used to input the prompt text into a large language model so that the large language model performs intention recognition on the target text and obtains a target intention corresponding to the target text output by the large language model.
[0112] In a possible implementation, the intent recognition module 301 is also used to identify target keywords contained in the target text; obtain the correspondence between the pre-saved keyword combination and the intent, and if the correspondence does not save the target keyword combination composed of the target keywords, execute the subsequent step of inputting the target text to be recognized into the intent recognition model.
[0113] In a possible implementation, the intent recognition module 301 is also used to determine the first candidate intent corresponding to the target keyword combination in the corresponding relationship if a target keyword combination composed of the target keywords is saved in the corresponding relationship; and determine the first candidate intent as the target intent corresponding to the target text.
[0114] In one possible implementation, the processing module 302 is specifically used to determine the target account for inputting the target text, and obtain the target user tag and target user information corresponding to the saved target account; wherein the user information includes the user's geographic location, time and operation record; obtain a pre-configured prompt template, wherein the prompt template contains a task definition, a first field for filling in the text to be recognized, a second field for filling in the user tag, a third field for filling in the user information, and a fourth field for filling in the intent to be selected; add the target text to the first field, add the target user tag to the second field, add the target user information to the third field, and add each saved intent to be recognized to the fourth field; determine the filled-in prompt template as the prompt text.
[0115] In a possible implementation, the prompt template further includes a fifth field for filling in the sample text and the corresponding sample intention;
[0116] The processing module 302 is specifically used to obtain each text and the corresponding intention stored in the database, determine the similarity between the target text and each text according to a preset similarity algorithm; determine the first preset number of texts with the highest corresponding similarity as candidate texts; sort the candidate texts through the Rerank sorting model; determine the second preset number of candidate texts with the highest sorting as target example texts corresponding to the target text; and add the target example text and the corresponding target intention to the fifth field.
[0117] In a possible implementation manner, the prompt template further includes a sixth field for filling in the replied text and the corresponding intention in the turn-to-turn dialogue;
[0118] The processing module 302 is also used to obtain the target question text and corresponding intention that have been answered in the multi-round dialogue where the target text is located, if it is determined that the target text is not the first-round question in the multi-round dialogue; and add the target answered text and corresponding intention to the sixth field.
[0119] In a possible implementation, the intent recognition module 301 is also used to input the target text into an intent classification model to obtain a target intent category corresponding to the target text output by the intent classification model; obtain each saved intent belonging to the target intent category, and determine each intent as each intent to be recognized.
[0120] In a possible implementation, the intention recognition module 301 is further configured to determine the intention corresponding to the highest confidence as the target intention corresponding to the target text if the highest confidence is not less than the preset threshold.
[0121] In a possible implementation, the processing module 302 is also used to receive a feedback operation input by a user regarding the target intent; if the feedback operation is an operation indicating that the target intent is correctly identified, the target text and the target intent are correspondingly saved in a database.
[0122] Embodiment 10:
[0123] Based on the above embodiments, the present application also provides an electronic device, Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown in FIG. Figure 4 As shown, it includes: a processor 401, a communication interface 402, a memory 403 and a communication bus 404, wherein the processor 401, the communication interface 402, and the memory 403 communicate with each other through the communication bus 404;
[0124] The memory 403 stores a computer program. When the program is executed by the processor 401, the processor 401 performs the following steps:
[0125] Inputting the target text to be recognized into the intent recognition model, and obtaining the confidence that the target text output by the intent recognition model belongs to each intent;
[0126] If the highest confidence level is less than a preset threshold, constructing a prompt text for performing intent recognition on the target text;
[0127] The prompt text is input into a large language model so that the large language model performs intent recognition on the target text, and a target intent corresponding to the target text output by the large language model is obtained.
[0128] In a possible implementation, before inputting the target text to be recognized into the intention recognition model, the method further includes:
[0129] Identifying target keywords contained in the target text;
[0130] Obtain a pre-saved correspondence between a keyword combination and an intent. If the correspondence does not store a target keyword combination consisting of the target keywords, execute a subsequent step of inputting the target text to be recognized into the intent recognition model.
[0131] In a possible implementation, the method further includes:
[0132] If a target keyword combination consisting of the target keywords is stored in the corresponding relationship, determining a first candidate intent corresponding to the target keyword combination in the corresponding relationship;
[0133] The first candidate intent is determined as the target intent corresponding to the target text.
[0134] In a possible implementation, constructing a prompt text for performing intent recognition on the target text includes:
[0135] Determine the target account for inputting the target text, and obtain the target user tag and target user information corresponding to the saved target account; wherein the user information includes the user's geographic location, time and operation record;
[0136] Obtain a preconfigured prompt template, wherein the prompt template includes a task definition, a first field for filling in the text to be recognized, a second field for filling in the user tag, a third field for filling in the user information, and a fourth field for filling in the intent to be selected;
[0137] Add the target text to the first field, add the target user tag to the second field, add the target user information to the third field, and add each stored intent to be identified to the fourth field;
[0138] The filled-in prompt template is determined as the prompt text.
[0139] In a possible implementation, the prompt template further includes a fifth field for filling in the sample text and the corresponding sample intention;
[0140] Before determining the filled prompt template as the prompt text, the method further includes:
[0141] Obtain each text and the corresponding intention stored in the database, and determine the similarity between the target text and each text according to a preset similarity algorithm;
[0142] Determine a first preset number of texts with the highest corresponding similarity as candidate texts;
[0143] Sorting the candidate texts by using a Rerank sorting model;
[0144] Determine a second preset number of candidate texts ranked first as target example texts corresponding to the target text;
[0145] The target example text and the corresponding target intent are added to the fifth field.
[0146] In a possible implementation manner, the prompt template further includes a sixth field for filling in the replied text and the corresponding intention in the turn-to-turn dialogue;
[0147] Before determining the filled prompt template as the prompt text, the method further includes:
[0148] If it is determined that the target text is a non-first-round question in a multi-round dialogue, then obtaining the saved target question text and the corresponding intention that have been answered in the multi-round dialogue where the target text is located;
[0149] The target replied text and the corresponding intent are added to the sixth field.
[0150] In a possible implementation, the process of determining each intention to be identified includes:
[0151] Inputting the target text into an intent classification model, and obtaining a target intent category corresponding to the target text output by the intent classification model;
[0152] Obtain each saved intention belonging to the target intention category, and determine each intention as each intention to be identified.
[0153] In a possible implementation, the method further includes:
[0154] If the highest confidence is not less than the preset threshold, the intention corresponding to the highest confidence is determined as the target intention corresponding to the target text.
[0155] In a possible implementation, the method further includes:
[0156] Receiving a feedback operation input by a user for the target intention;
[0157] If the feedback operation is an operation indicating that the target intent is correctly identified, the target text and the target intent are correspondingly saved in a database.
[0158] Since the principle of solving the problem by the above electronic device is similar to that of the intention recognition method, the implementation of the above electronic device can refer to the embodiment of the method, and the repeated parts will not be repeated.
[0159] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. The communication interface 402 is used for communication between the above electronic device and other devices. The memory may include a random access memory (RAM) and may also include a non-volatile memory (NVM), such as at least one disk storage. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0160] The above-mentioned processor can be a general-purpose processor, including a central processing unit, a network processor (Network Processor, NP), etc.; it can also be a digital signal processing processor (Digital Signal Processing, DSP), an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, etc.
[0161] Embodiment 11:
[0162] On the basis of the above embodiments, an embodiment of the present invention further provides a computer-readable storage medium, in which a computer program executable by a processor is stored. When the program runs on the processor, the processor implements the following steps when executing:
[0163] Inputting the target text to be recognized into the intent recognition model, and obtaining the confidence that the target text output by the intent recognition model belongs to each intent;
[0164] If the highest confidence level is less than a preset threshold, constructing a prompt text for performing intent recognition on the target text;
[0165] The prompt text is input into a large language model so that the large language model performs intent recognition on the target text, and a target intent corresponding to the target text output by the large language model is obtained.
[0166] In a possible implementation, before inputting the target text to be recognized into the intention recognition model, the method further includes:
[0167] identifying target keywords contained in the target text;
[0168] Obtain a pre-saved correspondence between a keyword combination and an intent. If the correspondence does not store a target keyword combination consisting of the target keywords, execute a subsequent step of inputting the target text to be recognized into the intent recognition model.
[0169] In a possible implementation, the method further includes:
[0170] If a target keyword combination consisting of the target keywords is stored in the corresponding relationship, determining a first candidate intent corresponding to the target keyword combination in the corresponding relationship;
[0171] The first candidate intent is determined as the target intent corresponding to the target text.
[0172] In a possible implementation, constructing a prompt text for performing intent recognition on the target text includes:
[0173] Determine the target account for inputting the target text, and obtain the target user tag and target user information corresponding to the saved target account; wherein the user information includes the user's geographic location, time and operation record;
[0174] Obtain a preconfigured prompt template, wherein the prompt template includes a task definition, a first field for filling in the text to be recognized, a second field for filling in the user tag, a third field for filling in the user information, and a fourth field for filling in the intent to be selected;
[0175] Add the target text to the first field, add the target user tag to the second field, add the target user information to the third field, and add each stored intent to be identified to the fourth field;
[0176] The filled-in prompt template is determined as the prompt text.
[0177] In a possible implementation, the prompt template further includes a fifth field for filling in the sample text and the corresponding sample intention;
[0178] Before determining the filled prompt template as the prompt text, the method further includes:
[0179] Obtain each text and the corresponding intention stored in the database, and determine the similarity between the target text and each text according to a preset similarity algorithm;
[0180] Determine a first preset number of texts with the highest corresponding similarity as candidate texts;
[0181] Sorting the candidate texts by using a Rerank sorting model;
[0182] Determine a second preset number of candidate texts ranked first as target example texts corresponding to the target text;
[0183] The target example text and the corresponding target intent are added to the fifth field.
[0184] In a possible implementation manner, the prompt template further includes a sixth field for filling in the replied text and the corresponding intention in the turn-to-turn dialogue;
[0185] Before determining the filled prompt template as the prompt text, the method further includes:
[0186] If it is determined that the target text is a non-first-round question in a multi-round dialogue, then obtaining the saved target question text and the corresponding intention that have been answered in the multi-round dialogue where the target text is located;
[0187] The target replied text and the corresponding intent are added to the sixth field.
[0188] In a possible implementation, the process of determining each intention to be identified includes:
[0189] Inputting the target text into an intent classification model, and obtaining a target intent category corresponding to the target text output by the intent classification model;
[0190] Obtain each saved intention belonging to the target intention category, and determine each intention as each intention to be identified.
[0191] In a possible implementation, the method further includes:
[0192] If the highest confidence is not less than the preset threshold, the intention corresponding to the highest confidence is determined as the target intention corresponding to the target text.
[0193] In a possible implementation, the method further includes:
[0194] Receiving a feedback operation input by a user for the target intention;
[0195] If the feedback operation is an operation indicating that the target intent is correctly identified, the target text and the target intent are correspondingly saved in a database.
[0196] Since the principle of solving the problem by the above-mentioned computer program product is similar to that of the intention recognition method, the implementation of the above-mentioned computer program product can refer to the implementation of the method, and the repeated parts will not be repeated.
[0197] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0198] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0199] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0200] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0201] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A method for intention recognition, characterized in that: The method comprises: Inputting the target text to be recognized into the intent recognition model, and obtaining the confidence that the target text output by the intent recognition model belongs to each intent; If the highest confidence level is less than a preset threshold, constructing a prompt text for performing intent recognition on the target text; The prompt text is input into a large language model so that the large language model performs intent recognition on the target text, and a target intent corresponding to the target text output by the large language model is obtained.
2. The method according to claim 1, characterized in that: Before inputting the target text to be recognized into the intention recognition model, the method further includes: Identifying target keywords contained in the target text; Obtain a pre-saved correspondence between a keyword combination and an intent. If the correspondence does not store a target keyword combination consisting of the target keywords, execute a subsequent step of inputting the target text to be recognized into the intent recognition model.
3. The method according to claim 2, characterized in that The method further comprises: If a target keyword combination consisting of the target keywords is stored in the corresponding relationship, determining a first candidate intent corresponding to the target keyword combination in the corresponding relationship; The first candidate intent is determined as the target intent corresponding to the target text.
4. The method according to claim 1, characterized in that The constructing of the prompt text for performing intent recognition on the target text includes: Determine the target account for inputting the target text, and obtain the target user tag and target user information corresponding to the saved target account; wherein the user information includes the user's geographic location, time and operation record; Obtain a preconfigured prompt template, wherein the prompt template includes a task definition, a first field for filling in the text to be recognized, a second field for filling in the user tag, a third field for filling in the user information, and a fourth field for filling in the intent to be selected; Add the target text to the first field, add the target user tag to the second field, add the target user information to the third field, and add each stored intent to be identified to the fourth field; The filled-in prompt template is determined as the prompt text.
5. The method according to claim 4, characterized in that The prompt template also includes a fifth field for filling in the sample text and the corresponding sample intention; Before determining the filled prompt template as the prompt text, the method further includes: Obtain each text and the corresponding intention stored in the database, and determine the similarity between the target text and each text according to a preset similarity algorithm; Determine a first preset number of texts with the highest corresponding similarity as candidate texts; Sorting the candidate texts by using a Rerank sorting model; Determine a second preset number of candidate texts ranked first as target example texts corresponding to the target text; The target example text and the corresponding target intent are added to the fifth field.
6. The method according to claim 4, characterized in that The prompt template also includes a sixth field for filling in the replied text and the corresponding intention in the turn-by-turn dialogue; Before determining the filled prompt template as the prompt text, the method further includes: If it is determined that the target text is a non-first-round question in a multi-round dialogue, then obtaining the saved target question text and the corresponding intention that have been answered in the multi-round dialogue where the target text is located; The target replied text and the corresponding intent are added to the sixth field.
7. The method according to claim 4, characterized in that The process of determining each intention to be identified includes: Inputting the target text into an intent classification model, and obtaining a target intent category corresponding to the target text output by the intent classification model; Obtain each saved intention belonging to the target intention category, and determine each intention as each intention to be identified.
8. The method according to claim 1, characterized in that The method further comprises: If the highest confidence is not less than the preset threshold, the intention corresponding to the highest confidence is determined as the target intention corresponding to the target text.
9. The method according to claim 1, characterized in that: The method further comprises: Receiving a feedback operation input by a user for the target intention; If the feedback operation is an operation indicating that the target intent is correctly identified, the target text and the target intent are correspondingly saved in a database.
10. An electronic device, characterized in that: The electronic device comprises at least a processor and a memory, and the processor is used to implement the steps of the intention recognition method as claimed in any one of claims 1 to 9 when executing a computer program stored in the memory.