Emotion analysis model training method, emotion analysis method, and electronic device

By constructing a sentiment segmenter for the art field and adjusting model parameters, the problem of high error rate in sentiment analysis and detection of public opinion in the field of cultural relics and art was solved, and more accurate sentiment analysis of public opinion texts related to art transactions was achieved.

CN116738986BActive Publication Date: 2026-11-24YIYUAN DIGITAL (BEIJING) TECH GRP CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310282762.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-21
Publication Date
2026-11-24
Estimated Expiration
2043-03-21

AI Technical Summary

Technical Problem

The high error rate in sentiment analysis and detection of public opinion in the field of cultural relics and artworks is mainly due to the dynamic updates of industry "jargon" and the extremely unbalanced distribution of sample set categories caused by the much higher proportion of positive and neutral texts than negative texts.

Method used

By constructing a sentiment segmenter for the art field, the diversity of training data is enhanced. The sentiment segmenter is used to accurately segment texts related to art transaction sentiment, determine classification vectors, and optimize the sentiment analysis model by adjusting the model parameters of the initial sentiment analysis model.

Benefits of technology

This improved the applicability and accuracy of sentiment analysis models in the field of art, and enhanced the efficiency of sentiment analysis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116738986B_ABST
    Figure CN116738986B_ABST
Patent Text Reader

Abstract

This invention provides a sentiment analysis model training method, a sentiment analysis method, and an electronic device, relating to the field of cultural relics and art technology. The method includes: acquiring a training set of public opinion on art transactions; determining multiple pairs of sentence data on art transactions based on each first sample of public opinion text on art transactions and tag data; constructing a sentiment segmenter for the art domain; determining a first identifier and a second identifier based on the sentiment segmenter for the art domain, each first sample of public opinion text on art transactions, and each pair of sentence data on art transactions; determining a first classification vector corresponding to each first sample of public opinion text on art transactions and a second classification vector corresponding to each second sample of public opinion text on art transactions based on each first identifier and each second identifier; and adjusting the model parameters of the initial sentiment analysis model based on each first classification vector and each second classification vector to obtain the sentiment analysis model, thereby improving the accuracy of the sentiment analysis results and the analysis efficiency of the sentiment analysis model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of cultural relics and artworks, and in particular to a method for training an emotion analysis model, an emotion analysis method, and an electronic device. Background Technology

[0002] Global public opinion information on the trade of cultural relics and artworks comes from a wide range of sources, uses diverse languages, and covers numerous topics. This information is characterized by incompleteness, peculiarity, massive volume, and dynamism. Therefore, it is very difficult to conduct sentiment analysis on public opinion information related to the trade of cultural relics and artworks.

[0003] In related technologies, sentiment analysis was initially achieved through matching sentiment dictionaries, while in recent years, deep learning has been used for natural language processing. General-domain sentiment analysis typically employs multi-head attention mechanisms combined with neural networks, meaning manually labeled sentiment data is directly input into the Bidirectional Encoder Representation from Transformers (BERT) model for training. Vertical-domain sentiment analysis builds upon general-domain analysis by training with domain-specific data to obtain word vectors, replacing the word embedding layer of the BERT model, and then training with manually labeled domain-specific sentiment data to obtain a domain-specific sentiment analysis model.

[0004] However, due to the influence of the industry, there is a large amount of industry "jargon" in the field of cultural relics and artworks, which is constantly being updated. In addition, the proportion of positive and neutral texts in the public opinion data of cultural relics and artworks is far higher than that of negative texts, resulting in an extremely unbalanced distribution of text categories in the sample set, leading to an extremely high detection error rate. Summary of the Invention

[0005] This invention provides a method for training a sentiment analysis model, a sentiment analysis method, and an electronic device to solve the problem of extremely high detection error rates in existing technologies.

[0006] This invention provides a method for training a sentiment analysis model, comprising: Obtain a training set of public opinion on art transactions; the training set of public opinion on art transactions includes multiple first sample art transaction public opinion texts and tag data for each first sample art transaction public opinion text; Based on each of the first sample art transaction public opinion texts and the tag data, multiple art transaction public opinion text sentence pairs are determined; each art transaction public opinion text sentence pair includes two second sample art transaction public opinion texts; Build an emotion segmenter for the art field; Based on the aforementioned art domain sentiment segmenter, each of the first sample art transaction sentiment texts, and each of the art transaction sentiment text sentence pairs, a first identifier corresponding to each character in each of the first sample art transaction sentiment texts and a second identifier corresponding to each character in each of the second sample art transaction sentiment texts are determined; Based on each of the first identifiers and each of the second identifiers, a first classification vector corresponding to each of the first sample art transaction public opinion texts and a second classification vector corresponding to each of the second sample art transaction public opinion texts are determined; Based on each of the first classification vectors and each of the second classification vectors, the model parameters of the initial sentiment analysis model are adjusted to obtain the sentiment analysis model.

[0007] According to a sentiment analysis model training method provided by the present invention, the construction of a sentiment segmenter for the art domain includes: Obtain a first lexicon and target information; the target information includes negative words in the field of art and at least one of the following: emoticons; kaomoji; online emotional terms; the first lexicon includes multiple first emotional words and the identifier of each first emotional word; Based on the target information, the first vocabulary is replaced to obtain a second vocabulary; the second vocabulary includes multiple second sentiment words and the identifier of each second sentiment word; Based on the second vocabulary, a sentiment segmenter for the art domain is determined.

[0008] According to a sentiment analysis model training method provided by the present invention, the step of determining a first identifier corresponding to each character in each of the first sample art transaction sentiment texts and a second identifier corresponding to each character in each of the second sample art transaction sentiment texts, based on the sentiment segmenter in the art domain, each of the first sample art transaction sentiment texts, and each of the sentence pairs of the art transaction sentiment texts, includes: Based on the aforementioned art sentiment segmenter, each character in the first sample art transaction public opinion text is converted to obtain the first identifier corresponding to each character in the first sample art transaction public opinion text; Based on the aforementioned art sentiment segmenter, each character in each second sample art transaction sentiment text sentence pair is transformed to obtain a second identifier corresponding to each character in each second sample art transaction sentiment text.

[0009] According to a sentiment analysis model training method provided by the present invention, the step of determining a first classification vector corresponding to each first sample art transaction sentiment text and a second classification vector corresponding to each second sample art transaction sentiment text based on each first identifier and each second identifier includes: Each first identifier and each second identifier are encoded to obtain a first word embedding vector corresponding to each first identifier and a second word embedding vector corresponding to each second identifier; Based on the embedding vectors of the first word and the second word, the first classification vector corresponding to each of the first sample art transaction public opinion texts and the second classification vector corresponding to each of the second sample art transaction public opinion texts are determined respectively.

