Intention classification method and device for problem data

By vectorizing the target question data and matching the vector database, prompt corpus is generated to improve the accuracy of intent classification, solving the bias problem caused by random sample selection in traditional intent classification methods, and achieving more accurate and faster intent classification results. .

CN118673151APending Publication Date: 2024-09-20SUZHOU LANGDONG NET TEC CO LTD

Patent Information

Application Number
CN202411019217.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-29
Publication Date
2024-09-20

AI Technical Summary

Technical Problem

In a multi-round question and answer scenario, traditional intent classification methods have biases in intent classification due to random selection of training data, which affects the accuracy of answer text generation.

Method used

By vectorizing the target question data to be classified, using a vector database to match similar sample data, and generating prompt corpus based on similar sample data and intent category labels, inputting the large language model for intent classification improves the accuracy of the classification results.

Benefits of technology

This method selects sample data with high similarity through vector recall, provides powerful reference information, improves the accuracy and speed of intent classification, enriches the sample size of large language models, and improves the effect of intent classification in specific scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118673151A
    Figure CN118673151A
Patent Text Reader

Abstract

The invention relates to a problem data intention classification method and device. The method comprises the steps of obtaining to-be-classified target problem data; performing vectorization processing on the target problem data to obtain a vectorization result corresponding to the target problem data; utilizing the vectorization result to respectively match from a vector database to obtain similar sample data under each preset intention category; generating a first prompt corpus according to the target problem data, the similar sample data and the intention category label corresponding to the similar sample data; and inputting the first prompt corpus into the first large language model to obtain an intention classification result which is generated by the first large language model and corresponds to the target problem data. By adopting the method, the similar sample data with relatively high similarity with the target problem data can be selected by utilizing a vector recall mode, and a powerful reference message is provided for the intention classification of the first large language model learning problem data, so that the first large language model is helped to output a more accurate intention classification result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of natural language processing, and in particular to a method and device for classifying the intent of question data. Background Art

[0002] The multi-round question-answering scenario is a common task scenario in the field of natural language processing technology. However, in the chat dialogue task in the field of business inquiries, some user questions require the use of enterprise proprietary databases to obtain information to generate answers, while other user questions are suitable for obtaining relevant information through the Internet to generate answers. In addition, some user questions are invalid questions, such as meaningless input or greetings, etc., which do not require information. Therefore, achieving accurate intent classification of question data in multi-round question-answering scenarios is crucial for the task of generating answer text.

[0003] In traditional technology, a classification model is usually trained to predict intent categories, and the first few intent categories predicted are used as candidate categories. Then, the corresponding samples of these intent categories are randomly selected from the training data as examples. Finally, these intent categories and their corresponding examples are combined with user questions to form prompt data, which is then given to a large language model for classification prediction. However, when using the above intent classification method, since the training data is randomly selected, it has a certain degree of randomness, which can easily lead to deviations in intent classification of the large language model. Summary of the invention

[0004] Based on this, it is necessary to provide a more accurate intent classification method, apparatus, computer device, computer-readable storage medium and computer program product for question data in response to the above technical problems.

[0005] In a first aspect, the present application provides a method for classifying the intent of question data, comprising:

[0006] Obtain target problem data to be classified;

[0007] Performing vectorization processing on the target problem data to obtain a vectorization result corresponding to the target problem data;

[0008] Using the vectorization results, respectively matching and obtaining similar sample data under each preset intent category from a vector database;

[0009] Generate a first prompt corpus according to the target question data, the similar sample data, and the intention category label corresponding to the similar sample data;

[0010] The first prompt corpus is input into a first large language model to obtain an intent classification result corresponding to the target question data generated by the first large language model.

[0011] In one embodiment, the vectorization processing of the target problem data to obtain a vectorization result corresponding to the target problem data includes:

[0012] Performing named entity recognition on the target question data to obtain an entity recognition result of the target question data;

[0013] According to the entity category corresponding to the entity recognition result, the entity recognition result in the target question data is replaced with the corresponding category field to obtain the replaced target question data;

[0014] Performing word segmentation processing on the replaced target question data to obtain corresponding word segmentation results;

[0015] The word segmentation result is converted into corresponding vectorized data to obtain a vectorized result corresponding to the target question data.

[0016] In one embodiment, obtaining target problem data to be classified includes:

[0017] Obtaining currently input target dialogue data, historical dialogue data generated before the target dialogue data, and question category labels corresponding to the historical dialogue data;

[0018] Constructing a second prompt corpus according to the historical dialogue data, the question category label, and the target dialogue data;

[0019] Inputting the second prompt corpus into a second largest language model to obtain a question classification result corresponding to the target dialogue data generated by the second largest language model;

[0020] The target question data is determined according to the question classification result.

[0021] In one embodiment, the step of inputting the second prompt corpus into a second large language model to obtain a question classification result generated by the second large language model and corresponding to the target dialogue data includes:

[0022] Generate a first convolution result corresponding to the second prompt corpus by using the second largest language model using its own weight parameters;

[0023] Generate a second convolution result corresponding to the second prompt corpus by using the second largest language model using a low-rank matrix, where the low-rank matrix is ​​used to store model parameters learned by the second largest language model in a pre-training fine-tuning phase;

[0024] The question classification result is generated by the second large language model according to the first convolution result and the second convolution result.

[0025] In one embodiment, generating the first prompt corpus according to the target question data, the similar sample data, and the intent category label corresponding to the similar sample data includes:

[0026] Obtaining role description information matching the current application scenario and category description information corresponding to each of the intent categories;

[0027] Constructing corresponding question-answer corpus according to the similar sample data and the intent category labels corresponding to the similar sample data;

[0028] The role description information, the category description information, the question and answer corpus, and the target question data are concatenated to obtain the first prompt corpus.

[0029] In one embodiment, the using the vectorization result to match and obtain similar sample data under each preset intent category from a vector database includes:

[0030] Obtaining a sample vector corresponding to the sample question data under each of the intent categories stored in the vector database;

[0031] Sorting the sample vectors according to the similarity between the vectorization result and the sample vectors to obtain sorted sample vectors under each of the intent categories;

[0032] Determining a preset number of similar sample vectors under each of the intent categories according to the sorting results of the sample vectors;

[0033] The sample question data corresponding to the similar sample vector is used as the similar sample data.

[0034] In a second aspect, the present application also provides a device for classifying the intent of question data, including:

[0035] A question acquisition module is used to obtain target question data to be classified;

[0036] A problem vectorization module, used to perform vectorization processing on the target problem data to obtain a vectorization result corresponding to the target problem data;

[0037] A vector recall module, used to use the vectorization result to match and obtain similar sample data under each preset intent category from the vector database;

[0038] A corpus generation module, configured to generate a first prompt corpus according to the target question data, the similar sample data, and the intent category label corresponding to the similar sample data;

[0039] An intention classification module is used to input the first prompt corpus into a first large language model to obtain an intention classification result corresponding to the target question data generated by the first large language model. In a third aspect, the present application also provides a computer device. The computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the intention classification method of the question data described in any one of the embodiments of the first aspect when executing the computer program.

[0040] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method for classifying the intent of question data as described in any one of the embodiments of the first aspect.

[0041] In a fifth aspect, the present application further provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the method for classifying the intent of question data described in any one of the embodiments of the first aspect above is implemented.

[0042] The above-mentioned intent classification method, device, computer equipment, computer-readable storage medium and computer program product for question data, by vectorizing the target question data to be classified, and using the vectorization result of the target question data to match the similar sample data of the target question data under each preset intent category from the vector database. Generate a first prompt corpus based on the target question data, similar sample data and the intent category labels corresponding to the similar sample data. Input the first prompt corpus into the first large language model to obtain the intent classification result corresponding to the target question data generated by the first large language model, and be able to use the vector recall method to select similar sample data with a high similarity to the target question data, which provides a strong reference message for the first large language model to learn the intent classification of question data, and has more classification value than the randomly acquired or fixedly set sample data in the prior art, thereby helping the first large language model to output more accurate intent classification results. In addition, due to the adoption of the above-mentioned intent classification method for question data, similar sample data under each preset intent category and its corresponding intent category labels and target question data are used to construct the input prompt corpus of the first language model, which can enrich the sample size processed by the first language model, thereby helping the first language model to present better intent classification effects in specific question intent classification scenarios, such as faster intent classification speed or more accurate intent classification results. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0044] Figure 1 An application scenario diagram of an intention classification method for question data in one embodiment;

[0045] Figure 2 A flowchart of a method for classifying the intent of question data in one embodiment;

[0046] Figure 3 A schematic diagram of a flow chart of an entity recognition result replacement step in one embodiment;

[0047] Figure 4 A flowchart of a target dialogue question classification step in one embodiment;

[0048] Figure 5 A flowchart of a step of generating a question classification result in one embodiment;

[0049] Figure 6 It is a flowchart of the first prompt corpus construction step in one embodiment;

[0050] Figure 7 A schematic diagram of a flow chart of a similar sample data determination step in one embodiment;

[0051] Figure 8 A flowchart of a method for classifying the intent of question data in another embodiment;

[0052] Fig. 9 is a structural block diagram of an apparatus 900 for classifying the intention of question data in one embodiment;

[0053] Fig.10 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0054] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0055] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.

[0056] The intention classification method of question data provided in the embodiment of the present application can be applied to Figure 1 In the application scenario shown in the figure, the client 100 and the server 200 can communicate through the network. The vector database 300 can be used to store the vectorization results of the sample question data carrying the intent category label. The vector database 300 can be integrated on the server 200, or placed on the cloud or other network servers.

