Text category detection method and device, equipment, medium and product
By using a large model to determine the correlation between the text to be detected and the preset vocabulary and the correlation between the extended tags, the problem of inaccurate classification in zero-shot text category detection is solved, and high-accuracy text category detection is achieved.
Patent Information
- Application Number
- CN202411541023.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-31
- Publication Date
- 2026-02-10
AI Technical Summary
In existing technologies, neural network models require a large amount of labeled data for training when detecting text categories, which leads to inaccurate classification results in the case of zero samples.
The correlation between the text to be detected and the pre-defined vocabulary is determined by a large model. The labels are expanded and their correlation with the category to be detected and the prediction information are determined. The text category is determined by combining the correlation and prediction information.
This enables text classification without training a large model, improving detection accuracy and versatility under zero-shot conditions.
Smart Images

Figure CN121501993A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the technical field of data processing, and in particular, to a text category detection method, device, equipment, medium and product. BACKGROUND
[0002] With the development of the Internet, the application range of text processing is gradually expanding, at which time the demand for text transmission is also increasingly high. In various application fields of text processing, the security and management of text data are indispensable links. For example, in the related art, a text can be subjected to security inspection through type detection of the text to achieve management of the text.
[0003] In the related art, a neural network model is usually used to detect the category of a text. However, the neural network model needs to be trained through a large amount of labeled data before use. If the training data of a certain text category is less, the classification result of the trained neural network model will be inaccurate. SUMMARY
[0004] The present disclosure is proposed in view of the above problems. The present disclosure provides a text category detection method, device, equipment, medium and product.
[0005] According to one aspect of the present disclosure, a text category detection method is provided, comprising:
[0006] determining first prediction information of a to-be-detected text by a large model; wherein the first prediction information is used to indicate the correlation between the to-be-detected text and each preset word in a preset word table;
[0007] labeling extension is performed on a to-be-detected category of the to-be-detected text to obtain a first extended label;
[0008] determining a first correlation between the first extended label and each to-be-detected category, and determining prediction information of the first extended label based on the first prediction information to obtain second prediction information; the second prediction information is used to indicate the correlation between the first extended label and the to-be-detected text;
[0009] determining a text category of the to-be-detected text based on the first correlation and the second prediction information.
[0010] In addition, according to another embodiment of one aspect of the present disclosure, the determination of the text category of the to-be-detected text based on the first correlation and the second prediction information comprises:
[0011] determine a weight of a second extended label in the first extended labels according to the first correlations, wherein the weight is used to indicate a contribution degree of the second extended label to determining a category of the to-be-detected text as each to-be-detected category by the large model, the second extended label being an extended label in the first extended labels that meets a similarity requirement with the preset word;
[0012] determine the text category of the to-be-detected text based on the second prediction information of the second extended label and the weight.
[0013] In addition, in another embodiment according to one aspect of the present disclosure, the determining the text category of the to-be-detected text based on the second prediction information of the second extended label and the weight includes:
[0014] determine a second correlation between each to-be-detected category and the to-be-detected text by the large model;
[0015] determine the text category of the to-be-detected text based on the second prediction information of the second extended label, the weight, and the second correlation.
[0016] In addition, in another embodiment according to one aspect of the present disclosure, the determining the weight of the second extended label according to the first correlations includes:
[0017] screen an extended label that meets a similarity threshold between the preset word from the first extended labels to obtain a second extended label;
[0018] calculate the weight of the second extended label based on a first correlation corresponding to the second extended label.
[0019] In addition, in another embodiment according to one aspect of the present disclosure, the calculating the weight of the second extended label based on the first correlation corresponding to the second extended label includes:
[0020] perform calculation on the first correlation corresponding to the second extended label to obtain an average conditional probability value of the second extended label;
[0021] determine the weight of the second extended label based on the first correlation corresponding to the second extended label and the average conditional probability value.
[0022] In addition, in another embodiment according to one aspect of the present disclosure, the determining the text category of the to-be-detected text based on the second prediction information of the second extended label, the weight, and the second correlation includes:
[0023] determine a third extended label based on the second prediction information of the second extended label, the weight, and the second correlation, wherein the third extended label is a second extended label that meets the prediction requirement and the weight requirement;
[0024] determine the text category of the text to be detected based on the second prediction information corresponding to the third extended label, the weight, and the second correlation.
[0025] In addition, in another embodiment according to one aspect of the present disclosure, the determining the text category of the text to be detected based on the second prediction information of the second extended label, the weight, and the second correlation comprises:
[0026] calculate the product of the weight of the second extended label and the second prediction information of the second extended label, and perform summation operation on the products of all the second extended labels to obtain a first operation result;
[0027] perform addition operation on the first operation result and the second correlation to obtain a second operation result, wherein the second operation result is used to indicate the association degree between the text to be detected and each of the categories to be detected;
[0028] determine the text category of the text to be detected based on the second operation result.
[0029] In addition, in another embodiment according to one aspect of the present disclosure, the determining the text category of the text to be detected based on the second operation result comprises:
[0030] the maximum operation result in the second operation result;
[0031] determine the category word corresponding to the maximum operation result as the text category of the text to be detected.
[0032] In addition, in another embodiment according to one aspect of the present disclosure, the determining the first correlation between the first extended label and each of the categories to be detected comprises:
[0033] input the categories to be detected and the detection requirements of the categories to be detected into a large model for processing to obtain the first correlation between the first extended label and each of the categories to be detected.
[0034] In addition, in another embodiment according to one aspect of the present disclosure, the determining the prediction information of the first extended label based on the first prediction information to obtain second prediction information comprises:
[0035] determine a word that meets the requirement in terms of similarity with each of the first extended labels from the preset words to obtain a target word;
[0036] Determine second prediction information of the first extended label based on the first prediction information of the target word.
[0037] According to another aspect of the present disclosure, a text category detection apparatus is provided, comprising:
[0038] A prediction module is configured to determine first prediction information of a text to be detected by a large model, wherein the first prediction information is used to indicate the correlation between the text to be detected and each preset word in a preset word table;
[0039] An extension module is configured to perform label extension on a category to be detected of the text to be detected to obtain a first extended label;
[0040] A first determination module is configured to determine a first correlation between the first extended label and each category to be detected, and determine prediction information of the first extended label based on the first prediction information to obtain second prediction information, wherein the second prediction information is used to indicate the correlation between the first extended label and the text to be detected;
[0041] A second determination module is configured to determine a text category of the text to be detected based on the first correlation and the second prediction information.
[0042] According to yet another aspect of the present disclosure, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of a log template determination method.
[0043] According to yet another aspect of the present disclosure, a computer readable storage medium is provided, which stores a computer program / instruction, wherein the computer program / instruction is executed by a processor to implement the steps of a log template determination method.
[0044] According to yet another aspect of the present disclosure, a computer program product is provided, comprising a computer program / instruction, wherein the computer program / instruction is executed by a processor to implement the steps of a log template determination method.
[0045] As will be described in detail below, a text category detection method, apparatus, device, medium and product according to embodiments of the present disclosure. In embodiments of the present disclosure, first, a first prediction information of a to-be-detected text is determined by a large model; wherein the first prediction information is used to indicate the correlation between the to-be-detected text and each preset word in a preset word table; then, a to-be-detected category of the to-be-detected text is label extended to obtain a first extended label; next, a first correlation between the first extended label and each to-be-detected category is determined, and a prediction information of the first extended label is determined based on the first prediction information to obtain a second prediction information; wherein the second prediction information is used to indicate the correlation between the first extended label and the to-be-detected text; finally, based on the first correlation and the second prediction information, a text category of the to-be-detected text is determined.
[0046] In the above embodiments, by the way of determining the correlation between the first extended label of the to-be-detected category of the to-be-detected text and the to-be-detected text (i.e., the second prediction information) through the correlation (i.e., the first prediction information) between each preset word in the prediction word table of the large model and the to-be-detected text, the classification of the text can be realized without training the large model, thereby solving the problem that the model cannot be trained in the zero sample case and directly using the large model to predict will cause errors. The technical solution of the present disclosure can be extended according to specific classification scenarios to improve the generality of various detections under zero samples, and has good engineering application prospect and value. By combining the first correlation and the second prediction information, the text category of the to-be-detected text is determined, which can improve the detection accuracy of the to-be-detected text, thereby obtaining a text category with higher accuracy.
[0047] It is to be understood that both the foregoing general description and the following detailed description are exemplary and are intended to provide further explanation of the subject technology. BRIEF DESCRIPTION OF DRAWINGS
[0048] The foregoing and other objects, features and advantages of the present disclosure will become more apparent from the following detailed description, which proceeds with reference to the accompanying drawings. The accompanying drawings are provided to assist in understanding the present disclosure and constitute a part of the specification, together with the detailed description, to explain the present disclosure and, like reference numerals refer to corresponding or like parts throughout the several views of the drawings. The drawings provided are for illustrative purposes only and are not intended to limit the present disclosure.
[0049] Figure 1 A flowchart of a text category detection method provided by embodiments of the present disclosure is shown.
[0050] Figure 2 A flowchart of label extension in a text category detection method provided by embodiments of the present disclosure is shown.
[0051] Figure 3A flow chart of third extension label determination in a text category detection method provided by an embodiment of the present disclosure is shown.
[0052] Figure 4 A flow chart of first prediction information determination in a text category detection method provided by an embodiment of the present disclosure is shown.
[0053] Figure 5 A flow chart of first prediction information determination in a text category detection method provided by an embodiment of the present disclosure is shown.
[0054] Figure 6 A flow chart of a text category detection method provided by an embodiment of the present disclosure is shown.
[0055] Figure 7 A schematic diagram of a text category detection apparatus provided by an embodiment of the present disclosure is shown.
[0056] Figure 8 A schematic diagram of an electronic device provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0057] In order to make the objectives, technical solutions and advantages of the present disclosure more apparent, the following will describe example embodiments according to the present disclosure in detail with reference to the accompanying drawings. Obviously, the described embodiments are only some of the embodiments of the present disclosure, rather than all the embodiments of the present disclosure, and it should be understood that the present disclosure is not limited to the example embodiments described herein.
[0058] It should be noted that: similar reference numerals and letters represent similar items in the following drawings, and therefore, once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings.
[0059] The term "and / or" herein is only to describe an association relationship, which means that there can be three relationships, for example, A and / or B can mean that A exists alone, A and B exist together, and B exists alone. In addition, the term "at least one" herein means any one of a plurality or any combination of at least two of a plurality, for example, including at least one of A, B, and C can mean including any one or more elements selected from the set consisting of A, B, and C.
[0060] It has been found through research that, with the development of the Internet, the application range of text processing is gradually expanding, at which time the demand for text transmission is also increasingly high. In various application fields of text processing, the security and management of text data are essential links. For example, in related technologies, a text can be subjected to security inspection by a type detection method to achieve management of the text.
[0061] In the related art, a neural network model is usually used to detect the category of a text. However, before the neural network model is used, a large amount of labeled data needs to be used for training. If the training data of a certain text category is less, the classification result of the trained neural network model will be inaccurate.
[0062] Based on the above research, the present disclosure provides a method, device, equipment, medium and product for detecting a zero-shot text category. By determining the relevance between the first extended label of the detected category of the detected text and the detected text based on the relevance between each preset word in the prediction word table of the large model and the detected text (i.e., the first prediction information), the classification of the text can be realized without training the large model, thereby solving the problem that model training cannot be performed in a zero-shot situation and directly using the large model for prediction will cause errors. The technical solution of the present disclosure can be extended according to specific classification scenarios to improve the generality of various detections under zero-shot, and has good engineering application prospects and value. By combining the first relevance and the second prediction information, the text category of the detected text can be determined, thereby improving the detection accuracy of the detected text and obtaining a text category with higher accuracy.
[0063] To facilitate the understanding of the present embodiment, first, a text category detection method disclosed by the present embodiment is introduced in detail. The execution subject of the text category detection method provided by the present embodiment is generally an electronic device with certain computing power. In some possible implementation manners, the text category detection method can be realized by calling the computer readable instructions stored in the memory by the processor.
[0064] Referring to Figure 1 FIG. 1 is a flowchart of a text category detection method provided by the present embodiment. The method includes steps S101-S104, wherein:
[0065] S101, determining first prediction information of a detected text by a large model; wherein the first prediction information is used to indicate the relevance between the detected text and each preset word in a preset word table.
[0066] In the embodiment of the present disclosure, the first detected data can be input to the large model. The first detected data includes the detected text and the first prefix fine-tuning parameter prompt 1.
[0067] Here, the first prefix fine-tuning parameter is used to indicate the detection requirement set by the detected text. For example, the first prefix fine-tuning parameter can be set as “the detected text is a content of what topic, only respond to topic classification, and no explanation is needed”.
[0068] Here, after the first to-be-detected data is input into the large model, an output result of the large model is obtained; wherein the output result can be used to indicate the relevance between each preset word in a preset word table of the large model and the to-be-detected text (i.e., first prediction information). Wherein the preset word table can include various categories of words, for example, sensitive category, plant category, and animal category, etc.
[0069] Here, the large model includes a multi-layer decoder network and a linear layer. Wherein the linear layer can output the prediction probability of all preset words in the preset word table of the large model, and after the prediction probability is processed by a normalization softmax layer, the first prediction information is obtained.
[0070] S102, the category words of the to-be-detected categories of the to-be-detected text are expanded to obtain first expansion labels.
[0071] In an embodiment of the present disclosure, the category words of the to-be-detected categories can be input into the knowledge base for retrieval to obtain the expansion label words of the category words. Then, the expansion label words are determined as the first expansion labels of each to-be-detected category.
[0072] Here, the background knowledge words, related topic words, synonyms, antonyms, etc. of the category words can be obtained by retrieval. Then, the above-mentioned words obtained by retrieval are determined as the expansion label words.
[0073] For example, in the case of a sensitive category as the to-be-detected category, the words related to the sensitive category can be output by retrieval, i.e., the expansion label words of the sensitive category.
[0074] S103, determine the first relevance between the first expansion label and each to-be-detected category, and determine the prediction information of the first expansion label based on the first prediction information to obtain second prediction information; the second prediction information is used to indicate the relevance between the first expansion label and the to-be-detected text.
[0075] In an embodiment of the present disclosure, the first expansion label and each detection category can be input into the large model, so as to determine the first relevance between the first expansion label and each to-be-detected category according to the output result of the large model.
[0076] Here, the maximum first relevance of the first expansion label relative to each to-be-detected category can be determined. Then, the to-be-detected category corresponding to the maximum first relevance can be determined as the to-be-detected category of the first expansion label.
[0077] In the embodiments of the present disclosure, the similarity between the first extended label and each preset word in the preset word table can be determined. The first prediction information corresponding to the preset word with the greatest similarity to the first extended label is determined as the prediction information of the first extended label, thereby obtaining the second prediction information.
[0078] Here, if there is a same prediction word as the first extended label in the preset word table, the first prediction information of the same prediction word can be determined as the prediction information of the first extended label, that is, the second prediction information.
[0079] In the embodiments of the present disclosure, first, the weight of the first extended label can be determined based on the first correlation. Then, the text category of the to-be-detected text is determined based on the weight of the first extended label word and the second prediction information.
[0080] In the embodiments of the present disclosure, first, the first prediction information of the to-be-detected text is determined by the large model; wherein the first prediction information is used to indicate the correlation between the to-be-detected text and each preset word in the preset word table; then, the to-be-detected category of the to-be-detected text is labeled to obtain the first extended label; next, the first correlation between the first extended label and each to-be-detected category is determined, and the prediction information of the first extended label is determined based on the first prediction information to obtain the second prediction information; wherein the second prediction information is used to indicate the correlation between the first extended label and the to-be-detected text; finally, the text category of the to-be-detected text is determined based on the first correlation and the second prediction information.
[0081] In the above embodiments, the way of determining the correlation between the first extended label of the to-be-detected category of the to-be-detected text and the to-be-detected text based on the correlation between each preset word in the prediction word table of the large model and the to-be-detected text (i.e., the first prediction information) can realize the classification of the text without training the large model, thereby solving the problem that the model cannot be trained in the zero sample case and directly using the large model for prediction will cause errors. The technical solution of the present disclosure can be extended according to specific classification scenarios to improve the generality of various detections under zero samples, and has good engineering application prospect and value. The way of determining the text category of the to-be-detected text by combining the first correlation and the second prediction information can improve the detection accuracy of the to-be-detected text, thereby obtaining a text category with higher accuracy.
[0082] The above steps will be described in detail below with reference to specific embodiments.
[0083] As described above, in this embodiment, firstly, the text to be detected is obtained, and the first prefix fine-tuning parameter prompt 1 of the text to be detected is determined. prompt 1 can be designed as "the above text is about a certain topic; only the topic category needs to be answered, no explanation is required." After designing prompt 1, firstly, the text to be detected is concatenated with prompt 1 to obtain the input text (i.e., the first data to be detected described in the above embodiment); then, the input text is input into a large model for processing, thereby outputting the correlation between the text to be detected and each preset word in the preset vocabulary, i.e., the first prediction information.
[0084] For example, the input text could be "XXXX, XXXXXXX. The above text is about a certain topic; just reply with the topic category, no explanation is needed." In the prediction process of a large model, firstly, the hidden layer output is obtained through a multi-layer decoder network. Then, it passes through a linear layer to obtain the predicted probabilities of all preset words in the large model's predefined vocabulary, generally referred to as the logits value. Unlike common large model predictions, the technical solution disclosed in this publication selects the logits value output by the model's linear layer, i.e., the first prediction information (hereinafter denoted as p). D Store it.
[0085] After obtaining the first prediction information, the labels of the categories to be detected in the text can be expanded to obtain the first expanded labels.
[0086] Here, we assume the category to be detected is a sensitive category. In this case, we can first determine the category terms of the sensitive category. Then, we search the knowledge base based on the sensitive category to obtain the first expanded tag.
[0087] like Figure 2 The diagram shown is a flowchart illustrating the process of expanding the target category of the text to be detected to obtain the first expanded label in a text category detection method provided in this embodiment of the present disclosure. Figure 2 As shown, the process specifically includes the following steps:
[0088] First, the category terms of the category to be detected are input into the knowledge base module. Second, the knowledge base module is used to retrieve the category to be detected. Finally, the extended tags associated with each category term are determined, resulting in the first extended tag.
[0089] Here, the set of extended tags can be determined based on the category word and the first extended tag; for example, the set of extended tags L = {s1: l1~ln1, s2: l'1~l'n2……}; where s1 is the first category word, l1~ln1 are the first extended tags obtained by expanding based on the first category word, and n1 is the number of first extended tags obtained by expanding based on the first category word. S2 is the second category word, l'1~l'n2 are the first extended tags obtained by expanding based on the second category word, and n2 is the number of first extended tags obtained by expanding based on the second category word.
[0090] After obtaining the first extended label in the manner described above, a first correlation between the first extended label and each of the categories to be detected can be determined.
[0091] In an optional embodiment, the above steps for determining the first correlation between the first extended label and each category to be detected specifically include the following steps:
[0092] The categories to be detected and their detection requirements are input into a large model for processing to obtain the first correlation between the first extended label and each category to be detected.
[0093] In the embodiments of this disclosure, the detection requirement of the category to be detected can be understood as the second prefix fine-tuning parameter prompt2. Here, the category to be detected and the second prefix fine-tuning parameter can be input into a large model for processing, and the correlation between the first extended label and each category to be detected, i.e., the first correlation, can be determined based on the output of the large model.
[0094] In this embodiment of the disclosure, after obtaining the first extended tag, the prediction information of the first extended tag can be determined based on the first prediction information to obtain the second prediction information.
[0095] In an optional implementation, the above steps determine the prediction information of the first extended tag based on the first prediction information to obtain the second prediction information, specifically including the following steps:
[0096] S11, Identify words from the preset words that meet the similarity requirements of each first extended tag to obtain the target words;
[0097] S12, based on the first prediction information of the target word, determine the second prediction information of the first extended label.
[0098] In this embodiment of the disclosure, for each first extended tag, words whose similarity to the first extended tag meets the requirements can be determined from all preset words, thereby obtaining the target word. For example, the word with the highest similarity to the first extended tag can be determined from all preset words, and this word can be determined as the target word. At this time, the first prediction information corresponding to the target word can be determined as the prediction information of the first extended tag, that is, the second prediction information.
[0099] In addition, words with a similarity greater than threshold A to the first extended tag can be identified from all preset words as target words. In this case, there can be one or more target words. Next, the first prediction information of at least one target word can be averaged, and the resulting average value is determined as the prediction information of the first extended tag, i.e., the second prediction information.
[0100] After obtaining the first correlation and the second prediction information, the text category of the text to be detected can be determined based on the first correlation and the second prediction information.
[0101] In the embodiments of this disclosure, the weight of the first extended tag can be determined based on the first relevance. Then, based on the weight of the first extended tag word and the second prediction information, the text category of the text to be detected is determined. This step will be described below in conjunction with a specific implementation process.
[0102] In an optional embodiment, the above steps determine the text category of the text to be detected based on the first correlation and the second prediction information, specifically including the following steps:
[0103] S21, Based on the first relevance, determine the weight of the second extended label in the first extended label; wherein, the weight is used to indicate the degree of contribution of the second extended label to the determination of the category of the text to be detected as each category in the large model, and the second extended label is the category word in the first extended label that meets the similarity requirement with the preset word;
[0104] S22, determine the text category of the text to be detected based on the second prediction information and weights of the second extended label.
[0105] In the embodiments of this disclosure, the similarity requirement can be that the similarity between the first extended tag and each preset word is greater than a preset similarity threshold. The preset similarity threshold can be the aforementioned threshold A. In addition, it can be set to other thresholds. No specific limitation is made here, as long as it can be implemented.
[0106] First, the similarity between the first extended tag and each preset word can be determined. Then, the first extended tag that meets the similarity requirement is determined as the second extended tag. Next, the weight of the second extended tag can be determined based on the first relevance corresponding to the second extended tag.
[0107] Here, the first correlation can be determined through the following steps:
[0108] First, determine the second prefix fine-tuning parameters, which represent the detection requirements of the category to be detected. Second, concatenate the second prefix fine-tuning parameters with the category to be detected to obtain the concatenated content. Finally, input the concatenated content into the large model for processing, obtaining the first relevance output by the large model.
[0109] The second prefix fine-tuning parameter indicates the detection requirement for category words. Users can set this parameter according to their actual needs, for example, "What words are relatively related to this word? Just give the words without any further explanation." In this case, the large model can output the first extended label related to the category word and the first relevance corresponding to the first extended label.
[0110] In addition, the technical solution disclosed herein can also be achieved through the above... Figure 2 The described method determines the first expanded label. Then, by simply using the first expanded label and the category word as input to the large model, the first relevance of the large model's output can be obtained.
[0111] After obtaining the weights of the second extended labels, the second prediction information and weights of the second extended labels can be calculated to obtain the text category of the text to be detected.
[0112] In an optional embodiment, the above steps determine the text category of the text to be detected based on the second prediction information and weights of the second extended label, specifically including the following steps:
[0113] First, the correlation between each category to be detected and the text to be detected is determined through a large model, thus obtaining the second correlation.
[0114] Then, based on the second prediction information, weight, and second relevance of the second extended label, the text category of the text to be detected is determined.
[0115] In the embodiments of this disclosure, firstly, each category to be detected can be concatenated with the first method described above to obtain concatenated content. Then, the concatenated content is input into a large model for processing to obtain the correlation between the category to be detected and the text to be detected, i.e., the second correlation. After obtaining the second correlation, the second prediction information, weights, and second correlation can be calculated to obtain the text category of the text to be detected.
[0116] In an optional embodiment, the above steps, based on the first relevance, determine the weight of the second extended label in the first extended label, specifically including the following steps:
[0117] First, expand tags that meet the similarity threshold with preset words are selected from the first expand tags to obtain the second expand tags;
[0118] Then, based on the first relevance corresponding to the second extended label, the weight of the second extended label is calculated.
[0119] In the embodiments of this disclosure, an extended tag in the first extended tag that meets a similarity threshold with a preset word, that is, an extended tag that meets the similarity threshold requirement with a preset word, is then referred to as a second extended tag. For example, the similarity threshold can be set to 1. In this case, the first extended tag that is completely similar to the preset word can be determined as the second extended tag.
[0120] After obtaining the second extended label, the first relevance corresponding to the second extended label can be normalized to obtain the weight of the second extended label.
[0121] In this embodiment of the disclosure, the weight of the second extended label is calculated based on the first relevance corresponding to the second extended label, specifically including the following steps:
[0122] First, the first relevance corresponding to the second extended label is calculated to obtain the average conditional probability value of the second extended label;
[0123] Then, based on the first relevance and average conditional probability value corresponding to the second extended label, the weight of the second extended label is determined.
[0124] In the embodiments of this disclosure, firstly, the number of second extended tags under each category to be detected can be determined. Then, based on the number of second extended tags corresponding to each category to be detected and the first relevance of the second extended tags, the average conditional probability value of the second extended tags corresponding to each category word is calculated. Wherein, the average conditional probability value p corresponding to the s-th category to be detected... S L Meets the following conditions:
[0125] p S L =1 / H∑ n(s) i=1 p c (d i );
[0126] Where H is the number of second extended tags, i ranges from 1 to n(s), n(s) is the number of second extended tags corresponding to the s-th category word, and pc (d i ) is the i-th second extended tag corresponding to the s-th category word.
[0127] Next, the average conditional probability value p is determined. S L Next, the weights of each second extended label corresponding to the s-th category word can be determined. Specifically, the weight p of the ith second extended label corresponding to the s-th category word... s A (d i It meets the following conditions:
[0128] p s A (d i ) = p s c (d i ) / p S L ;
[0129] Where, p s c (d i ) represents the first relevance of the i-th second extended tag corresponding to the s-th category word.
[0130] In an optional embodiment, the above steps determine the text category of the text to be detected based on the second prediction information, weight, and second relevance of the second extended label, specifically including the following steps:
[0131] First, based on the second prediction information and weight of the second extended label, the third extended label is determined; wherein, the third extended label is the second extended label that meets both the prediction requirements and the weight requirements.
[0132] Then, based on the second prediction information, weight, and second relevance corresponding to the third extended label, the text category of the text to be detected is determined.
[0133] In the embodiments of this disclosure, the prediction requirement is that the prediction probability in the second prediction information is greater than a preset prediction probability threshold; the weight requirement is that the weight is greater than a preset weight threshold. Those skilled in the art can set the preset prediction probability threshold and preset weight threshold according to actual needs, as long as they are feasible, and will not be elaborated further here.
[0134] Here, the second extended label that does not meet the preset prediction requirements and the preset weight requirements can be removed to obtain the third extended label.
[0135] Then, the text category of the text to be detected can be obtained by performing calculations based on the second prediction information, weight, and second relevance corresponding to the third extended label.
[0136] Reference Figure 3 The diagram shown is a flowchart of the determination of the third extended label in a text category detection method provided in this embodiment of the present disclosure, wherein:
[0137] First, a second extended tag that meets the preset similarity requirement with the preset words is identified from the first extended tag. Second, the first prediction information of the preset words corresponding to the second extended tag is determined as the second prediction information of that second extended tag. Third, the weight of the second extended tag is determined based on the first relevance of the second extended tag. Finally, a third extended tag that meets both the prediction requirement and the weight requirement is identified from the second extended tags.
[0138] In the above embodiments, expanding category terms using words from the knowledge base may introduce noise. Therefore, the steps described above for determining the third expanded label can be used to remove second expanded labels that have little impact on the category prediction of the text to be detected. This improves the accuracy of category detection for the text to be detected.
[0139] In an optional embodiment, the above steps determine the text category of the text to be detected based on the second prediction information, weight, and second relevance of the second extended label, specifically including the following steps:
[0140] First, calculate the product between the weight of the second extended label and the second prediction information of the second extended label, and sum the products of all the second extended labels to obtain the first calculation result;
[0141] Next, the first operation result is added to the second correlation to obtain the second operation result; the second operation result is used to indicate the degree of correlation between the text to be detected and each category to be detected.
[0142] Finally, the text category of the text to be detected is determined based on the result of the second operation.
[0143] In the embodiments of this disclosure, firstly, a third extended label can be determined from the second extended label. Secondly, the weight of the third extended label and the second prediction information corresponding to each category to be detected can be determined. Finally, a first calculation result corresponding to each category to be detected is determined.
[0144] Here, the weight of the third extended label can be determined by the weight of the corresponding second extended label, and the second prediction information corresponding to the third extended label can be determined by the second prediction information corresponding to the second extended label.
[0145] Wherein, the first operation result D corresponding to the s-th category to be detected S Meets the following conditions:
[0146] D S=∑ ms) j=1 (p s A (d j )*p s D (d j ));
[0147] Where, p s A (d i p represents the weight of the j-th third extended label corresponding to the s-th category to be detected, where j ranges from 1 to m(s), and m(s) is the number of third extended labels corresponding to the s-th category to be detected. s D (d j ) represents the second prediction information of the j-th third extended label corresponding to the s-th category to be detected.
[0148] Here, after determining the first operation result of each category to be detected, the first operation result of each category to be detected can be added to the second correlation corresponding to that category to obtain the second operation result corresponding to each category to be detected.
[0149] Wherein, the second operation result p corresponding to the s-th category to be detected s Meets the following conditions:
[0150] p s =D s +p D (s);
[0151] Where, p D (s) represents the second correlation corresponding to the s-th category to be detected.
[0152] Finally, the degree of influence of each category to be detected on the text to be detected can be determined based on the second calculation result, and the text category of the text to be detected can be determined by the degree of influence.
[0153] In an optional embodiment, the above steps determine the text category of the text to be detected based on the second calculation result, specifically including the following steps:
[0154] First, the largest result in the second operation result;
[0155] Then, the category word corresponding to the largest calculation result is determined as the text category of the text to be detected.
[0156] In the embodiments of this disclosure, the second operation results corresponding to each category to be detected can be normalized (softmax) to obtain the normalized second operation results.
[0157] Here, after determining the result of the normalized second AND operation, the maximum result among the normalized second AND operation results can be determined.
[0158] Reference Figure 4 The diagram shown is a flowchart of determining the first prediction information in a text category detection method provided in this embodiment of the present disclosure, wherein:
[0159] First, based on the weight of the third tag and the second prediction information, the second operation result for each category word is determined. Second, the second operation result is normalized. Third, the largest operation result among the normalized second operation results is determined. Finally, the category word corresponding to the largest operation result is determined as the text category of the text to be detected.
[0160] Reference Figure 5 The diagram shown is a flowchart of determining the first prediction information in a text category detection method provided in this embodiment of the present disclosure, wherein:
[0161] First, the text to be detected is input into a pre-trained model. Second, the large model processes the text. Finally, the output of the large model is used as the first prediction.
[0162] Reference Figure 6 The diagram shown is a flowchart of a text category detection method provided in this embodiment of the present disclosure, including: a data input module, a large model module, a knowledge base module, a calibration module, a label mapping module, and a category detection module, wherein:
[0163] The data input module is used to input the text to be detected and the first extended label into the large model module, and to input the category words of the category to be detected into the knowledge base module.
[0164] The large model module is used to determine the first prediction information between the text to be detected and all preset words in the preset vocabulary (i.e., the preset vocabulary); and to determine the first correlation between the first extended label and the category word.
[0165] The knowledge base module is used to perform expansion processing based on category words to obtain the first expanded tag.
[0166] Here, the knowledge base module mainly consists of a knowledge base containing various categories of category words, as well as background knowledge words, related topic words, synonyms, antonyms, etc., related to the category words. This module takes the category words as input and retrieves and outputs words related to that category word (i.e., the first extended tags).
[0167] The calibration module is used to filter the first extended labels to obtain the second extended labels. Then, the weights of the second extended labels are determined.
[0168] The label mapping module is used to remove second extended labels that do not meet the weight and prediction requirements, resulting in third extended labels. Then, based on the weights corresponding to the third extended labels and the second prediction information, the second calculation result is determined.
[0169] The category detection module is used to determine the text category of the text to be detected based on the result of the second operation.
[0170] In the above embodiments, by determining the correlation between the first extended label of the target category of the target text and the target text (i.e., the second prediction information) based on the correlation between each preset word in the prediction vocabulary of the large model and the target text, text classification can be achieved without training the large model. This solves the problem that model training is impossible in zero-shot scenarios, and that directly using the large model for prediction leads to errors. This disclosed technical solution can be extended according to specific classification scenarios, improving the versatility of various detection methods under zero-shot conditions, and has good engineering application prospects and value. By combining the first correlation and the second prediction information to determine the text category of the target text, the detection accuracy of the target text can be improved, resulting in a more accurate text category.
[0171] Based on the same inventive concept, this disclosure also provides a text category detection device corresponding to the text category detection method. Since the principle of the device in this disclosure for solving the problem is similar to the text category detection method described above, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be described again.
[0172] Reference Figure 7 The diagram shown is a schematic of a text category detection device provided in an embodiment of this disclosure. The device includes: a prediction module 11, an expansion module 12, a first determination module 13, and a second determination module 14; wherein:
[0173] The prediction module is used to determine the first prediction information of the text to be detected through a large model; wherein, the first prediction information is used to indicate the correlation between the text to be detected and each preset word in the preset vocabulary;
[0174] An extension module is used to extend the tags of the detection categories of the text to be detected, so as to obtain the first extended tags;
[0175] A first determining module is configured to determine a first correlation between the first extended tag and each of the categories to be detected, and to determine the prediction information of the first extended tag based on the first prediction information to obtain second prediction information; the second prediction information is used to indicate the correlation between the first extended tag and the text to be detected.
[0176] The second determining module is used to determine the text category of the text to be detected based on the first correlation and the second prediction information.
[0177] Specifically, the second determining module is further configured to determine the weight of the second extended label in the first extended label based on the first relevance; wherein the weight is used to indicate the degree of contribution of the second extended label to the determination of the category of the text to be detected as each category in the large model, and the second extended label is the extended label in the first extended label that meets the similarity requirement with the preset word;
[0178] The text category of the text to be detected is determined based on the second prediction information of the second extended label and the weight.
[0179] Furthermore, the second determining module is also used to determine the correlation between each of the categories to be detected and the text to be detected through a large model, thereby obtaining a second correlation.
[0180] The text category of the text to be detected is determined based on the second prediction information of the second extended label, the weight, and the second correlation.
[0181] Furthermore, the second determining module is also used to filter extended tags from the first extended tags that meet the similarity threshold with the preset words to obtain the second extended tags;
[0182] The weight of the second extended label is calculated based on the first relevance corresponding to the second extended label.
[0183] Furthermore, the second determining module is also used to calculate the first correlation corresponding to the second extended label to obtain the average conditional probability value of the second extended label;
[0184] The weight of the second extended label is determined based on the first relevance corresponding to the second extended label and the average conditional probability value.
[0185] Furthermore, the second determining module is also used to determine a third extended label based on the second prediction information of the second extended label and the weight; wherein the third extended label is the second extended label that meets both the prediction requirements and the weight requirements;
[0186] Based on the second prediction information, weight, and second relevance corresponding to the third extended label, the text category of the text to be detected is determined.
[0187] Furthermore, the second determining module is also used to calculate the product between the weight of the second extended label and the second prediction information of the second extended label, and to sum the products of all the second extended labels to obtain the first calculation result;
[0188] The first calculation result is added to the second correlation to obtain a second calculation result; wherein, the second calculation result is used to indicate the degree of correlation between the text to be detected and each of the categories to be detected;
[0189] The text category of the text to be detected is determined based on the result of the second calculation.
[0190] Furthermore, the second determining module is also used to determine the largest calculation result among the second calculation results;
[0191] The category word corresponding to the largest calculation result is determined as the text category of the text to be detected.
[0192] Specifically, the first determining module is also used to input the category to be detected and the detection requirements of the category to be detected into the large model for processing, so as to obtain the first correlation between the first extended label and each of the categories to be detected.
[0193] This embodiment determines the correlation between the first extended label of the text to be detected and the text itself (i.e., the second prediction information) by using the correlation between each preset word in the prediction vocabulary of a large model and the text to be detected (i.e., the first prediction information). This method enables text classification without training a large model, thus solving the problem that model training is impossible in zero-shot scenarios and that directly using a large model for prediction leads to errors. This disclosed technical solution can be extended according to specific classification scenarios, improving the versatility of various detection methods under zero-shot conditions, and has good engineering application prospects and value. By combining the first correlation and the second prediction information to determine the text category of the text to be detected, the detection accuracy of the text can be improved, resulting in a more accurate text category.
[0194] The processing flow of each module in the device and the interaction flow between each module can be referred to the relevant descriptions in the above method embodiments, and will not be detailed here.
[0195] Corresponding to Figure 1 In addition to the text category detection method in this disclosure, this embodiment also provides an electronic device 800, such as... Figure 8 The diagram shown is a structural schematic of an electronic device 800 provided in an embodiment of this disclosure, including:
[0196] The system includes a processor 81, a memory 82, and a bus 83. The memory 82 stores execution instructions and includes main memory 821 and external memory 822. The main memory 821, also called internal memory, temporarily stores the computational data in the processor 81, as well as data exchanged with external memory such as a hard disk. The processor 81 exchanges data with the external memory 822 through the main memory 821. When the electronic device 800 is running, the processor 81 communicates with the memory 82 through the bus 83, causing the processor 81 to execute the following instructions:
[0197] The first prediction information of the text to be detected is determined by a large model; wherein the first prediction information is used to indicate the correlation between the text to be detected and each preset word in the preset vocabulary;
[0198] The detection category of the text to be detected is expanded to obtain the first expanded label;
[0199] A first correlation is determined between the first extended tag and each of the categories to be detected, and prediction information of the first extended tag is determined based on the first prediction information to obtain second prediction information; the second prediction information is used to indicate the correlation between the first extended tag and the text to be detected.
[0200] Based on the first correlation and the second prediction information, the text category of the text to be detected is determined.
[0201] The basic principles of this disclosure have been described above with reference to specific embodiments. However, it should be noted that the advantages, benefits, and effects mentioned in this disclosure are merely examples and not limitations, and should not be considered as essential features of each embodiment of this disclosure. Furthermore, the specific details disclosed above are for illustrative and facilitative purposes only, and are not limitations. These details do not limit the scope of this disclosure to the necessity of employing the aforementioned specific details for implementation.
[0202] The block diagrams of devices, apparatuses, devices, and systems disclosed herein are merely illustrative examples and are not intended to require or imply that they must be connected, arranged, or configured in the manner shown in the block diagrams. As those skilled in the art will recognize, these devices, apparatuses, devices, and systems can be connected, arranged, and configured in any manner. Words such as “comprising,” “including,” “having,” etc., are open-ended terms meaning “including but not limited to,” and are used interchangeably with them. The terms “or” and “and” as used herein refer to the terms “and / or,” and are used interchangeably with them unless the context clearly indicates otherwise. The term “such as” as used herein refers to the phrase “such as but not limited to,” and is used interchangeably with it.
[0203] Additionally, as used herein, the “or” used in a list of items beginning with “at least one” indicates a separate list, such that a list of, for example, “at least one of A, B, or C” means A or B or C, or AB or AC or BC, or ABC (i.e., A and B and C). Furthermore, the word “exemplary” does not imply that the described example is preferred or better than other examples.
[0204] It should also be noted that in the systems and methods of this disclosure, the components or steps can be decomposed and / or recombined. These decompositions and / or recombinations should be considered as equivalent solutions to this disclosure.
[0205] Various changes, substitutions, and modifications can be made to the technology described herein without departing from the teachings defined by the appended claims. Furthermore, the scope of the claims of this disclosure is not limited to the specific aspects of the processes, machines, manufactures, events, means, methods, and actions described above. Currently existing or later-developed processes, machines, manufactures, events, means, methods, or actions that perform substantially the same function or achieve substantially the same result as the corresponding aspects described herein can be utilized. Therefore, the appended claims include such processes, machines, manufactures, events, means, methods, or actions within their scope.
[0206] The above description of the disclosed aspects is provided to enable any person skilled in the art to make or use this disclosure. Various modifications to these aspects will be readily apparent to those skilled in the art, and the general principles defined herein may be applied to other aspects without departing from the scope of this disclosure. Therefore, this disclosure is not intended to be limited to the aspects shown herein, but rather to be carried out within the widest scope consistent with the principles and novel features disclosed herein.
[0207] The above description has been given for purposes of illustration and description. Furthermore, this description is not intended to limit the embodiments of this disclosure to the forms disclosed herein. Although numerous exemplary aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, alterations, additions, and sub-combinations therein.
Claims
1. A text category detection method, characterized in that, include: The first prediction information of the text to be detected is determined by a large model; wherein the first prediction information is used to indicate the correlation between the text to be detected and each preset word in the preset vocabulary; The detection category of the text to be detected is expanded to obtain the first expanded label; A first correlation is determined between the first extended tag and each of the categories to be detected, and prediction information of the first extended tag is determined based on the first prediction information to obtain second prediction information; the second prediction information is used to indicate the correlation between the first extended tag and the text to be detected. Based on the first correlation and the second prediction information, the text category of the text to be detected is determined.
2. The method as described in claim 1, characterized in that, Determining the text category of the text to be detected based on the first correlation and the second prediction information includes: Based on the first correlation, the weight of the second extended label in the first extended label is determined; wherein, the weight is used to indicate the degree of contribution of the second extended label to the determination of the category of the text to be detected as each category in the large model, and the second extended label is the extended label in the first extended label that meets the similarity requirement with the preset word; The text category of the text to be detected is determined based on the second prediction information of the second extended label and the weight.
3. The method as described in claim 2, characterized in that, The process of determining the text category of the text to be detected based on the second prediction information of the second extended tag and the weight includes: The correlation between each category to be detected and the text to be detected is determined by a large model to obtain a second correlation. The text category of the text to be detected is determined based on the second prediction information of the second extended label, the weight, and the second correlation.
4. The method as described in claim 2, characterized in that, Determining the weight of the second extended tag in the first extended tag based on the first correlation includes: The second extended tag is obtained by filtering the extended tags from the first extended tag that meet the similarity threshold with the preset words; The weight of the second extended label is calculated based on the first relevance corresponding to the second extended label.
5. The method as described in claim 4, characterized in that, The step of calculating the weight of the second extended label based on the first relevance corresponding to the second extended label includes: The first correlation corresponding to the second extended label is calculated to obtain the average conditional probability value of the second extended label; The weight of the second extended label is determined based on the first relevance corresponding to the second extended label and the average conditional probability value.
6. The method as described in claim 3, characterized in that, The process of determining the text category of the text to be detected based on the second prediction information of the second extended label, the weight, and the second relevance includes: Based on the second prediction information of the second extended label and the weight, a third extended label is determined; wherein, the third extended label is the second extended label that meets both the prediction requirements and the weight requirements; Based on the second prediction information, weight, and second relevance corresponding to the third extended label, the text category of the text to be detected is determined.
7. The method as described in claim 3, characterized in that, The process of determining the text category of the text to be detected based on the second prediction information of the second extended label, the weight, and the second relevance includes: Calculate the product between the weight of the second extended label and the second prediction information of the second extended label, and sum the products of all the second extended labels to obtain the first calculation result; The first calculation result is added to the second correlation to obtain a second calculation result; wherein, the second calculation result is used to indicate the degree of correlation between the text to be detected and each of the categories to be detected; The text category of the text to be detected is determined based on the result of the second calculation.
8. The method as described in claim 7, characterized in that, Determining the text category of the text to be detected based on the second calculation result includes: The largest result among the second calculation results; The category word corresponding to the largest calculation result is determined as the text category of the text to be detected.
9. The method as described in claim 1, characterized in that, Determining the first correlation between the first extended label and each of the categories to be detected includes: The detection category and the detection requirements of the detection category are input into the large model for processing to obtain the first correlation between the first extended label and each of the detection categories.
10. The method as described in claim 1, characterized in that, The step of determining the prediction information of the first extended tag based on the first prediction information to obtain the second prediction information includes: From the preset words, words that meet the similarity requirements for each of the first extended tags are determined to obtain target words; Based on the first prediction information of the target word, the second prediction information of the first extended tag is determined.
11. A text category detection device, characterized in that, include: The prediction module is used to determine the first prediction information of the text to be detected through a large model; wherein, the first prediction information is used to indicate the correlation between the text to be detected and each preset word in the preset vocabulary; An extension module is used to extend the tags of the detection categories of the text to be detected, so as to obtain the first extended tags; A first determining module is configured to determine a first correlation between the first extended tag and each of the categories to be detected, and to determine the prediction information of the first extended tag based on the first prediction information to obtain second prediction information; the second prediction information is used to indicate the correlation between the first extended tag and the text to be detected. The second determining module is used to determine the text category of the text to be detected based on the first correlation and the second prediction information.
12. A computer device, comprising a memory, a processor, and a computer program stored in the memory, characterized in that, The processor executes the computer program to implement the steps of the text category detection method according to claims 1 to 10.
13. A computer-readable storage medium having a computer program / instructions stored thereon, characterized in that, When the computer program / instruction is executed by the processor, it implements the steps of the text category detection method according to claims 1 to 10.
14. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instruction is executed by the processor, it implements the steps of the text category detection method according to claims 1 to 10.