[0010] According to a sentiment analysis model training method provided by the present invention, the step of adjusting the model parameters of an initial sentiment analysis model based on each first classification vector and each second classification vector to obtain a sentiment analysis model includes: Based on each of the second classification vectors, the second classification vectors are transformed to obtain the target vector; Based on the target vectors and clustering algorithms described above, the value of the first contrastive loss function is calculated; Based on each of the first classification vectors, determine the clustering loss function value; Based on the first comparison loss function value and the clustering loss function value, the target loss function value is determined; Based on the target loss function value, the model parameters of the initial sentiment analysis model are adjusted to obtain the sentiment analysis model.

[0011] According to a sentiment analysis model training method provided by the present invention, the step of calculating a first contrastive loss function value based on each of the target vectors includes: Based on each of the target vectors, a second contrastive loss function value is calculated; the second contrastive loss function value is used to separate the third art transaction public opinion text from a batch of art transaction public opinion text sentence pairs; the third art transaction public opinion text represents any one of the two second sample art transaction public opinion texts included in the art transaction public opinion text sentence pair; The first contrastive loss function value is calculated based on the second contrastive loss function value.

[0012] According to the sentiment analysis model training method provided by the present invention, the step of determining the clustering loss function value based on each first classification vector and a clustering algorithm includes: Based on each of the first classification vectors and the clustering algorithm, the category distribution probability is calculated respectively; the category distribution probability represents the probability of assigning each of the first sample art transaction public opinion texts to the kth cluster; k is a positive integer; Calculate the target distribution probability based on the distribution probability of each category and the soft classification probability of each first classification vector in each batch of first art transaction public opinion text. The divergence value is calculated based on the category distribution probability and the target distribution probability; Based on the divergence value, the clustering loss function value is determined.

[0013] According to a sentiment analysis model training method provided by the present invention, the step of adjusting the model parameters of the initial sentiment analysis model based on the target loss function value to obtain the sentiment analysis model includes: If the target loss function value does not meet the preset conditions, adjust the model parameters of the initial sentiment analysis model and repeat the above steps to determine the target loss function value. If the target loss function value meets the preset conditions, the sentiment analysis model is determined based on the model parameters of the finally updated initial sentiment analysis model.

[0014] This invention also provides a sentiment analysis method, comprising: Obtain the text of public opinion regarding art transactions to be analyzed; The text of public opinion regarding the art transaction to be analyzed is input into the sentiment analysis model to obtain the sentiment analysis results output by the sentiment analysis model; the sentiment analysis model is trained based on the sentiment analysis model training method described in any of the above methods.

[0015] The present invention also provides a sentiment analysis model training device, comprising: The first acquisition module is used to acquire a training set of public opinion on art transactions; the training set of public opinion on art transactions includes multiple first sample art transaction public opinion texts and tag data for each first sample art transaction public opinion text; The teaming module is used to determine multiple pairs of art transaction public opinion texts based on each of the first sample art transaction public opinion texts and the tag data; each pair of art transaction public opinion texts includes two second sample art transaction public opinion texts. Build modules for constructing sentiment segmenters for the art field; The determination module is used to determine, based on the art domain sentiment segmenter, each first sample art transaction sentiment text and each sentence pair of the art transaction sentiment text, a first identifier corresponding to each character in each first sample art transaction sentiment text and a second identifier corresponding to each character in each second sample art transaction sentiment text; The feature extraction module is used to determine, based on each of the first identifiers and each of the second identifiers, a first classification vector corresponding to each of the first sample art transaction public opinion texts and a second classification vector corresponding to each of the second sample art transaction public opinion texts; The adjustment module is used to adjust the model parameters of the initial sentiment analysis model based on each of the first classification vectors and each of the second classification vectors to obtain the sentiment analysis model.

[0016] The present invention also provides an emotion analysis device, comprising: The second acquisition module is used to acquire the public opinion text of the art transaction to be analyzed; The analysis module is used to input the public opinion text of the art transaction to be analyzed into the sentiment analysis model and obtain the sentiment analysis results output by the sentiment analysis model; the sentiment analysis model is trained based on the sentiment analysis model training method described in any of the above methods.

[0017] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the sentiment analysis model training method or sentiment analysis method as described above.

[0018] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the sentiment analysis model training method or sentiment analysis method as described above.

[0019] The sentiment analysis model training method, sentiment analysis method, and electronic device provided by this invention enhance the diversity of training data by determining multiple art transaction sentiment text sentence pairs based on multiple first sample art transaction sentiment texts and the label data of each first sample art transaction sentiment text during the training of the sentiment analysis model. Each art transaction sentiment text sentence pair includes two second sample art transaction sentiment texts. Furthermore, by constructing a sentiment segmenter for the art domain, the system can accurately segment the second sample of art transaction sentiment text and the first sample of art transaction sentiment text. This yields the first identifier for each character in the second sample of art transaction sentiment text and the second identifier for each character in the second sample of art transaction sentiment text. This allows for the determination of the first classification vector for each first sample of art transaction sentiment text and the second classification vector for each second sample of art transaction sentiment text. Based on these first and second classification vectors, the model parameters of the initial sentiment analysis model are further adjusted to obtain the desired sentiment analysis model. This improves the applicability of the sentiment analysis model, resulting in more accurate sentiment analysis results when performing sentiment analysis on art transaction sentiment text in the art domain, thus enhancing the analysis efficiency of the sentiment analysis model. Attached Figure Description

[0020] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0021] Figure 1 This is one of the flowcharts illustrating the sentiment analysis model training method provided by the present invention; Figure 2 This is the second flowchart illustrating the training method for the sentiment analysis model provided by this invention; Figure 3 This is a flowchart illustrating the sentiment analysis method provided by the present invention; Figure 4 This is a schematic diagram of the structure of the sentiment analysis model training device provided by the present invention; Figure 5 This is a schematic diagram of the emotion analysis device provided by the present invention; Figure 6 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation

[0022] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.

[0023] The following is combined with Figures 1-3 The present invention describes the training method for the sentiment analysis model and the sentiment analysis method.

[0024] Figure 1 This is one of the flowcharts illustrating the sentiment analysis model training method provided by this invention, such as... Figure 1 As shown, the method includes steps 101-106; wherein, Step 101: Obtain the art transaction public opinion training set; the art transaction public opinion training set includes multiple first sample art transaction public opinion texts and the tag data of each first sample art transaction public opinion text.

[0025] It should be noted that the sentiment analysis model training method provided by the present invention is applicable to the scenario of public opinion sentiment analysis in the process of art transactions in the field of cultural relics and artworks. The execution subject of the method can be a sentiment analysis model training device, such as an electronic device, or a control module in the sentiment analysis model training device for executing the sentiment analysis model training method.

