Model training method, information classification method, device, equipment and storage medium

By adding prompts and labels to the text-based public opinion classification model and training it with the BERT model, the problem of insufficient accuracy in public opinion polarity classification was solved, and a more efficient public opinion classification effect was achieved.

CN115310443BActive Publication Date: 2026-02-24SHANGHAI PUDONG DEVELOPMENT BANK
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211083152.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-06
Publication Date
2026-02-24
Estimated Expiration
2042-09-06

AI Technical Summary

Technical Problem

Existing text-based public opinion classification models are insufficient in terms of accuracy in classifying public opinion polarity, making it difficult to effectively distinguish texts with high similarity, resulting in poor classification performance.

Method used

By adding prompts and labels to the initial training samples, a public opinion classification model based on the bidirectional language representation transformation model BERT is constructed. The model is then trained using the target loss relation to enhance the focus on the polarity of public opinion.

Benefits of technology

It improved the accuracy of public opinion classification, effectively alleviated the problem of insufficient training sample labeling, optimized the model output results, and thus improved the public opinion classification effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115310443B_ABST
    Figure CN115310443B_ABST
Patent Text Reader

Abstract

Embodiments of the present application disclose a model training method, an information classification method, an apparatus, a device and a storage medium. The method comprises: obtaining an initial training sample set; adding prompt information and label information on the basis of a sample information text in the initial training sample to obtain a target training sample set, wherein the prompt information is used to inquire about the public opinion category of the sample information text, and the label information simultaneously contains at least two public opinion categories; inputting the target training sample set into a public opinion classification model, determining a target loss relationship according to the output of the public opinion classification model; and training the public opinion classification model according to the target loss relationship. The technical solution of the embodiments of the present application optimizes the model output result from the perspective of public opinion polarity by adding the label information and the prompt information, so that the public opinion classification effect of the trained model is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of artificial intelligence technology, and in particular to model training methods, information classification methods, devices, equipment and storage media. Background Technology

[0002] In recent years, research on text-based public opinion classification has continued to be one of the hot topics in the fields of natural language processing and text classification. The research on text-based public opinion classification covers multiple fields including natural language processing, information retrieval, and information extraction.

[0003] Text-based public opinion classification refers to the process of analyzing, processing, and classifying texts containing public opinion information using natural language processing and text classification techniques. The main research approaches for text-based public opinion classification are divided into semantic-based public opinion dictionary methods and machine learning-based methods. Semantic-based public opinion dictionary methods first require the construction of a public opinion dictionary, which mainly involves expanding existing electronic dictionaries. Machine learning-based public opinion classification requires constructing a public opinion classifier using machine learning methods. The text to be classified is then passed through this classifier to determine the public opinion polarity. Commonly used public opinion classification features include public opinion terms, parts of speech, and negative expression templates.

[0004] However, existing text-based public opinion classification models generally fail to pay sufficient attention to the polarity of public opinion. They often treat public opinion classification as a text classification task, but these two tasks are significantly different. Text classification focuses on the core semantic information of the text to determine its category, while public opinion classification should pay more attention to the detailed expressions within the text. A slight shift or change in expression can cause highly similar texts to have different public opinion polarities. Therefore, simply treating public opinion classification as a text classification task results in poor performance and low accuracy. Summary of the Invention

[0005] This invention provides a model training method, an information classification method, an apparatus, a device, and a storage medium, which can improve the accuracy of public opinion classification.

[0006] In a first aspect, embodiments of the present invention provide a model training method, including:

[0007] Obtain an initial training sample set, wherein the initial training samples in the initial training sample set include sample information text;

[0008] Based on the sample information text in the initial training samples, prompt information and tag information are added to obtain the target training sample set. The prompt information is used to inquire about the public opinion category of the sample information text, and the tag information contains at least two public opinion categories at the same time.

[0009] The target training sample set is input into the public opinion classification model, and the target loss relationship is determined based on the output of the public opinion classification model. The public opinion classification model is constructed based on the bidirectional language representation transformation model BERT.

[0010] The public opinion classification model is trained based on the target loss relationship.

[0011] Secondly, embodiments of the present invention provide an information classification method, including:

[0012] Obtain the text of the information to be categorized;

[0013] Based on the information text to be classified, add prompts and tags to obtain the target data to be classified;

[0014] The target data to be classified is input into a preset public opinion classification model. The target public opinion category corresponding to the information text to be classified is determined according to the output of the preset public opinion classification model. The preset public opinion classification model is obtained by the model training method described in the first aspect above.

[0015] Thirdly, embodiments of the present invention also provide a model training apparatus, comprising:

[0016] The training sample acquisition module is used to acquire an initial training sample set, wherein the initial training samples in the initial training sample set include sample information text.

[0017] The target training sample determination module is used to add prompt information and tag information to the sample information text in the initial training samples to obtain a target training sample set. The prompt information is used to ask the public opinion category of the sample information text, and the tag information contains at least two public opinion categories at the same time.

[0018] The target loss relationship determination module is used to input the target training sample set into the public opinion classification model and determine the target loss relationship based on the output of the public opinion classification model, wherein the public opinion classification model is constructed based on the bidirectional language representation transformation model BERT;

[0019] The training module is used to train the public opinion classification model based on the target loss relationship.

[0020] Fourthly, embodiments of the present invention also provide an information classification device, comprising:

[0021] The information text acquisition module is used to acquire the information text to be classified.

[0022] The information adding module is used to add prompts and tags to the text to be classified, so as to obtain the target data to be classified.

[0023] The public opinion category determination module is used to input the target data to be classified into a preset public opinion classification model, and determine the target public opinion category corresponding to the information text to be classified according to the output of the preset public opinion classification model, wherein the preset public opinion classification model is obtained by the model training method as described in any one of claims 1-4.

[0024] Fifthly, embodiments of the present invention provide an electronic device, the electronic device comprising:

[0025] One or more processors;

[0026] Storage device for storing one or more programs.

[0027] When the one or more programs are executed by the one or more processors, the one or more processors implement the model training method of the first aspect described above, and / or implement the information classification method of the second aspect described above.

[0028] In a sixth aspect, embodiments of the present invention also provide a computer-readable storage medium storing a computer program that enables a processor to implement the model training method of the first aspect described above, and / or to implement the information classification method of the second aspect described above.

