Large model-based intention recognition method and device, electronic equipment and storage medium
By obtaining descriptions of query statements and preset intents in conversational human-computer interaction, and using large models and historical interaction information for intent recognition, the problem of low accuracy in user intent recognition is solved, achieving higher accuracy in intent recognition and processing of complex intents.
Patent Information
- Application Number
- CN202411046153.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-31
- Publication Date
- 2024-11-12
AI Technical Summary
In conversational human-computer interaction scenarios, existing technologies have low accuracy in recognizing user intent and struggle to effectively identify the user's true intent.
By matching the query statement with the description information of the preset intent, a first candidate intent is generated. The intent is then identified using a large model, and the accuracy of intent identification is improved by combining historical interaction information and a pre-trained language model.
It improves the accuracy of user intent recognition, reduces interference from irrelevant intents, and enhances the ability of large models to recognize complex intents.
Smart Images

Figure CN118940768A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to the field of artificial intelligence technology such as natural language processing and large models, and specifically to an intent recognition method, device, electronic device and storage medium based on large models. Background Art
[0002] With the continuous development of artificial intelligence (AI) technology, the mode of human-computer interaction has evolved from imperative to conversational. Among them, for conversational human-computer interaction scenarios (such as intent recognition systems, recommendation systems, public opinion systems, retrieval systems, text classification systems, etc.), it is necessary to first understand the user's intent, and then give the user the answer they want based on the user's intent. Therefore, how to identify user intent is very important for conversational human-computer interaction scenarios. Summary of the invention
[0003] The present disclosure provides a method, device, electronic device and storage medium for intent recognition based on a large model.
[0004] According to a first aspect of the present disclosure, a method for identifying intentions based on a large model is provided, comprising:
[0005] Obtaining a query statement, a preset intent, and description information of the preset intent;
[0006] Matching the query statement with the preset intent and the description information of the preset intent to obtain a first candidate intent corresponding to the query statement;
[0007] Generate first prompt information according to the query statement, the first candidate intent and the description information of the first candidate intent;
[0008] The first prompt information is input into the big model to determine the first target intent corresponding to the query statement from the first candidate intents.
[0009] According to a second aspect of the present disclosure, a large model fine-tuning method is provided, comprising:
[0010] Acquire a sample data set, wherein the sample data set includes a sample sentence, a third candidate intent corresponding to the sample sentence, description information corresponding to the third candidate intent, and an intent label corresponding to the sample sentence;
[0011] Generate fourth prompt information according to the sample sentence, the third candidate intent and the description information corresponding to the third candidate intent;
[0012] Inputting the fourth prompt information into the initial large model to obtain the target prediction intention corresponding to the sample sentence;
[0013] According to the difference between the target predicted intent and the intent label, the initial large model is fine-tuned to obtain a fine-tuned large model.
[0014] According to a third aspect of the present disclosure, there is provided an intention recognition device based on a large model, comprising:
[0015] An acquisition module, used to acquire a query statement, a preset intent, and description information of the preset intent;
[0016] A matching module, used to match the query statement with the preset intent and the description information of the preset intent to obtain a first candidate intent corresponding to the query statement;
[0017] A generating module, configured to generate first prompt information according to the query statement, the first candidate intent and the description information of the first candidate intent;
[0018] An identification module is used to input the first prompt information into a large model to determine the first target intent corresponding to the query statement from the first candidate intents.
[0019] According to a fourth aspect of the present disclosure, a large model fine-tuning device is provided, comprising:
[0020] An acquisition module, configured to acquire a sample data set, wherein the sample data set includes a sample sentence, a third candidate intent corresponding to the sample sentence, description information corresponding to the third candidate intent, and an intent label corresponding to the sample sentence;
[0021] A generating module, configured to generate fourth prompt information according to the sample sentence, the third candidate intent and description information corresponding to the third candidate intent;
[0022] A prediction module, used for inputting the fourth prompt information into an initial large model to obtain a target prediction intention corresponding to the sample sentence;
[0023] A fine-tuning module is used to fine-tune the initial large model according to the difference between the target predicted intent and the intent label to obtain a fine-tuned large model.
[0024] According to a fifth aspect of the present disclosure, there is provided an electronic device, including:
[0025] at least one processor; and
[0026] a memory communicatively connected to the at least one processor; wherein,
[0027] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the large model-based intention recognition method as described in the first aspect, or execute the large model-based fine-tuning method as described in the second aspect.
[0028] According to the sixth aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute the large model-based intention recognition method as described in the first aspect, or to execute the large model-based fine-tuning method as described in the second aspect.
[0029] According to the seventh aspect of the present disclosure, a computer program product is provided, comprising computer instructions, which, when executed by a processor, implement the steps of the large model-based intent recognition method as described in the first aspect, or execute the steps of the large model-based fine-tuning method as described in the second aspect.
[0030] The intention recognition method, device, electronic device and storage medium based on the large model provided by the present disclosure have the following beneficial effects:
[0031] In the disclosed embodiment, a query statement, a preset intent, and description information of the preset intent are obtained, and then the query statement is matched with the preset intent and the description information of the preset intent to obtain the first candidate intent corresponding to the query statement, and then the first prompt information is generated according to the query statement, the first candidate intent, and the description information of the first candidate intent, and finally the first prompt information is input into the big model to determine the first target intent corresponding to the query statement from the first candidate intent. Thus, the first candidate intent corresponding to the query statement can be determined first, and then based on the first candidate intent and the corresponding description information, the big model is guided to identify the first target intent corresponding to the query statement from the first candidate intent, so that the interference of irrelevant intent can be eliminated first, reducing the task difficulty of intent recognition of the big model and improving the accuracy of intent recognition.
[0032] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.
[0034] Figure 1 It is a flowchart of a method for identifying intentions based on a large model provided according to an embodiment of the present disclosure;
[0035] Figure 2is a flowchart of a method for identifying intentions based on a large model provided according to another embodiment of the present disclosure;
[0036] Figure 3 is a flowchart of a method for identifying intentions based on a large model provided according to another embodiment of the present disclosure;
[0037] Figure 4 is a flowchart of a method for identifying intentions based on a large model provided according to another embodiment of the present disclosure;
[0038] Figure 5 It is a flowchart of a large model fine-tuning method provided according to an embodiment of the present disclosure;
[0039] Figure 6 is a flow chart of a large model fine-tuning method provided according to another embodiment of the present disclosure;
[0040] Figure 7 is a structural schematic diagram of an intention recognition device based on a large model provided according to an embodiment of the present disclosure;
[0041] Figure 8 is a structural schematic diagram of a large model-based fine-tuning device provided according to another embodiment of the present disclosure;
[0042] Fig. 9 is a block diagram of an electronic device for implementing an embodiment of the present disclosure. DETAILED DESCRIPTION
[0043] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0044] In the technical solution of the present disclosure, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0045] The following describes the large model-based intent recognition method, device, electronic device and storage medium of the embodiments of the present disclosure with reference to the accompanying drawings.
[0046] It should be noted that the executor of the big model-based intention recognition method in the embodiment of the present disclosure is a big model-based intention recognition device, which can be implemented by software and / or hardware. The device can be configured in an electronic device, which may include but is not limited to a terminal, a server, etc.
[0047] Figure 1 It is a flowchart of a large model-based intent recognition method provided according to an embodiment of the present disclosure.
[0048] like Figure 1 As shown, the intention recognition method based on the large model includes:
[0049] Step 101, obtain a query statement, a preset intent, and description information of the preset intent.
[0050] The query statement may be input by a user, for example, the user inputs the query statement in natural language. In the disclosed embodiment, there is no restriction on the input method of the query statement, for example, the input method may include but is not limited to: touch input (such as sliding, clicking, etc.), keyboard input, voice input, etc.
[0051] The preset intent may be all possible intents that are pre-set and stored in the database. For example, the preset intent may be a creative intent, such as drawing, creating poetry, creating videos, creating tables, etc.; it may also be a file processing intent, such as translating text, explaining text, summarizing knowledge points, etc.; it may also be a search intent, such as searching for files, searching for pictures, etc. This disclosure does not limit this.
[0052] The description information of the preset intent may include a definition of the preset intent, i.e., used to explain the preset intent. For example, if the preset intent is file search intent, the corresponding definition may be "referring to the user's search behavior, and the input may be a keyword or an expression to find related content."
[0053] Step 102, matching the query statement with the preset intent and the description information of the preset intent to obtain the first candidate intent corresponding to the query statement.
[0054] In some embodiments, keyword matching may be performed between the query statement and preset intents and corresponding description information, and a preset number of intents with the highest matching degree may be determined as the first candidate intents.
[0055] In some embodiments, the first coding vector corresponding to the query statement, the second coding vector corresponding to the preset intent and the description information of the preset intent can be determined, the similarity between the first coding vector and the second coding vector can be determined, and the first number of preset intents with the largest similarity can be determined as the first candidate intent. Thus, the first candidate intent can be determined based on the similarity between the first coding vector corresponding to the query statement and the second coding vector corresponding to the preset intent and the description information, thereby improving the accuracy of the determined first candidate intent.
[0056] In some embodiments, the query statement can be encoded based on the encoder to obtain a first encoding vector, and the preset intent and the description information of the preset intent can be jointly encoded based on the encoder to obtain a second encoding vector.
[0057] The first number may be 5, 10, etc. This disclosure does not limit this.
[0058] In some embodiments, the cosine similarity between the first encoding vector and the second encoding vector may be determined as the similarity between the first encoding vector and the second encoding vector. Alternatively, the similarity between the first encoding vector and the second encoding vector may be determined based on the Euclidean distance between the first encoding vector and the second encoding vector. This disclosure is not limited to this.
[0059] In some embodiments, a query statement is input into an intent recall model to obtain a first encoding vector, and a preset intent and the description information corresponding to the preset intent are spliced and input into the intent recall model to obtain a second encoding vector corresponding to the preset intent. The intent recall model is generated by training a pre-trained language model based on sample statements and corresponding intent labels. Thus, based on the intent recall model obtained by further training the pre-trained language model, the query statement, the preset intent and the corresponding description information can be encoded, so that the determined first encoding vector and the second encoding vector are more accurate, thereby further improving the accuracy of the determined first candidate intent.
[0060] The pre-trained language model may be an Albert model, a Bert model, etc. This disclosure does not limit this.
[0061] In some embodiments, Albert's architecture mainly includes two key aspects: sharing of embedding layers and cross-layer parameter sharing.
[0062] The sharing of the embedding layer includes word embedding sharing and position embedding sharing. In Albert, the word embedding matrix of all input texts is shared. This means that for the same words, no matter where they appear, they will share the same word embedding vector. Albert also shares the position embedding, so that the embedding vector for each position is also the same. Therefore, the number of parameters can be reduced by sharing these embeddings.
[0063] Among them, cross-layer parameter sharing further reduces the number of model parameters by sharing parameters between hidden layers. In BERT, each layer has its own parameters, which leads to higher model complexity. Albert reduces this complexity by sharing parameters to different layers, thereby reducing the overall number of parameters.
[0064] In some embodiments, the training tasks of the pre-trained language model mainly include Masked Language Modeling (MLM) and Sentence Order Prediction (SOP).
[0065] In the masked language modeling task, Albert randomly masks some of the words in the input text, and then the model needs to predict what these masked words are. This task encourages the model to learn the associations and language structures between words, because the model needs to infer the masked words based on the context.
[0066] Among them, in the sentence order prediction task, Albert needs to judge whether two sentences are adjacent sentences in the original text. For a pair of adjacent sentences, there is a 50% probability that they are adjacent sentences in the original text, and a 50% probability that they are random sentences from different documents. Albert needs to learn to distinguish between these two situations in order to better understand the semantics and logical structure of the text.
[0067] In the disclosed embodiment, after obtaining the pre-trained language model, the pre-trained language model is trained again based on sample sentences and intent labels, thereby enhancing the model's ability to match query sentences with preset intent encodings.
[0068] Specifically, the pre-trained language model can be retrained using data pairs (query, intent, label), where query is a sample sentence, intent is the machine description of the intent label, and label is 1. The pre-trained language model can use the Multiple Negatives Ranking Loss function to calculate the loss. The loss function formula is as follows:
[0069]
[0070] Among them, J(x, y, θ) is the loss function, x is the query, y is the intent, θ is the model parameter, K is the batch size, P is the probability, S is the similarity function, assuming that the batch size is K, input X = (x i ,…,x K ), the output is Y=(y i ,…,y K ), the loss function will convert (x i ,y i ) as a positive example, maximizing its similarity, and taking the other data (x i ,y j ), i≠j is taken as a negative example and its similarity is minimized.
[0071] Step 103, generating first prompt information according to the query statement, the first candidate intent and the description information of the first candidate intent.
[0072] Among them, the first prompt information is used to prompt the large model to determine the first target intent corresponding to the query statement from the first candidate intent based on the first candidate intent and the corresponding description information.
[0073] In some embodiments, the query statement, the first candidate intent, and the description information of the first candidate intent may be filled into the first prompt template to obtain the first prompt information.
[0074] For example, the first prompt template can be "Please determine the target intent corresponding to the query statement from the first candidate intent based on the first candidate intent and the corresponding description information. The query statement is XXX, the first candidate intent includes XXX, and the description information of the first candidate intent is XXX."
[0075] If the query statement is "Help me find GPT4.pdf", the first candidate intent is "file search, image search", the description information of file search can be "refers to the user's behavior of searching for files, and the input may be file name, file location, etc.", and the description information of image search can be "refers to the user's behavior of searching for images, and the input may be image name, image content, etc.", then the corresponding first prompt information can be: Please determine the target intent corresponding to the query statement from the first candidate intent based on the first candidate intent and the corresponding description information. The query statement is "Help me find GPT4.pdf", and the first candidate intent includes "file search, image search", the description information of file search can be "refers to the user's behavior of searching for files, and the input may be file name, file location, etc.", and the description information of image search can be "refers to the user's behavior of searching for images, and the input may be image name, image content, etc.".
[0076] Step 104, input the first prompt information into the big model to determine the first target intent corresponding to the query statement from the first candidate intent.
[0077] Among them, Large Language Model (LLM) is a hot topic in the field of artificial intelligence in recent years. LLM has learned rich language knowledge and world knowledge through pre-training on massive text data, so that it can achieve amazing results in various natural language processing (NLP), image generation and other tasks. For example, Wenxinyiyan and ChatGPT are applications developed based on LLM. They can generate fluent, logical, and creative text content, and can even have natural conversations with humans. Specifically, LLM can be a general pre-trained Transformer (Generative Pretrained Transformer, GPT) model based on Transformer, or an Enhanced Representation through Knowledge Integration (ERNIE) model based on knowledge integration.
[0078] In the embodiments of the present disclosure, the large model may be an existing large model, or may be a model obtained by fine-tuning the existing large model. For the specific implementation of large model fine-tuning, refer to the detailed description in the subsequent embodiments of the present disclosure.
[0079] In the disclosed embodiment, a large model can be used to determine the first target intent corresponding to the query statement from the first candidate intent based on the first prompt information.
[0080] In some embodiments, the first target intention may be one or more, and this disclosure does not limit this.
[0081] In the disclosed embodiment, a query statement, a preset intent, and description information of the preset intent are obtained, and then the query statement is matched with the preset intent and the description information of the preset intent to obtain the first candidate intent corresponding to the query statement, and then the first prompt information is generated according to the query statement, the first candidate intent, and the description information of the first candidate intent, and finally the first prompt information is input into the big model to determine the first target intent corresponding to the query statement from the first candidate intent. Thus, the first candidate intent corresponding to the query statement can be determined first, and then based on the first candidate intent and the corresponding description information, the big model is guided to identify the first target intent corresponding to the query statement from the first candidate intent, so that the interference of irrelevant intent can be eliminated first, reducing the task difficulty of intent recognition of the big model and improving the accuracy of intent recognition.
[0082] Figure 2 is a flowchart of a method for identifying intent based on a large model according to another embodiment of the present disclosure; Figure 2 As shown, the intention recognition method based on the large model includes:
[0083] Step 201, obtain the query statement, the preset intent and the description information of the preset intent.
[0084] Step 202: match the query statement with the preset intent and the description information of the preset intent to obtain the first candidate intent corresponding to the query statement.
[0085] The specific implementation forms of step 201 and step 202 can refer to the detailed descriptions in other embodiments of the present disclosure, and will not be described in detail here.
[0086] Step 203: Obtain the user ID of the query statement.
[0087] Among them, the user account that inputs the query statement can be determined as the user identification. When the user account is not logged in, the identification of the electronic device that inputs the query statement (for example, IP address) can also be determined as the user identification of the query statement.
[0088] Step 204: determine historical interaction information corresponding to the query statement according to the user identifier.
[0089] In some embodiments, the historical interaction information may include at least one of the following: historical query statements corresponding to the user identifier; second candidate intents corresponding to the historical query statements; description information corresponding to the second candidate intents; second target intents corresponding to the historical query statements; and reply statements corresponding to the historical query statements. Thus, the large model can combine multiple historical interaction information to perform intent recognition on the query statements, thereby improving the accuracy of the first target intent obtained.
[0090] Among them, one or more query statements input by the user identifier before inputting the query statement may be determined as historical query statements.
[0091] The specific implementation method of determining the second candidate intent corresponding to the historical query is the same as the implementation method of determining the first candidate intent corresponding to the query, which will not be elaborated in detail here.
[0092] In some embodiments, prompt information can be generated based on historical query statements, third candidate intents and corresponding description information, and historical interaction information before the historical query statements, and then the prompt information can be input into the big model to obtain the second target intent corresponding to the historical query statements.
[0093] Among them, the reply statement corresponding to the historical query statement can be the answer corresponding to the query statement obtained by processing the query statement according to the second target intention.
[0094] Step 205, generating first prompt information based on the query statement, the first candidate intent, the description information of the first candidate intent and the historical interaction information.
[0095] Among them, the first prompt information is used to prompt the large model to determine the first target intent corresponding to the query statement from the first candidate intent based on the historical interaction information, the first candidate intent and the corresponding description information.
[0096] In some embodiments, the query statement, historical interaction information, the first candidate intent and the description information of the first candidate intent may be filled into the second prompt template to obtain the first prompt information.
[0097] For example, the first prompt template can be "Please determine the target intent corresponding to the query statement from the first candidate intent based on the historical interaction information, the first candidate intent and the corresponding description information. The query statement is XXX, the historical interaction information is XXX, the first candidate intent includes XXX, and the description information of the first candidate intent is XXX."
[0098] Step 206, input the first prompt information into the big model to determine the first target intent corresponding to the query statement from the first candidate intent.
[0099] In the disclosed embodiment, the big model can identify the first target intent corresponding to the query statement from the first candidate intent based on historical interaction information, the first candidate intent and the corresponding description information.
[0100] In the disclosed embodiment, a query statement, a preset intent, and description information of the preset intent are obtained, the query statement is matched with the preset intent and the description information of the preset intent to obtain a first candidate intent corresponding to the query statement, a user identifier of the query statement is obtained, historical interaction information corresponding to the query statement is determined based on the user identifier, first prompt information is generated based on the query statement, the first candidate intent, the description information of the first candidate intent, and the historical interaction information, and finally the first prompt information is input into the big model to determine the first target intent corresponding to the query statement from the first candidate intent. Thus, the first candidate intent and historical interaction information corresponding to the query statement can be determined first, and then based on the first candidate intent and the corresponding description information and historical interaction information, the big model is guided to identify the first target intent corresponding to the query statement from the first candidate intent, thereby not only eliminating the interference of irrelevant intents first and reducing the difficulty of the big model's intent recognition task, but also enabling the big model to identify the intent of the query statement in conjunction with the contextual interaction information, further improving the accuracy of intent recognition.
[0101] Figure 3 is a flowchart of a method for identifying intent based on a large model according to another embodiment of the present disclosure; Figure 3 As shown, the intention recognition method based on the large model includes:
[0102] Step 301: input the first prompt information into the big model to obtain the first intent corresponding to the query statement from the first candidate intent.
[0103] The first prompt word may be generated based on the query sentence, the first candidate intent, and the description information of the first candidate intent, or may be generated based on the query sentence, the first candidate intent, the description information of the first candidate intent, and the historical interaction information. The specific implementation method can refer to the detailed description in other embodiments of the present disclosure, and will not be described in detail here.
[0104] It should be noted that for query statements containing complex intents, it is difficult to identify all intents in the query statement at one time. Therefore, in the disclosed embodiment, a large model can be used for multiple interactions to accurately identify all intents in the complex intent. For example, "help me summarize the GPT4.pdf file" is a query statement with complex intent, which contains two intents. The first intent is the file search intent, and the second intent is the full text summary intent.
[0105] The first intent may be the intent corresponding to the first processing operation in the query. For example, if the query is "help me summarize the GPT4.pdf file", the corresponding first operation should be to search for the GPT4.pdf file, and the second operation is to summarize the file. Therefore, the first intent is the file search intent.
[0106] Step 302: Generate second prompt information according to the first intention and the first prompt information.
[0107] The second prompt word is used to prompt the large model to continue to perform intent recognition on the query statement based on the first candidate intent remaining except the first intent, so as to obtain the second intent of the query statement.
[0108] In some embodiments, the first intention and the first prompt information may be filled into a third prompt template to obtain the second prompt information.
[0109] Step 303: input the second prompt information into the large model to determine the second intent corresponding to the query statement from other first candidate intents except the first intent.
[0110] Among them, the processing operation corresponding to the second intention in the query statement is located after the processing operation corresponding to the first intention in the query statement.
[0111] For example, if the query is "help me summarize the GPT4.pdf file", the first step should be to search for the GPT4.pdf file, and the second step is to summarize the file. Therefore, the first intention is to search for the file, and the second intention is to summarize the file. Therefore, the processing operation corresponding to the second intention in the query is located after the processing operation corresponding to the first intention in the query.
[0112] Step 304, generating new second prompt information according to the second intention and the second prompt information, and returning to execute the operation of obtaining the second intention until the large model outputs the end indication information.
[0113] In some embodiments, the second intention and the second prompt information are filled into a third prompt template to generate new second prompt information.
[0114] Among them, the new second prompt information can be used to prompt the large model to continue to identify the intent of the query statement based on the first candidate intent remaining in addition to the first intent and the second intent.
[0115] In some embodiments, after the large model has finished recognizing the intent of the query statement, it can output an end indication message, for example, outputting "intent recognition is finished", "intent recognition has been completed", etc. This disclosure does not limit this.
[0116] In some embodiments, the second intention may be one or more, which is not limited in the present disclosure.
[0117] Step 305: determine the first intention and the second intention as the first target intention.
[0118] In the disclosed embodiment, after obtaining the first prompt information, the first prompt information is input into the big model to obtain the first intention corresponding to the query statement from the first candidate intention, and the second prompt information is generated according to the first intention and the first prompt information. Then, the second prompt information is input into the big model to determine the second intention corresponding to the query statement from other first candidate intentions except the first intention, wherein the processing operation corresponding to the second intention in the query statement is located after the processing operation corresponding to the first intention in the query statement, and then according to the second intention and the second prompt information, a new second prompt information is generated, and the operation of obtaining the second intention is returned until the big model outputs the end indication information, and finally the first intention and the second intention are determined as the first target intention. In this way, by interacting with the big model multiple times, the big model can perform multiple intent recognition on the query statement, which can not only recognize the complex intent in the query statement, but also improve the accuracy of intent recognition.
[0119] Figure 4 is a flowchart of a method for identifying intent based on a large model according to another embodiment of the present disclosure; Figure 4 As shown, the intention recognition method based on the large model includes:
[0120] Step 401, obtain the query statement, the preset intent and the description information of the preset intent.
[0121] Step 402, matching the query statement with the preset intent and the description information of the preset intent to obtain the first candidate intent corresponding to the query statement.
[0122] The specific implementation forms of step 401 and step 402 can refer to the detailed descriptions in other embodiments of the present disclosure, and will not be described in detail here.
[0123] Step 403, when the description information includes the parameter type corresponding to the preset intent and the definition information corresponding to the parameter type, generate third prompt information according to the query statement, the first candidate intent and the description information corresponding to the first candidate intent.
[0124] Among them, the third prompt word is used to prompt the large model to determine the first target intent corresponding to the query statement from the first candidate intent, and extract the target parameters corresponding to the first target intent from the query statement.
[0125] The description information of the preset intent may include definition information of the preset intent. Alternatively, the description information of the preset intent may include parameter types corresponding to the preset intent and definition information corresponding to each parameter type.
[0126] For example, if the preset intent is file search intent, the corresponding parameter types may include: time, file type, operation behavior, file location, keywords, etc. Among them, the definition information corresponding to time can be "the file time that the user wants to retrieve, which can be the exact time 2023, September 3, or a relative time description such as last week or a few days ago"; the definition information corresponding to the file type can be "the file format that the user wants to search for, the file type, can be a basic file type such as a document or video, or a specific format such as pdf or ppt, or a content classification of a video such as a movie, TV series, variety show, or cartoon".
[0127] In some embodiments, the query statement, the first candidate intent, and the description information of the first candidate intent may be filled into the fourth prompt template to obtain the third prompt information.
[0128] For example, the first prompt template can be "Please determine the target intent corresponding to the query statement from the first candidate intent based on the first candidate intent and the corresponding description information, and extract the target parameters in the query statement based on the parameter type corresponding to the target intent. The query statement is XXX, the first candidate intent includes XXX, and the description information of the first candidate intent is XXX."
[0129] In some embodiments, when the description information includes the parameter type corresponding to the preset intent and the definition information corresponding to the parameter type, the third prompt information can also be generated based on the query statement, the first candidate intent, the description information corresponding to the first candidate intent and the historical interaction information.
[0130] In the disclosed embodiment, when the description information includes the parameter type corresponding to the preset intent and the definition information corresponding to the parameter type, the large model can also be prompted by a third prompt word to simultaneously obtain the first target intent corresponding to the query statement and the target parameter corresponding to the first target intent.
[0131] Step 404, input the third prompt information into the large model to obtain the first target intent corresponding to the query statement and the target parameter associated with the first target intent in the query statement.
[0132] It should be noted that since the third prompt word is used to prompt the large model to determine the first target intent corresponding to the query sentence from the first candidate intent, and to extract the target parameter corresponding to the first target intent from the query sentence, it is possible to obtain the first target intent corresponding to the query sentence output by the large model, and the target parameter associated with the first target intent in the query sentence.
[0133] Step 405, determining a reply statement corresponding to the query statement according to the first target intention and target parameters.
[0134] In the disclosed embodiment, after the first target intent and target parameters are determined, the query statement can be processed according to the target intent and target parameters to obtain a reply statement corresponding to the query statement.
[0135] In some embodiments, a reply statement corresponding to the query statement can be generated according to the first target intent and target parameters through template matching, machine learning and other technologies.
[0136] In the disclosed embodiment, when the description information includes the parameter type corresponding to the preset intent and the definition information corresponding to the parameter type, a third prompt information is generated according to the query statement, the first candidate intent and the description information corresponding to the first candidate intent, and the third prompt information is input into the big model to obtain the first target intent corresponding to the query statement and the target parameter associated with the first target intent in the query statement, and finally the reply statement corresponding to the query statement is determined according to the first target intent and the target parameter. Thus, when the description information includes the parameter type corresponding to the preset intent and the definition information corresponding to the parameter type, the big model can be prompted to simultaneously obtain the first target intent corresponding to the query statement and the target parameter corresponding to the first target intent in the query statement, and then generate a reply statement, thereby improving the efficiency and accuracy of determining the reply statement.
[0137] Figure 5 is a flow chart of a large model fine-tuning method provided according to another embodiment of the present disclosure; Figure 5 As shown, the intention recognition method based on the large model includes:
[0138] Step 501, obtaining a sample data set, wherein the sample data set includes a sample sentence, a third candidate intent corresponding to the sample sentence, description information corresponding to the third candidate intent, and an intent label corresponding to the sample sentence.
[0139] The sample statements may be statements collected online, for example, using a web crawler technology to collect sample statements online. Alternatively, historical query statements may be used as sample statements.
[0140] Among them, the method for determining the third candidate intent corresponding to the sample sentence can refer to the detailed description of the method for determining the first candidate intent corresponding to the query sentence in the present disclosure, and will not be repeated here.
[0141] The intent label corresponding to the sample sentence may be the first intent corresponding to the sample sentence determined manually.
[0142] In some embodiments, the intent tag corresponding to the sample sentence includes all intents corresponding to the sample sentence. The intent tag may include one intent or multiple intents, which is not limited in the present disclosure.
[0143] Step 502: Generate fourth prompt information based on the sample sentence, the third candidate intent and the description information corresponding to the third candidate intent.
[0144] Among them, the fourth prompt word is used to prompt the initial large model to predict the intent corresponding to the sample sentence from the third candidate intent based on the third candidate intent and the corresponding description information.
[0145] In some embodiments, the sample sentence, the third candidate intent, and the description information corresponding to the third candidate intent may be filled into the first prompt template to obtain fourth prompt information.
[0146] In some embodiments, when the sample data set also includes historical interaction samples corresponding to the sample sentence, the fourth prompt information is generated according to the sample sentence, the third candidate intent, the description information corresponding to the third candidate intent, and the historical interaction samples. Thus, by fine-tuning the initial large model in combination with the historical interaction samples corresponding to the sample sentence, the performance of the fine-tuned large model in combining with the historical interaction information to perform intent recognition can be improved, and then the fine-tuned large model can combine with the historical interaction information corresponding to the query sentence to perform intent recognition on the query sentence, thereby improving the accuracy of query sentence intent recognition.
[0147] In some embodiments, the historical interaction sample may include at least one of the following: a historical sample sentence corresponding to the user identification of the sample sentence; a fourth candidate intent corresponding to the historical sample sentence; descriptive information corresponding to the fourth candidate intent; a third target intent corresponding to the historical sample sentence; and a reply sentence corresponding to the historical sample sentence.
[0148] Among them, one or more query statements input by the user identifier of the sample statement before inputting the sample statement may be determined as the historical sample statements.
[0149] The specific implementation method of determining the fourth candidate intent corresponding to the historical sample sentence is the same as the implementation method of determining the first candidate intent corresponding to the query sentence, which will not be elaborated here.
[0150] In some embodiments, the third target intent corresponding to the historical sample sentence may be an intent label corresponding to the historical sample sentence that is manually annotated.
[0151] Among them, the reply sentence corresponding to the historical sample sentence can be the answer corresponding to the sample sentence obtained by processing the query sentence according to the third target intention.
[0152] In some embodiments, the sample sentence, the third candidate intent, the description information corresponding to the third candidate intent, and the historical interaction sample can be filled into the second prompt template to obtain the fourth prompt information.
[0153] Step 503, input the fourth prompt information into the initial large model to obtain the target prediction intention corresponding to the sample sentence.
[0154] Among them, the initial large model can be an untrained general pre-trained (Generative Pretrained Transformer, GPT) model, an enhanced representation through knowledge integration (Enhanced Representation through Knowledge Integration, ERNIE) model, etc.
[0155] Step 504, fine-tuning the initial large model according to the difference between the target predicted intent and the intent label to obtain a fine-tuned large model.
[0156] In some embodiments, a preset loss function can be used to calculate the difference between the target predicted intent and the intent label, and the initial large model can be fine-tuned based on the calculated loss value.
[0157] In the disclosed embodiment, based on the existing initial large model, a small amount of sample data set is added to fine-tune the initial large model, so that the fine-tuned large model can maintain the performance of the initial large model while enhancing the performance of the fine-tuned large model in the intent recognition scenario.
[0158] Among them, the fine-tuned large model is used to identify the intent of query statements.
[0159] In the disclosed embodiment, a sample data set is obtained, wherein the sample data set includes a sample sentence, a third candidate intent corresponding to the sample sentence, descriptive information corresponding to the third candidate intent, and an intent label corresponding to the sample sentence. A fourth prompt information is generated based on the sample sentence, the third candidate intent, and the descriptive information corresponding to the third candidate intent. The fourth prompt information is input into the initial large model to obtain the target predicted intent corresponding to the sample sentence. The initial large model is fine-tuned based on the difference between the target predicted intent and the intent label to obtain the fine-tuned large model. Thus, the initial large model is fine-tuned based on the sample sentence, the third candidate intent corresponding to the sample sentence, the descriptive information corresponding to the third candidate intent, and the intent label corresponding to the sample sentence, thereby improving the performance of the fine-tuned large model, and further improving the accuracy of intent recognition for query sentences based on the fine-tuned large model.
[0160] Figure 6 is a flow chart of a large model fine-tuning method provided according to another embodiment of the present disclosure; Figure 6 As shown, the intention recognition method based on the large model includes:
[0161] Step 601, obtaining a sample data set, wherein the sample data set includes a sample sentence, a third candidate intent corresponding to the sample sentence, description information corresponding to the third candidate intent, and an intent label corresponding to the sample sentence.
[0162] Step 602: Generate fourth prompt information based on the sample sentence, the third candidate intent and the description information corresponding to the third candidate intent.
[0163] In some embodiments, fourth prompt information may also be generated based on the sample sentence, the third candidate intent, description information corresponding to the third candidate intent, and historical interaction samples.
[0164] Step 603, when the intent label is the first intent sequence, the fourth prompt information is input into the initial large model to obtain the first predicted intent corresponding to the sample sentence from the third candidate intent.
[0165] Among them, the processing operation corresponding to the i-th intention in the first intention sequence in the sample sentence is located after the processing operation corresponding to the i-1-th intention in the sample sentence.
[0166] For example, if the sample sentence is "help me summarize the GPT4.pdf file", the corresponding first step should be to search for the GPT4.pdf file, and the second step is to summarize the file. Therefore, the first intention in the first intention sequence is the file search intention, and the second intention is the file summary intention.
[0167] Among them, the first predicted intent is the first intent corresponding to the predicted sample sentence after the large model predicts the intent of the sample sentence based on the candidate intent.
[0168] Step 604, generating fifth prompt information according to the first predicted intention and the fourth prompt information.
[0169] Among them, the fifth prompt word is used to prompt the first predicted intention corresponding to the initial large model sample sentence, and based on the third candidate intention remaining except the first predicted intention, continue to perform intent recognition on the query sentence to predict the second predicted intention corresponding to the sample sentence.
[0170] In some embodiments, the first predicted intention and the fourth prompt information may be filled into the third prompt template to obtain the fifth prompt information.
[0171] Step 605, input the fifth prompt information into the initial large model to determine the second predicted intention corresponding to the sample sentence from other third candidate intentions except the first predicted intention.
[0172] Among them, the second prediction intention predicted by the initial large model is the corresponding processing operation in the query statement, which is located after the processing operation corresponding to the first prediction intention in the query statement.
[0173] Step 606, generate new fifth prompt information according to the second prediction intention and the fifth prompt information, and return to execute the operation of obtaining the second prediction intention until the initial large model outputs the end indication information.
[0174] In some embodiments, the second predicted intent and the fifth prompt information are filled into the third prompt template to generate new fifth prompt information.
[0175] Among them, the new fifth prompt information can be used to prompt the initial large model to continue to identify the intent of the sample sentence based on the third candidate intent remaining in addition to the first predicted intent and the second predicted intent.
[0176] In some embodiments, after the initial large model completes the intent recognition of the sample sentence, an end indication message may be output, such as "intent recognition completed", "intent recognition completed", etc. This disclosure does not limit this.
[0177] In some embodiments, the second predicted intention may be one or more, which is not limited in the present disclosure.
[0178] Step 607, the first predicted intention and the second predicted intention outputted in sequence by the initial large model are determined as a second intention sequence, and the second intention sequence is the target predicted intention.
[0179] Among them, the second intention sequence is the first predicted intention, the second predicted intention of the first output, the second predicted intention of the second output, and so on.
[0180] Step 608, determining a first difference value between the i-th intention in the first intention sequence and the i-th predicted intention in the second intention sequence.
[0181] In some embodiments, a first difference value between the i-th intention in the first intention sequence and the i-th predicted intention in the second intention sequence can be calculated based on a preset loss function.
[0182] Step 609: determine a target difference value according to the first difference value corresponding to each intention in the first intention sequence.
[0183] In some embodiments, the sum of the first difference values corresponding to each intention in the first intention sequence may be determined as the target difference value.
[0184] Therefore, based on the first difference value between the i-th intent in the first intent sequence and the i-th predicted intent in the second intent sequence, the target difference value is determined, so that the large model can learn the order of processing operations corresponding to each intent in the sample sentence, and then accurately identify all intents in the query sentence and the order of intents in the query sentence.
[0185] Step 610: fine-tune the initial large model according to the target difference value to obtain a fine-tuned large model.
[0186] In the disclosed embodiment, when the intent label is the first intent sequence, the fourth prompt information is input into the initial large model to obtain the first predicted intent corresponding to the sample sentence from the third candidate intent, and the fifth prompt information is generated based on the first predicted intent and the fourth prompt information. The fifth prompt information is input into the initial large model to determine the second predicted intent corresponding to the sample sentence from other third candidate intents except the first predicted intent, and then a new fifth prompt information is generated based on the second predicted intent and the fifth prompt information, and the operation of obtaining the second predicted intent is returned until the initial large model outputs the end indication information, and the first predicted intent and the second predicted intent outputted in sequence by the initial large model are determined as the second intent sequence, and finally the first difference value between the i-th intent in the first intent sequence and the i-th predicted intent in the second intent sequence is determined, and the target difference value is determined based on the first difference value corresponding to each intent in the first intent sequence, and the initial large model is fine-tuned to obtain the fine-tuned large model. Therefore, when fine-tuning the large model, multiple interactions can be performed with the large model, and the loss can be calculated based on the intent sequence corresponding to the sample sentences, so that the large model can not only recognize all intents in the sample sentences, but also learn the order of processing operations corresponding to each intent in the sample sentences. In this way, the fine-tuned large model can not only recognize complex intents, but also recognize the order of each intent in the query sentence.
[0187] Figure 7 is a schematic diagram of a structure of an intention recognition device based on a large model provided according to an embodiment of the present disclosure; Figure 7 As shown, the intention recognition device 700 based on the large model includes:
[0188] The acquisition module 701 is used to acquire the query statement, the preset intent and the description information of the preset intent;
[0189] A matching module 702, used to match the query statement with the preset intent and the description information of the preset intent to obtain a first candidate intent corresponding to the query statement;
[0190] A generating module 703, configured to generate first prompt information according to the query statement, the first candidate intent and the description information of the first candidate intent;
[0191] The identification module 704 is used to input the first prompt information into the big model to determine the first target intent corresponding to the query statement from the first candidate intent.
[0192] In some embodiments of the present disclosure, the generating module 703 is used to:
[0193] Get the user ID of the query statement;
[0194] Determine historical interaction information corresponding to the query statement according to the user identifier;
[0195] Based on the query statement, the first candidate intent, the description information of the first candidate intent and the historical interaction information, the first prompt information is generated.
[0196] In some embodiments of the present disclosure, the historical interaction information includes at least one of the following:
[0197] Historical query statements corresponding to user IDs;
[0198] The second candidate intent corresponding to the historical query statement;
[0199] Description information corresponding to the second candidate intent;
[0200] The second target intent corresponding to the historical query statement;
[0201] The reply statement corresponding to the historical query statement.
[0202] In some embodiments of the present disclosure, the identification module 704 is used to:
[0203] Inputting the first prompt information into the large model to obtain the first intent corresponding to the query statement from the first candidate intent;
[0204] Generate second prompt information according to the first intention and the first prompt information;
[0205] Input the second prompt information into the large model to determine the second intent corresponding to the query statement from other first candidate intents except the first intent, wherein the processing operation corresponding to the second intent in the query statement is located after the processing operation corresponding to the first intent in the query statement;
[0206] Generate new second prompt information according to the second intention and the second prompt information, and return to execute the operation of obtaining the second intention until the large model outputs the end indication information;
[0207] The first intention and the second intention are determined as the first target intention.
[0208] In some embodiments of the present disclosure, the matching module 702 is used to:
[0209] Determine a first encoding vector corresponding to the query statement, a preset intent, and a second encoding vector corresponding to description information of the preset intent;
[0210] determining a similarity between the first encoding vector and the second encoding vector;
[0211] A first number of preset intentions with the greatest similarity are determined as first candidate intentions.
[0212] In some embodiments of the present disclosure, the matching module 702 is used to:
[0213] Input the query sentence into the intent recall model to obtain the first encoding vector;
[0214] The preset intent and the description information corresponding to the preset intent are spliced and input into the intent recall model to obtain a second encoding vector corresponding to the preset intent;
[0215] Among them, the intent recall model is generated by training the pre-trained language model based on sample sentences and corresponding intent labels.
[0216] In some embodiments of the present disclosure, a determination module is further included, which is used to:
[0217] In the case where the description information includes the parameter type corresponding to the preset intent and the definition information corresponding to the parameter type, third prompt information is generated according to the query statement, the first candidate intent and the description information corresponding to the first candidate intent, wherein the third prompt word is used to prompt the large model to determine the first target intent corresponding to the query statement from the first candidate intent, and to extract the target parameter corresponding to the first target intent from the query statement;
[0218] Input the third prompt information into the large model to obtain the first target intent corresponding to the query statement and the target parameter associated with the first target intent in the query statement;
[0219] According to the first target intention and target parameters, a reply statement corresponding to the query statement is determined.
[0220] It should be noted that the aforementioned explanation of the large model-based intention recognition method is also applicable to the large model-based intention recognition device of this embodiment, and will not be repeated here.
[0221] In the disclosed embodiment, a query statement, a preset intent, and description information of the preset intent are obtained, and then the query statement is matched with the preset intent and the description information of the preset intent to obtain the first candidate intent corresponding to the query statement, and then the first prompt information is generated according to the query statement, the first candidate intent, and the description information of the first candidate intent, and finally the first prompt information is input into the big model to determine the first target intent corresponding to the query statement from the first candidate intent. Thus, the first candidate intent corresponding to the query statement can be determined first, and then based on the first candidate intent and the corresponding description information, the big model is guided to identify the first target intent corresponding to the query statement from the first candidate intent, so that the interference of irrelevant intent can be eliminated first, reducing the task difficulty of intent recognition of the big model and improving the accuracy of intent recognition.
[0222] Figure 8is a structural diagram of a large model-based fine-tuning device provided according to an embodiment of the present disclosure; Figure 8 As shown, the large model-based fine-tuning device 800 includes:
[0223] An acquisition module 801 is used to acquire a sample data set, wherein the sample data set includes a sample sentence, a third candidate intent corresponding to the sample sentence, description information corresponding to the third candidate intent, and an intent label corresponding to the sample sentence;
[0224] A generating module 802, configured to generate fourth prompt information according to the sample sentence, the third candidate intent and the description information corresponding to the third candidate intent;
[0225] Prediction module 803, used for inputting the fourth prompt information into the initial large model to obtain the target prediction intent corresponding to the sample sentence;
[0226] The fine-tuning module 804 is used to fine-tune the initial large model according to the difference between the target predicted intent and the intent label to obtain a fine-tuned large model.
[0227] In some embodiments of the present disclosure, the generating module 802 is used to:
[0228] When the sample data set also includes historical interaction samples corresponding to the sample sentence, fourth prompt information is generated according to the sample sentence, the third candidate intent, the description information corresponding to the third candidate intent, and the historical interaction samples.
[0229] In some embodiments of the present disclosure, the prediction module 803 is used to:
[0230] In the case where the intent label is the first intent sequence, the fourth prompt information is input into the initial large model to obtain the first predicted intent corresponding to the sample sentence from the third candidate intent, wherein the processing operation corresponding to the i-th intent in the first intent sequence in the sample sentence is located after the processing operation corresponding to the i-1-th intent in the sample sentence;
[0231] generating fifth prompt information according to the first predicted intention and the fourth prompt information;
[0232] Inputting the fifth prompt information into the initial large model to determine the second predicted intent corresponding to the sample sentence from other third candidate intents except the first predicted intent;
[0233] Generate new fifth prompt information according to the second prediction intention and the fifth prompt information, and return to execute the operation of obtaining the second prediction intention until the initial large model outputs the end indication information;
[0234] The first predicted intention and the second predicted intention outputted in sequence by the initial large model are determined as the second intention sequence, and the second intention sequence is the target predicted intention.
[0235] In some embodiments of the present disclosure, the fine-tuning module 804 is used to:
[0236] Determining a first difference value between an i-th intention in the first intention sequence and an i-th predicted intention in the second intention sequence;
[0237] Determining a target difference value according to a first difference value corresponding to each intention in the first intention sequence;
[0238] According to the target difference value, the initial large model is fine-tuned to obtain a fine-tuned large model.
[0239] It should be noted that the aforementioned explanation of the large model-based fine-tuning method is also applicable to the large model-based fine-tuning device of this embodiment, and will not be repeated here.
[0240] In the disclosed embodiment, a sample data set is obtained, wherein the sample data set includes a sample sentence, a third candidate intent corresponding to the sample sentence, descriptive information corresponding to the third candidate intent, and an intent label corresponding to the sample sentence. A fourth prompt information is generated based on the sample sentence, the third candidate intent, and the descriptive information corresponding to the third candidate intent. The fourth prompt information is input into the initial large model to obtain the target predicted intent corresponding to the sample sentence. The initial large model is fine-tuned based on the difference between the target predicted intent and the intent label to obtain the fine-tuned large model. Thus, the initial large model is fine-tuned based on the sample sentence, the third candidate intent corresponding to the sample sentence, the descriptive information corresponding to the third candidate intent, and the intent label corresponding to the sample sentence, thereby improving the performance of the fine-tuned large model, and further improving the accuracy of intent recognition for query sentences based on the fine-tuned large model.
[0241] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
[0242] Fig. 9 A schematic block diagram of an example electronic device 900 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0243] like Figure 8 As shown, the device 900 includes a computing unit 901, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 902 or a computer program loaded from a storage unit 908 into a random access memory (RAM) 903. In the RAM 903, various programs and data required for the operation of the device 900 can also be stored. The computing unit 901, the ROM 902, and the RAM 903 are connected to each other via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.
[0244] A number of components in the device 900 are connected to the I / O interface 905, including: an input unit 906, such as a keyboard, a mouse, etc.; an output unit 907, such as various types of displays, speakers, etc.; a storage unit 908, such as a disk, an optical disk, etc.; and a communication unit 909, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 909 allows the device 900 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0245] The computing unit 901 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 901 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 901 performs the various methods and processes described above, such as a large model-based intent recognition method, or a large model fine-tuning method. For example, in some embodiments, a large model-based intent recognition method, or a large model fine-tuning method may be implemented as a computer software program, which is tangibly included in a machine-readable medium, such as a storage unit 908. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 900 via the ROM 902 and / or the communication unit 909. When the computer program is loaded into the RAM 903 and executed by the computing unit 901, one or more steps of the large model-based intent recognition method or the large model fine-tuning method described above may be performed. Alternatively, in other embodiments, the computing unit 901 may be configured to execute a large model-based intent recognition method, or a large model fine-tuning method, in any other appropriate manner (for example, by means of firmware).
[0246] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0247] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0248] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0249] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0250] The systems and techniques described herein can be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), the Internet, and a blockchain network.
[0251] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship between the client and the server is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services ("Virtual Private Server", or "VPS" for short). The server may also be a server of a distributed system, or a server combined with a blockchain.
[0252] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0253] In addition, the terms "first" and "second" are used for descriptive purposes only and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of the present disclosure, the meaning of "multiple" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined. In the description of the present disclosure, the words "if" and "if" used can be interpreted as "at the time of" or "when" or "in response to determination" or "under the circumstances of".
[0254] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A method for intent recognition based on a large model, wherein: include: Obtaining a query statement, a preset intent, and description information of the preset intent; Matching the query statement with the preset intent and the description information of the preset intent to obtain a first candidate intent corresponding to the query statement; Generate first prompt information according to the query statement, the first candidate intent and the description information of the first candidate intent; The first prompt information is input into the big model to determine the first target intent corresponding to the query statement from the first candidate intents.
2. The method according to claim 1, wherein: The generating first prompt information according to the query statement, the first candidate intent and the description information of the first candidate intent includes: Obtaining a user ID for the query statement; Determining historical interaction information corresponding to the query statement according to the user identifier; The first prompt information is generated based on the query statement, the first candidate intent, the description information of the first candidate intent and the historical interaction information.
3. The method according to claim 2, wherein: The historical interaction information includes at least one of the following: The historical query statements corresponding to the user identifier; A second candidate intent corresponding to the historical query statement; description information corresponding to the second candidate intent; The second target intent corresponding to the historical query statement; The reply statement corresponding to the historical query statement.
4. The method according to claim 1 or 2, wherein: The step of inputting the first prompt information into the big model to determine the first target intent corresponding to the query statement from the first candidate intents includes: Inputting the first prompt information into the large model to obtain the first intent corresponding to the query statement from the first candidate intent; Generate second prompt information according to the first intention and the first prompt information; Inputting the second prompt information into the large model to determine a second intent corresponding to the query statement from other first candidate intents except the first intent, wherein the processing operation corresponding to the second intent in the query statement is located after the processing operation corresponding to the first intent in the query statement; Generate new second prompt information according to the second intention and the second prompt information, and return to execute the operation of obtaining the second intention until the large model outputs the end indication information; The first intention and the second intention are determined as the first target intention.
5. The method according to claim 1, wherein: The matching the query statement with the preset intent and the description information of the preset intent to obtain a first candidate intent corresponding to the query statement includes: Determine a first encoding vector corresponding to the query statement, and a second encoding vector corresponding to the preset intent and description information of the preset intent; Determining a similarity between the first encoding vector and the second encoding vector; A first number of preset intentions with the greatest similarity are determined as the first candidate intentions.
6. The method according to claim 5, wherein: The determining of the first coding vector corresponding to the query statement, the preset intent and the second coding vector corresponding to the description information of the preset intent includes: Inputting the query sentence into the intention recall model to obtain the first encoding vector; splicing the preset intent and the description information corresponding to the preset intent into the intent recall model to obtain a second encoding vector corresponding to the preset intent; The intent recall model is generated by training a pre-trained language model based on sample sentences and corresponding intent labels.
7. The method according to claim 1, wherein: Also includes: In a case where the description information includes the parameter type corresponding to the preset intent and the definition information corresponding to the parameter type, third prompt information is generated according to the query statement, the first candidate intent and the description information corresponding to the first candidate intent, wherein the third prompt word is used to prompt the large model to determine the first target intent corresponding to the query statement from the first candidate intent, and to extract the target parameter corresponding to the first target intent from the query statement; Inputting the third prompt information into the large model to obtain the first target intent corresponding to the query statement and the target parameter associated with the first target intent in the query statement; According to the first target intention and the target parameters, a reply statement corresponding to the query statement is determined.
8. A large model fine-tuning method, wherein: include: Acquire a sample data set, wherein the sample data set includes a sample sentence, a third candidate intent corresponding to the sample sentence, description information corresponding to the third candidate intent, and an intent label corresponding to the sample sentence; Generate fourth prompt information according to the sample sentence, the third candidate intent and the description information corresponding to the third candidate intent; Inputting the fourth prompt information into the initial large model to obtain the target prediction intention corresponding to the sample sentence; According to the difference between the target predicted intent and the intent label, the initial large model is fine-tuned to obtain a fine-tuned large model.
9. The method according to claim 8, wherein: The generating fourth prompt information according to the sample sentence, the third candidate intent and the description information corresponding to the third candidate intent includes: When the sample data set also includes a historical interaction sample corresponding to the sample sentence, the fourth prompt information is generated according to the sample sentence, the third candidate intent, the description information corresponding to the third candidate intent and the historical interaction sample.
10. The method according to claim 8 or 9, wherein: The step of inputting the fourth prompt information into the initial large model to obtain the target prediction intention corresponding to the sample sentence includes: In the case where the intention label is the first intention sequence, the fourth prompt information is input into the initial large model to obtain the first predicted intention corresponding to the sample sentence from the third candidate intention, wherein the processing operation corresponding to the i-th intention in the first intention sequence in the sample sentence is located after the processing operation corresponding to the i-1-th intention in the sample sentence; generating fifth prompt information according to the first predicted intention and the fourth prompt information; Inputting the fifth prompt information into the initial large model to determine the second predicted intent corresponding to the sample sentence from other third candidate intents except the first predicted intent; Generate new fifth prompt information according to the second prediction intention and the fifth prompt information, and return to execute the operation of obtaining the second prediction intention until the initial large model outputs the end indication information; The first predicted intention and the second predicted intention sequentially output by the initial large model are determined as the second intention sequence, and the second intention sequence is the target predicted intention.
11. The method according to claim 10, wherein: The step of fine-tuning the initial large model according to the difference between the target predicted intent and the intent label to obtain a fine-tuned large model includes: Determining a first difference value between an i-th intention in the first intention sequence and an i-th predicted intention in the second intention sequence; determining a target difference value according to a first difference value corresponding to each intention in the first intention sequence; According to the target difference value, the initial large model is fine-tuned to obtain a fine-tuned large model.
12. An intention recognition device based on a large model, wherein: include: An acquisition module, used to acquire a query statement, a preset intent, and description information of the preset intent; A matching module, used to match the query statement with the preset intent and the description information of the preset intent to obtain a first candidate intent corresponding to the query statement; A generating module, configured to generate first prompt information according to the query statement, the first candidate intent and the description information of the first candidate intent; An identification module is used to input the first prompt information into a large model to determine the first target intent corresponding to the query statement from the first candidate intents.
13. The device according to claim 12, wherein: The generating module is used for: Obtaining a user ID for the query statement; Determining historical interaction information corresponding to the query statement according to the user identifier; The first prompt information is generated based on the query statement, the first candidate intent, the description information of the first candidate intent and the historical interaction information.
14. The device according to claim 13, wherein: The historical interaction information includes at least one of the following: The historical query statements corresponding to the user identifier; A second candidate intent corresponding to the historical query statement; description information corresponding to the second candidate intent; The second target intent corresponding to the historical query statement; The reply statement corresponding to the historical query statement.
15. The device according to claim 12 or 13, wherein: The identification module is used to: Inputting the first prompt information into the large model to obtain the first intent corresponding to the query statement from the first candidate intent; Generate second prompt information according to the first intention and the first prompt information; Inputting the second prompt information into the large model to determine a second intent corresponding to the query statement from other first candidate intents except the first intent, wherein the processing operation corresponding to the second intent in the query statement is located after the processing operation corresponding to the first intent in the query statement; Generate new second prompt information according to the second intention and the second prompt information, and return to execute the operation of obtaining the second intention until the large model outputs the end indication information; The first intention and the second intention are determined as the first target intention.
16. The device according to claim 12, wherein: The matching module is used for: Determine a first encoding vector corresponding to the query statement, and a second encoding vector corresponding to the preset intent and description information of the preset intent; Determining a similarity between the first encoding vector and the second encoding vector; A first number of preset intentions with the greatest similarity are determined as the first candidate intentions.
17. The device according to claim 16, wherein: The matching module is used for: Inputting the query sentence into the intention recall model to obtain the first encoding vector; splicing the preset intent and the description information corresponding to the preset intent into the intent recall model to obtain a second encoding vector corresponding to the preset intent; The intent recall model is generated by training a pre-trained language model based on sample sentences and corresponding intent labels.
18. The device according to claim 12, wherein: Also included is a determination module for: In a case where the description information includes the parameter type corresponding to the preset intent and the definition information corresponding to the parameter type, third prompt information is generated according to the query statement, the first candidate intent and the description information corresponding to the first candidate intent, wherein the third prompt word is used to prompt the large model to determine the first target intent corresponding to the query statement from the first candidate intent, and to extract the target parameter corresponding to the first target intent from the query statement; Inputting the third prompt information into the large model to obtain the first target intent corresponding to the query statement and the target parameter associated with the first target intent in the query statement; According to the first target intention and the target parameters, a reply statement corresponding to the query statement is determined.
19. A large model fine-tuning device, wherein: include: An acquisition module, configured to acquire a sample data set, wherein the sample data set includes a sample sentence, a third candidate intent corresponding to the sample sentence, description information corresponding to the third candidate intent, and an intent label corresponding to the sample sentence; A generating module, configured to generate fourth prompt information according to the sample sentence, the third candidate intent and description information corresponding to the third candidate intent; A prediction module, used for inputting the fourth prompt information into an initial large model to obtain a target prediction intention corresponding to the sample sentence; A fine-tuning module is used to fine-tune the initial large model according to the difference between the target predicted intent and the intent label to obtain a fine-tuned large model.
20. The device according to claim 19, wherein The generating module is used for: When the sample data set also includes a historical interaction sample corresponding to the sample sentence, the fourth prompt information is generated according to the sample sentence, the third candidate intent, the description information corresponding to the third candidate intent and the historical interaction sample.
21. The device according to claim 19 or 20, wherein: The prediction module is used to: In the case where the intention label is the first intention sequence, the fourth prompt information is input into the initial large model to obtain the first predicted intention corresponding to the sample sentence from the third candidate intention, wherein the processing operation corresponding to the i-th intention in the first intention sequence in the sample sentence is located after the processing operation corresponding to the i-1-th intention in the sample sentence; generating fifth prompt information according to the first predicted intention and the fourth prompt information; Inputting the fifth prompt information into the initial large model to determine the second predicted intent corresponding to the sample sentence from other third candidate intents except the first predicted intent; Generate new fifth prompt information according to the second prediction intention and the fifth prompt information, and return to execute the operation of obtaining the second prediction intention until the initial large model outputs the end indication information; The first predicted intention and the second predicted intention sequentially output by the initial large model are determined as the second intention sequence, and the second intention sequence is the target predicted intention.
22. The device according to claim 21, wherein The fine-tuning module is used to: Determining a first difference value between an i-th intention in the first intention sequence and an i-th predicted intention in the second intention sequence; determining a target difference value according to a first difference value corresponding to each intention in the first intention sequence; According to the target difference value, the initial large model is fine-tuned to obtain a fine-tuned large model.
23. An electronic device, comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the method of any one of claims 1-7, or to execute the method of any one of claims 8-11.
24. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to enable the computer to execute the method according to any one of claims 1 to 7, or to be able to execute the method according to any one of claims 8 to 11.
25. A computer program product, comprising computer instructions, wherein when the computer instructions are executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented, or the steps of the method according to any one of claims 8 to 11 are executed.
Citation Information
Cited By
Data query method and device based on cloud search service, equipment and medium
CN120492482A
Intelligent complex intention recognition method and system based on large model
CN120950649A
