Corpus label determination method and apparatus, electronic device, and storage medium
By training the target classification model with benchmark and sample corpora, and introducing distance loss values to adjust parameters, the problem of insufficient accuracy in determining closed domain labels is solved, thereby improving the accuracy and generalization ability of corpus labels.
Patent Information
- Application Number
- CN202210705381.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-21
- Publication Date
- 2026-02-03
- Estimated Expiration
- 2042-06-21
AI Technical Summary
In existing technologies, when determining corpus labels using closed domains, the correlation between the corpus to be categorized and the target corpus category is insufficient, leading to reduced label accuracy.
By obtaining a baseline label set and a sample label set, a target classification model is trained using the baseline corpus and the sample corpus. Distance loss is introduced to adjust the model parameters and improve the accuracy of the corpus labels.
It improves the generalization effect of the target classification model and the accuracy of corpus labels, especially in the ability to identify other corpus categories.
Smart Images

Figure CN115203405B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, and in particular to a method, apparatus, electronic device and storage medium for determining corpus tags. Background Technology
[0002] Currently, to improve model training performance, training samples are typically expanded to increase their quantity, thereby enhancing generalization and accuracy. In related technologies, training sample expansion generally involves closed-domain expansion; that is, given a specific target corpus category, the labels of the corpus to be categorized are assigned to one of the target corpus categories. This requires a certain degree of correlation between the corpus to be categorized and the target corpus category. However, the corpus to be categorized often depicts aimless content; therefore, using the aforementioned closed-domain approach to determine corpus labels reduces the accuracy of label determination. Summary of the Invention
[0003] The following is an overview of the subject matter described in detail herein. This overview is not intended to limit the scope of the claims.
[0004] This application provides a method, apparatus, electronic device, and storage medium for determining corpus tags, which can improve the accuracy of determining corpus tags.
[0005] On the one hand, embodiments of this application provide a method for determining corpus tags, including:
[0006] Obtain a baseline tag set and a sample tag set, wherein the baseline tag set includes multiple baseline corpus tags, which are used to indicate baseline corpus categories; the sample tag set includes extended corpus tags and all the baseline corpus tags, which are used to indicate corpus categories other than the baseline corpus categories.
[0007] Obtain multiple benchmark corpora corresponding to the benchmark label set, and obtain multiple sample corpora corresponding to the sample label set;
[0008] Initialize the original classification model;
[0009] Take any one of the sample corpora and the benchmark corpora corresponding to each of the benchmark corpus labels as a corpus data set, input the corpus data set into the original classification model, and obtain the sample classification result vector corresponding to the sample corpus;
[0010] A classification loss value is calculated based on the sample classification result vector and the sample label set, and a distance loss value is calculated based on the sample classification result vector, wherein the distance loss value is used to characterize the uniformity of the distance between the sample corpus and each of the benchmark corpus labels;
[0011] The target loss value is determined based on the classification loss value and the distance loss value. The parameters of the original classification model are adjusted based on the target loss value to obtain the target classification model.
[0012] Obtain the target corpus, input the target corpus into the target classification model, and obtain the target corpus label of the target corpus.
[0013] On the other hand, embodiments of this application also provide a corpus tagging device, including:
[0014] The tag set acquisition module is used to acquire a benchmark tag set and a sample tag set. The benchmark tag set includes multiple benchmark corpus tags, which are used to indicate benchmark corpus categories. The sample tag set includes extended corpus tags and all the benchmark corpus tags, which are used to indicate corpus categories other than the benchmark corpus categories.
[0015] The corpus acquisition module is used to acquire multiple benchmark corpora corresponding to the benchmark label set and multiple sample corpora corresponding to the sample label set.
[0016] The model initialization module is used to initialize the original classification model.
[0017] The first model processing module is used to take any one of the sample corpora and the benchmark corpora corresponding to each of the benchmark corpora labels as a corpus data set, input the corpus data set into the original classification model, and obtain the sample classification result vector corresponding to the sample corpus;
[0018] The loss value calculation module is used to calculate a classification loss value based on the sample classification result vector and the sample label set, and to calculate a distance loss value based on the sample classification result vector, wherein the distance loss value is used to characterize the uniformity of the distance between the sample corpus and each of the benchmark corpus labels;
[0019] The parameter adjustment module is used to determine the target loss value based on the classification loss value and the distance loss value, and adjust the parameters of the original classification model based on the target loss value to obtain the target classification model;
[0020] The second model processing module is used to acquire the target corpus, input the target corpus into the target classification model, and obtain the target corpus label of the target corpus.
[0021] Furthermore, the sample classification result vector includes the sample probability values of the sample corpus belonging to various categories of the benchmark corpus, and the aforementioned loss value calculation module is specifically used for:
[0022] Calculate the target logarithm value of each of the sample probability values;
[0023] Calculate the product of each sample probability value and the corresponding target logarithm value;
[0024] The distance loss value is calculated based on the sum of the products corresponding to the probability values of each sample.
[0025] Furthermore, the aforementioned first model processing module is specifically used for:
[0026] Obtain a first reference corpus and a second reference corpus, wherein the sentence similarity between the first reference corpus and the second reference corpus is greater than or equal to a preset first similarity threshold;
[0027] The first reference corpus and the second reference corpus are input into the reference model, and the first reference corpus and the second reference corpus are encoded to obtain the first reference corpus vector corresponding to the first reference corpus and the second reference corpus vector corresponding to the second reference corpus.
[0028] Determine the first vector similarity between the first reference corpus vector and the second reference corpus vector, and calculate the reference loss value based on the first vector similarity;
[0029] The parameters of the reference model are adjusted based on the reference loss value, and the original classification model is initialized based on the adjusted parameters of the reference model.
[0030] Furthermore, the aforementioned corpus acquisition module is specifically used for:
[0031] Display the corpus input interface;
[0032] Multiple candidate corpora input from the corpus input interface are obtained, and the candidate corpora are segmented to obtain candidate keywords.
[0033] The candidate keyword that matches any of the benchmark corpus tags in the benchmark tag set is taken as the target keyword, and the target keyword is highlighted in the corpus input interface;
[0034] When at least one of the target keywords is highlighted in the candidate corpus, the candidate corpus is used as the benchmark corpus corresponding to the benchmark tag set.
[0035] Furthermore, the aforementioned second model processing module is specifically used for:
[0036] The target corpus is input into the target classification model, and the target corpus is encoded to obtain a target corpus vector;
[0037] Obtain the corpus tag vectors for each of the aforementioned benchmark corpus tags;
[0038] Determine the second vector similarity between the target corpus vector and each of the corpus label vectors, and obtain the target classification result vector corresponding to the target corpus based on the second vector similarity, wherein the target classification result vector includes the target probability value of the target corpus belonging to each of the benchmark corpus categories;
[0039] The target probability value is compared with a preset probability threshold, and the target corpus label is obtained based on the comparison result.
[0040] Furthermore, the aforementioned second model processing module is specifically used for:
[0041] When all the target probability values are less than or equal to a preset probability threshold, the target corpus label of the target corpus is determined to be the extended corpus label;
[0042] Alternatively, when at least one of the target probability values is greater than the probability threshold, the target corpus label of the target corpus is determined to be the benchmark corpus label corresponding to the benchmark corpus category with the largest target probability value.
[0043] Furthermore, the aforementioned second model processing module is also used for:
[0044] When the target corpus label is any one of multiple benchmark corpus labels, the corpus confidence of the target corpus is determined based on the target classification result vector;
[0045] When the confidence level of the corpus is greater than or equal to a preset confidence threshold, the target corpus and the target corpus labels are determined as target training data;
[0046] Initialize the first model to be trained, and adjust the parameters of the first model to be trained according to the target training data to obtain the corpus recognition model.
[0047] Furthermore, the aforementioned second model processing module is also used for:
[0048] Obtain the text to be identified, input the text to be identified into the text recognition model, and recognize the text to be identified to obtain a first recognition result;
[0049] The text to be identified is input into the key semantic recognition model, and the text to be identified is recognized to obtain a second recognition result. The key semantic recognition model is pre-trained based on the target training data.
[0050] The target recognition result of the corpus to be recognized is obtained based on the first recognition result and the second recognition result.
[0051] Furthermore, the aforementioned second model processing module is specifically used for:
[0052] Obtain historical corpus and the historical recognition results of the historical corpus, perform word segmentation on the historical corpus and the corpus to be recognized, and obtain multiple first words of the historical corpus and multiple second words of the corpus to be recognized;
[0053] Encode each first word and each second word to obtain a first word vector corresponding to each first word and a second word vector corresponding to each second word;
[0054] Calculate the first average vector corresponding to multiple first word vectors and the second average vector corresponding to multiple second word vectors, determine the third vector similarity between the first average vector and the second average vector, and when the third vector similarity is greater than or equal to a preset second similarity threshold, use the historical recognition result as the third recognition result of the corpus to be recognized;
[0055] The target recognition result of the corpus to be recognized is obtained based on the first recognition result, the second recognition result, and the third recognition result.
[0056] Furthermore, the aforementioned second model processing module is specifically used for:
[0057] Obtain multiple preset candidate corpus templates, and obtain a target corpus template that matches the corpus to be identified from the multiple candidate corpus templates;
[0058] The target corpus template is input into the corpus recognition model, and the target corpus template is recognized to obtain a fourth recognition result;
[0059] The target recognition result of the corpus to be recognized is obtained based on the first recognition result, the second recognition result and the fourth recognition result.
[0060] Furthermore, each of the aforementioned benchmark corpus tags corresponds to multiple benchmark corpora. Furthermore, the aforementioned second model processing module is specifically used for:
[0061] Multiple benchmark corpora are input into the target classification model, and each benchmark corpus is encoded to obtain a benchmark corpus vector for each benchmark corpus.
[0062] The benchmark corpus vectors under the same benchmark corpus label are concatenated to obtain the corpus label vector of the corresponding benchmark corpus label; or, the benchmark corpus vectors under the same benchmark corpus label are weighted to obtain the corpus label vector of the corresponding benchmark corpus label; or, the corresponding vector elements in the benchmark corpus vectors under the same benchmark corpus label are summed to obtain the corpus label vector of the corresponding benchmark corpus label.
[0063] On the other hand, embodiments of this application also provide an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the above-described corpus tag determination method.
[0064] On the other hand, embodiments of this application also provide a computer-readable storage medium storing a computer program, which is executed by a processor to implement the above-described corpus tag determination method.
[0065] On the other hand, embodiments of this application also provide a computer program product, which includes a computer program stored in a computer-readable storage medium. A processor of a computer device reads the computer program from the computer-readable storage medium and executes the computer program, causing the computer device to perform the corpus tag determination method described above.
[0066] The embodiments of this application include at least the following beneficial effects: By obtaining a benchmark label set and a sample label set, multiple benchmark corpora corresponding to the benchmark label set are obtained, and multiple sample corpora corresponding to the sample label set are obtained. Since the sample label set includes all benchmark corpus labels and extended corpus labels, and the extended corpus labels are used to indicate other corpus categories besides the benchmark corpus categories (i.e., other corpus categories may also exist in the sample corpus), the target classification model trained based on the benchmark corpus and sample corpus can have the ability to identify corpus of other corpus categories, thereby improving the generalization effect of the target classification model. When using the target classification model to determine the target corpus label of the target corpus, the accuracy of the target corpus label can be improved. Furthermore, a distance loss value is introduced during the training of the target classification model. When the sample corpus does not belong to any benchmark corpus category, the distance between the sample corpus and different benchmark corpus labels can be made more uniform, thereby improving the training effect of the target classification model, thus improving the performance of the target classification model, and further improving the accuracy of determining the corpus label.
[0067] Other features and advantages of this application will be set forth in the following description and will be apparent in part from the description or may be learned by practicing the application. Attached Figure Description
[0068] The accompanying drawings are used to provide a further understanding of the technical solutions of this application and constitute a part of the specification. They are used together with the embodiments of this application to explain the technical solutions of this application and do not constitute a limitation on the technical solutions of this application.
[0069] Figure 1 A schematic diagram of an implementation environment provided for an embodiment of this application;
[0070] Figure 2 A schematic diagram illustrating another implementation environment provided for an embodiment of this application;
[0071] Figure 3 A flowchart illustrating the corpus tag determination method provided in this application embodiment;
[0072] Figure 4 This is a schematic diagram illustrating parameter adjustment of a reference model as provided in an embodiment of this application.
[0073] Figure 5 A flowchart illustrating the process of adjusting the parameters of the original classification model provided in an embodiment of this application;
[0074] Figure 6 A schematic diagram of the corpus input interface provided in the embodiments of this application;
[0075] Figure 7 A flowchart for determining target corpus labels for a target corpus provided in this application embodiment;
[0076] Figure 8 A schematic diagram illustrating a real-world application scenario of the target classification model provided in the embodiments of this application;
[0077] Figure 9 This is a schematic diagram of the corpus tag determination device provided in the embodiments of this application;
[0078] Figure 10 This is a partial structural block diagram of a terminal provided in an embodiment of this application;
[0079] Figure 11 A partial structural block diagram of the server provided in an embodiment of this application. Detailed Implementation
[0080] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0081] It should be noted that in various specific embodiments of this application, when processing data related to the characteristics of the target object, such as target object attribute information or attribute information sets, is required, the permission or consent of the target object will be obtained first. Furthermore, the collection, use, and processing of this data will comply with the relevant laws, regulations, and standards of the relevant countries and regions. In addition, when embodiments of this application need to obtain target object attribute information, separate permission or consent from the target object will be obtained through pop-up windows or redirection to a confirmation page. Only after obtaining the separate permission or consent of the target object will the necessary target object-related data for the normal operation of the embodiments of this application be obtained.
[0082] To facilitate understanding of the technical solutions provided in the embodiments of this application, some key terms used in the embodiments of this application will be explained below:
[0083] Short text query corpus: A request statement entered by a user in a dialogue system, usually containing only one intention or expectation of the user. For example: "Play a song by singer S"; "Tell me the story of Yu Gong moving mountains"; "I want to watch movie M", etc.
[0084] Skills: An abstraction of specific abilities in a dialogue system, such as musical skills. This means that the dialogue system can understand music-related query data, perform operations such as domain matching and parameter extraction, and thus express the key information in the query data in a structured way. This information is then passed to subsequent services to facilitate their corresponding feedback, and finally completes a voice interaction process with the user.
[0085] Skill corpus: Users need to provide a certain amount of training corpus when creating skills. However, in actual use, especially when third-party users create their own skills, they often only provide a very small amount of skill corpus. Directly using this corpus to train online models will result in severe overfitting, and the effect will often be unsatisfactory.
[0086] Other corpora: Corpora other than skill corpora, generally depicting users' aimless conversations.
[0087] Artificial intelligence (AI) is the theory, methods, technology, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results. In other words, AI is a comprehensive technology within computer science that attempts to understand the essence of intelligence and produce a new kind of intelligent machine that can react in a way similar to human intelligence. AI studies the design principles and implementation methods of various intelligent machines, enabling them to possess the functions of perception, reasoning, and decision-making.
[0088] Artificial intelligence (AI) is a comprehensive discipline encompassing a wide range of fields, including both hardware and software technologies. Fundamental AI technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interactive systems, and mechatronics. AI software technologies primarily include computer vision, speech processing, natural language processing, as well as machine learning / deep learning, autonomous driving, and intelligent transportation.
[0089] Machine Learning (ML) is a multidisciplinary field involving probability theory, statistics, approximation theory, convex analysis, and algorithm complexity theory. It specifically studies how computers can simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to endow computers with intelligence; its applications span all areas of artificial intelligence. Machine learning and deep learning typically include techniques such as artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and instruction-based learning.
[0090] Currently, online dialogue is widely used in various scenarios, such as online shopping, online medical consultations, and intelligent customer service. Online dialogue systems are generally based on pre-trained models. To improve the training effect of the model, the training samples are usually expanded to increase the number of training samples and improve the model's generalization effect and accuracy. In related technologies, the expansion of training samples is generally a closed-domain expansion, that is, given a specific target corpus category, the label of the corpus to be classified is determined as one of the target corpus categories. This requires that the corpus to be classified and the target corpus categories have a certain degree of correlation. For example, if the target corpus categories include music, sports, and movies (of course, there are more categories in actual applications; these are just a few examples), then when expanding the training samples, corpus will be automatically captured within the scope of music, sports, and movies.
[0091] However, the corpus to be categorized often depicts aimless content, and in many cases, the corpus to be categorized does not belong to the aforementioned target corpus categories. For example, the automatically captured corpus may be a home furnishing category. In this case, if the aforementioned method for determining the corpus label is used to target closed domains, it may be identified as the category with the highest similarity among the three target corpus categories of music, sports, and movies. For example, it may be identified as the movie category. It can be seen that using the aforementioned method for determining the corpus label will reduce the accuracy of determining the corpus label.
[0092] Based on this, embodiments of this application provide a method, apparatus, electronic device, and storage medium for determining corpus tags, which can improve the accuracy of determining corpus tags.
[0093] Reference Figure 1 , Figure 1 This is a schematic diagram of an implementation environment provided in an embodiment of this application. The implementation environment includes a first terminal 101 and a first server 102, wherein the first terminal 101 and the first server 102 are connected via a communication network. Exemplarily, the first server 102 can acquire a baseline label set and a sample label set, acquire multiple baseline corpora corresponding to the baseline label set, acquire multiple sample corpora corresponding to the sample label set, initialize an original classification model, take any sample corpus and the baseline corpora corresponding to each baseline corpus label as a corpus data set, input the corpus data set into the original classification model, obtain a sample classification result vector corresponding to the sample corpus, calculate a classification loss value based on the sample classification result vector and the sample label set, calculate a distance loss value based on the sample classification result vector, determine a target loss value based on the classification loss value and the distance loss value, adjust the parameters of the original classification model based on the target loss value, and obtain a target classification model. The first terminal 101 can receive the target corpus input by the user and send it to the first server 102. After acquiring the target corpus, the first server 102 inputs the target corpus into the target classification model to obtain the target corpus label of the target corpus. Figure 1 In the implementation environment shown, the first terminal 101 and the first server 102 cooperate to determine the corpus tags. For example, the first terminal 101 provides a corresponding operation interface to receive the target corpus input based on the operation interface, and then the first server 102 determines the corresponding target corpus tags based on the target classification model. The first server 102 then returns the target corpus tags to the first terminal 101.
[0094] Reference Figure 2 , Figure 2This is a schematic diagram of another implementation environment provided by an embodiment of this application. This implementation environment includes a second terminal 201 or a second server 202. Exemplarily, the second terminal 201 or the second server 202 can acquire a baseline label set and a sample label set, acquire multiple baseline corpora corresponding to the baseline label set, acquire multiple sample corpora corresponding to the sample label set, initialize an original classification model, use any sample corpus and the baseline corpora corresponding to each baseline corpus label as a corpus data set, input the corpus data set into the original classification model, obtain a sample classification result vector corresponding to the sample corpus, calculate a classification loss value based on the sample classification result vector and the sample label set, calculate a distance loss value based on the sample classification result vector, determine a target loss value based on the classification loss value and the distance loss value, adjust the parameters of the original classification model based on the target loss value, and obtain a target classification model. The second terminal 201 or the second server 202 can acquire target corpora, input the target corpora into the target classification model, and obtain target corpus labels for the target corpora. Figure 2 In the implementation environment shown, the second terminal 201 or the second server 202 can also independently determine the corpus tags.
[0095] The first server 102 and the second server 202 can be independent physical servers, or a server cluster or distributed system composed of multiple physical servers. They can also be cloud servers providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. Furthermore, the first server 102 and the second server 202 can also be node servers in a blockchain network.
[0096] The first terminal 101 and the second terminal 201 can be smartphones, tablets, laptops, desktop computers, smart speakers, smartwatches, vehicle terminals, etc., but are not limited to these. The first terminal 101 and the first server 102 can be directly or indirectly connected through wired or wireless communication, and this application embodiment does not impose any limitations.
[0097] The methods provided in this application can be applied to various technical fields, including but not limited to cloud technology, artificial intelligence, and other technical fields.
[0098] Reference Figure 3 , Figure 3This is a flowchart illustrating the corpus tag determination method provided in the embodiments of this application. The corpus tag determination method can be executed by a terminal, or by a server, or by a combination of a terminal and a server. The corpus tag determination method includes, but is not limited to, the following steps 301 to 307.
[0099] Step 301: Obtain the baseline label set and the sample label set.
[0100] The baseline label set includes multiple baseline corpus labels, which indicate the category of the baseline corpus. Different baseline corpus labels indicate different baseline corpus categories. The sample label set includes extended corpus labels and all baseline corpus labels. Extended corpus labels indicate corpus categories other than the baseline corpus categories. The baseline corpus category can be the category to which the corpus to be extended belongs.
[0101] For example, the baseline label set may include baseline corpus label one, baseline corpus label two, and baseline corpus label three, used to indicate category A, category B, and category C, respectively. Correspondingly, the sample label set may include baseline corpus label one, baseline corpus label two, baseline corpus label three, and extended corpus labels, corresponding to category A, category B, category C, and category Other, respectively. Category Other refers to other corpus categories besides categories A, B, and C, i.e., the remaining corpus. Category Other is a general category and may not be used to indicate a specific corpus category. Specifically, baseline corpus label one can be (1,0,0), baseline corpus label two can be (0,1,0), baseline corpus label three can be (0,0,1), and extended corpus label can be (0,0,0).
[0102] Step 302: Obtain multiple benchmark corpora corresponding to the benchmark label set, and obtain multiple sample corpora corresponding to the sample label set.
[0103] This involves obtaining multiple benchmark corpora corresponding to the benchmark label set, specifically the benchmark corpora corresponding to each benchmark corpus label in the benchmark label set. The number of benchmark corpora corresponding to each benchmark corpus label can be multiple. Similarly, it involves obtaining multiple sample corpora corresponding to the sample label set, specifically the sample corpora corresponding to each benchmark corpus label and the sample corpora corresponding to the extended corpus labels in the sample label set. The number of sample corpora corresponding to each benchmark corpus label can be multiple, and the number of sample corpora corresponding to the extended corpus labels can also be multiple. It's important to understand that the benchmark corpora and sample corpora corresponding to the same benchmark corpus label are two different types of corpora.
[0104] For example, following the example in step 301, multiple benchmark corpora corresponding to the benchmark label set are obtained, namely, multiple benchmark corpora S1 corresponding to benchmark corpus label one, multiple benchmark corpora S2 corresponding to benchmark corpus label two, and multiple benchmark corpora S3 corresponding to benchmark corpus label three; multiple sample corpora corresponding to the sample label set are obtained, namely, multiple sample corpora S4 corresponding to benchmark corpus label one, multiple sample corpora S5 corresponding to benchmark corpus label two, multiple sample corpora S6 corresponding to benchmark corpus label three, and multiple sample corpora S7 corresponding to the extended corpus label.
[0105] Step 303: Initialize the original classification model;
[0106] The original classification model, which is the untrained model used to determine the corpus labels, can be implemented in one way by including an encoding layer to encode the corpus input to it. This encoding layer can be implemented using a BERT layer. After initializing the original classification model, it can be trained using sample corpora and a benchmark corpus. The original classification model encodes the benchmark and sample corpora, obtaining the benchmark vector corresponding to the benchmark corpus and the sample vector corresponding to the sample corpus. The original classification model is then trained based on the vector similarity between the benchmark vector and the sample vector.
[0107] In one possible implementation, the parameters of the original classification model can be obtained through random initialization. Alternatively, when initializing the original classification model, a first reference corpus and a second reference corpus can be obtained, wherein the sentence similarity between the first reference corpus and the second reference corpus is greater than or equal to a preset first similarity threshold. The first reference corpus and the second reference corpus are input into the reference model, and the first reference corpus and the second reference corpus are encoded to obtain a first reference corpus vector corresponding to the first reference corpus and a second reference corpus vector corresponding to the second reference corpus. A first vector similarity is determined between the first reference corpus vector and the second reference corpus vector, and a reference loss value is calculated based on the first vector similarity. The parameters of the reference model are adjusted based on the reference loss value, and the original classification model is initialized based on the adjusted parameters of the reference model.
[0108] Specifically, refer to Figure 4 , Figure 4This diagram illustrates parameter adjustment of a reference model according to an embodiment of this application. The reference model also includes an encoding layer, such as a BERT layer. The first and second reference corpora are samples used for parameter adjustment of the reference model. Both the first and second reference corpora are sentences, and they are similar to each other, thus forming a positive sample pair. When obtaining the first and second reference corpora, it is necessary to determine the sentence similarity between them. This can be achieved by segmenting the first and second reference corpora into words to determine the word vectors in each corpus. Then, the sentence vectors are determined based on these word vectors. Finally, the sentence similarity between the first and second reference corpora is calculated. The first similarity threshold can be determined based on actual conditions, such as 0.9 or 0.8, and is not limited in this embodiment.
[0109] After obtaining the first reference corpus vector corresponding to the first reference corpus and the second reference corpus vector corresponding to the second reference corpus through the encoding layer of the reference model, pooling can be performed on the first and second reference corpus vectors to obtain corresponding first and second pooling vectors. This reduces the vector dimension of the first and second reference corpus vectors, achieving feature compression and thus reducing computational load and improving data processing efficiency. Similarly, determining the first vector similarity between the first and second reference corpus vectors can be done by determining the cosine similarity or Euclidean distance, etc., which is not limited in this embodiment. After determining the first vector similarity, the reference loss value can be calculated by comparing the loss function, and then the parameters of the reference model can be adjusted. The adjusted parameters can be the parameters of the BERT layer in the reference model. Correspondingly, the adjusted parameters of the BERT layer based on the reference model can be used as the initial parameters of the BERT layer of the original classification model to achieve the effect of pre-training the original classification model.
[0110] Since the first and second reference corpora are similar to each other, adjusting the parameters of the BERT layer based on the first and second reference corpora can improve the performance of the reference model in the task of judging corpus similarity. In the embodiments of this application, the training of the original classification model is also based on the vector similarity between the sample corpus vector and the benchmark corpus vector. It can be seen that the BERT layer of the reference model and the BERT layer of the original classification model have a high degree of fit. Therefore, initializing the original classification model based on the parameters adjusted by the reference model can improve the basic performance of the original classification model, thereby improving the training efficiency of the original classification model.
[0111] Step 304: Take any sample corpus and the benchmark corpus corresponding to each benchmark corpus label as a corpus data set, input the corpus data set into the original classification model, and obtain the sample classification result vector corresponding to the sample corpus.
[0112] The constructed corpus data set includes a sample corpus and benchmark corpora corresponding to each benchmark corpus label. The number of benchmark corpora corresponding to each benchmark corpus label can be one or more.
[0113] For example, following the example in step 302, the corpus dataset may include one sample corpus S4, one benchmark corpus S1, one benchmark corpus S2, and one benchmark corpus S3; or, the corpus dataset may include one sample corpus S7, multiple benchmark corpora S1, multiple benchmark corpora S2, and multiple benchmark corpora S3. It is understood that when training the original classification model, each sample corpus will be used to construct a corpus dataset and input into the original classification model in the above manner.
[0114] In one possible implementation, after inputting the corpus dataset into the original classification model, the baseline corpus and sample corpus can be encoded separately through an encoding layer to obtain the baseline corpus vector corresponding to the baseline corpus and the sample corpus vector corresponding to the sample corpus. Then, the corpus label vector corresponding to each baseline corpus label is determined based on the baseline corpus vector. Specifically, when there is only one baseline corpus corresponding to a baseline corpus label, the corpus label vector of that label is the baseline corpus vector of the corresponding baseline corpus. When there are multiple baseline corpus labels corresponding to a baseline corpus label, the corpus label vector of that label can be obtained by integrating the baseline corpus vectors of the multiple corresponding baseline corpus labels. Among these, when there are multiple baseline corpus labels corresponding to a baseline corpus label, the integration methods for the baseline corpus vectors of the multiple baseline corpus labels include at least the following:
[0115] The first integration method is to concatenate the baseline corpus vectors under the same baseline corpus label to obtain the corpus label vector for the corresponding baseline corpus label. For example, if there are three baseline corpus vectors under a certain baseline corpus label, namely E1, E2 and E3, then the corpus label vector is E1E2E3.
[0116] The second integration method is to weight the baseline corpus vectors under the same baseline corpus label to obtain the corpus label vector for the corresponding baseline corpus label. For example, if there are three baseline corpus vectors under a certain baseline corpus label, namely E1, E2 and E3, with corresponding weights a1, a2 and a3 respectively, then the corpus label vector is a1*E1+a2*E2+a3*E3. It can be understood that the weights corresponding to the baseline corpus vectors can be determined according to actual needs, and this application embodiment does not limit them.
[0117] The third integration method is to sum the corresponding vector elements in the benchmark corpus vectors under the same benchmark corpus label to obtain the corpus label vector for the corresponding benchmark corpus label. For example, if there are three benchmark corpus vectors under a certain benchmark corpus label, namely E1, E2 and E3, and the vector elements of benchmark corpus vector E1 include (e11, e12, e13), the vector elements of benchmark corpus vector E2 include (e21, e22, e23), and the vector elements of benchmark corpus vector E3 include (e31, e32, e33), then the corpus label vector is (e11+e21+e31, e12+e22+e32, e13+e23+e33).
[0118] After obtaining the sample corpus vector and the corpus label vector, the vector similarity between the sample corpus vector and the corpus label vector can be calculated. Then, the sample classification result vector can be obtained based on the vector similarity between the sample corpus vector and the corpus label vector. The vector similarity between the sample corpus vector and the corpus label vector can be cosine similarity or Euclidean distance, etc., which is not limited in the embodiments of this application.
[0119] Specifically, the vector similarity between the sample corpus vector and the corpus label vector can be normalized to obtain the sample classification result vector. For example, continuing from the example in step 301, the vector similarity between the sample corpus vector and the corpus label vector corresponding to category A is L1, the vector similarity between the sample corpus vector and the corpus label vector corresponding to category B is L2, and the vector similarity between the sample corpus vector and the corpus label vector corresponding to category C is L3. Then, normalizing L1, L2, and L3 yields l1, l2, and l3, and the sample classification result vector at this time is (l1, l2, l3).
[0120] Step 305: Calculate the classification loss value based on the sample classification result vector and the sample label set, and calculate the distance loss value based on the sample classification result vector.
[0121] In one possible implementation, the cross-entropy loss value can be calculated based on the sample classification result vector and the sample label set to obtain the classification loss value. When calculating the classification loss value, the corresponding baseline corpus labels or extended corpus labels from the sample label set can be used. The sample classification result vector can actually be a probability distribution, including the probability values of the sample corpus belonging to various baseline corpus categories. Similarly, the baseline corpus labels or extended corpus labels can also be probability distributions.
[0122] For example, if the sample classification result vector is (0.3, 0.4, 0.5) and the corresponding baseline corpus label is (1, 0, 0), then the classification loss value can be calculated based on the cross-entropy function using the probability distributions (0.3, 0.4, 0.5) and (1, 0, 0).
[0123] The distance loss value is used to characterize the uniformity of distance between the sample corpus and different benchmark corpus labels. When calculating the distance loss value, the target logarithm value of each sample probability value can be calculated, the product between each sample probability value and the corresponding target logarithm value can be calculated, and the distance loss value can be calculated based on the sum of the products corresponding to each sample probability value. Specifically, it can be expressed by the following formula:
[0124] H=-∑P i *logP i
[0125] Where H represents the distance loss value, P i The probability distribution corresponding to the sample classification result vector is represented by i, which is a positive integer. log represents the logarithmic value, and the logarithmic base can be 2. Of course, other logarithmic bases can also be used, which are not limited in the embodiments of this application.
[0126] By taking the negative logarithm of each sample probability value, the amount of information carried when the sample corpus belongs to each benchmark corpus category can be obtained. Multiplying this information by the corresponding sample probability and summing the results yields the expected value of the sample corpus belonging to all benchmark corpus categories, thus characterizing the uniformity of distance between the sample corpus and each benchmark corpus label. The distance loss value is obtained by calculating the product of the sample probability value and the corresponding target logarithm. A larger distance loss value indicates a more uniform probability distribution corresponding to the sample classification result vector, meaning a more uniform distance between the sample corpus and different benchmark corpus labels. Therefore, when the sample corpus label is an extended corpus label, the distance between the sample corpus and various benchmark corpus categories is more similar, meaning the sample corpus is not biased towards any single benchmark corpus category, thereby improving the training effect of the original classification model.
[0127] Step 306: Determine the target loss value based on the classification loss value and the distance loss value, and adjust the parameters of the original classification model based on the target loss value to obtain the target classification model.
[0128] In one possible implementation, the goal of training the original classification model is to minimize the target loss value. A smaller classification loss value results in a smaller error in the original classification model, while a larger distance loss value results in a smaller error. Therefore, when determining the target loss value based on the classification and distance loss values, the target loss value can be obtained by summing the reciprocals of the classification and distance loss values; alternatively, it can be obtained by subtracting the classification and distance loss values; or it can be obtained by weighting the reciprocals of the classification and distance loss values. This embodiment does not limit the approach. Adjusting the parameters of the original classification model based on the target loss value can involve adjusting the parameters of the encoding layer of the original classification model.
[0129] Step 307: Obtain the target corpus, input the target corpus into the target classification model, and obtain the target corpus label of the target corpus.
[0130] The target corpus is the corpus whose labels need to be determined, and this corpus can be automatically captured. By acquiring a baseline label set and a sample label set, multiple baseline corpora corresponding to the baseline label set and multiple sample corpora corresponding to the sample label set are obtained. Since the sample label set includes all baseline corpus labels and extended corpus labels (extended corpus labels indicate corpus categories other than the baseline corpus categories, meaning other corpus categories may also exist in the sample corpus), training the target classification model based on the baseline and sample corpora can enable it to identify corpus categories other than the baseline corpus categories, thereby improving the generalization effect of the target classification model. When using the target classification model to determine the target corpus labels, the accuracy of the target corpus labels can be improved. Furthermore, a distance loss value is introduced during the training of the target classification model. When the sample corpus does not belong to any baseline corpus category, the distance between the sample corpus and different baseline corpus labels becomes more uniform, thereby improving the training effect of the target classification model, improving its performance, and further improving the accuracy of determining corpus labels.
[0131] The following specific example illustrates the principle of obtaining the target classification model by adjusting the parameters of the original classification model based on the target loss value in the embodiments of this application.
[0132] Reference Figure 5 , Figure 5This is a flowchart illustrating the process of adjusting the parameters of the original classification model according to an embodiment of this application. The baseline label set includes three types of baseline corpus labels, used to indicate categories A, B, and C, respectively. Correspondingly, the baseline corpus set includes baseline corpora for categories A, B, and C. The sample label set includes the aforementioned three types of baseline corpus labels and extended corpus labels. The extended corpus labels are used to indicate category Other. Correspondingly, the sample corpus set includes sample corpora for categories A, B, C, and Other. Of course, the specific category of the sample corpora for category Other can be arbitrary, and the more types of sample corpora for category Other, the better the adjustment effect on the parameters of the original classification model. Next, an arbitrary sample corpus is extracted from the sample corpus set, and baseline corpora corresponding to categories A, B, and C are extracted from the baseline corpus set respectively, forming a corpus data set with the sample corpus. Next, the corpus dataset is input into the original classification model. An encoding layer encodes the sample corpus and the baseline corpus for each category, resulting in sample corpus vectors and baseline corpus vectors for each category. If multiple baseline corpus vectors exist for the same category, they can be weighted to obtain the corresponding corpus label vector for that category. Then, the similarity between the sample corpus vectors and each baseline corpus vector is calculated. Based on the similarity, the sample classification result vector is determined, and then the classification loss and distance loss values are calculated. Based on the classification loss and distance loss values, the target loss value is determined, and the parameters of the original classification model are adjusted according to the target loss value.
[0133] In one possible implementation, when obtaining multiple benchmark corpora corresponding to the benchmark tag set, the data can be provided by a target object. The target object can be an object with the authority to provide sample corpora, such as a user. Specifically, a corpus input interface can be displayed; multiple candidate corpora input from the corpus input interface can be obtained; the candidate corpora can be segmented to obtain multiple candidate keywords; the candidate keyword that matches any benchmark corpus tag in the benchmark tag set can be used as the target keyword, and the target keyword can be highlighted in the corpus input interface; when there is at least one highlighted target keyword in the candidate corpus, the candidate corpus is used as the benchmark corpus corresponding to the benchmark tag set.
[0134] Specifically, refer to Figure 6 , Figure 6This is a schematic diagram of the corpus input interface provided in this application embodiment. The corpus input interface includes a corpus input box 601. The target object can input corresponding candidate corpus through the corpus input box 601 according to the corpus intent. The corpus input interface also includes a batch import button 602, allowing the target object to import multiple candidate corpora at once. After receiving the candidate corpus input by the target object, the server or terminal performs word segmentation processing on the candidate corpus to obtain multiple candidate keywords. For example, if the candidate corpus is "which day this month is suitable for moving," the candidate keywords obtained after word segmentation are "this month," "which day," "suitable," and "move." Matching the candidate keywords with the baseline corpus tags can be semantically matched. Specifically, this can be achieved by obtaining a preset correspondence table between the baseline corpus tags and multiple keywords. By searching the correspondence table, it can be determined whether the candidate keyword exists in the table. If it exists, it indicates that the candidate keyword matches the baseline corpus tag. For example, if one of the baseline corpus tags in the baseline tag set is "check the Chinese calendar", then the candidate keywords that match the baseline corpus tag "check the Chinese calendar" are "this month", "which day", and "move". "This month", "which day", and "move" are the target keywords. At this time, "this month", "which day", and "move" can be highlighted in the corpus input interface. Since the baseline corpus tags are generally fixed, while the candidate corpus is input by the target object, the input by the target object is not necessarily the candidate corpus that matches the baseline corpus tag. For example, the target object may input the candidate corpus "Have you eaten?", which is obviously not a match with the baseline corpus tag "check the Chinese calendar". Figure 6 The processing principles for the remaining candidate corpora are similar and will not be elaborated here.
[0135] Therefore, by matching each candidate keyword in the candidate corpus with the labels of the baseline corpus, and highlighting the matched target keywords, when at least one highlighted target keyword exists in the candidate corpus, the candidate corpus is used as the baseline corpus corresponding to the baseline label set. This allows for the validation of the candidate corpus input by the target audience, thereby improving the accuracy and rationality of the baseline corpus. Furthermore, by highlighting target keywords in the corpus input interface, if the candidate corpus input by the target audience does not contain a highlighted target keyword, it indicates that the candidate corpus does not meet the requirements, thus serving as a reminder to the target audience.
[0136] In one possible implementation, after training the original classification model to obtain the target classification model, the target corpus label can be determined using the target classification model. This involves inputting the target corpus into the target classification model to obtain its target corpus label. The principle behind determining the target corpus label is similar to that of determining the sample classification result vector of the sample corpus. Specifically, the target corpus can be input into the target classification model, encoded to obtain a target corpus vector, and the corpus label vectors of each baseline corpus label can be obtained. A second vector similarity is determined between the target corpus vector and each corpus label vector. Based on the second vector similarity, the target classification result vector corresponding to the target corpus is obtained. The target probability value is compared with a preset probability threshold, and the target corpus label is obtained based on the comparison result.
[0137] The target classification result vector includes the target probability value of the target corpus belonging to various benchmark corpus categories. That is, the target classification result vector is similar to the sample classification result vector. After determining the second vector similarity between the target corpus vector and each corpus label vector, the second vector similarity can be normalized to obtain the target classification result vector.
[0138] When at least one target probability value is greater than a preset probability threshold, the target corpus label is determined to be the benchmark corpus label corresponding to the benchmark corpus category with the highest target probability value. For example, suppose the target classification result vector is (0.8, 0.6, 0.85), that is, the probability of the target corpus belonging to category A is 0.8, the probability of belonging to category B is 0.75, and the probability of belonging to category C is 0.85. The preset probability threshold can be 0.7. Then the benchmark corpus category with the highest target probability value is category C, and the target corpus label of the target corpus can be determined to be (0,0,1). It is understood that the probability threshold can be determined according to the actual situation. In addition to 0.7, it can also be 0.75, 0.8, etc., and this application embodiment does not limit it.
[0139] Based on this, when all target probability values are less than or equal to the probability threshold, the target corpus label is determined to be the extended corpus label. For example, suppose the target classification result vector is (0.56, 0.6, 0.58), meaning the probability of the target corpus belonging to category A is 0.56, the probability of belonging to category B is 0.6, and the probability of belonging to category C is 0.58. Then, all target probability values are less than 0.7, indicating that the target corpus does not belong to any of the categories A, B, and C. Therefore, the target corpus label for this target corpus is determined to be (0,0,0).
[0140] Because a distance loss value was introduced when adjusting the parameters of the original classification model, the target probability values of the target corpus belonging to various benchmark corpus categories will differ little when the target corpus does not belong to any of the benchmark corpus categories. Therefore, by introducing a probability threshold, the target probability value can be truncated based on the probability threshold, thereby completing the identification of target corpus of the Other category. This can achieve the recognition effect of open domain and improve the accuracy of the identified target corpus labels.
[0141] In one possible implementation, when each benchmark corpus label corresponds to multiple benchmark corpora, similar to obtaining the corpus label vectors of each benchmark corpus label during the process of adjusting the parameters of the original classification model, when obtaining the corpus label vectors of each benchmark corpus label during the process of determining the target corpus label, multiple benchmark corpora can be input into the target classification model to encode each benchmark corpus, obtaining the benchmark corpus vector of each benchmark corpus; the benchmark corpus vectors under the same benchmark corpus label can be concatenated to obtain the corpus label vector of the corresponding benchmark corpus label; or, the benchmark corpus vectors under the same benchmark corpus label can be weighted to obtain the corpus label vector of the corresponding benchmark corpus label; or, the corresponding vector elements in the benchmark corpus vectors under the same benchmark corpus label can be summed to obtain the corpus label vector of the corresponding benchmark corpus label.
[0142] In one possible implementation, the corpus label vectors of each benchmark corpus label obtained during the adjustment of the parameters of the original classification model can also be pre-placed in the target classification model. When using the target classification model to determine the target corpus label of the target corpus, the pre-placed corpus label vectors can be read directly.
[0143] The following specific example illustrates the principle of determining the target corpus label of the target corpus in the embodiments of this application.
[0144] Reference Figure 7 , Figure 7This flowchart illustrates the process of determining target corpus labels for a given target corpus, as provided in this embodiment. The baseline label set includes three types of baseline corpus labels, used to indicate categories A, B, and C, respectively. Correspondingly, the baseline corpus set includes baseline corpora for categories A, B, and C. The target corpus set includes multiple target corpora of unknown types. Next, any target corpus is extracted from the target corpus set, and baseline corpora for categories A, B, and C are extracted from the baseline corpus set, forming a corpus data set with the target corpus. The corpus data set is then input into a target classification model. An encoding layer encodes the target corpus and the baseline corpora for each category, obtaining the target corpus vector and the baseline corpus vectors for each category. If there are multiple baseline corpus vectors for the same category, they can be weighted to obtain the corresponding corpus label vector for that category. Finally, the similarity between the target corpus vector and each baseline corpus vector is calculated, and the target classification result vector is determined based on the similarity. Finally, the target corpus labels are determined by combining probability thresholds.
[0145] In one possible implementation, the target corpus label is determined and can be used to expand the training sample. Specifically, when the target corpus label is any one of multiple benchmark corpus labels, that is, when the category of the target corpus is one of the benchmark corpus categories, the corpus confidence of the target corpus is determined according to the target classification result vector. When the corpus confidence is greater than or equal to a preset confidence threshold, the target corpus and the target corpus label are determined as target training data. The first model to be trained is initialized, and the parameters of the first model to be trained are adjusted according to the target training data to obtain the corpus recognition model.
[0146] The confidence level of the target corpus can be determined by the distribution of target probability values. The confidence level can be the average difference between two target probability values in the target classification result vector, or the highest target probability value in the target classification result vector. For example, when the target classification result vector is (0.8, 0.6, 0.85), the differences between the two target probability values are 0.2, 0.25, and 0.05, so the confidence level could be (0.2 + 0.25 + 0.05) / 3 = 0.17, or it could be 0.85. It is understood that the confidence threshold can be determined according to different calculation methods for corpus confidence, and this embodiment does not limit it.
[0147] The first model to be trained differs from the original classification model. The target classification model, obtained by training the original classification model, can be used to expand the training samples of the first model to be trained; the target training data is the expanded training sample. Similarly, the corpus recognition model can be used to classify the corpus to be recognized. The corpus recognition model and the target classification model are two independent models with different functions.
[0148] Based on the target corpus being one of the base corpus categories, the confidence level of the target corpus is further determined. By comparing the confidence level of the target corpus with a confidence threshold, the target corpus labels can be made more accurate, improving the rationality of the target corpus labels. This results in better expansion of the training samples of the first model to be trained.
[0149] It should be noted that the confidence threshold and the aforementioned probability threshold are two independent thresholds. The probability threshold is used to truncate the target corpus of the Other category, while the confidence threshold is used to further filter the target corpus of the benchmark corpus category. Of course, the values of the confidence threshold and the probability threshold can be equal, and this application does not limit them.
[0150] Referring to Table 1, which is a comparison table of model performance for different processing methods provided in the embodiments of this application, it can be seen from ablation experiments 0 and 1 that compared to adding extended corpus labels to both the baseline label set and the sample label set, adding extended corpus labels only to the sample label set significantly improves the performance of the trained target classification model. This also indicates that the corpus of the Other category is an open domain and does not have a unified class center. In addition, it can be seen from ablation experiments 1 and 2 that adding distance loss values to train the original classification model also significantly improves the performance of the trained target classification model.
[0151] Table 1
[0152]
[0153] Referring to Table 2, which compares the performance of the target classification model provided in this application embodiment with that of classification models in related technologies, it can be seen that the overall performance of the target classification model provided in this application embodiment is improved compared to the classification method of sentence pair matching using ES search in related technologies.
[0154] Table 2
[0155]
[0156]
[0157] In one possible implementation, after obtaining the corpus recognition model, the corpus to be recognized can be acquired, input into the corpus recognition model, and the corpus to be recognized can be recognized to obtain a first recognition result; the corpus to be recognized can be input into the key semantic recognition model, and the corpus to be recognized can be recognized to obtain a second recognition result; and the target recognition result of the corpus to be recognized can be obtained based on the first recognition result and the second recognition result.
[0158] The corpus to be identified is the corpus to be classified in practical applications. The key semantic recognition model is pre-trained based on the target training data and is used to determine the semantic information of the corpus to be identified. That is, the target training data can be used to train both the corpus recognition model and the key semantic recognition model.
[0159] Key semantics can be the semantics of keywords in the corpus to be identified. For example, if the corpus to be identified is "Which day this month is suitable for moving?", the key semantics could be "time". If the corpus to be identified is "Can I get married next week?", the key semantics could be "zodiac sign". Furthermore, key semantics can be... Figure 6 The corpus input interface shown is displayed.
[0160] Based on the first recognition result obtained by using a corpus recognition model to identify the corpus to be identified, a second recognition result is obtained by further using a key semantic recognition model to identify the corpus to be identified, and thus the target recognition result is obtained, which can make the target recognition result contain richer information. In one possible implementation, the target recognition result can be a combination of the first recognition result and the second recognition result, and when displaying the target recognition result, the first recognition result and the second recognition result can be displayed simultaneously.
[0161] In one possible implementation, when obtaining the target recognition result of the corpus to be recognized based on the first and second recognition results, a third recognition result can be further introduced. Specifically, historical corpus and historical recognition results of the historical corpus can be obtained. The historical corpus and the corpus to be recognized are segmented to obtain multiple first words in the historical corpus and multiple second words in the corpus to be recognized. Each first word and each second word is encoded to obtain a first word vector corresponding to each first word and a second word vector corresponding to each second word. The first average vector corresponding to the multiple first word vectors and the second average vector corresponding to the multiple second word vectors are calculated. The third vector similarity between the first average vector and the second average vector is determined. When the third vector similarity is greater than or equal to a preset second similarity threshold, the historical recognition result is used as the third recognition result of the corpus to be recognized. The target recognition result of the corpus to be recognized is obtained based on the first, second, and third recognition results.
[0162] The historical corpus consists of corpora that have been identified before the corpus to be identified. For example, the corpus to be identified could be "When do I eat breakfast in the morning?", and the historical corpus could be "What time do I eat today?". The historical corpus is segmented into words, resulting in the first words "today", "what time", and "eat". The corpus to be identified is segmented into words, resulting in the second words "morning", "when", and "eat breakfast". The first words "today", "what time", and "eat" are then encoded to obtain the first word vectors corresponding to "today", "what time", and "eat". Similarly, the second words "morning", "when", and "eat breakfast" are encoded to obtain the second word vectors corresponding to "morning", "when", and "eat breakfast". Next, the first average vectors of the first word vectors corresponding to "today", "what time", and "eat" are calculated. The second average vectors of the second word vectors corresponding to "morning", "when", and "eat breakfast" are calculated. The third vector similarity between the first and second average vectors is calculated using methods such as cosine similarity or Euclidean distance. When the third vector similarity is greater than or equal to the preset second similarity threshold, it indicates that the historical recognition results of the historical corpus are of reference value for the corpus to be recognized. Therefore, the target recognition result of the corpus to be recognized can be obtained based on the first, second, and third recognition results, thereby further enriching the information contained in the target recognition result.
[0163] It is understood that the second similarity threshold can be determined according to the actual situation, such as 0.9, 0.8, etc., and this application embodiment does not limit it.
[0164] In one possible implementation, when obtaining the target recognition result of the corpus to be recognized based on the first recognition result and the second recognition result, a fourth recognition result can be further introduced. Specifically, multiple preset candidate corpus templates can be obtained, and a target corpus template that matches the corpus to be recognized can be obtained from the multiple candidate corpus templates. The target corpus template is input into the corpus recognition model, and the target corpus template is recognized to obtain the fourth recognition result. The target recognition result of the corpus to be recognized is obtained based on the first recognition result, the second recognition result and the fourth recognition result.
[0165] The candidate corpus template is a pre-set reference corpus. By determining the semantic similarity between the candidate corpus template and the corpus to be identified, a target corpus template matching the corpus to be identified can be obtained from multiple candidate corpus templates. For example, the candidate corpus template can be segmented to obtain multiple third words, each third word can be encoded to obtain multiple third word vectors, the third average vector of the multiple third word vectors can be calculated, and the fourth vector similarity between the second average vector and the third average vector can be determined. When the fourth vector similarity is greater than or equal to the pre-set third similarity threshold, the candidate corpus template is determined as the target corpus template. Since the target corpus template matches the corpus to be identified, the fourth recognition result obtained by inputting the target corpus template into the corpus recognition model is referential for the corpus to be identified. Therefore, the target recognition result of the corpus to be identified can be obtained based on the first recognition result, the second recognition result, and the fourth recognition result, thereby further enriching the information contained in the target recognition result.
[0166] In addition, after obtaining the target corpus template that matches the corpus to be identified from multiple candidate corpus templates, the preset fourth identification result corresponding to the target corpus template can also be obtained. That is, the preset fourth identification result corresponding to the target corpus template has been predetermined and stored, thereby improving the efficiency of obtaining the fourth identification result.
[0167] In addition, the target recognition results of the corpus to be recognized can be obtained based on the first recognition result, the second recognition result, the third recognition result and the fourth recognition result, thereby further enriching the information contained in the target recognition results.
[0168] The following example illustrates the practical application scenario of the target classification model in this application.
[0169] Reference Figure 8 , Figure 8This diagram illustrates a practical application scenario of the target classification model provided in this application. Specifically, the original classification model is first trained to obtain the target classification model. During the training of the original classification model, a benchmark corpus, which can be a skill-based corpus, can be input by the user. After obtaining the target classification model, the target corpus is captured. Based on the benchmark corpus and the target classification model, the target corpus label is determined, and it is then determined whether the target corpus can serve as an extended training sample. The target corpus that can serve as a training sample is added to the original training sample to achieve the effect of expanding the training sample. Then, the corpus recognition model and the key semantic recognition model are trained separately to obtain the trained corpus recognition model and the key semantic recognition model. The training of the original classification model, the corpus recognition model, and the key semantic recognition model can be performed offline. Next, the online processing flow begins. First, the system receives the corpus to be identified sent online by the terminal. This corpus can be short text queries. The trained corpus recognition model and key semantic recognition model process the corpus to obtain the first and second recognition results. Alternatively, the third and fourth recognition results can be obtained through historical corpus matching and corpus template matching. Finally, the first, second, third, and fourth recognition results are merged to obtain the target recognition result, which is then processed by the downstream processing unit. The downstream processing unit can perform different processing methods depending on the application scenario. For example, in online intelligent dialogue applications, the downstream processing unit can select the corresponding dialogue model based on the target recognition result to obtain a quick and accurate response. Alternatively, in online translation applications, the downstream processing unit can obtain the corresponding matching dictionary based on the target recognition result to obtain a quick and accurate translation result.
[0170] It should be further noted that although the steps in the above flowcharts are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated in this embodiment, there is no strict order restriction for the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the above flowcharts may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages in other steps.
[0171] Reference Figure 9 , Figure 9 This is a schematic diagram of the structure of the corpus tagging device 900 provided in the embodiments of this application. The corpus tagging device 900 includes:
[0172] The tag set acquisition module 901 is used to acquire a benchmark tag set and a sample tag set. The benchmark tag set includes multiple benchmark corpus tags, and different benchmark corpus tags are used to indicate different benchmark corpus categories. The sample tag set includes all benchmark corpus tags and extended corpus tags, and extended corpus tags are used to indicate corpus categories other than the benchmark corpus categories.
[0173] The corpus acquisition module 902 is used to acquire multiple benchmark corpora corresponding to the benchmark label set and multiple sample corpora corresponding to the sample label set.
[0174] Model initialization module 903 is used to initialize the original classification model;
[0175] The first model processing module 904 is used to take any sample corpus and the benchmark corpus corresponding to each benchmark corpus label as a corpus data set, input the corpus data set into the original classification model, and obtain the sample classification result vector corresponding to the sample corpus.
[0176] The loss calculation module 905 is used to calculate the classification loss value based on the sample classification result vector and the sample label set, and to calculate the distance loss value based on the sample classification result vector. The distance loss value is used to characterize the uniformity of the distance between the sample corpus and different benchmark corpus labels.
[0177] The parameter adjustment module 906 is used to determine the target loss value based on the classification loss value and the distance loss value, and adjust the parameters of the original classification model based on the target loss value to obtain the target classification model;
[0178] The second model processing module 907 is used to acquire the target corpus, input the target corpus into the target classification model, and obtain the target corpus label of the target corpus.
[0179] Furthermore, the sample classification result vector includes the sample probability values of the sample corpus belonging to various benchmark corpus categories. The aforementioned loss calculation module is specifically used for:
[0180] Calculate the target logarithm of the probability values for each sample;
[0181] Calculate the product of each sample probability value and the corresponding target logarithm value;
[0182] The distance loss value is calculated by summing the products corresponding to the probability values of each sample.
[0183] Furthermore, the aforementioned model initialization module 903 is specifically used for:
[0184] Obtain a first reference corpus and a second reference corpus, wherein the sentence similarity between the first reference corpus and the second reference corpus is greater than or equal to a preset first similarity threshold;
[0185] The first reference corpus and the second reference corpus are input into the reference model, and the first reference corpus and the second reference corpus are encoded to obtain the first reference corpus vector corresponding to the first reference corpus and the second reference corpus vector corresponding to the second reference corpus.
[0186] Determine the first vector similarity between the first reference corpus vector and the second reference corpus vector, and calculate the reference loss value based on the first vector similarity;
[0187] Adjust the parameters of the reference model based on the reference loss value, and initialize the original classification model based on the adjusted parameters of the reference model.
[0188] Furthermore, the aforementioned corpus acquisition module 902 is specifically used for:
[0189] Display the corpus input interface;
[0190] The system obtains multiple candidate corpora input from the corpus input interface, performs word segmentation on the candidate corpora, and obtains multiple candidate keywords from the candidate corpora.
[0191] Candidate keywords that match any benchmark corpus label in the benchmark label set are used as target keywords, and the target keywords are highlighted in the corpus input interface.
[0192] When there is at least one highlighted target keyword in the candidate corpus, the candidate corpus is used as the benchmark corpus corresponding to the benchmark tag set.
[0193] Furthermore, the aforementioned second model processing module 907 is specifically used for:
[0194] The target corpus is input into the target classification model, and the target corpus is encoded to obtain the target corpus vector;
[0195] Obtain the corpus label vectors for each benchmark corpus label;
[0196] Determine the second vector similarity between the target corpus vector and each corpus label vector, and obtain the target classification result vector corresponding to the target corpus based on the second vector similarity. The target classification result vector includes the target probability value of the target corpus belonging to each benchmark corpus category.
[0197] The target probability value is compared with a preset probability threshold, and the target corpus label is obtained based on the comparison result.
[0198] Furthermore, the aforementioned second model processing module 907 is specifically used for:
[0199] When all target probability values are less than or equal to the preset probability threshold, the target corpus label of the target corpus is determined as the extended corpus label;
[0200] Alternatively, when at least one target probability value is greater than the probability threshold, the target corpus label of the target corpus is determined to be the benchmark corpus label corresponding to the benchmark corpus category with the highest target probability value.
[0201] Furthermore, the aforementioned second model processing module 907 is also used for:
[0202] When the target corpus label is any one of the multiple baseline corpus labels, the corpus confidence of the target corpus is determined based on the target classification result vector;
[0203] When the confidence level of the corpus is greater than or equal to the preset confidence threshold, the target corpus and its labels are determined as the target training data.
[0204] Initialize the first model to be trained, and adjust the parameters of the first model to be trained according to the target training data to obtain the corpus recognition model.
[0205] Furthermore, the aforementioned second model processing module 907 is also used for:
[0206] Obtain the text to be recognized, input the text to be recognized into the text recognition model, recognize the text to be recognized, and obtain the first recognition result;
[0207] The text to be identified is input into the key semantic recognition model, which then identifies the text to be identified and obtains the second recognition result. The key semantic recognition model is pre-trained based on the target training data.
[0208] The target recognition result of the corpus to be recognized is obtained based on the first recognition result and the second recognition result.
[0209] Furthermore, the aforementioned second model processing module 907 is specifically used for:
[0210] Obtain historical corpus and historical recognition results of historical corpus, perform word segmentation on historical corpus and corpus to be recognized to obtain multiple first words of historical corpus and multiple second words of corpus to be recognized;
[0211] Encode each first word and each second word to obtain the first word vector corresponding to each first word and the second word vector corresponding to each second word;
[0212] Calculate the first average vector corresponding to multiple first word vectors and the second average vector corresponding to multiple second word vectors, determine the third vector similarity between the first average vector and the second average vector, and when the third vector similarity is greater than or equal to the preset second similarity threshold, use the historical recognition result as the third recognition result of the corpus to be recognized.
[0213] The target recognition result of the corpus to be recognized is obtained based on the first recognition result, the second recognition result, and the third recognition result.
[0214] Furthermore, the aforementioned second model processing module 907 is specifically used for:
[0215] Obtain multiple preset candidate corpus templates, and then select the target corpus template that matches the corpus to be identified from the multiple candidate corpus templates;
[0216] The target corpus template is input into the corpus recognition model, and the target corpus template is recognized to obtain the fourth recognition result;
[0217] The target recognition result of the corpus to be recognized is obtained based on the first recognition result, the second recognition result, and the fourth recognition result.
[0218] Furthermore, each benchmark corpus label corresponds to multiple benchmark corpora. Furthermore, the aforementioned second model processing module 907 is specifically used for:
[0219] Multiple benchmark corpora are input into the target classification model, and each benchmark corpus is encoded to obtain the benchmark corpus vector of each benchmark corpus;
[0220] To obtain the corresponding corpus label vector, concatenate the corpus vectors under the same corpus label; or, weight the corpus vectors under the same corpus label to obtain the corresponding corpus label vector; or, sum the corresponding vector elements in the corpus vectors under the same corpus label to obtain the corresponding corpus label vector.
[0221] The aforementioned corpus label determination device 900 and corpus label determination method are based on the same inventive concept. Therefore, the corpus label determination device 900 acquires a benchmark label set and a sample label set, acquires multiple benchmark corpora corresponding to the benchmark label set, and acquires multiple sample corpora corresponding to the sample label set. Since the sample label set includes all benchmark corpus labels and extended corpus labels, and the extended corpus labels are used to indicate other corpus categories besides the benchmark corpus categories (i.e., other corpus categories may also exist in the sample corpora), the target classification model trained based on the benchmark corpora and sample corpora can be equipped with the ability to identify corpora of other categories, thereby improving the generalization effect of the target classification model. When using the target classification model to determine the target corpus labels of the target corpus, the accuracy of the target corpus labels can be improved. Furthermore, a distance loss value is introduced during the training of the target classification model. When the sample corpus does not belong to any benchmark corpus category, the distance between the sample corpus and different benchmark corpus labels can be made more uniform, thereby improving the training effect of the target classification model, thus improving the performance of the target classification model, and further improving the accuracy of determining corpus labels.
[0222] The electronic device provided in this application embodiment for executing the above-described corpus tag determination method can be a terminal, as shown below. Figure 10 , Figure 10 This is a partial structural block diagram of a terminal provided in an embodiment of this application. The terminal includes: a radio frequency (RF) circuit 1010, a memory 1020, an input unit 1030, a display unit 1040, a sensor 1050, an audio circuit 1060, a wireless fidelity (WiFi) module 1070, a processor 1080, and a power supply 1090, among other components. Those skilled in the art will understand that... Figure 10 The terminal structure shown does not constitute a limitation on the terminal and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0223] The RF circuit 1010 can be used to receive and transmit signals during information transmission or calls. In particular, it receives downlink information from the base station and processes it with the processor 1080; in addition, it transmits uplink data to the base station.
[0224] The memory 1020 can be used to store software programs and modules. The processor 1080 executes various functional applications and data processing of the terminal by running the software programs and modules stored in the memory 1020.
[0225] The input unit 1030 can be used to receive input numeric or character information, and to generate key signal inputs related to the terminal's settings and function control. Specifically, the input unit 1030 may include a touch panel 1031 and other input devices 1032.
[0226] The display unit 1040 can be used to display input or provided information, as well as various menus of the terminal. The display unit 1040 may include a display panel 1041.
[0227] Audio circuitry 1060, speaker 1061, and microphone 1062 provide an audio interface.
[0228] In this embodiment, the processor 1080 included in the terminal can execute the corpus tag determination method of the previous embodiment.
[0229] The electronic device provided in this application embodiment for performing the above-described corpus tag determination method can also be a server, see reference. Figure 11 , Figure 11 The diagram illustrates a partial structural block of a server provided in this application embodiment. The server 1100 can vary significantly due to different configurations or performance characteristics. It may include one or more Central Processing Units (CPUs) 1122 (e.g., one or more processors) and a memory 1132, and one or more storage media 1130 (e.g., one or more mass storage devices) for storing application programs 1142 or data 1144. The memory 1132 and storage media 1130 may be temporary or persistent storage. The program stored in the storage media 1130 may include one or more modules (not shown in the diagram), each module including a series of instruction operations on the server 1100. Furthermore, the CPU 1122 may be configured to communicate with the storage media 1130 and execute the series of instruction operations in the storage media 1130 on the server 1100.
[0230] Server 1100 may also include one or more power supplies 1126, one or more wired or wireless network interfaces 1150, one or more input / output interfaces 1158, and / or one or more operating systems 1141, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, etc.
[0231] The processor in server 1100 can be used to execute the corpus label determination method.
[0232] This application also provides a computer-readable storage medium for storing program code for executing the corpus tag determination method of the foregoing embodiments.
[0233] This application also provides a computer program product, which includes a computer program stored in a computer-readable storage medium. A processor of a computer device reads the computer program from the computer-readable storage medium and executes the computer program, causing the computer device to perform the corpus tag determination method described above.
[0234] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented, for example, in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatuses.
[0235] It should be understood that in this application, "at least one (item)" means one or more, and "more than" means two or more. "And / or" is used to describe the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one (item) of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one (item) of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.
[0236] It should be understood that in the description of the embodiments of this application, "multiple" means two or more, "greater than", "less than", "exceeding" etc. are understood to exclude the number itself, and "above", "below", "within" etc. are understood to include the number itself.
[0237] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, or indirect coupling or communication connection between apparatuses or units, and may be electrical, mechanical, or other forms.
[0238] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0239] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0240] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0241] It should also be understood that the various implementation methods provided in this application can be combined arbitrarily to achieve different technical effects.
[0242] The above provides a detailed description of the preferred embodiments of this application. However, this application is not limited to the above-described embodiments. Those skilled in the art can make various equivalent modifications or substitutions without departing from the spirit of this application. All such equivalent modifications or substitutions are included within the scope defined by the claims of this application.
Claims
1. A method for determining corpus tags, characterized in that, include: Obtain a baseline tag set and a sample tag set, wherein the baseline tag set includes multiple baseline corpus tags, which are used to indicate baseline corpus categories; the sample tag set includes extended corpus tags and all the baseline corpus tags, which are used to indicate corpus categories other than the baseline corpus categories. Obtain multiple benchmark corpora corresponding to the benchmark label set, and obtain multiple sample corpora corresponding to the sample label set; Initialize the original classification model; Any sample corpus and the benchmark corpus corresponding to each benchmark corpus label are used as a corpus data set. The corpus data set is input into the original classification model. The sample classification result vector corresponding to the sample corpus is obtained based on the vector similarity between the benchmark corpus vector corresponding to the benchmark corpus and the sample corpus vector corresponding to the sample corpus. The sample classification result vector includes the sample probability value of the sample corpus belonging to each of the benchmark corpus categories. A classification loss value is calculated based on the sample classification result vector and the sample label set, and a distance loss value is calculated based on the sample classification result vector, wherein the distance loss value is used to characterize the uniformity of the distance between the sample corpus and each of the benchmark corpus labels; The target loss value is determined based on the classification loss value and the distance loss value. The parameters of the original classification model are adjusted based on the target loss value to obtain the target classification model. Obtain the target corpus, input the target corpus into the target classification model, and obtain the target corpus label of the target corpus.
2. The corpus tag determination method according to claim 1, characterized in that, The step of calculating the distance loss value based on the sample classification result vector includes: Calculate the target logarithm value of each of the sample probability values; Calculate the product of each sample probability value and the corresponding target logarithm value; The distance loss value is calculated based on the sum of the products corresponding to the probability values of each sample.
3. The corpus tag determination method according to claim 1, characterized in that, The initialization of the original classification model includes: Obtain a first reference corpus and a second reference corpus, wherein the sentence similarity between the first reference corpus and the second reference corpus is greater than or equal to a preset first similarity threshold; The first reference corpus and the second reference corpus are input into the reference model, and the first reference corpus and the second reference corpus are encoded to obtain the first reference corpus vector corresponding to the first reference corpus and the second reference corpus vector corresponding to the second reference corpus. Determine the first vector similarity between the first reference corpus vector and the second reference corpus vector, and calculate the reference loss value based on the first vector similarity; The parameters of the reference model are adjusted based on the reference loss value, and the original classification model is initialized based on the adjusted parameters of the reference model.
4. The corpus tag determination method according to claim 1, characterized in that, The step of obtaining multiple benchmark corpora corresponding to the benchmark tag set includes: Display the corpus input interface; Multiple candidate corpora input from the corpus input interface are obtained, and the candidate corpora are segmented to obtain candidate keywords. The candidate keyword that matches any of the benchmark corpus tags in the benchmark tag set is taken as the target keyword, and the target keyword is highlighted in the corpus input interface; When at least one of the target keywords is highlighted in the candidate corpus, the candidate corpus is used as the benchmark corpus corresponding to the benchmark tag set.
5. The corpus tag determination method according to any one of claims 1 to 4, characterized in that, The step of inputting the target corpus into the target classification model to obtain the target corpus label includes: The target corpus is input into the target classification model, and the target corpus is encoded to obtain a target corpus vector; Obtain the corpus tag vectors for each of the aforementioned benchmark corpus tags; Determine the second vector similarity between the target corpus vector and each of the corpus label vectors, and obtain the target classification result vector corresponding to the target corpus based on the second vector similarity, wherein the target classification result vector includes the target probability value of the target corpus belonging to each of the benchmark corpus categories; The target probability value is compared with a preset probability threshold, and the target corpus label is obtained based on the comparison result.
6. The corpus tag determination method according to claim 5, characterized in that, The step of obtaining the target corpus label based on the comparison result includes: When all the target probability values are less than or equal to a preset probability threshold, the target corpus label of the target corpus is determined to be the extended corpus label; Alternatively, when at least one of the target probability values is greater than the probability threshold, the target corpus label of the target corpus is determined to be the benchmark corpus label corresponding to the benchmark corpus category with the largest target probability value.
7. The corpus tag determination method according to claim 5, characterized in that, The method further includes: When the target corpus label is any one of multiple benchmark corpus labels, the corpus confidence of the target corpus is determined based on the target classification result vector; When the confidence level of the corpus is greater than or equal to a preset confidence threshold, the target corpus and the target corpus labels are determined as target training data; Initialize the first model to be trained, and adjust the parameters of the first model to be trained according to the target training data to obtain the corpus recognition model.
8. The corpus tag determination method according to claim 7, characterized in that, The method further includes: Obtain the text to be identified, input the text to be identified into the text recognition model, and recognize the text to be identified to obtain a first recognition result; The text to be identified is input into the key semantic recognition model, and the text to be identified is recognized to obtain a second recognition result. The key semantic recognition model is pre-trained based on the target training data. The target recognition result of the corpus to be recognized is obtained based on the first recognition result and the second recognition result.
9. The corpus tag determination method according to claim 8, characterized in that, The step of obtaining the target recognition result of the corpus to be recognized based on the first recognition result and the second recognition result includes: Obtain historical corpus and the historical recognition results of the historical corpus, perform word segmentation on the historical corpus and the corpus to be recognized, and obtain multiple first words of the historical corpus and multiple second words of the corpus to be recognized; Encode each first word and each second word to obtain a first word vector corresponding to each first word and a second word vector corresponding to each second word; Calculate the first average vector corresponding to multiple first word vectors and the second average vector corresponding to multiple second word vectors, determine the third vector similarity between the first average vector and the second average vector, and when the third vector similarity is greater than or equal to a preset second similarity threshold, use the historical recognition result as the third recognition result of the corpus to be recognized; The target recognition result of the corpus to be recognized is obtained based on the first recognition result, the second recognition result, and the third recognition result.
10. The corpus tag determination method according to claim 8, characterized in that, The step of obtaining the target recognition result of the corpus to be recognized based on the first recognition result and the second recognition result includes: Obtain multiple preset candidate corpus templates, and obtain a target corpus template that matches the corpus to be identified from the multiple candidate corpus templates; The target corpus template is input into the corpus recognition model, and the target corpus template is recognized to obtain a fourth recognition result; The target recognition result of the corpus to be recognized is obtained based on the first recognition result, the second recognition result and the fourth recognition result.
11. The corpus tag determination method according to claim 5, characterized in that, Each of the aforementioned benchmark corpus tags corresponds to multiple benchmark corpora. The step of obtaining the corpus tag vector for each benchmark corpus tag includes: Multiple benchmark corpora are input into the target classification model, and each benchmark corpus is encoded to obtain a benchmark corpus vector for each benchmark corpus. The benchmark corpus vectors under the same benchmark corpus label are concatenated to obtain the corpus label vector of the corresponding benchmark corpus label; or, the benchmark corpus vectors under the same benchmark corpus label are weighted to obtain the corpus label vector of the corresponding benchmark corpus label; or, the corresponding vector elements in the benchmark corpus vectors under the same benchmark corpus label are summed to obtain the corpus label vector of the corresponding benchmark corpus label.
12. A corpus tagging device, characterized in that, include: The tag set acquisition module is used to acquire a benchmark tag set and a sample tag set. The benchmark tag set includes multiple benchmark corpus tags, which are used to indicate benchmark corpus categories. The sample tag set includes extended corpus tags and all the benchmark corpus tags, which are used to indicate corpus categories other than the benchmark corpus categories. The corpus acquisition module is used to acquire multiple benchmark corpora corresponding to the benchmark label set and multiple sample corpora corresponding to the sample label set. The model initialization module is used to initialize the original classification model. The first model processing module is used to take any one of the sample corpora and the benchmark corpora corresponding to each of the benchmark corpora labels as a corpus data set, input the corpus data set into the original classification model, and obtain the sample classification result vector corresponding to the sample corpora based on the vector similarity between the benchmark corpus vector corresponding to the benchmark corpora and the sample corpus vector corresponding to the sample corpora. The sample classification result vector includes the sample probability value of the sample corpora belonging to various benchmark corpus categories. The loss value calculation module is used to calculate a classification loss value based on the sample classification result vector and the sample label set, and to calculate a distance loss value based on the sample classification result vector, wherein the distance loss value is used to characterize the uniformity of the distance between the sample corpus and each of the benchmark corpus labels; The parameter adjustment module is used to determine the target loss value based on the classification loss value and the distance loss value, and adjust the parameters of the original classification model based on the target loss value to obtain the target classification model; The second model processing module is used to acquire the target corpus, input the target corpus into the target classification model, and obtain the target corpus label of the target corpus.
13. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the corpus tag determination method according to any one of claims 1 to 11.
14. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the corpus tag determination method according to any one of claims 1 to 11.
15. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the corpus tag determination method according to any one of claims 1 to 11.
Citation Information
Patent Citations
Model training method and device for named entity recognition, and recognition method and device
CN113298253A