[0029] The model training scheme provided in this embodiment of the invention obtains an initial training sample set, wherein the initial training samples in the initial training sample set include sample information text. Based on the sample information text in the initial training samples, prompt information and tag information are added to obtain a target training sample set. The prompt information is used to inquire about the public opinion category of the sample information text, and the tag information simultaneously contains at least two public opinion categories. The target training sample set is input into a public opinion classification model, and a target loss relationship is determined based on the output of the public opinion classification model. The public opinion classification model is constructed based on the bidirectional language representation transformation model BERT, and the public opinion classification model is trained according to the target loss relationship. By adopting the above technical solution, after obtaining the initial training sample set, label information containing public opinion categories and prompt information for inquiring about public opinion categories are added to the sample information text in the initial training samples, thereby obtaining the target training sample set. The target training sample set is then input into the public opinion classification model. Based on the target loss relationship determined by the model's output, the public opinion classification model is trained. By adding label information and prompt information, the focus on the public opinion polarity of the training samples is enhanced, effectively alleviating the problem of insufficient labeling of training samples and avoiding the problem of difficulty in distinguishing public opinion polarity in highly similar texts. The model output results are optimized from the perspective of public opinion polarity, thereby improving the public opinion classification performance of the trained model.

[0030] The information classification scheme provided in this invention involves: acquiring the information text to be classified; adding prompts and tags to the information text to obtain target data to be classified; inputting the target data to be classified into a preset public opinion classification model; and determining the target public opinion category corresponding to the information text to be classified based on the output of the preset public opinion classification model. The preset public opinion classification model is obtained using the model training method described above. By adopting the above technical solution, target data to be classified is obtained by adding tags containing public opinion categories and prompts for inquiring about public opinion categories to the information text to be classified. This target data is then input into the preset public opinion classification model, and finally, the target public opinion category corresponding to the information text to be classified is determined based on the model's output. By adding tags and prompts to the information text to be classified, the preset public opinion classification model pays more attention to the public opinion polarity of the information text during encoding, optimizing the model output from the perspective of public opinion polarity and effectively improving the public opinion classification effect.

[0031] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description

[0032] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0033] Figure 1 This is a flowchart of a model training method provided in Embodiment 1 of the present invention;

[0034] Figure 2 This is a flowchart of a model training method provided in Embodiment 2 of the present invention;

[0035] Figure 3 This is a schematic diagram of the training process of a preset public opinion classification model provided in Embodiment 2 of the present invention;

[0036] Figure 4 This is a flowchart of an information classification method provided in Embodiment 3 of the present invention;

[0037] Figure 5 This is a schematic diagram of the structure of a model training device according to Embodiment 4 of the present invention;

[0038] Figure 6This is a schematic diagram of the structure of an information classification device according to Embodiment 5 of the present invention;

[0039] Figure 7 This is a schematic diagram of the structure of an electronic device provided according to Embodiment Six of the present invention. Detailed Implementation

[0040] The present invention will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and not intended to limit it. Furthermore, it should be noted that, for ease of description, the accompanying drawings show only the parts relevant to the present invention, and not all of the structures.

[0041] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention 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 embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. In the description of this invention, unless otherwise stated, "a plurality of" means two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist; for example, A and / or B can represent: A alone, A and B simultaneously, and B alone. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or device that includes 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 devices.

[0042] Example 1

[0043] Figure 1 This is a flowchart of a model training method provided in Embodiment 1 of the present invention. This embodiment is applicable to the training of models. The method can be executed by a model training device, which can be implemented in hardware and / or software. The model training device can be configured in an electronic device, which can be composed of two or more physical entities or a single physical entity.

[0044] like Figure 1 As shown, the model training method provided in Embodiment 1 of the present invention specifically includes the following steps:

[0045] Step 101: Obtain the initial training sample set.

[0046] The initial training samples in the initial training sample set include sample information text.

[0047] In this embodiment, multiple sample information texts can be acquired as samples to form a set of sample information texts, i.e., the initial training sample set. The samples in the initial training sample set can be used as the initial samples for training the model. Here, information text can be understood as text text of the information category used to train the model. Before acquiring information text, the topic of the text can be preset to obtain information text with the preset topic. For example, if the preset topic is the financial field, then information text with the financial field topic can be acquired.

[0048] Optionally, the sample information text can be the information text obtained after data preprocessing of the acquired original information sample. Preprocessing may include removing special characters and stop words.

[0049] Step 102: Based on the sample information text in the initial training samples, add prompt information and label information to obtain the target training sample set.

[0050] The prompt information is used to inquire about the public opinion category of the sample information text. The tag information contains at least two public opinion categories, and the specific number is not limited, such as 2, 3, 4 or more.

[0051] In this embodiment, a prompt message for inquiring about the public opinion category can be added at a first preset position in the sample information text, and a tag message containing the public opinion category can be added at a second preset position in the sample information text, thereby obtaining the target training sample set. For example, the prompt message can be text information such as "Public opinion polarity is [MASK]" or "Public opinion category is [MASK]", and the tag message can be text information such as "good, mediocre, bad" (corresponding to 3 public opinion categories) or "good, bad" (corresponding to 2 public opinion categories). Here, [MASK] can be understood as a mask for the features used to determine the public opinion category, and the first preset position can be before the second preset position.

[0052] For example, if the initial training sample is represented as [CLS] news text [SEP], then after adding prompt information and tag information, it becomes [CLS] public opinion polarity is [MASK] [SEP] good mediocre bad [SEP] news text [SEP], where "public opinion polarity is [MASK]" is the prompt information and "good mediocre bad" is the tag information.

[0053] S103. Input the target training sample set into the public opinion classification model, and determine the target loss relationship based on the output of the public opinion classification model.

[0054] The public opinion classification model is based on the Bidirectional Encoder Representations from Transformers (BERT) model.

[0055] In this embodiment, the target training sample set can be used as input to the public opinion classification model. Then, based on the data output by the public opinion classification model and referring to the real public opinion category of the sample information text, the loss relationship of the public opinion classification model can be determined, namely the target loss relationship (specifically, the target loss value). The loss relationship can be expressed as a loss function.

[0056] Optionally, the public opinion classification model can be a model obtained by fine-tuning the Chinese BERT pre-trained model. Specifically, it can be fine-tuned for the aforementioned preset topics to make the resulting public opinion classification model more suitable for classifying the public opinion polarity of the aforementioned preset topics. Optionally, the Masked Language Model (MLM) task can be used for fine-tuning.

[0057] S104. Train the public opinion classification model according to the target loss relationship.