[0057] There may be multiple rounds of question-and-answer dialogues between the client 100 and the server 200. For example, after the client 100 sends the historical question data 130 to the server 200, the server 200 may generate an intent classification result 230 corresponding to the historical question data 130. After the client 100 sends the historical question data 150 to the server 200, the server 200 may generate an intent classification result 250 corresponding to the historical question data 150. After the client 100 sends the historical question data 170 to the server 200, the server 200 may generate an intent classification result 270 corresponding to the historical question data 170.

[0058] The following uses the intent classification method provided in this embodiment to illustrate how the server 200 generates the intent classification result 290 corresponding to the target question data 190 sent by the client 100:

[0059] Exemplarily, the server 200 may obtain the target question data 190 currently sent by the user through the client 100. The target question data 190 is vectorized to obtain a vectorization result corresponding to the target question data 190. The vectorization result is used to match the similar sample data 1902 under each preset intent category from the vector database 300. The server 200 may generate a first prompt corpus based on the target question data 190, the similar sample data 1902, and the intent category label 1904 corresponding to the similar sample data 1902. The server 200 may input the first prompt corpus into the first large language model to obtain an intent classification result 290 corresponding to the target question data 190 generated by the first large language model.

[0060] Among them, the client 100 can be installed in various personal computers, laptops, smart phones, tablet computers, Internet of Things devices and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart car devices, projection devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. Head-mounted devices can be virtual reality (VR) devices, augmented reality (AR) devices, smart glasses and other terminal devices. The server 200 can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud computing services.

[0061] In an exemplary embodiment, Figure 2 As shown in the figure, a method for classifying the intent of question data is provided, which is applied to Figure 1 The server 200 in the example is used as an example to illustrate the method, which includes the following steps S202 to S210. Among them:

[0062] Step S202, obtaining target question data to be classified.

[0063] For example, the server can obtain the dialogue text currently input by the user through the client through communication interaction with the client, and use various machine learning technologies, such as rule-based natural language processing systems, sentiment analysis models, classification algorithm models, or sequence-to-sequence learning models (such as Transformer), to extract target question data to be classified from the dialogue text.

[0064] Step S204, performing vectorization processing on the target problem data to obtain a vectorization result corresponding to the target problem data.

[0065] Exemplarily, the server may perform word segmentation processing on the target question data to obtain the word segmentation result of the target question data. The word segmentation result of the target question data is vectorized using One-Hot encoding or a word vector neural network model (such as Word2Vec or GloVe, etc.) to obtain a vectorization result corresponding to the target question data.

[0066] Step S206: Use the vectorization result to match and obtain similar sample data under each preset intent category from the vector database.

[0067] Among them, the intent categories may include but are not limited to proprietary question categories (intent categories that require obtaining information from a proprietary database to generate answers), general question categories (intent categories that can obtain information through the Internet to generate answers), and invalid question categories (i.e., question categories that have no practical meaning).

[0068] The vector database may store sample vectors corresponding to the sample problem data. The vector database may adopt milvus vector library (an open source vector database for unstructured data), chroma vector library (an open source vector database for building embedded vectors), etc.

[0069] Exemplarily, the server may use the vectorization result of the target question data to match the sample vectors in the vector database under each preset intent category to obtain the similarity between the vectorization result and the sample vector. The sample vectors are sorted according to the similarity, or, based on the comparison result between the similarity and a preset threshold, similar sample vectors corresponding to the vectorization result under each preset intent category are determined. Sample question data corresponding to the similar sample vectors are obtained as similar sample data.

[0070] Step S208: Generate a first prompt corpus according to the target question data, the similar sample data, and the intention category labels corresponding to the similar sample data.

[0071] Exemplarily, the server may construct a question-answer corpus corresponding to the similar sample data using the similar sample data and the intent category labels corresponding to the similar sample data, and concatenate the question-answer corpus corresponding to the similar sample data with the target question data to generate the first prompt corpus.

[0072] Step S210: input the first prompt corpus into the first large language model to obtain the intent classification result corresponding to the target question data generated by the first large language model.

[0073] Among them, the large language model, that is, Large Language Models, referred to as LLMs model, is a deep learning model trained with a large amount of text data, which can generate natural language text or understand the meaning of language text. Optionally, in some embodiments, the first large language model can adopt a generative language model (such as chatglm-13b model), a parameter model (qwen-14b model), etc.

[0074] Exemplarily, a first language model for intent recognition is stored in the server. The first prompt corpus is input into the first language model, and the correspondence between similar sample data and the intent category labels corresponding to the similar sample data is learned through the first language model, and the intent category corresponding to the target question data is determined from a plurality of preset intent categories according to the learned correspondence, thereby outputting the intent classification result corresponding to the target question data.