[0026] Specifically, before acquiring the art transaction public opinion training set, we first acquire historical data and tag data of art transaction public opinion information. The data format is text, and the tag data is categorized as positive, neutral, or negative. Positive indicates that the text is a positive policy document, neutral indicates that the text is meaningless content, such as an auction announcement by a company, and negative indicates that the text is content related to illegal transactions.

[0027] The historical data of public opinion information regarding art transactions will be cleaned, including but not limited to: meaningless text (usernames, nicknames, or advertisements, etc.), non-text data (HTML tags, URLs, phone numbers, or email addresses, etc.), and stop words (repeated words or phrases that do not contain any emotion). For emojis in the historical data of public opinion information regarding art transactions, these emojis will be converted into their corresponding Chinese translations.

[0028] Furthermore, sample balancing was performed on various data types within the historical data of public opinion information regarding art transactions. The historical data on public opinion information regarding art transactions was balanced using upsampling (oversampling). Upsampling involves using the label with the largest amount of data as the standard, and generating the same number of samples from other labels with smaller amounts of data as the label with the largest amount of data. Generation methods included naive random upsampling, simple data augmentation (EasyData Augmentation), back-translation of data, and text generation using a text generator (gpt2).

[0029] After cleaning the historical data of public opinion information on art transactions and balancing the amount of various types of tag data, a training set of public opinion information on art transactions is obtained; the training set of public opinion information on art transactions includes multiple first sample art transaction public opinion texts and tag data for each first sample art transaction public opinion text.

[0030] Step 102: Based on each of the first sample art transaction public opinion texts and the tag data, determine multiple pairs of art transaction public opinion text sentences; the art transaction public opinion text sentence pairs include two second sample art transaction public opinion texts.

[0031] Specifically, due to the need for comparative learning, each first sample art transaction public opinion text needs to be combined and paired, and the paired data must have high semantic similarity with the original first sample art transaction public opinion text.

[0032] There are three methods for obtaining sentence pairs from art transaction public opinion texts: data augmentation, virtual augmentation, or similar combination. 1) Data augmentation: While preserving the semantics of the labeled data as much as possible, a large amount of labeled data is generated from a small amount of labeled data. Specific methods include back-translation, EDA, and Natural Language Processing Augmentation (NLPAug). EDA includes synonym replacement, random insertion, random replacement, or random deletion. 2) Virtual augmentation: A copy of the original data is used as the paired data. 3) Similar combination: Data of the same category as the original data is directly used for pairing.

[0033] In practice, based on the first sample art transaction public opinion texts and label data included in the art transaction public opinion training set, paired datasets can be obtained by using data augmentation, virtual augmentation, or similar combinations. The paired datasets include multiple pairs of art transaction public opinion text sentences; among them, each pair of art transaction public opinion text sentences includes two second sample art transaction public opinion texts; the two second sample art transaction public opinion texts can be the same or different, and the second sample art transaction public opinion texts can be the same as or different from the first sample art transaction public opinion texts.

[0034] Step 103: Construct an emotion segmenter for the field of artworks.

[0035] Specifically, based on the public opinion texts generated during the art transaction process in the art field, a sentiment segmenter for the art field can be further constructed.

[0036] Step 104: Based on the art domain sentiment segmenter, each of the first sample art transaction sentiment texts, and each of the art transaction sentiment text sentence pairs, determine the first identifier corresponding to each character in each of the first sample art transaction sentiment texts and the second identifier corresponding to each character in each of the second sample art transaction sentiment texts.

[0037] Specifically, based on the constructed art domain sentiment segmenter, the first sample art transaction sentiment texts, and the sentence pairs of each art transaction sentiment text, the art domain sentiment segmenter can be used to segment each character in each first sample art transaction sentiment text and each second sample art transaction sentiment text in each sentence pair, thereby determining the first identifier corresponding to each character in each first sample art transaction sentiment text and the second identifier corresponding to each character in each second sample art transaction sentiment text.

[0038] Step 105: Based on each of the first identifiers and each of the second identifiers, determine the first classification vector corresponding to each of the first sample art transaction public opinion texts and the second classification vector corresponding to each of the second sample art transaction public opinion texts.

[0039] Specifically, based on each first identifier and each second identifier, the neural network feature extraction module embeds each first identifier and each second identifier into a high-dimensional vector space to obtain the first classification vector corresponding to each first sample art transaction public opinion text and the second classification vector corresponding to each second sample art transaction public opinion text. Since the label data includes positive, neutral, and negative types, the number of first classification vectors and second classification vectors is 3 each.

[0040] Step 106: Based on each of the first classification vectors and each of the second classification vectors, adjust the model parameters of the initial sentiment analysis model to obtain the sentiment analysis model.

[0041] Specifically, an initial sentiment analysis model is pre-built. During the training process of the initial sentiment analysis model, the model parameters of the initial sentiment analysis model can be further adjusted based on the obtained first classification vectors and second classification vectors, and finally the sentiment analysis model is obtained.

[0042] The sentiment analysis model training method provided by this invention enhances the diversity of training data by determining multiple pairs of art transaction sentiment texts based on the multiple first-sample art transaction sentiment texts and the label data of each first-sample art transaction sentiment text in the art transaction sentiment training set. Each pair of art transaction sentiment texts includes two second-sample art transaction sentiment texts. Furthermore, by constructing a sentiment segmenter for the art domain, the system can accurately segment the second sample of art transaction sentiment text and the first sample of art transaction sentiment text. This yields the first identifier for each character in the second sample of art transaction sentiment text and the second identifier for each character in the second sample of art transaction sentiment text. This allows for the determination of the first classification vector for each first sample of art transaction sentiment text and the second classification vector for each second sample of art transaction sentiment text. Based on these first and second classification vectors, the model parameters of the initial sentiment analysis model are further adjusted to obtain the desired sentiment analysis model. This improves the applicability of the sentiment analysis model, resulting in more accurate sentiment analysis results when performing sentiment analysis on art transaction sentiment text in the art domain, thus enhancing the analysis efficiency of the sentiment analysis model.

[0043] Optionally, the specific implementation process of step 103 above includes: 1) Obtain a first lexicon and target information; the target information includes negative words in the field of art and at least one of the following: emoticons; kaomoji; online emotional terms; the first lexicon includes multiple first emotional words and the identifier of each first emotional word.

[0044] Specifically, the pre-trained model (distilbert-base-nli-stsb-mean-tokens) and the first vocabulary list (vocab.txt) of the pre-trained model are obtained. The first vocabulary list includes multiple first sentiment words and the identifiers of each first sentiment word.

[0045] Furthermore, target information can be obtained, which includes negative terms in the field of art and at least one of the following: emoticons; kaomojis; online emotional terms; among which, negative terms in the field of art include, for example, tomb raiding, black donkey hooves, funerary objects, Luoyang shovel, digging sweet potatoes, or yellow goods.