[0058] In this embodiment, the public opinion classification model can be trained based on the numerical value corresponding to the loss relationship. Generally, the smaller the value, the better the classification effect of the public opinion classification model; conversely, the larger the value, the worse the classification effect output by the public opinion classification model. The accuracy of the public opinion classification model in classifying public opinion can be improved by adjusting the relevant parameters of the public opinion classification model, such as the weight coefficient and / or the offset parameter.

[0059] The model training method provided in this embodiment of the invention obtains an initial training sample set, wherein the initial training samples in the initial training sample set include sample information text. Based on the sample information text in the initial training samples, prompt information and tag information are added to obtain a target training sample set. The prompt information is used to inquire about the public opinion category of the sample information text, and the tag information simultaneously contains at least two public opinion categories. The target training sample set is input into a public opinion classification model, and a target loss relationship is determined based on the output of the public opinion classification model. The public opinion classification model is constructed based on the bidirectional language representation transformation model BERT, and the public opinion classification model is trained according to the target loss relationship. By adopting the above technical solution, after obtaining the initial training sample set, label information containing public opinion categories and prompt information for inquiring about public opinion categories are added to the sample information text in the initial training samples, thereby obtaining the target training sample set. The target training sample set is then input into the public opinion classification model. Based on the target loss relationship determined by the model's output, the public opinion classification model is trained. By adding label information and prompt information, the focus on the public opinion polarity of the training samples is enhanced, effectively alleviating the problem of insufficient labeling of training samples and avoiding the problem of difficulty in distinguishing public opinion polarity in highly similar texts. The model output results are optimized from the perspective of public opinion polarity, thereby improving the public opinion classification performance of the trained model.

[0060] Optionally, the prompt information includes a mask, and the output of the public opinion classification model includes the mask encoding corresponding to the mask. The mask encoding is used as a judgment feature representation based on the public opinion category judgment. The output of the public opinion classification model also includes the public opinion tag encoding corresponding to the at least two public opinion categories in the tag information. The public opinion tag encoding is used as a category feature representation of the public opinion category. The advantage of this setting is that by using mask encoding and public opinion tag encoding, the public opinion classification model can better learn the vocabulary of the defined domain.

[0061] Specifically, in addition to information about the public opinion category of the sample information text, the prompt message may also include a mask. After inputting the target training sample set containing the prompt message and tag information into the public opinion classification model, the model will output the encoding of the mask (mask encoding) and the encoding of the tags (public opinion tag encoding). The mask can be specifically determined based on the aforementioned MLM.

[0062] For example, the encoding output by the classification model can be represented as:

[0063] Bert out =BERT([[CLS],x1,x2…x n [SEP], sentence_mask)

[0064] Bert out ∈R bs×M×q The output encoding tensor of the public opinion classification model is a multidimensional array of encodings. BERT is the BERT model, i.e., the public opinion classification model, where x1, x2…x n The input characters in the target training sample set correspond to the input quantity of the public opinion classification model, where n is the number of characters and sentence_mask∈R. bs×M is the mask matrix in the target training sample set, bs is the batch size, q represents the dimension of the output vector, and M is the order of the matrix, which is generally n+2, for example, n=510, M=512.

[0065] Optionally, the target loss relationship is determined based on a preset contrastive loss function, which is set based on a preset objective. The preset objective includes: making the judgment feature representation corresponding to the same public opinion category close to the category feature representation, and making the judgment feature representation corresponding to different public opinion categories far away from the category feature representation. The advantage of this setting is that it brings the feature representations of samples of the same public opinion category and their corresponding labels closer together, and widens the feature representations of samples of different public opinion categories and their corresponding labels further apart.

[0066] The inventors discovered that contrastive learning in supervised tasks can easily cause feature representations to lose their 'consistency,' meaning the spatial distribution of feature representations is no longer uniform. For example, a simple bag-of-words encoding representation:

[0067] Sentence 1: [0,0,0,1,0,0]

[0068] Sentence 2: [0,0,1,0,0,0]

[0069] The classifier is represented as: [0,0,1,1,0,0]

[0070] In this example, according to the classifier's representation, both sentence 1 and sentence 2 belong to the category '1'. However, through contrastive learning, the encoding representations of sentence 1 and sentence 2 have a similarity of 0, which can easily lead to an uneven distribution of sentence encoding space.

[0071] In this embodiment of the invention, in order to solve the problem of uneven distribution of the encoding space, the principle of contrastive learning is changed from bringing the representations of samples of the same class closer and distancing the representations of samples of different classes further apart to bringing the representations of samples of the same class closer to their corresponding labels and distancing the representations of samples with other labels further apart. This is because in supervised classification tasks, labels are the only contrastive measure that can distinguish the features of different samples without affecting the 'consistency' of the text sentence.

[0072] Specifically, in this embodiment of the invention, the closer the judgment feature representation and the category feature representation of the same public opinion category are, the smaller the output result of the contrastive loss function; conversely, the farther apart the judgment feature representation and the category feature representation of the same public opinion category are, or the closer the judgment feature representation and the category feature representation of different public opinion categories are, the larger the output result of the contrastive loss function. Here, the judgment feature representation of the public opinion category can be understood as the mask encoding at the mask position in the prompt information, and the category feature representation of the public opinion category can be understood as the public opinion tag encoding at the public opinion category position in the tag information.

[0073] For example, as described above, if the samples in the target training sample set with added prompts and labels are [CLS], the public opinion polarity is [MASK], [SEP], good, mediocre, bad, [SEP], and the information text is [SEP], then the encoding of the mask [MASK] position is C∈R. bs×q It can be used as a judgment feature representation as a basis for judging public opinion categories. The encoding of "good, mediocre, bad" is B∈R. bs ×nclass×q , can be used as a category feature representation of public opinion categories, where q is the dimension of the output vector. Here, nclass is the number of public opinion categories; in this example, nclass = 3.

[0074] Optionally, the preset comparison loss function includes a first comparison loss function and a second comparison loss function. In the first comparison loss function, each target training sample in the target training sample set is sequentially determined as the current target training sample. The similarity calculation result between the current mask encoding of the current target training sample and the first comparison sentiment label encoding is negatively correlated with the loss relationship corresponding to the first comparison loss function. The first comparison sentiment label encoding is the sentiment label encoding of target training samples in the target training sample set, excluding the current target training sample, that correspond to the same sentiment category (which can be understood as the same real sentiment category) as the current target training sample. The similarity calculation result between the current mask encoding of the current target training sample and the second comparison sentiment label encoding is positively correlated with the loss relationship corresponding to the first comparison loss function. The second comparison sentiment label encoding is the sentiment label encoding of target training samples in the target training sample set, excluding the current target training sample, that correspond to different sentiment categories (which can be understood as different real sentiment categories) than the current target training sample. Specifically, the similarity calculation can be a dot product calculation.

[0075] For example, the first contrastive loss function The expression can be represented as:

[0076]

[0077] Among them, C i ∈R q C i This represents the current mask encoding of the i-th target training sample (the current target training sample). This represents the p-th first public opinion tag code to be compared, "·" represents the dot product operator, exp(x) represents e to the power of x, γ represents the temperature coefficient, and N represents the number of samples. This represents the code of the a-th second public opinion tag to be compared, |P i | represents the number of target training samples in the target training sample set that, excluding the i-th target training sample, correspond to the same public opinion category as the i-th target training sample. Let i = 1, 2, 3, ..., N. Let P represent a set of N samples. i A represents the public opinion label code in the target training sample set, excluding the i-th target training sample, that corresponds to the same public opinion category as the i-th target training sample. i This represents the public opinion label encoding matrix of the target training samples in the target training sample set, excluding the i-th target training sample, which correspond to different public opinion categories than the i-th target training sample. It can be seen that... The larger the calculation result, The smaller the calculated result, the more negatively correlated the similarity calculation result between the current mask encoding of the current target training sample and the first public opinion tag encoding to be compared is with the value of the loss relationship corresponding to the first comparison loss function. The larger the calculation result, The larger the calculation result, the more positively correlated the similarity calculation result between the current mask encoding of the current target training sample and the second public opinion tag encoding to be compared is with the value of the loss relationship corresponding to the first comparison loss function.

[0078] In the second comparison loss function, each public opinion label code output by the public opinion classification model is sequentially determined as the current public opinion label code. The similarity calculation result between the current public opinion label code and the first comparison mask code is negatively correlated with the loss relationship corresponding to the second comparison loss function. The first comparison mask code is the mask code of the target training sample in the target training sample set that corresponds to the same public opinion category (which can be understood as the same real public opinion category) as the current public opinion label code. The similarity calculation result between the current public opinion label code and the second comparison mask code is positively correlated with the loss relationship corresponding to the second comparison loss function. The second comparison mask code is the public opinion label code of the target training sample in the target training sample set that corresponds to a different public opinion category (which can be understood as a different real public opinion category) than the current public opinion label code. The larger the value of the similarity calculation result, the higher the degree of closeness.

[0079] For example, the second contrastive loss function The expression can be represented as:

[0080]

[0081] Among them, C k ∈R q C k This represents the encoding of the k-th first mask to be compared. This represents the i-th public opinion tag code, "·" represents the dot product operator, exp(x) represents e to the power of x, γ represents the temperature coefficient, N represents the number of samples, and C a ∈R q C a Represents the encoding of the a-th second mask to be compared, |K i | represents the number of target training samples in the target training sample set that belong to the same public opinion category as the target training sample with the i-th public opinion tag code, excluding the target training sample with the i-th public opinion tag code. Let i = 1, 2, 3, ..., N, K i This represents the target training samples in the target training sample set that, excluding the target training sample to which the i-th public opinion tag code belongs, belong to the same public opinion category as the target training sample to which the i-th public opinion tag code belongs. i This represents the mask encoding matrix of target training samples in the target training sample set, excluding the i-th public opinion tag encoding, that correspond to different public opinion categories than the target training sample to which the i-th public opinion tag encoding belongs. It can be seen that... The larger the calculation result, The smaller the calculated similarity result, the more negatively correlated the similarity calculation result between the current sentiment tag code and the first mask code to be compared is with the value of the loss relationship corresponding to the second comparison loss function. The larger the calculation result, The larger the calculation result, the more positively correlated the similarity calculation result between the current public opinion tag code and the second mask code to be compared is with the value of the loss relationship corresponding to the second comparison loss function.

[0082] The advantage of setting the contrast loss function in this way is that by using the determined first and second contrast loss functions, the uniformity of the encoding space distribution of the training samples of the public opinion classification model can be guaranteed.

[0083] Example 2

[0084] Figure 2 This is a flowchart of a model training method provided in Embodiment 2 of the present invention. The technical solution of the present invention is further optimized based on the above optional technical solutions, and provides a specific method for determining the target loss relationship when training the model.

[0085] Optionally, determining the target loss relationship based on the output of the public opinion classification model includes: determining a preset contrastive loss function and a preset cross-entropy loss function based on the output of the public opinion classification model; determining a target loss function based on the weighted sum of the preset contrastive loss function and the preset cross-entropy loss function; wherein, in the preset cross-entropy loss function, each target training sample in the target training sample set is sequentially determined as the current target training sample, and the similarity calculation result between the current mask encoding and the current public opinion tag encoding of the current target training sample is negatively correlated with the value of the loss relationship corresponding to the preset cross-entropy loss function; the sum of the similarity calculation results between the current mask encoding of the current target training sample and the public opinion tag encodings corresponding to at least two public opinion categories corresponding to the current target training sample is positively correlated with the value of the loss relationship corresponding to the preset cross-entropy loss function. The advantage of this setting is that by utilizing the preset contrastive loss function and the preset cross-entropy loss function, the accuracy of the model in identifying public opinion categories can be further improved.

[0086] like Figure 2 As shown, the model training method provided in Embodiment 2 of the present invention specifically includes the following steps:

[0087] S201. Obtain the initial training sample set.

[0088] S202. Based on the sample information text in the initial training samples, add prompt information and label information to obtain the target training sample set.

[0089] S203. Input the target training sample set into the public opinion classification model, and determine the preset contrast loss function and the preset cross-entropy loss function based on the output of the public opinion classification model.

[0090] In the preset cross-entropy loss function, each target training sample in the target training sample set is sequentially determined as the current target training sample. The similarity calculation result of the current mask encoding and the current public opinion tag encoding of the current target training sample is negatively correlated with the value of the loss relationship corresponding to the preset cross-entropy loss function. The sum of the similarity calculation results of the current mask encoding of the current target training sample and the public opinion tag encodings corresponding to at least two public opinion categories corresponding to the current target training sample is positively correlated with the value of the loss relationship corresponding to the preset cross-entropy loss function.

[0091] Specifically, Figure 3 This is a schematic diagram illustrating the training process of a preset public opinion classification model provided in Embodiment 2 of the present invention, as follows: Figure 3 As shown, the target training sample set can be input into the public opinion classification model (BERT Encoder). The target loss relationship can be determined based on the output, namely the preset contrastive loss function and the preset cross-entropy loss function. The preset contrastive loss function can be calculated by calculating the first contrastive loss function and the second contrastive loss function in a set manner, thereby obtaining the preset contrastive loss function. For example, the preset contrastive loss function is obtained by summing the first contrastive loss function and the second contrastive loss function.

[0092] Optionally, if the distribution of public opinion categories in the target training sample set is unbalanced—for example, the number of samples corresponding to the label information of the neutral public opinion category accounts for a large proportion of the total number of training samples in the target training sample set, while the number of samples corresponding to the label information of the negative and positive public opinion categories is small—then the number of samples for the negative and positive public opinion categories can be increased. The advantage of this setting is that it balances the distribution of public opinion polarity, thereby ensuring the effectiveness of training the public opinion classification model.

[0093] For example, a pre-defined contrastive loss function The expression can be represented as:

[0094]

[0095] For example, a preset cross-entropy loss function The expression can be represented as:

[0096]

[0097] Among them, C i ∈R q C iThis represents the i-th mask encoding, which is the current mask encoding of the current target training sample. This represents the i-th public opinion tag code, i.e., the current public opinion tag code; "·" represents the similarity calculation symbol; exp(x) represents e raised to the power of x; and N represents the number of samples. Let i = 1, 2, 3, ..., N, L be the set of public opinion categories. This represents the l-th sentiment label code of the i-th sample, that is, the sentiment label codes corresponding to at least two sentiment categories of the current target training sample. It can be seen that... The larger the calculation result, The smaller the calculated result, the more negatively correlated the similarity calculation result between the current mask encoding and the current public opinion tag encoding is with the value of the loss relationship corresponding to the preset cross-entropy loss function. The larger the calculation result, The larger the calculation result, that is, the sum of the similarity calculation results of the current mask encoding and the public opinion tag encoding corresponding to at least two public opinion categories corresponding to the current target training sample, is positively correlated with the value of the loss relationship corresponding to the preset cross-entropy loss function.

[0098] S204. Determine the target loss function based on the weighted sum of the preset contrast loss function and the preset cross-entropy loss function.

[0099] For example, the target loss function The expression can be represented as:

[0100]

[0101] Where 'a' is the weighting coefficient.

[0102] Optional, also applicable to and Set weighting coefficients, such as a1 and a2.

[0103] S205. Train the public opinion classification model according to the target loss relationship.

[0104] The model training method provided in this embodiment of the invention, after obtaining an initial training sample set, adds label information containing public opinion categories and prompt information containing masks to the sample information text in the initial training samples to obtain a target training sample set. This target training sample set is then input into a public opinion classification model. Based on the mask encoding and public opinion label encoding of the model's output, the loss relationships corresponding to the preset contrastive loss function and the preset cross-entropy loss function are determined respectively. The two are then weighted and summed to obtain the target loss relationship. This target loss relationship is used to train the public opinion classification model. By adding label information and prompt information to the training samples, the encoding representation of the public opinion classification model focuses more on public opinion polarity information, distinguishes the public opinion polarity features of different training samples, and maintains the uniformity of the feature representation of the information text, that is, the spatial distribution of the feature representation remains uniform, which is more conducive to learning with fewer samples. The public opinion classification performance of the trained model is thus improved.

[0105] Example 3

[0106] Figure 4 The flowchart of an information classification method provided in Embodiment 3 of the present invention is applicable to the classification of public opinion. The method can be executed by an information classification device, which can be implemented in hardware and / or software. The information classification device can be configured in an electronic device, or it can be configured in the same electronic device as a model training device. The electronic device can be composed of two or more physical entities, or it can be composed of a single physical entity.

[0107] like Figure 4 As shown, the information classification method provided in Embodiment 3 of the present invention specifically includes the following steps:

[0108] S301. Obtain the text of the information to be categorized.

[0109] In this embodiment, the information text to be classified can be understood as information text whose public opinion category is unknown.

[0110] S302. Based on the information text to be classified, add prompt information and tag information to obtain the target data to be classified.

[0111] In this embodiment, a prompt message for inquiring about the public opinion category can be added at a third preset position in the text to be classified, and a tag message containing the public opinion category can be added at a fourth preset position in the sample text, thereby obtaining the target data to be classified. For example, the prompt message can be text information such as "Public opinion polarity is [MASK]" or "Public opinion category is [MASK]", and the tag message can be text information such as "good, mediocre, bad" or "good, bad". Here, [MASK] can be understood as a mask for the features used to determine the public opinion category, and the third preset position can be before the fourth preset position.

[0112] S303. Input the target data to be classified into a preset public opinion classification model, and determine the target public opinion category corresponding to the information text to be classified based on the output of the preset public opinion classification model.

[0113] The preset public opinion classification model is obtained using the model training method described in the above embodiments.

[0114] In this embodiment, as Figure 4 As shown, by inputting the target data to be classified into the preset public opinion classification model, the target public opinion category of the target data to be classified can be obtained. The preset public opinion classification model can be understood as a public opinion classification model that meets the requirements, trained using the model training method of the above embodiment.

[0115] The information classification method provided in this embodiment of the invention obtains the information text to be classified, adds prompt information and tag information to the information text to be classified to obtain target data to be classified, inputs the target data to be classified into a preset public opinion classification model, and determines the target public opinion category corresponding to the information text to be classified based on the output of the preset public opinion classification model. The preset public opinion classification model is obtained using a model training method. The technical solution of this embodiment of the invention adds tag information containing public opinion category and prompt information for inquiring about the public opinion category to the information text to be classified, obtains target data to be classified, inputs the target data to be classified into a preset public opinion classification model, and finally determines the target public opinion category corresponding to the information text to be classified based on the output of the model. By adding tag information and prompt information to the information text to be classified, the preset public opinion classification model pays more attention to the public opinion polarity of the information text during encoding, optimizes the model output from the perspective of public opinion polarity, and effectively improves the public opinion classification effect.

[0116] Optionally, the prompt information includes a mask, and the output of the preset public opinion classification model includes the mask encoding corresponding to the mask. The mask encoding is used as a judgment feature representation based on the public opinion category judgment. The output of the preset public opinion classification model also includes the public opinion tag encoding corresponding to the at least two public opinion categories in the tag information. The public opinion tag encoding is used as a category feature representation of the public opinion category.

[0117] Specifically, in addition to information about the public opinion category of the sample information text, the prompt message can also include a mask. After inputting the target training sample set containing the prompt message and tag information into the preset public opinion classification model, the model will output the encoding of the mask (mask encoding) and the encoding of the tags (public opinion tag encoding). The advantage of this setup is that by using mask encoding and public opinion tag encoding, the public opinion classification model can better learn the vocabulary of the defined domain.

[0118] Optionally, determining the public opinion category of the information text to be classified based on the output of the preset public opinion classification model includes: determining predicted values ​​corresponding to at least two public opinion categories based on the target mask encoding and target public opinion tag encoding output by the preset public opinion classification model, thereby obtaining a set of predicted values; and determining the public opinion category corresponding to the largest predicted value in the preset value set as the target public opinion category corresponding to the information text to be classified. The advantage of this setting is that, by calculating the predicted values, the target public opinion category corresponding to the information text to be classified can be accurately obtained.

[0119] Specifically, preset methods, such as similarity calculation, can be used to calculate the target mask code and the target public opinion tag code, thereby obtaining the predicted value and the predicted value set.

[0120] For example, predicted value The expression can be represented as:

[0121]

[0122] Where arg represents the symbol for calculating the principal argument of a complex number, max represents taking the maximum value, and n represents the category of public opinion, which can be understood as the index of the public opinion category. The value of n ranges from 1 to nclass, such as 1, 2, and 3. I ∈R q C I This represents the encoding of the i-th target mask. This represents the nth public opinion label code for the i-th target data to be classified.

[0123] Example 4

[0124] Figure 5 This is a schematic diagram of a model training device provided in Embodiment 4 of the present invention. Figure 5 As shown, the device includes: a training sample acquisition module 401, a target training sample determination module 402, a target loss relationship determination module 403, and a training module 404, wherein:

[0125] The training sample acquisition module is used to acquire an initial training sample set, wherein the initial training samples in the initial training sample set include sample information text.

[0126] The target training sample determination module is used to add prompt information and tag information to the sample information text in the initial training samples to obtain a target training sample set. The prompt information is used to ask the public opinion category of the sample information text, and the tag information contains at least two public opinion categories at the same time.

[0127] The target loss relationship determination module is used to input the target training sample set into the public opinion classification model and determine the target loss relationship based on the output of the public opinion classification model, wherein the public opinion classification model is constructed based on the bidirectional language representation transformation model BERT;

[0128] The training module is used to train the public opinion classification model based on the target loss relationship.

[0129] The model training apparatus provided in this embodiment of the invention, after obtaining an initial training sample set, adds label information containing public opinion categories and prompt information for inquiring about public opinion categories to the sample information text in the initial training samples, thereby obtaining a target training sample set. This target training sample set is then input into a public opinion classification model. Based on the target loss relationship determined by the model's output, the public opinion classification model is trained. By adding label information and prompt information, the focus on the public opinion polarity of the training samples is enhanced, effectively alleviating the problem of insufficient labeling of training samples and avoiding the difficulty in distinguishing public opinion polarity from highly similar texts. The model output results are optimized from the perspective of public opinion polarity, thus improving the public opinion classification performance of the trained model.

[0130] Optionally, the prompt information includes a mask, and the output of the public opinion classification model includes a mask encoding corresponding to the mask. The mask encoding is used as a judgment feature representation based on the public opinion category judgment. The output of the public opinion classification model also includes public opinion tag encodings corresponding to the at least two public opinion categories in the tag information. The public opinion tag encoding is used as a category feature representation of the public opinion category. The target loss relationship is determined based on a preset contrastive loss function, and the preset contrastive loss function is set based on a preset target. The preset target includes: making the judgment feature representation corresponding to the same public opinion category close to the category feature representation, and making the judgment feature representation corresponding to different public opinion categories far away from the category feature representation.

[0131] Optionally, the preset contrast loss function includes a first contrast loss function and a second contrast loss function;

[0132] In the first comparison loss function, each target training sample in the target training sample set is sequentially determined as the current target training sample. The similarity calculation result between the current mask code and the first comparison sentiment label code of the current target training sample is negatively correlated with the value of the loss relationship corresponding to the first comparison loss function. The first comparison sentiment label code is the sentiment label code of the target training sample in the target training sample set, excluding the current target training sample, which corresponds to the same sentiment category as the current target training sample. The similarity calculation result between the current mask code and the second comparison sentiment label code of the current target training sample is positively correlated with the value of the loss relationship corresponding to the first comparison loss function. The second comparison sentiment label code is the sentiment label code of the target training sample in the target training sample set, excluding the current target training sample, which corresponds to a different sentiment category than the current target training sample.

[0133] In the second comparison loss function, each public opinion label code output by the public opinion classification model is sequentially determined as the current public opinion label code. The similarity calculation result between the current public opinion label code and the first comparison mask code is negatively correlated with the loss relationship corresponding to the second comparison loss function. The first comparison mask code is the mask code of the target training sample in the target training sample set that corresponds to the same public opinion category as the current public opinion label code. The similarity calculation result between the current public opinion label code and the second comparison mask code is positively correlated with the loss relationship corresponding to the second comparison loss function. The second comparison mask code is the public opinion label code of the target training sample in the target training sample set that corresponds to a different public opinion category than the current public opinion label code.

[0134] The higher the value of the similarity calculation result, the greater the degree of closeness.

[0135] Optional, the target loss relationship determination module includes:

[0136] The first loss function determination unit is used to determine a preset contrast loss function and a preset cross-entropy loss function based on the output of the public opinion classification model.

[0137] The second loss function determination unit is used to determine the target loss function based on the weighted sum of the preset contrast loss function and the preset cross-entropy loss function;

[0138] In the preset cross-entropy loss function, each target training sample in the target training sample set is sequentially determined as the current target training sample. The similarity calculation result of the current mask encoding and the current public opinion tag encoding of the current target training sample is negatively correlated with the value of the loss relationship corresponding to the preset cross-entropy loss function. The sum of the similarity calculation results of the current mask encoding of the current target training sample and the public opinion tag encodings corresponding to at least two public opinion categories corresponding to the current target training sample is positively correlated with the value of the loss relationship corresponding to the preset cross-entropy loss function.

[0139] The model training apparatus provided in this embodiment of the invention can execute the model training method provided in any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0140] Example 5