[0075] The above-mentioned method for classifying the intent of question data, by vectorizing the target question data to be classified, uses the vectorization result of the target question data to match the similar sample data of the target question data under each preset intent category from the vector database. Generate a first prompt corpus according to the target question data, similar sample data and the intent category label corresponding to the similar sample data. The first prompt corpus is input into the first language model to obtain the intent classification result corresponding to the target question data generated by the first language model, and the similar sample data with a high similarity to the target question data can be selected by vector recall, which provides a strong reference message for the first language model to learn the intent classification of question data, and has more classification value than the sample data randomly obtained or fixedly set in the prior art, thereby helping the first language model to output a more accurate intent classification result. In addition, due to the use of the above-mentioned method for classifying the intent of question data, similar sample data under each preset intent category and its corresponding intent category label and the target question data are used to construct the input prompt corpus of the first language model, which can enrich the sample volume processed by the first language model, thereby helping the first language model to present a better intent classification effect in a specific problem intent classification scenario, such as a faster intent classification speed or a more accurate intent classification result.

[0076] Optionally, in some implementations, entities in the problem data may interfere with the vector recall, thereby reducing the reference value of the sample obtained by the recall. Therefore, in order to improve the accuracy of the vector recall, the entities in the problem data may be replaced. In an exemplary embodiment, Figure 3 As shown, the above step S204 may also include the following steps S302 to S308. Among them:

[0077] Step S302, performing named entity recognition on the target question data to obtain an entity recognition result of the target question data.

[0078] Among them, the entity recognition results may include but are not limited to company names, names of people, places, dates, etc.

[0079] Exemplarily, the server may store entity recognition models, such as the Conditional Random Field (CRF) model, the Support Vector Machine (SVM) model, the Universal Information Extraction (UIE) model, etc. The target question data is input into the entity recognition model, and the entity recognition model performs named entity recognition on the target question data based on the entity prior knowledge of the labeled data learned during the training phase, so as to obtain the entity recognition result corresponding to the target question data generated by the entity recognition model.

[0080] Step S304, according to the entity category corresponding to the entity recognition result, the entity recognition result in the target question data is replaced with the corresponding category field to obtain the replaced target question data.

[0081] Exemplarily, the server may store a category field corresponding to each entity category, for example, the category field corresponding to the company name category may be "company name". According to the entity category corresponding to the entity recognition result of the target question data, the category field used to replace the entity content in the target question data may be determined. For the entity recognition result under each entity category in the target question data, the category field corresponding to the entity category is used to replace it, and the replaced target question data is obtained.

[0082] Step S306, performing word segmentation processing on the replaced target question data to obtain corresponding word segmentation results.

[0083] Step S308, converting the word segmentation result into corresponding vectorized data to obtain a vectorized result corresponding to the target question data.

[0084] Exemplarily, vector tools may be run in the server, such as a Chinese text embedding model (text2vec-base-chinese), a sentence transformer, etc. The vector tool is used to perform word segmentation processing on the replaced target question data, and the word segmentation result of the target question data is converted into corresponding vectorized data according to the preset data processing logic, thereby obtaining a vectorized result corresponding to the target question data.

[0085] Similarly, the sample vectors stored in the vector database may also be obtained by performing entity replacement on the sample question data in the above steps S302 to S308 and then performing vectorization processing.

[0086] In this embodiment, the entity recognition results in the target question data are replaced by the category field corresponding to the entity category of the entity recognition results, and the replaced target question data is vectorized to obtain the corresponding vectorized results. This can avoid the influence of the entity on the subsequent vector recall, and make the similar sample data obtained by the subsequent vector recall based on the vectorization results more accurate.

[0087] In an exemplary embodiment, Figure 4 As shown, step S202 may include the following steps S402 to S408. Among them:

[0088] Step S402, obtaining the currently input target dialogue data, the historical dialogue data generated before the target dialogue data, and the question category label corresponding to the historical dialogue data.

[0089] The question category labels may include but are not limited to independent question categories (ie, question categories that are not related to the context) and multi-round question categories (ie, question categories that are related to the context).

[0090] Exemplarily, the server may obtain target conversation data input by the current user through the client, read historical conversation data generated between the same client and the server before the target conversation data, and obtain question category labels corresponding to the historical conversation data input by the user through the client.

[0091] Step S404: construct a second prompt corpus based on the historical dialogue data, question category labels, and target dialogue data.

[0092] Step S406: input the second prompt corpus into the second largest language model to obtain a question classification result corresponding to the target dialogue data generated by the second largest language model.

[0093] Exemplarily, the server may construct a question-answer corpus based on the historical conversation data and the question category labels corresponding to the historical conversation data. The question-answer corpus and the target conversation data are concatenated to obtain a second prompt corpus. The second prompt corpus is input into the second largest language model for question classification, and the prior knowledge of question classification is learned from the historical conversation data and the question category labels corresponding to the historical conversation data by the second largest language model, and the question classification result corresponding to the target conversation data is determined based on the prior knowledge of question classification.