[0046] 2) Based on the target information, the first word list is replaced to obtain a second word list; the second word list includes multiple second sentiment words and the identifier of each second sentiment word.

[0047] Specifically, the first vocabulary can be replaced based on the acquired target information. For example, positions 1 to 99 ([unused1] to [unused99]) in the first vocabulary can be replaced with the three types of words represented by the target information to obtain the second vocabulary (emotion_vocab.txt); or, if the number of words exceeds 99, the three types of words represented by the target information can be added using the built-in function (tokenizer.add_tokens) to obtain the second vocabulary; the second vocabulary includes multiple second sentiment words and the identifier of each second sentiment word.

[0048] 3) Based on the second vocabulary, determine the sentiment segmenter for the art domain.

[0049] Specifically, based on the second vocabulary, an emotional segmenter for the art domain can be determined.

[0050] The sentiment analysis model training method provided by this invention obtains a first lexicon and target information. The target information includes negative words in the art field and at least one of the following: emoticons; kaomoji; online sentiment terms. The first lexicon includes multiple first sentiment words and their identifiers. The first lexicon is then replaced according to the target information to obtain a second lexicon. The second lexicon includes multiple second sentiment words and their identifiers. A sentiment segmenter for the art field is then determined based on the second lexicon, enabling the segmenter to accurately segment first and second sample art transaction sentiment texts in the art field. This segmentation yields the first identifier corresponding to each character in the first sample art transaction sentiment text and the second identifier corresponding to each character in the second sample art transaction sentiment text. This method further determines the sentiment analysis model, improving its applicability and making the sentiment analysis results more accurate and efficient when performing sentiment analysis on art transaction sentiment texts in the art field.

[0051] Optionally, the specific implementation process of step 104 above includes: Based on the art sentiment segmenter, each character in each of the first sample art transaction sentiment texts is transformed to obtain a first identifier corresponding to each character in each of the first sample art transaction sentiment texts; based on the art sentiment segmenter, each character in each of the second sample art transaction sentiment texts in each of the sentence pairs of the art transaction sentiment texts is transformed to obtain a second identifier corresponding to each character in each of the second sample art transaction sentiment texts.

[0052] Specifically, an art sentiment segmenter is used to segment each character in the first sample art transaction sentiment text, and then each segmented character is converted into a first identifier corresponding to each character in the first sample art transaction sentiment text; then, an art sentiment segmenter is used to segment each character in each second sample art transaction sentiment text sentence pair, and then each segmented character is converted into a second identifier corresponding to each character in the second sample art transaction sentiment text.

[0053] Optionally, the specific implementation process of step 105 above includes: a) Encode each of the first identifiers and each of the second identifiers respectively to obtain the first word embedding vector corresponding to each of the first identifiers and the second word embedding vector corresponding to each of the second identifiers.

[0054] Specifically, an encoder or pre-trained model can be used to encode each first identifier and each second identifier to obtain the first word embedding vector (corpus_embeddings) corresponding to the first identifier of each character in the first sample art transaction public opinion text and the second word embedding vector corresponding to the second identifier of each character in the second sample art transaction public opinion text.

[0055] b) Based on each of the first word embedding vectors and each of the second word embedding vectors, determine the first classification vector corresponding to each of the first sample art transaction public opinion texts and the second classification vector corresponding to each of the second sample art transaction public opinion texts.

[0056] Specifically, based on each first word embedding vector and each second word embedding vector, the neural network feature extraction module calculates each first word embedding vector and each second word embedding vector respectively, and inputs each first word embedding vector and each second word embedding vector into the neural network feature extraction module to obtain the first classification vector corresponding to each first sample art transaction public opinion text and the second classification vector corresponding to each second sample art transaction public opinion text output by the neural network feature extraction module.

[0057] Optionally, the specific implementation process of step 106 above includes: 1) Based on each of the second classification vectors, transform each of the second classification vectors to obtain the target vector.

[0058] Specifically, the contrastive loss module consists of a Multilayer Perceptron (MLP) and a contrastive loss function. This module is used to separate the art transaction sentiment text sentence pairs corresponding to each positively labeled data in each batch from those corresponding to other positively labeled data, thereby obtaining a higher level of semantic feature representation. The MLP structure consists of a fully connected linear layer, a ReLU activation function, and another fully connected linear layer. The contrastive loss function is constructed based on the sample data size M of each batch (Mini-batch). The first sample art transaction sentiment text (i1) is processed by the data pairing module to obtain the second sample art transaction sentiment text (i2), increasing the data size from M to 2M. The art transaction sentiment text sentence pairs in each batch (Mini-batch) are then... (∈Mini-batch) is used as a positive sample, while the other (2M-2) second sample art transaction sentiment texts in that batch are used as negative samples.

[0059] In practice, each second classification vector is input into a multilayer perceptron, which then transforms the second classification vectors to obtain a higher-dimensional target vector.

[0060] 2) Calculate the first contrast loss function value based on each of the target vectors.

[0061] Specifically, based on the target vectors obtained from the multilayer perceptron transformation, a first contrastive loss function can be further calculated. It should be noted that optimizing the value of the first contrastive loss function not only helps to implicitly encode the classification semantic structure into the representation, but also improves the reasoning ability for pairwise semantics.

[0062] 3) Determine the clustering loss function value based on each of the first classification vectors and the clustering algorithm.

[0063] Specifically, based on the first-class vectors output by the neural network feature extraction module, a clustering loss module is used to determine the clustering loss function value. This module consists of a linear mapping layer and a Kullback-Leibler Divergence (KL) loss function. The linear mapping layer uses the K-Means clustering algorithm to cluster the multiple first-class vectors corresponding to all the first-sample art transaction sentiment texts into clusters of 3, resulting in three initial cluster center coordinates (cluster_centers). The basic idea of ​​the K-means algorithm is to cluster around k points in space, classifying the first-class vectors closest to these k points. During training, the values ​​of each cluster center are updated iteratively until the best clustering result is obtained.

[0064] In the process of cluster training using the K-Means algorithm, the cluster center coordinates (cluster_centers) obtained by the K-Means algorithm are converted into parameters that can participate in model training. By continuously updating the cluster center coordinate values ​​during the training process to achieve optimization, these trained parameters are the parameters of the linear mapping layer.

[0065] 4) Determine the target loss function value based on the first comparison loss function value and the clustering loss function value.