[0141] Figure 6 This is a schematic diagram of the structure of an information classification device provided in Embodiment 4 of the present invention. Figure 6 As shown, the device includes: an information text acquisition module 501, an information addition module 502, and a public opinion category determination module 503, wherein:

[0142] The information text acquisition module is used to acquire the information text to be classified.

[0143] The information adding module is used to add prompts and tags to the text to be classified, so as to obtain the target data to be classified.

[0144] The public opinion category determination module is used to input the target data to be classified into a preset public opinion classification model, and determine the target public opinion category corresponding to the information text to be classified based on the output of the preset public opinion classification model. The preset public opinion classification model is obtained by the model training method described above.

[0145] The information classification device provided in this embodiment of the invention adds tag information containing public opinion category and prompt information for inquiring about public opinion category to the information text to be classified, thereby obtaining target data to be classified. The target data to be classified is then input into a preset public opinion classification model. Finally, the target public opinion category corresponding to the information text to be classified is determined based on the output of the model. By adding tag information and prompt information to the information text to be classified, the preset public opinion classification model pays more attention to the public opinion polarity of the information text during encoding, optimizes the model output results from the perspective of public opinion polarity, and effectively improves the public opinion classification effect.

[0146] Optionally, the prompt information includes a mask, and the output of the preset public opinion classification model includes the mask encoding corresponding to the mask. The mask encoding is used as a judgment feature representation based on the public opinion category judgment. The output of the preset public opinion classification model also includes the public opinion tag encoding corresponding to the at least two public opinion categories in the tag information. The public opinion tag encoding is used as a category feature representation of the public opinion category.