[0094] Step S408, determining target question data according to the question classification result.

[0095] Optionally, in some implementations, when the question classification result of the target dialogue data is an independent question category, the target question data to be classified can be extracted from the target dialogue data. In other implementations, when the question classification result of the target dialogue data is a multi-round question category, it is necessary to combine the historical dialogue data and the context information of the target dialogue data to determine the corresponding target question data.

[0096] In this embodiment, a second prompt corpus is constructed by using target conversation data, historical conversation data, and question category labels corresponding to the historical conversation data, and a second largest language model is used to generate a question classification result corresponding to the target conversation data according to the second prompt corpus. The corresponding target question data is determined according to the question classification result. This can be applicable to intent recognition scenarios under different question categories, and in question-and-answer scenarios of independent question categories, only the target conversation data is used to determine the target question data, so as to avoid interference of historical conversation data on the intent classification of the target question data; in question-and-answer scenarios of multiple rounds of question categories, the target question data is determined by combining historical conversation data and target conversation data, so as to avoid losing context information of multiple rounds of conversations, thereby helping to improve the accuracy of subsequent intent recognition.

[0097] Optionally, in some embodiments, the second largest language model can be obtained by fine-tuning the basic model using historical dialogue data and its corresponding question category labels as training data. The basic model may include but is not limited to generative language models (such as chatglm-6b, chatglm2-6b, chatglm3-6b, etc.), parameter models (such as qwen-7b model), etc. The fine-tuning training method may include but is not limited to the low-rank adaptive training method of large language models (Low-Rank Adaptation of Large Language Models, referred to as LORA method), Chinese pre-training model tuning method (such as P-tuning method), full parameter fine-tuning method, etc.

[0098] In an exemplary embodiment, the second largest language model trained in the LORA manner is used as an example to illustrate the generation process of the question classification result. That is, the second largest language model described in this embodiment can be obtained by adding a neural network bypass next to the linear transformation module of the basic model (that is, the convolution module of the fully connected layer), and this neural network bypass is obtained by doing the inner product of two small matrices. The middle dimension of the two small matrices is the rank (generally very small). The input and output shapes of the two small matrices are consistent with the original model parameters of the basic model. During the pre-training process of the basic model, the original model parameters of the basic model are not improved, but the model parameters of this neural network bypass are fine-tuned, and the model parameter update amount learned in the fine-tuning training phase is simulated by low-rank decomposition (first reducing the dimension of one of the small matrices, and then increasing the dimension of another small matrix).

[0099] like Figure 5 As shown, step S406 may include the following steps S502 to S506. Among them:

[0100] Step S502: Generate a first convolution result corresponding to the second prompt corpus by using the second largest language model using its own weight parameters.

[0101] Exemplarily, the server may perform convolution processing on the second prompt corpus using its own original weight parameters through the linear transformation module of the base model in the second largest language model to generate a first convolution result corresponding to the second prompt corpus.

[0102] Step S504: Generate a second convolution result corresponding to the second prompt corpus using a low-rank matrix through a second largest language model.

[0103] Among them, the low-rank matrix, that is, the matrix with a very small rank obtained by the inner product of two small matrices in the neural network bypass as mentioned above, can be used to store the model parameters learned by the second largest language model in the pre-training fine-tuning stage.

[0104] Exemplarily, the server may perform convolution processing on the second prompt corpus using the model parameters learned in the pre-training fine-tuning phase of the second language model stored in the low-rank matrix through the second language model to obtain a second convolution result corresponding to the second prompt corpus.

[0105] Step S506: Generate a question classification result based on the first convolution result and the second convolution result through the second largest language model.

[0106] Exemplarily, the server may superimpose the first convolution result and the second convolution result through the second largest language model to obtain a superimposed convolution result, and generate a question classification result corresponding to the target dialogue data according to the characteristics of the superimposed convolution result.

[0107] In this embodiment, the second largest language model obtained by fine-tuning training based on the LORA method generates a question classification result corresponding to the target dialogue data according to the second prompt corpus, which can improve the generation efficiency and generation accuracy of the question classification result. In addition, by fine-tuning training using the LORA method to obtain the second largest language model, the amount of data calculation in the fine-tuning training process can be reduced, thereby improving the training efficiency of the second largest language model.

[0108] In an exemplary embodiment, Figure 6 As shown, step S208 may include the following steps S602 to S606. Among them:

[0109] Step S602, obtaining role description information matching the current application scenario and category description information corresponding to each intent category.