[0066] Specifically, based on the first contrastive loss function value and the clustering loss function value, the target loss function value can be further determined using formula (1), wherein the jointly optimized target loss function is expressed by formula (1), where: (1) in, This represents the target loss function value. This represents the value of the first contrastive loss function. Indicates weight, The value represents the clustering loss function, and M represents the total number of sentence pairs in each batch of art transaction public opinion texts. This represents the divergence value of the j-th second sample of public opinion text regarding art transactions. Let C represent the value of the second contrastive loss function for the i-th pair of text sentences related to art transactions, let C represent the label of the clustering loss function value, and let I represent the label of the first contrastive loss function value.

[0067] It is important to note that the clustering loss function is optimized only on the art transaction sentiment training set, not on the paired dataset; the contrastive loss function is optimized only on the paired dataset. By jointly optimizing the first contrastive loss function and the clustering loss function, the distance between different categories in the text semantic space is increased, while the intra-category distance is decreased.

[0068] 5) Based on the target loss function value, adjust the model parameters of the initial sentiment analysis model to obtain the sentiment analysis model.

[0069] Specifically, based on the target loss function value, it is further determined whether the training process meets the preset conditions, and the sentiment analysis model is obtained by adjusting the model parameters of the initial sentiment analysis model.

[0070] Optionally, calculating the first contrastive loss function value based on each of the target vectors includes: Based on each of the target vectors, a second contrastive loss function value is calculated; the second contrastive loss function value is used to separate the third art transaction public opinion text from a batch of art transaction public opinion text sentence pairs; the third art transaction public opinion text represents any one of the two second sample art transaction public opinion texts included in the art transaction public opinion text sentence pairs; based on the second contrastive loss function value, a first contrastive loss function value is calculated.

[0071] Specifically, the third art transaction sentiment text refers to any one of the two second sample art transaction sentiment texts included in the art transaction sentiment text sentence pair, for example, the art transaction sentiment text sentence pair ( , The third type of public opinion text on art transactions can be used to... It can also be used as Based on the target vectors output by the multilayer perceptron of the contrast loss module, the norm is calculated to obtain the result, and then the value of the second contrast loss function is calculated based on the result.

[0072] For example, suppose z i1 and z i2 The result obtained by norm calculation of the output of MLP, i.e. , For any pair of art transaction sentiment texts in each batch, the second sample of art transaction sentiment texts... The third sample of art transaction sentiment text is obtained by minimizing the calculated second contrastive loss function. It is separated from multiple pairs of art transaction sentiment text sentences corresponding to all negative labeled data in the Mini-batch. Among them, the second contrastive loss function value It is expressed by formula (2), where: (2) in, Indicates an indicator function, This represents the temperature parameter, set to 0.5; sim represents the dot product. , T represents transpose.

[0073] Furthermore, based on the calculated second contrastive loss function value, the second contrastive loss function values ​​of all art transaction sentiment text sentence pairs in the Mini-batch are averaged to finally obtain the first contrastive loss function value. It is expressed by formula (3), where: (3) Optionally, determining the clustering loss function value based on each of the first classification vectors and the clustering algorithm includes: a) Calculate the category distribution probability based on each of the first classification vectors and the clustering algorithm; the category distribution probability represents the probability of assigning each of the first sample art transaction public opinion texts to the kth cluster; k is a positive integer.

[0074] Specifically, based on the first classification vectors output by the neural network feature extraction module, the K-Means clustering algorithm is used to cluster all the first sample art transaction public opinion texts corresponding to each first classification vector with a cluster size of k, where k is a positive integer. The K-Means clustering algorithm is an unsupervised clustering algorithm, which is used to cluster first sample art transaction public opinion texts from the same semantic category into the same cluster.

[0075] Suppose there are labeled data with K categories (clusters), and each category is represented in the representation space by the coordinates (centroid) of its cluster center, denoted as μ. k , First Sample of Art Transaction Public Opinion Text x j The representation in the representation space of the art transaction public opinion training set i1 can be represented as e j =ψ(x j Based on Maaten and Hinton (2008), the class distribution probability is calculated using the Student's-t distribution, i.e., x... j The probability assigned to the k-th cluster is expressed by formula (4), where: (4) in, Let α represent the probability distribution of the category, and let α represent the degrees of freedom of the Student's-t distribution. Let α = 1. This represents the initial cluster center coordinates at each iteration. Represents the first classification vector. This represents the updated cluster center coordinates, and K represents the total number of categories.

[0076] b) Calculate the target distribution probability based on the distribution probability of each category and the soft classification probability of each first classification vector in each batch of first sample art transaction public opinion text.

[0077] Specifically, based on the distribution probability of each category and the soft classification probability corresponding to each first classification vector in the first batch of art transaction public opinion texts, the target distribution probability is calculated using formula (5); where, (5) in, Represents the target distribution probability. k=1,…,K This represents the soft classification probability of each first-classification vector in the first sample of art transaction public opinion text in each batch. This represents the soft classification probability after iterative updates.

[0078] Furthermore, the target distribution probability is first divided by the category distribution probability q jk By increasing the probability to the power of 2 and then normalizing it using soft classification probabilities, we can learn from high-confidence clusters while reducing the bias caused by imbalanced clustering.

[0079] c) Calculate the divergence value based on the category distribution probability and the target distribution probability.

[0080] Specifically, the divergence value is calculated using KLDivLoss, i.e., Kullback-Leibler divergence. For tensors of the same shape... , ,in It is input. The objective is defined as follows: The KL divergence is defined as: (6) The class distribution probability (q) is obtained by using KL divergence. jk ) Target distribution probability (p jk (Closer, divergence value) Calculate using formula (7), where: (7) in, This represents the category distribution probability corresponding to the j-th first sample of public opinion text regarding art transactions. Let represent the target distribution probability corresponding to the j-th first sample of public opinion text on art transactions.

[0081] d) Determine the clustering loss function value based on the divergence value.

[0082] Specifically, based on the calculated divergence value, the clustering loss function value can be further calculated using formula (8), where: (8) It should be noted that during training, the gradient descent update is performed after summing the clustering loss function values ​​for each mini-batch. On the one hand, a group of data in a batch collectively determines the direction of the gradient, making gradient descent less prone to errors and reducing its randomness; on the other hand, since the number of samples in a batch is much smaller than the entire dataset, the computational cost is not very high.

[0083] Optionally, adjusting the model parameters of the initial sentiment analysis model based on the target loss function value to obtain the sentiment analysis model includes: If the target loss function value does not meet the preset conditions, adjust the model parameters of the initial sentiment analysis model and repeat the above steps to determine the target loss function value; if the target loss function value meets the preset conditions, determine the sentiment analysis model based on the model parameters of the finally updated initial sentiment analysis model.