[0147] Optional, the public opinion category determination module includes:

[0148] The prediction value determination unit is used to determine the prediction values ​​corresponding to at least two of the public opinion categories based on the target mask code and target public opinion tag code output by the preset public opinion classification model, and to obtain a set of prediction values.

[0149] The public opinion category determination unit is used to determine the public opinion category corresponding to the maximum predicted value in the preset value set as the target public opinion category corresponding to the information text to be classified.

[0150] Example 6

[0151] Figure 7 This is a schematic diagram of the structure of an electronic device provided in Embodiment 6 of the present invention, as shown below. Figure 7 As shown, the device includes a processor 601, a memory 602, an input device 603, and an output device 604; the number of processors 601 in the device can be one or more. Figure 6 Taking a processor 601 as an example; the processor 601, memory 602, input device 603, and output device 604 in the device can be connected via a bus or other means. Figure 6 Taking the example of a connection between China and Israel via a bus.

[0152] The memory 602, as a computer-readable storage medium, can be used to store software programs, computer-executable programs, and modules, such as modules corresponding to the model training method in this embodiment of the invention (e.g., training sample acquisition module 401, target training sample determination module 402, target loss relationship determination module 403, and training module 404 in the model training device), and / or modules corresponding to the information classification method in this embodiment of the invention (e.g., information text acquisition module 501, information addition module 502, and public opinion category determination module 503 in the information classification device). The processor 601 executes various functional applications and data processing of the device by running the software programs, instructions, and modules stored in the memory 602, that is, implementing the above-mentioned model training method and / or information classification method.