[0110] Exemplarily, the server can obtain the role description information input by the user and matching the current application scenario through the client, as well as the category description information corresponding to each intent category. For example, in the application scenario of the business query field, the role description information of "You are a developer with professional knowledge in the business query field" can be obtained. When the intent category includes a proprietary question category, the category description information of "proprietary questions include searching for companies, querying company details and other business query field questions" can be obtained. When the intent category includes a general question category, the category description information of "general questions are non-business query field questions" can be obtained. When the intent category includes an invalid question category, the category description information of "questions with no practical significance" can be obtained.

[0111] Step S604: construct corresponding question-answer corpus according to the similar sample data and the intent category labels corresponding to the similar sample data.

[0112] Step S606, concatenating the role description information, the category description information, the question and answer corpus, and the target question data to obtain a first prompt corpus.

[0113] For example, the server can use similar sample data as question description information, and use the intent category label corresponding to the similar sample data as answer description information to construct the corresponding question and answer corpus. According to the preset word order, the role description information, category description information, question and answer corpus and target question data are spliced ​​to obtain the first prompt corpus.

[0114] In this embodiment, the first prompt corpus is obtained by splicing the role description information matching the current application scenario, the category description information corresponding to each intent category, the question and answer corpus constructed based on similar sample data and the intent category labels corresponding to the similar sample data, and the target question data. This can improve the data richness of the first prompt corpus, thereby helping the first language model to learn more information features and improve the intent classification accuracy of the target question data.

[0115] In an exemplary embodiment, Figure 7 As shown, the above step S206 can also be implemented by using steps S702 to S708. Among them:

[0116] Step S702, obtaining sample vectors corresponding to sample question data under each intent category stored in the vector database.

[0117] Exemplarily, the server may obtain all sample vectors stored in the vector database, and determine the intent category to which the sample vector corresponding to the sample question data belongs according to the intent category label corresponding to the sample question data, thereby obtaining sample vectors under each intent category.

[0118] Step S704, sorting the sample vectors according to the similarity between the vectorization result and the sample vectors to obtain sorted sample vectors under each intent category.

[0119] For example, the server may use a cosine similarity algorithm or a Jaccard similarity coefficient algorithm to perform operations on the vectorization results of the target question data and the sample vectors corresponding to the sample question data stored in the vector database to obtain the similarity between the vectorization results and the sample vectors. According to the numerical value of the similarity, the sample vectors under the same intent category are sorted from high to low, so that the sorted sample vectors under each intent category can be obtained.

[0120] Step S706: Determine a preset number of similar sample vectors under each intent category according to the sorting result of the sample vectors.

[0121] Step S708: taking the sample question data corresponding to the similar sample vector as similar sample data.

[0122] Exemplarily, the server may select a preset number of sample vectors from front to back as similar sample vectors corresponding to the vectorization result according to the sorting results of sample vectors under the same intent category, thereby obtaining a preset number of similar sample vectors of the vectorization result under each intent category. The sample question data corresponding to the similar sample vectors under each intent category is used as the similar sample data under each intent category corresponding to the target question data. Optionally, in some embodiments, the preset number may be 10.

[0123] In this embodiment, the sample vectors are sorted according to the similarity between the vectorization results of the target question data and the sample vectors under each intent category, and a preset number of sample question data are selected from the beginning to the end using the sorting results of the sample vectors as similar sample data corresponding to the target question data. This allows the similar sample data that is most similar to the target question data to be quickly selected from each intent category, thereby improving the efficiency of obtaining similar sample data.

[0124] In an exemplary embodiment, Figure 8 The invention also provides a method for classifying the intention of question data, including the following steps S802 to S814.

[0125] Step S802, obtaining the currently input target dialogue data, the historical dialogue data generated before the target dialogue data, and the question category label corresponding to the historical dialogue data.

[0126] Step S804: construct a second prompt corpus based on the historical dialogue data, question category labels and target dialogue data.

[0127] Step S806: input the second prompt corpus into the second largest language model to obtain a question classification result corresponding to the target dialogue data, and determine the target question data according to the question classification result.

[0128] Optionally, in some implementations, the second prompt corpus described below may be obtained: (You are an experienced chat customer service representative. You need to determine whether the target conversation data currently input by the client is an independent question or a multi-round question based on historical conversation data. The following is historical conversation data: Client: Question 1 Server: Answer 1; Client: Question 2 Server: Answer 2; ...; Client: target conversation data).

[0129] In this embodiment, by adopting the technical means of the above steps S802 to S806, it is possible to determine whether the current question task belongs to the independent question category or the multi-round question category based on the historical dialogue data and the current target dialogue data. Thus, the target question data for intent classification is determined based on the question category label, avoiding the interference of historical dialogue data in user intent recognition under the independent question category, and avoiding the lack of context information in user intent recognition under the multi-round question category.

[0130] Step S808, performing named entity recognition on the target question data, and replacing the entity recognition result in the target question data with the corresponding category field to obtain the replaced target question data.