[0084] Specifically, during model training, the calculated target loss function value is compared with preset conditions, which are that the target loss function value is minimized or tends to stabilize. If the target loss function value does not meet the preset conditions, the model parameters of the initial sentiment analysis model are adjusted, and the steps for determining the target loss function value are repeated. That is, the initial sentiment analysis model with updated model parameters is iterated and trained again until the target loss function value meets the preset conditions. If the target loss function value meets the preset conditions, the model parameters of the finally updated initial sentiment analysis model are used as the model parameters of the sentiment analysis model, thus obtaining the sentiment analysis model.

[0085] Figure 2 This is the second flowchart illustrating the sentiment analysis model training method provided by this invention, as shown below. Figure 2 As shown, the method includes steps 201-213; wherein, Step 201: Obtain the art transaction public opinion training set; the art transaction public opinion training set includes multiple first sample art transaction public opinion texts and the tag data of each first sample art transaction public opinion text.

[0086] Step 202: Identify multiple pairs of art transaction sentiment texts. Based on the first sample art transaction sentiment texts and tag data, a data pairing module is used to identify multiple pairs of art transaction sentiment texts; each pair includes two second sample art transaction sentiment texts.

[0087] Step 203: Construct an art-related sentiment segmenter.

[0088] Step 204: Determine multiple first identifiers and multiple second identifiers. Using an art sentiment segmentation tool, each character in each of the first sample art transaction sentiment texts and each of the second sample art transaction sentiment texts is transformed to obtain the first identifier corresponding to each character in each of the first sample art transaction sentiment texts and the second identifier corresponding to each character in each of the second sample art transaction sentiment texts.

[0089] Step 205: Determine multiple first word embedding vectors and multiple second word embedding vectors. Encode each first identifier and each second identifier to obtain the first word embedding vector corresponding to each first identifier and the second word embedding vector corresponding to each second identifier.

[0090] Step 206: Determine multiple first-classification vectors and multiple second-classification vectors. Based on each first-word embedding vector and each second-word embedding vector, a neural network feature extraction module is used to determine the first-classification vector corresponding to each first-sample art transaction public opinion text and the second-classification vector corresponding to each second-sample art transaction public opinion text.

[0091] Step 207: Transform each second-classification vector to obtain the target vector.

[0092] Step 208: Determine the first contrastive loss function value. Based on each target vector, calculate the second contrastive loss function value, and then calculate the first contrastive loss function value based on the second contrastive loss function value.

[0093] Step 209: Determine the category distribution probability and the target distribution probability. Based on each first classification vector and the clustering algorithm, calculate the category distribution probability respectively. Then, calculate the target distribution probability based on the category distribution probability and the soft classification probability corresponding to each first classification vector in each batch of first art transaction public opinion text.

[0094] Step 210: Determine the clustering loss function value. Calculate the divergence value based on the category distribution probability and the target distribution probability; then determine the clustering loss function value based on the divergence value.

[0095] Step 211: Determine the target loss function value based on the first contrast loss function value and the clustering loss function value.

[0096] Step 212: Determine whether the target loss function value meets the preset conditions. If the target loss function value does not meet the preset conditions, adjust the model parameters of the initial sentiment analysis model and proceed to steps 204 to 212; if the target loss function value meets the preset conditions, proceed to step 213.

[0097] Step 213: Determine the sentiment analysis model based on the model parameters of the final updated initial sentiment analysis model.

[0098] Figure 3 This is a flowchart illustrating the sentiment analysis method provided by the present invention, as shown below. Figure 3 As shown, the method includes steps 301-302; wherein, Step 301: Obtain the text of public opinion regarding art transactions to be analyzed; Step 302: Input the text of public opinion on art transactions to be analyzed into the sentiment analysis model to obtain the sentiment analysis results output by the sentiment analysis model; The sentiment analysis model is trained based on the sentiment analysis model training method described in the foregoing embodiments.

[0099] Specifically, by inputting the acquired public opinion text on art transactions to be analyzed into a trained sentiment analysis model, the sentiment analysis results corresponding to the public opinion text on art transactions to be analyzed can be obtained from the output of the sentiment analysis model. The sentiment analysis results can be positive, neutral, or negative.

[0100] The sentiment analysis method provided by this invention obtains sentiment analysis results by inputting the acquired text of public opinion on art transactions into a trained sentiment analysis model. During the training of the sentiment analysis model, the distance between different categories in the text semantic space is increased while the intra-category distance is decreased by jointly using the contrastive loss function and the clustering loss function. By updating the model parameters during iterative training, the final sentiment analysis model is obtained, improving its applicability. This makes the sentiment analysis results more accurate when performing sentiment analysis on public opinion texts related to art transactions in the field of cultural relics and art, thus improving the analysis efficiency of the sentiment analysis model.

[0101] The following describes the sentiment analysis model training device and the sentiment analysis device provided by the present invention. The sentiment analysis model training device described below and the sentiment analysis model training method described above can be referred to in correspondence with each other. The sentiment analysis device and the sentiment analysis method described above can be referred to in correspondence with each other.

[0102] Figure 4 This is a schematic diagram of the structure of the sentiment analysis model training device provided by the present invention, as shown below. Figure 4 As shown, the sentiment analysis model training device 400 includes a first acquisition module 401, a team formation module 402, a construction module 403, a first determination module 404, a second determination module 405, and an adjustment module 406; wherein, The first acquisition module 401 is used to acquire a training set of public opinion on art transactions; the training set of public opinion on art transactions includes multiple first sample art transaction public opinion texts and tag data of each first sample art transaction public opinion text; The teaming module 402 is used to determine multiple pairs of art transaction public opinion texts based on each of the first sample art transaction public opinion texts and the tag data; the art transaction public opinion text sentence pairs include two second sample art transaction public opinion texts; Module 403 is used to build a sentiment segmenter for the art domain; The first determining module 404 is used to determine, based on the art field sentiment segmenter, each first sample art transaction sentiment text and each sentence pair of art transaction sentiment text, a first identifier corresponding to each character in each first sample art transaction sentiment text and a second identifier corresponding to each character in each second sample art transaction sentiment text; The second determining module 405 is used to determine, based on each of the first identifiers and each of the second identifiers, a first classification vector corresponding to each of the first sample art transaction public opinion texts and a second classification vector corresponding to each of the second sample art transaction public opinion texts; The adjustment module 406 is used to adjust the model parameters of the initial sentiment analysis model based on each of the first classification vectors and each of the second classification vectors to obtain the sentiment analysis model.