[0153] The memory 602 may primarily include a program storage area and a data storage area. The program storage area may store the operating system and at least one application program required for a given function; the data storage area may store data created based on terminal usage. Furthermore, the memory 602 may include high-speed random access memory and non-volatile memory, such as at least one disk storage device, flash memory, or other non-volatile solid-state storage device. In some instances, the memory 602 may further include memory remotely located relative to the processor 601, which can be connected to the device / terminal / server via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.

[0154] The input device 604 can be used to receive input digital or character information, and to generate key signal inputs related to training samples, prompt information, or tag information of the device. The output device 604 may include a display device such as a display screen.

[0155] Example 7

[0156] Embodiment 7 of the present invention also provides a storage medium containing computer-executable instructions, which, when executed by a computer processor, are used to perform a model training method, the method comprising:

[0157] Obtain an initial training sample set, wherein the initial training samples in the initial training sample set include sample information text; based on the sample information text in the initial training samples, add prompt information and tag information to obtain a target training sample set, wherein the prompt information is used to inquire about the public opinion category of the sample information text, and the tag information simultaneously contains at least two public opinion categories; input the target training sample set into a public opinion classification model, determine the target loss relationship based on the output of the public opinion classification model, wherein the public opinion classification model is constructed based on the bidirectional language representation transformation model BERT; train the public opinion classification model according to the target loss relationship.

[0158] And / or, the computer may also execute instructions, when executed by a computer processor, for performing an information classification method, the method comprising: acquiring information text to be classified; adding prompt information and tag information to the information text to be classified to obtain target data to be classified; inputting the target data to be classified into a preset public opinion classification model; and determining the target public opinion category corresponding to the information text to be classified based on the output of the preset public opinion classification model, wherein the preset public opinion classification model is obtained using the model training method described above.

[0159] Of course, the computer-executable instructions provided in the embodiments of the present invention are not limited to the method operations described above, but can also execute the model training method and / or related operations in the information classification method provided in any embodiment of the present invention.

[0160] Based on the above description of the implementation methods, those skilled in the art can clearly understand that the present invention can be implemented using software and necessary general-purpose hardware, and of course, it can also be implemented using hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ROM), random access memory (RAM), flash memory, hard disk, or optical disk, etc., including several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments of the present invention.

[0161] It is worth noting that in the embodiments of the search device described above, the various units and modules included are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be achieved; in addition, the specific names of each functional unit are only for easy differentiation and are not used to limit the scope of protection of the present invention.

[0162] Note that the above description is merely a preferred embodiment of the present invention and the technical principles employed. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and various obvious changes, readjustments, and substitutions can be made without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments, and may include many other equivalent embodiments without departing from the concept of the present invention, the scope of which is determined by the scope of the appended claims.

Claims