[0131] Optionally, in some embodiments, the category field "Company Name" corresponding to the company name category may be used to replace "XX Company" in the target question data "What is the annual data of XX Company?", and the target question data after replacement may be "What is the annual data of Company Name?".

[0132] Step S810, vectorize the replaced target question data, and use the vectorization results corresponding to the target question data to match similar sample data under each preset intent category from the vector database.

[0133] Optionally, in some implementations, the server may search for corresponding similar sample data under the proprietary question category, the general question category, and the invalid question category in the vector database according to the vectorization result of the replaced target question data.

[0134] In this embodiment, by adopting the technical means of the above steps S808 to S810, the interference of entities in the target question data on the vector recall can be reduced, and the accuracy of obtaining similar sample data can be improved.

[0135] Step S812: Generate a first prompt corpus according to the target question data, similar sample data, and the intention category labels corresponding to the similar sample data.

[0136] Step S814: input the first prompt corpus into the first large language model to obtain the intent classification result corresponding to the target question data generated by the first large language model.

[0137] Optionally, in some implementations, since the first language model is an untrained model, the label data of the intent category can be expanded according to business needs, and the classification category can be dynamically added.

[0138] In this embodiment, by adopting the technical means of the above-mentioned step S812 to obtain the intent classification result, the stronger semantic understanding ability of the first language model can be used to improve the generation accuracy of the intent classification result.

[0139] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0140] Based on the same inventive concept, the embodiment of the present application also provides a device for classifying the intention of question data for implementing the method for classifying the intention of question data involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in the embodiments of one or more device for classifying the intention of question data provided below can refer to the limitations of the method for classifying the intention of question data above, and will not be repeated here.

[0141] In an exemplary embodiment, Fig. 9 As shown, a device 900 for classifying the intent of question data is provided, comprising: a question acquisition module 902, a question vectorization module 904, a vector recall module 906, a corpus generation module 908 and an intent classification module 910, wherein:

[0142] The question acquisition module 902 is used to acquire target question data to be classified.

[0143] The question vectorization module 904 is used to perform vectorization processing on the target question data to obtain a vectorization result corresponding to the target question data.

[0144] The vector recall module 906 is used to use the vectorization result to match and obtain similar sample data under each preset intent category from the vector database.

[0145] The corpus generation module 908 is used to generate a first prompt corpus according to the target question data, similar sample data and the intention category labels corresponding to the similar sample data.

[0146] The intention classification module 910 is used to input the first prompt corpus into the first large language model to obtain the intention classification result corresponding to the target question data generated by the first large language model.

[0147] In an exemplary embodiment, the question vectorization module 904 includes: an entity recognition unit, which is used to perform named entity recognition on the target question data to obtain the entity recognition result of the target question data; an entity replacement unit, which is used to replace the entity recognition result in the target question data with the corresponding category field according to the entity category corresponding to the entity recognition result to obtain the replaced target question data; a word segmentation processing unit, which is used to perform word segmentation processing on the replaced target question data to obtain the corresponding word segmentation result; a vectorization unit, which is used to convert the word segmentation result into the corresponding vectorized data to obtain the vectorized result corresponding to the target question data.

[0148] In an exemplary embodiment, the question acquisition module 902 includes: a dialogue acquisition unit, which is used to acquire the currently input target dialogue data, the historical dialogue data generated before the target dialogue data, and the question category label corresponding to the historical dialogue data; a corpus construction unit, which is used to construct a second prompt corpus based on the historical dialogue data, the question category label and the target dialogue data; a model classification unit, which is used to input the second prompt corpus into the second largest language model to obtain the question classification result corresponding to the target dialogue data generated by the second largest language model; and a question extraction unit, which is used to determine the target question data based on the question classification result.

[0149] In an exemplary embodiment, the model classification unit is also used to generate a first convolution result corresponding to the second prompt corpus through the second largest language model using its own weight parameters; generate a second convolution result corresponding to the second prompt corpus through the second largest language model using a low-rank matrix, and the low-rank matrix is ​​used to store the model parameters learned by the second largest language model in the pre-training fine-tuning stage; and generate a question classification result through the second largest language model based on the first convolution result and the second convolution result.

[0150] In an exemplary embodiment, the corpus generation module 908 is also used to obtain role description information matching the current application scenario and category description information corresponding to each intent category; construct corresponding question and answer corpus based on similar sample data and intent category labels corresponding to the similar sample data; and concatenate the role description information, category description information, question and answer corpus and target question data to obtain a first prompt corpus.

[0151] In an exemplary embodiment, the vector recall module 906 includes: a sample acquisition unit, used to obtain sample vectors corresponding to sample question data under each intent category stored in a vector database; a similarity sorting unit, used to sort the sample vectors according to the similarity between the vectorization result and the sample vector, to obtain the sorted sample vectors under each intent category; a vector determination unit, used to determine a preset number of similar sample vectors under each intent category according to the sorting result of the sample vector; and use the sample question data corresponding to the similar sample vectors as similar sample data.