[0103] The sentiment analysis model training device provided by this invention, during the training of the sentiment analysis model, determines multiple pairs of art transaction sentiment texts based on the multiple first sample art transaction sentiment texts and the label data of each first sample art transaction sentiment text included in the art transaction sentiment training set. Each pair of art transaction sentiment texts includes two second sample art transaction sentiment texts, thereby enhancing the diversity of the training data. Furthermore, by constructing a sentiment segmenter for the art domain, the sentiment segmenter can accurately segment the second sample art transaction sentiment text and the first sample art transaction sentiment text in the art domain. This yields the first identifier corresponding to each character in the second sample art transaction sentiment text and the second identifier corresponding to each character in each second sample art transaction sentiment text. This allows for the determination of at least one first classification vector and at least one second classification vector for each first sample art transaction sentiment text. Based on these first and second classification vectors, the model parameters of the initial sentiment analysis model are further adjusted to obtain the sentiment analysis model. This improves the applicability of the sentiment analysis model, making the sentiment analysis results more accurate when performing sentiment analysis on art transaction sentiment text in the art domain, and enhancing the analysis efficiency of the sentiment analysis model.

[0104] Optionally, the construction module 403 is specifically used for: Obtain a first lexicon and target information; the target information includes negative words in the field of art and at least one of the following: emoticons; kaomoji; online emotional terms; the first lexicon includes multiple first emotional words and the identifier of each first emotional word; Based on the target information, the first vocabulary is replaced to obtain a second vocabulary; the second vocabulary includes multiple second sentiment words and the identifier of each second sentiment word; Based on the second vocabulary, a sentiment segmenter for the art domain is determined.

[0105] Optionally, the first determining module 404 is specifically used for: Based on the aforementioned art sentiment segmenter, each character in the first sample art transaction public opinion text is converted to obtain the first identifier corresponding to each character in the first sample art transaction public opinion text; Based on the aforementioned art sentiment segmenter, each character in each second sample art transaction sentiment text sentence pair is transformed to obtain a second identifier corresponding to each character in each second sample art transaction sentiment text.

[0106] Optionally, the second determining module 405 is specifically used for: Each first identifier and each second identifier are encoded to obtain a first word embedding vector corresponding to each first identifier and a second word embedding vector corresponding to each second identifier; Based on the embedding vectors of each first word and each second word, at least one first classification vector and at least one second classification vector corresponding to each first sample art transaction public opinion text are determined.

[0107] Optionally, the adjustment module 406 is specifically used for: Based on each of the second classification vectors, the second classification vectors are transformed to obtain the target vector; Based on each of the target vectors, calculate the value of the first contrastive loss function; Based on each of the first classification vectors and the clustering algorithm, the clustering loss function value is determined; Based on the first comparison loss function value and the clustering loss function value, the target loss function value is determined; Based on the target loss function value, the model parameters of the initial sentiment analysis model are adjusted to obtain the sentiment analysis model.

[0108] Optionally, the adjustment module 406 is further configured to: Based on each of the target vectors, a second contrastive loss function value is calculated; the second contrastive loss function value is used to separate the third art transaction public opinion text from a batch of art transaction public opinion text sentence pairs; the third art transaction public opinion text represents any one of the two second sample art transaction public opinion texts included in the art transaction public opinion text sentence pair; The first contrastive loss function value is calculated based on the second contrastive loss function value.

[0109] Optionally, the adjustment module 406 is further configured to: Based on each of the first classification vectors and the clustering algorithm, the category distribution probability is calculated respectively; the category distribution probability represents the probability of assigning each of the first sample art transaction public opinion texts to the kth cluster; k is a positive integer; Calculate the target distribution probability based on the distribution probability of each category and the soft classification probability of each first classification vector in each batch of first art transaction public opinion text. The divergence value is calculated based on the category distribution probability and the target distribution probability; Based on the divergence value, the clustering loss function value is determined.

[0110] Optionally, the adjustment module 406 is further configured to: If the target loss function value does not meet the preset conditions, adjust the model parameters of the initial sentiment analysis model and repeat the above steps to determine the target loss function value. If the target loss function value meets the preset conditions, the sentiment analysis model is determined based on the model parameters of the finally updated initial sentiment analysis model.

[0111] Figure 5 This is a schematic diagram of the emotion analysis device provided by the present invention, as shown below. Figure 5 As shown, the sentiment analysis device 500 includes a second acquisition module 501 and an analysis module 502; wherein, The second acquisition module is used to acquire the public opinion text of the art transaction to be analyzed; The analysis module is used to input the text of public opinion regarding art transactions to be analyzed into the sentiment analysis model, and obtain the sentiment analysis results output by the sentiment analysis model; the sentiment analysis model is based on... Figure 4 The sentiment analysis model was trained using the training device shown.

[0112] The sentiment analysis device provided by this invention can obtain sentiment analysis results by inputting the acquired public opinion text on art transactions to be analyzed into a trained sentiment analysis model. During the training of the sentiment analysis model, by jointly using the contrastive loss function and the clustering loss function, the distance between different categories in the text semantic space is increased, while the intra-category distance is reduced. By updating the model parameters during iterative training, the final sentiment analysis model is obtained, improving its applicability. This makes the sentiment analysis results more accurate when performing sentiment analysis on public opinion texts on art transactions in the art field, thus improving the analysis efficiency of the sentiment analysis model.

[0113] Figure 6 This is a schematic diagram of the physical structure of an electronic device provided by the present invention, such as... Figure 6As shown, the electronic device may include: a processor 610, a communication interface 620, a memory 630, and a communication bus 640, wherein the processor 610, the communication interface 620, and the memory 630 communicate with each other through the communication bus 640. The processor 610 can call logical instructions in the memory 630 to execute a sentiment analysis model training method, which includes: acquiring an art transaction sentiment training set; the art transaction sentiment training set includes multiple first sample art transaction sentiment texts and label data for each first sample art transaction sentiment text; determining multiple art transaction sentiment text sentence pairs based on each first sample art transaction sentiment text and the label data; each art transaction sentiment text sentence pair includes two second sample art transaction sentiment texts; constructing an art domain sentiment segmenter; determining a first identifier corresponding to each character in each first sample art transaction sentiment text and a second identifier corresponding to each character in each second sample art transaction sentiment text based on the art domain sentiment segmenter, each first sample art transaction sentiment text, and each art transaction sentiment text sentence pair; determining a first classification vector corresponding to each first sample art transaction sentiment text and a second classification vector corresponding to each second sample art transaction sentiment text based on each first identifier and each second identifier; and adjusting the model parameters of the initial sentiment analysis model based on each first classification vector and each second classification vector to obtain the sentiment analysis model.

[0114] The processor 610 can call logical instructions in the memory 630 to execute a sentiment analysis method, which includes: acquiring the text of public opinion on art transactions to be analyzed; inputting the text of public opinion on art transactions to be analyzed into a sentiment analysis model to obtain the sentiment analysis result output by the sentiment analysis model; the sentiment analysis model is trained based on the sentiment analysis model training method described in any of the foregoing embodiments.