1. A model training method, characterized in that, include: Obtain an initial training sample set, wherein the initial training samples in the initial training sample set include sample information text; Based on the sample information text in the initial training samples, prompt information and tag information are added to obtain the target training sample set. The prompt information is used to inquire about the public opinion category of the sample information text, and the tag information contains at least two public opinion categories at the same time. The target training sample set is input into the public opinion classification model, and the target loss relationship is determined based on the output of the public opinion classification model. The public opinion classification model is constructed based on the bidirectional language representation transformation model BERT. The public opinion classification model is trained based on the target loss relationship; The prompt information includes a mask, and the output of the public opinion classification model includes the mask code corresponding to the mask. The mask code is used as a judgment feature representation based on the public opinion category. The output of the public opinion classification model also includes the public opinion tag codes corresponding to the at least two public opinion categories in the tag information. The public opinion tag codes are used as category feature representations of the public opinion categories. The target loss relationship is determined based on a preset contrastive loss function, which is set based on a preset target. The preset target includes: making the judgment feature representation corresponding to the same public opinion category close to the category feature representation, and making the judgment feature representation corresponding to different public opinion categories far away from the category feature representation.

2. The method according to claim 1, characterized in that, The preset contrast loss function includes a first contrast loss function and a second contrast loss function; In the first comparison loss function, each target training sample in the target training sample set is sequentially determined as the current target training sample. The similarity calculation result between the current mask code and the first comparison sentiment label code of the current target training sample is negatively correlated with the value of the loss relationship corresponding to the first comparison loss function. The first comparison sentiment label code is the sentiment label code of the target training sample in the target training sample set, excluding the current target training sample, which corresponds to the same sentiment category as the current target training sample. The similarity calculation result between the current mask code and the second comparison sentiment label code of the current target training sample is positively correlated with the value of the loss relationship corresponding to the first comparison loss function. The second comparison sentiment label code is the sentiment label code of the target training sample in the target training sample set, excluding the current target training sample, which corresponds to a different sentiment category than the current target training sample. In the second comparison loss function, each public opinion label code output by the public opinion classification model is sequentially determined as the current public opinion label code. The similarity calculation result between the current public opinion label code and the first comparison mask code is negatively correlated with the loss relationship corresponding to the second comparison loss function. The first comparison mask code is the mask code of the target training sample in the target training sample set that corresponds to the same public opinion category as the current public opinion label code. The similarity calculation result between the current public opinion label code and the second comparison mask code is positively correlated with the loss relationship corresponding to the second comparison loss function. The second comparison mask code is the public opinion label code of the target training sample in the target training sample set that corresponds to a different public opinion category than the current public opinion label code. The higher the value of the similarity calculation result, the greater the degree of closeness.

3. The method according to claim 1 or 2, characterized in that, Determining the target loss relationship based on the output of the public opinion classification model includes: Based on the output of the public opinion classification model, a preset contrast loss function and a preset cross-entropy loss function are determined. The target loss function is determined based on the weighted sum of the preset contrast loss function and the preset cross-entropy loss function; In the preset cross-entropy loss function, each target training sample in the target training sample set is sequentially determined as the current target training sample. The similarity calculation result of the current mask encoding and the current public opinion tag encoding of the current target training sample is negatively correlated with the value of the loss relationship corresponding to the preset cross-entropy loss function. The sum of the similarity calculation results of the current mask encoding of the current target training sample and the public opinion tag encodings corresponding to at least two public opinion categories corresponding to the current target training sample is positively correlated with the value of the loss relationship corresponding to the preset cross-entropy loss function.

4. An information classification method, characterized in that, include: Obtain the text of the information to be categorized; Based on the information text to be classified, add prompts and tags to obtain the target data to be classified; The target data to be classified is input into a preset public opinion classification model, and the target public opinion category corresponding to the information text to be classified is determined according to the output of the preset public opinion classification model. The preset public opinion classification model is obtained by the model training method described in any one of claims 1-3.

5. The method according to claim 4, characterized in that, The prompt information includes a mask, and the output of the preset public opinion classification model includes the mask encoding corresponding to the mask. The mask encoding is used as a judgment feature representation as the basis for judging the public opinion category. The output of the preset public opinion classification model also includes the public opinion tag encoding corresponding to the at least two public opinion categories in the tag information. The public opinion tag encoding is used as a category feature representation of the public opinion category. The step of determining the public opinion category of the information text to be classified based on the output of the preset public opinion classification model includes: Based on the target mask code and target public opinion tag code output by the preset public opinion classification model, at least two predicted values ​​corresponding to the public opinion categories are determined respectively, and a set of predicted values ​​is obtained. The public opinion category corresponding to the maximum predicted value in the preset value set is determined as the target public opinion category corresponding to the information text to be classified.

6. A model training device, characterized in that, include: The training sample acquisition module is used to acquire an initial training sample set, wherein the initial training samples in the initial training sample set include sample information text. The target training sample determination module is used to add prompt information and tag information to the sample information text in the initial training samples to obtain a target training sample set. The prompt information is used to ask the public opinion category of the sample information text, and the tag information contains at least two public opinion categories at the same time. The target loss relationship determination module is used to input the target training sample set into the public opinion classification model and determine the target loss relationship based on the output of the public opinion classification model, wherein the public opinion classification model is constructed based on the bidirectional language representation transformation model BERT; The training module is used to train the public opinion classification model based on the target loss relationship; The prompt information includes a mask, and the output of the public opinion classification model includes the mask encoding corresponding to the mask. The mask encoding is used as a judgment feature representation based on the public opinion category judgment. The output of the public opinion classification model also includes the public opinion tag encoding corresponding to the at least two public opinion categories in the tag information. The public opinion tag encoding is used as a category feature representation of the public opinion category. The target loss relationship is determined based on a preset contrastive loss function, which is set based on a preset target. The preset target includes: making the judgment feature representation corresponding to the same public opinion category close to the category feature representation, and making the judgment feature representation corresponding to different public opinion categories far away from the category feature representation.

7. An information classification device, characterized in that, include: The information text acquisition module is used to acquire the information text to be classified. The information adding module is used to add prompts and tags to the text to be classified, so as to obtain the target data to be classified. The public opinion category determination module is used to input the target data to be classified into a preset public opinion classification model, and determine the target public opinion category corresponding to the information text to be classified according to the output of the preset public opinion classification model, wherein the preset public opinion classification model is obtained by the model training method described in any one of claims 1-3.

8. An electronic device, characterized in that, The electronic device includes: One or more processors; Storage device for storing one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement the model training method as described in any one of claims 1-3, and / or implement the information classification method as described in any one of claims 4-5.

9. A computer-readable storage medium, characterized in that, It stores a computer program, characterized in that, when executed by a processor, the program implements the model training method as described in any one of claims 1-3, and / or implements the information classification method as described in any one of claims 4-5.

Citation Information

Patent Citations

  • Language model fine tuning method, text classification method, device and equipment

    CN114896395A