[0152] Each module in the apparatus 900 for classifying the intention of question data can be implemented in whole or in part by software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.

[0153] In an exemplary embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as shown in FIG. Fig.10 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store target problem data, vectorization results, similar sample data, first prompt corpus, intent classification results and other data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a method for intent classification of problem data is implemented.

[0154] Those skilled in the art will understand that Fig.10 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0155] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above-mentioned method embodiments when executing the computer program.

[0156] In an exemplary embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.

[0157] In an exemplary embodiment, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the steps in the above method embodiments are implemented.

[0158] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.

[0159] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0160] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A method for classifying the intent of question data, characterized in that: The method comprises: Obtain target problem data to be classified; Performing vectorization processing on the target problem data to obtain a vectorization result corresponding to the target problem data; Using the vectorization results, respectively matching and obtaining similar sample data under each preset intent category from a vector database; Generate a first prompt corpus according to the target question data, the similar sample data, and the intention category label corresponding to the similar sample data; The first prompt corpus is input into a first large language model to obtain an intent classification result corresponding to the target question data generated by the first large language model.

2. The method according to claim 1, characterized in that The vectorization processing of the target problem data to obtain a vectorization result corresponding to the target problem data includes: Performing named entity recognition on the target question data to obtain an entity recognition result of the target question data; According to the entity category corresponding to the entity recognition result, the entity recognition result in the target question data is replaced with the corresponding category field to obtain the replaced target question data; Performing word segmentation processing on the replaced target question data to obtain corresponding word segmentation results; The word segmentation result is converted into corresponding vectorized data to obtain a vectorized result corresponding to the target question data.

3. The method according to claim 1, characterized in that The step of obtaining target problem data to be classified includes: Obtaining currently input target dialogue data, historical dialogue data generated before the target dialogue data, and question category labels corresponding to the historical dialogue data; Constructing a second prompt corpus according to the historical dialogue data, the question category label, and the target dialogue data; Inputting the second prompt corpus into a second largest language model to obtain a question classification result corresponding to the target dialogue data generated by the second largest language model; The target question data is determined according to the question classification result.

4. The method according to claim 3, characterized in that The step of inputting the second prompt corpus into a second large language model to obtain a question classification result generated by the second large language model and corresponding to the target dialogue data includes: Generate a first convolution result corresponding to the second prompt corpus by using the second largest language model using its own weight parameters; Generate a second convolution result corresponding to the second prompt corpus by using the second largest language model using a low-rank matrix, where the low-rank matrix is ​​used to store model parameters learned by the second largest language model in a pre-training fine-tuning phase; The question classification result is generated by the second large language model according to the first convolution result and the second convolution result.

5. The method according to claim 1, characterized in that The generating a first prompt corpus according to the target question data, the similar sample data, and the intention category label corresponding to the similar sample data includes: Obtaining role description information matching the current application scenario and category description information corresponding to each of the intent categories; Constructing corresponding question-answer corpus according to the similar sample data and the intent category labels corresponding to the similar sample data; The role description information, the category description information, the question and answer corpus, and the target question data are concatenated to obtain the first prompt corpus.

6. The method according to claim 1, characterized in that The using the vectorization result to match and obtain similar sample data under each preset intent category from the vector database respectively includes: Obtaining a sample vector corresponding to the sample question data under each of the intent categories stored in the vector database; Sorting the sample vectors according to the similarity between the vectorization result and the sample vectors to obtain sorted sample vectors under each of the intent categories; Determining a preset number of similar sample vectors under each of the intent categories according to the sorting results of the sample vectors; The sample question data corresponding to the similar sample vector is used as the similar sample data.

7. A device for classifying the intention of question data, characterized in that: The device comprises: A question acquisition module is used to obtain target question data to be classified; A problem vectorization module, used to perform vectorization processing on the target problem data to obtain a vectorization result corresponding to the target problem data; A vector recall module, used to use the vectorization result to match and obtain similar sample data under each preset intent category from the vector database; A corpus generation module, configured to generate a first prompt corpus according to the target question data, the similar sample data, and the intent category label corresponding to the similar sample data; The intention classification module is used to input the first prompt corpus into a first large language model to obtain an intention classification result generated by the first large language model and corresponding to the target question data.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Intention recognition method and device

    CN115705355A

  • Large model-based intention recognition method and device, electronic equipment and storage medium

    CN117688946A

  • Task-based dialogue method based on vector retrieval and large language model

    CN117829295A

Cited By

  • Data classification method and device based on large model

    CN120632109A

  • Problem classification optimization method and device of large language model and storage medium

    CN120670599A

  • Method for performing control logic decision in complex dialogue based on large model fine tuning and dynamic sample

    CN121071100A