[0115] Furthermore, the logical instructions in the aforementioned memory 630 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0116] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements a sentiment analysis model training method provided by the methods described above. This method includes: acquiring a training set of public opinion on art transactions; the training set of public opinion on art transactions includes multiple first sample texts on art transactions and tag data for each of the first sample texts on art transactions; determining multiple pairs of sentence pairs of texts on art transactions based on each of the first sample texts on art transactions and the tag data; each pair of sentence pairs of texts on art transactions includes two second sample texts on art transactions; and constructing a sentiment analysis model for the art domain. A word segmenter is used; based on the art domain sentiment segmenter, each first sample art transaction sentiment text, and each sentence pair of the art transaction sentiment text, a first identifier corresponding to each character in each first sample art transaction sentiment text and a second identifier corresponding to each character in each second sample art transaction sentiment text are determined; based on each first identifier and each second identifier, a first classification vector corresponding to each first sample art transaction sentiment text and a second classification vector corresponding to each second sample art transaction sentiment text are determined; based on each first classification vector and each second classification vector, the model parameters of the initial sentiment analysis model are adjusted to obtain the sentiment analysis model.

[0117] When executed by a processor, the computer program implements the sentiment analysis methods provided by the above methods, which include: acquiring the public opinion text of art transactions to be analyzed; inputting the public opinion text of art transactions to be analyzed into a sentiment analysis model, and obtaining the sentiment analysis result output by the sentiment analysis model; wherein the sentiment analysis model is trained based on the sentiment analysis model training method described in any of the foregoing embodiments.

[0118] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0119] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence 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 ROM / RAM, magnetic disk, optical disk, etc., and includes 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 or some parts of the embodiments.

[0120] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for training a sentiment analysis model, characterized in that, include: Obtain a training set of public opinion on art transactions; the training set of public opinion on art transactions includes multiple first sample art transaction public opinion texts and tag data for each first sample art transaction public opinion text; Based on each of the first sample art transaction public opinion texts and the tag data, multiple art transaction public opinion text sentence pairs are determined; each art transaction public opinion text sentence pair includes two second sample art transaction public opinion texts; wherein, the method for obtaining the art transaction public opinion text sentence pairs includes data augmentation, virtual augmentation, or similar combinations; Obtain a first lexicon and target information; the target information includes negative words in the field of art and at least one of the following: emoticons; kaomoji; online sentiment terms; the first lexicon includes multiple first sentiment words and the identifiers of each first sentiment word; based on the target information, replace the first lexicon to obtain a second lexicon; the second lexicon includes multiple second sentiment words and the identifiers of each second sentiment word; based on the second lexicon, determine a sentiment word segmenter for the field of art; The aforementioned art domain sentiment segmenter is used to segment each character in the first sample art transaction sentiment text, and then each segmented character is converted into a first identifier corresponding to each character in the first sample art transaction sentiment text; the aforementioned art domain sentiment segmenter is used to segment each character in each second sample art transaction sentiment text in each art transaction sentiment text sentence pair, and then each segmented character is converted into a second identifier corresponding to each character in the second sample art transaction sentiment text; Based on each of the first identifiers and each of the second identifiers, a first classification vector corresponding to each of the first sample art transaction public opinion texts and a second classification vector corresponding to each of the second sample art transaction public opinion texts are determined; Based on each of the first classification vectors and each of the second classification vectors, the model parameters of the initial sentiment analysis model are adjusted to obtain the sentiment analysis model.

2. The sentiment analysis model training method according to claim 1, characterized in that, The step of determining the first classification vector corresponding to each first sample art transaction public opinion text and the second classification vector corresponding to each second sample art transaction public opinion text based on each first identifier and each second identifier includes: Each first identifier and each second identifier are encoded to obtain a first word embedding vector corresponding to each first identifier and a second word embedding vector corresponding to each second identifier; Based on the embedding vectors of the first word and the second word, the first classification vector corresponding to each of the first sample art transaction public opinion texts and the second classification vector corresponding to each of the second sample art transaction public opinion texts are determined respectively.

3. The sentiment analysis model training method according to any one of claims 1 to 2, characterized in that, The step of adjusting the model parameters of the initial sentiment analysis model based on each of the first classification vectors and each of the second classification vectors to obtain the sentiment analysis model includes: Based on each of the second classification vectors, the second classification vectors are transformed to obtain the target vector; Based on each of the target vectors, calculate the value of the first contrastive loss function; Based on each of the first classification vectors and the clustering algorithm, the clustering loss function value is determined; Based on the first comparison loss function value and the clustering loss function value, the target loss function value is determined; Based on the target loss function value, the model parameters of the initial sentiment analysis model are adjusted to obtain the sentiment analysis model.

4. The sentiment analysis model training method according to claim 3, characterized in that, The step of calculating the first contrastive loss function value based on each of the target vectors includes: Based on each of the target vectors, a second contrastive loss function value is calculated; the second contrastive loss function value is used to separate the third art transaction public opinion text from a batch of art transaction public opinion text sentence pairs; the third art transaction public opinion text represents any one of the two second sample art transaction public opinion texts included in the art transaction public opinion text sentence pair; The first contrastive loss function value is calculated based on the second contrastive loss function value.

5. The sentiment analysis model training method according to claim 3, characterized in that, The step of determining the clustering loss function value based on each of the first classification vectors and the clustering algorithm includes: Based on each of the first classification vectors and the clustering algorithm, the category distribution probability is calculated respectively; the category distribution probability represents the probability of assigning each of the first sample art transaction public opinion texts to the kth cluster; k is a positive integer; Calculate the target distribution probability based on the distribution probability of each category and the soft classification probability of each first classification vector in each batch of first art transaction public opinion text. The divergence value is calculated based on the category distribution probability and the target distribution probability; Based on the divergence value, the clustering loss function value is determined.

6. The sentiment analysis model training method according to claim 3, characterized in that, The step of adjusting the model parameters of the initial sentiment analysis model based on the target loss function value to obtain the sentiment analysis model includes: If the target loss function value does not meet the preset conditions, adjust the model parameters of the initial sentiment analysis model and repeat the above steps to determine the target loss function value. If the target loss function value meets the preset conditions, the sentiment analysis model is determined based on the model parameters of the finally updated initial sentiment analysis model.

7. A sentiment analysis method, characterized in that, include: Obtain the text of public opinion regarding art transactions to be analyzed; The text of public opinion regarding the art transaction to be analyzed is input into the sentiment analysis model to obtain the sentiment analysis results output by the sentiment analysis model. The sentiment analysis model is trained based on the sentiment analysis model training method described in any one of claims 1 to 6.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the sentiment analysis model training method as described in any one of claims 1 to 6, or the sentiment analysis method as described in claim 7.

Citation Information

Patent Citations

  • Microblog emotion determination method

    CN108647257A

  • Text sentiment classification method and device, electronic equipment and storage medium

    CN115221274A