A method and system for analyzing consumer consumption motivation
By constructing a motivation classification-entity extraction model and performing multi-task optimization training, the problem of general motivation classification for consumers purchasing products is solved, and the extraction and labeling efficiency of fine-grained information is improved.
Patent Information
- Application Number
- CN202311269528.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-28
- Publication Date
- 2025-05-09
- Estimated Expiration
- 2043-09-28
AI Technical Summary
In the prior art, consumers' motivation to purchase products is relatively general, and they cannot display more fine-grained information. The cost of manual labeling is high, and the labeling effect varies from person to person.
By annotating the consumption motivation classification and entity types in the training sample, a motivation classification-entity extraction model is constructed, and the annotated training sample is used for training to obtain a multi-task optimization extraction model. This model is able to extract consumer motivation entities and generate statistical tags through clustering and merging algorithms.
It realizes efficient labeling of text data, improves labeling efficiency and accuracy, can display more fine-grained consumption motivation information, and reduces manual labeling costs.
Smart Images

Figure CN119107126B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing, and in particular to a method and system for analyzing consumer consumption motivation. Background Art
[0002] At present, the consumer purchase motivation analysis process based on e-commerce reviews first manually defines the categories of consumer purchase motivations and determines the corresponding category labeling guidelines; then, according to the labeling guidelines, manually labels the standard training samples corresponding to each category; finally, the e-commerce reviews are labeled and counted by training a text classification model.
[0003] Since general text classification models can only count the category distribution of consumer purchase motivations, such as advertising attraction, product features, brand preferences, etc., they cannot display more fine-grained information. For example, if the purchase motivation is classified into the advertising attraction category, it is still impossible to know which platform the consumer was attracted by the advertisement. In order to be applicable to multi-category e-commerce review analysis scenarios, the purchase motivation classification model needs to annotate a large number of training samples, which has high manual annotation costs and the annotation effect varies from person to person. Summary of the invention
[0004] In view of the shortcomings of the prior art, the present invention provides a method and system for analyzing consumer consumption motivations, which solves the problem that the existing classification of consumer motivations for purchasing products is relatively general and cannot display more fine-grained information.
[0005] In order to solve the above technical problems, the present invention is solved by the following technical solutions:
[0006] A method for analyzing consumer consumption motivations comprises the following steps:
[0007] Labeling training samples, wherein the labeling content of the training samples includes the consumer's consumption motivation classification and the entity type extracted corresponding to the consumption motivation;
[0008] Constructing a motivation classification-entity extraction model, and using the labeled training samples to train the motivation classification-entity extraction model to obtain a multi-task optimized extraction model;
[0009] A clustering and merging algorithm is performed on the consumer motivation entities extracted by the multi-task optimization extraction model to generate statistical labels.
[0010] Optionally, training the motivation classification-entity extraction model using the labeled training samples includes the following steps:
[0011] Convert the labeled training samples into word segmentation sequences to obtain input sequences;
[0012] Constructing a classification layer and an entity recognition layer in the motivation classification-entity extraction model, wherein the classification layer and the entity recognition layer are arranged in parallel, and inputting the input sequence;
[0013] Calculating the final loss function of the final task learning of the motivation classification-entity extraction model;
[0014] The parameters of the motivation classification-entity extraction model are updated through a back-propagation algorithm to obtain a multi-task optimized extraction model.
[0015] Optionally, calculating the final loss function of the final task learning of the motivation classification-entity extraction model includes the following steps:
[0016] Calculating a loss function 1 of the classification layer and a loss function 2 of the entity recognition layer;
[0017] A final loss function is calculated based on the loss function one and the loss function two, wherein the final loss function = loss function one + loss function two.
[0018] Optionally, the calculation formula of the loss function 1 is:
[0019] Where n is the batch size of the training sample; C is the total number of categories of a single training sample; y ic represents the sign function, which takes 1 when the true category of training sample i is equal to c, otherwise it takes 0; p ic represents the predicted probability that sample i belongs to category c.
[0020] Optionally, the calculation formula of the second loss function is:
[0021] Among them, m represents the predicted word size; E represents the total number of categories of a single training sample; y ie represents the symbolic function, which takes 1 when the true category of training sample i is equal to e, otherwise it takes 0; p ie represents the predicted probability that sample i belongs to category e.
[0022] Optionally, a clustering and merging algorithm is performed on the consumer motivation entities extracted by the multi-task optimization extraction model to generate statistical labels, including the following steps:
[0023] Perform word segmentation on all the extracted consumer motivation entities to obtain corresponding digital text data, and convert the digital text data into vector representation data;
[0024] All the vector representation data are processed by a clustering algorithm to obtain aggregated normalized data, and the aggregated normalized data are marked with standard labels.
[0025] Optionally, the clustering algorithm processing includes the following steps:
[0026] Set each vector representation data as a separate cluster and calculate the initial similarity between each vector representation data;
[0027] Based on the calculated initial similarity, merge the most similar clusters and update the updated similarity between the merged clusters;
[0028] Repeat the step of merging the most similar clusters, set the convergence condition, and when the convergence condition is reached, stop the step of merging the most similar clusters to obtain aggregated normalized data.
[0029] Optionally, a method for calculating the similarity between the data represented by each vector includes:
[0030] The similarity between vector representation data is expressed by calculating the Euclidean distance.
[0031] A consumer consumption motivation analysis system, comprising a sample labeling unit, a training optimization unit and a clustering label unit;
[0032] The sample labeling unit is used to label training samples, wherein the labeling content of the training samples includes the consumer's consumption motivation classification and the entity type extracted corresponding to the consumption motivation;
[0033] The training optimization unit is used to obtain a motivation classification-entity extraction model, and use the labeled training samples to train the motivation classification-entity extraction model to obtain a multi-task optimization extraction model; the clustering label unit is used to perform a clustering merging algorithm on the consumer motivation entities extracted by the multi-task optimization extraction model to generate statistical labels.
[0034] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it implements any one of the above-mentioned methods for analyzing consumer consumption motivations.
[0035] Compared with the prior art, the technical solution provided by the present invention has the following beneficial effects:
[0036] The model is used to annotate text data, which improves the annotation efficiency. At the same time, by combining the needs of consumer motivation analysis, the motivation classification-entity extraction model that includes consumer motivation classification and entity extraction is optimized and trained to improve the accuracy of entity extraction and fine-grained mining of consumer motivations. The model then outputs the category information of consumer motivations and the corresponding key entity information, and the extracted key information is aggregated and counted through a clustering algorithm for easy statistical viewing. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0038] Figure 1 A flowchart for extracting classification tasks and entities for the model proposed in the first embodiment;
[0039] Figure 2 This is an input structure diagram of the Embedding module proposed in the first embodiment;
[0040] Figure 3 This is a single-layer structure diagram of the Transformer encoder proposed in this embodiment 1. DETAILED DESCRIPTION
[0041] The present invention is further described in detail below in conjunction with embodiments. The following embodiments are for explanation of the present invention but the present invention is not limited to the following embodiments.
[0042] Embodiment 1
[0043] A method for analyzing consumer consumption motivations comprises the following steps: firstly, training samples are labeled, wherein the labeled content of the training samples includes the classification of consumer consumption motivations and entity types corresponding to the consumption motivations. In this embodiment, the training samples refer to e-commerce reviews, and the consumption motivations need to be analyzed on the text of the e-commerce reviews, mainly dividing the consumption motivations into categories such as advertising attraction, product function, brand preference, friend recommendation, price and service, and then determining the entity types to be extracted for each category.
[0044] The entity categories extracted for various consumption motivations are specifically explained as follows: If the consumption motivation is advertising attraction, that is, consumers buy because they are attracted by various marketing advertisements (media platforms, exhibitions, guides, lists, etc.), comments on various marketing advertising platforms that attract consumers to buy are extracted, for example: "I saw them on APP1, so I placed an order to experience them", "I saw the product effect introduction on APP2, so I decided to buy it", then the entities corresponding to the extracted advertising attraction are APP1 and APP2.
[0045] If the consumption motivation is product function, and consumers purchase due to the influence of product function or experience (extra-long standby / automatic cleaning, etc.), the comments on the product function or experience that attracted consumers to buy are extracted, for example: "I bought it mainly because it has an extra-long standby time of 20 days" and "Because it can automatically clean with high-temperature steam, I chose it", then the entities corresponding to the extracted product functions are "extra-long standby time of 20 days" and "Automatic high-temperature steam cleaning".
[0046] If the consumption motivation is brand preference, consumers buy because of their trust in the brand (the brand is good / trustworthy / I am a fan of it, etc.), and the brands that attract consumers to buy are extracted. For example, "The reason why I bought this charger is because I trust brand A", "I am a fan of brand B", then the entities corresponding to the extracted brand preference are "Brand A" and "Brand B".
[0047] If the consumption motivation is friend recommendation, and the consumer buys because of recommendations from various objects (family, friends, occupations, etc.), the corresponding recommended objects are extracted. For example, "My friend recommended that I buy this mobile phone holder" and "My dentist recommended that I use this water flosser", then the entities corresponding to the friend recommendation extracted are "friend" and "dentist".
[0048] If the consumption motivation is price, and the consumer buys due to discounts, price cuts, promotions (shopping festivals / half-price / promotional offers, etc.), the corresponding promotional offer entity is extracted. For example, "I waited for the weekend when it was half-price" or "I bought it during the 618 event", then the entity corresponding to the extracted price is "weekend half-price" or "618 event".
[0049] If the consumption motivation is service, and the consumer is attracted to purchase because of additional services (extra-long warranty / free gifts / fast logistics / exclusive packaging, etc.), the corresponding additional services are extracted. For example, "Because it has a three-year warranty, I chose it", "Mainly because it can be returned without reason within seven days, I decided to give it a try", then the entities corresponding to the extracted services are "three-year warranty" and "seven-day no-reason return".
[0050] After determining the consumption motivation classification and the entities extracted corresponding to the consumption motivation classification, the training samples can be labeled. When labeling, you can first debug and build a prompt that can meet the labeling of consumption motivation samples. Then, based on the constructed prompt, batch label the consumption motivation classification and entity extracted training samples through the interface. When labeling in batches, the interface request parameter Temperature (value range 0.0-1.0) is used to adjust the diversity of the results returned by the interface. Since a higher Temperature value (such as 1.0) will increase the randomness of the results returned by the model, making it more diverse, and a lower Temperature value (such as 0.2) will reduce the randomness of the results returned by the model, making it more consistent and predictable, therefore, in order to ensure the controllability and consistency of the labeling results, Temperature takes a value of 0.
[0051] Compared with manual labeling, different labeling results may be caused by different labelers' understanding of the task. The large model service interface can better ensure the consistency of labeling results. At the same time, compared with manual labeling, the batch retrieval interface effectively improves the labeling efficiency and reduces the labeling cost.
[0052] After completing batch labeling, labeled training samples are obtained, and then a motivation classification-entity extraction model is constructed, and the labeled training samples are used to train the motivation classification-entity extraction model to obtain a multi-task optimized extraction model. Specifically, the motivation classification-entity extraction model is trained using the labeled training samples, including the following steps: converting the labeled training samples into word segmentation sequences to obtain an input sequence; constructing a classification layer and an entity recognition layer in the motivation classification-entity extraction model, and the classification layer and the entity recognition layer are set in parallel, and the input sequence is input; calculating the final loss function of the final task learning of the motivation classification-entity extraction model; updating the parameters of the motivation classification-entity extraction model through the back-propagation algorithm to obtain a multi-task optimized extraction model.
[0053] More specifically, the fine-tuning and optimization of the motivation classification-entity extraction model mainly involves fitting the task output of the model with the standard labels of the training samples, and finally enabling the model to fit the output of the corresponding task by correcting the parameters of the model.
[0054] First, the weights of the pre-trained motivation classification-entity extraction model are used as the initial parameters to initialize the model parameters. Then, the entire model is trained using the labeled training sample data, and the back-propagation algorithm and optimizer (such as Adam) are used to update the model weights.
[0055] In the purchase motivation classification task, a classification layer is added on top of the motivation classification-entity extraction model to map the text to the probability distribution of the consumer motivation label. The parameters of this classification layer need to be fine-tuned. Usually, cross entropy is used as the loss function (i.e., loss function 1), and the parameters are updated through back propagation.
[0056] In the entity extraction task, an entity recognition layer (NER) is added on top of the motivation classification-entity extraction model to identify entities in the text. Similar to consumer motivation classification, the parameters of the NER layer also need to be fine-tuned. The loss function is usually the loss function of sequence labeling, that is, loss function 2 (such as cross entropy), and the parameters are updated through back propagation.
[0057] During the fine-tuning process, the labeled training samples are converted into input sequences and then passed to the motivation classification-entity extraction model, the output layers of the two tasks are constructed, the loss functions are calculated respectively, and the two loss functions are added together as the loss function for the final task learning. Among them, by constructing two parallel task output layers, the calculation efficiency between the two layers of tasks is faster. At the same time, since the two output layers are set in series, the error of the entity recognition task will be superimposed on the text classification task, thereby affecting the accuracy of text classification. Therefore, the parallel setting in this embodiment can also reduce the error rate of model calculation, thereby improving the accuracy; the model parameters are updated through the back propagation algorithm, so that the model learns to fit the two tasks.
[0058] Among them, the calculation formula of loss function 1 is: Where n is the batch size of the training sample; C is the total number of categories of a single training sample; y ic represents the sign function, which takes 1 when the true category of training sample i is equal to c, otherwise it takes 0; p ic represents the predicted probability that sample i belongs to category c.
[0059] For the entity extraction task, the entity categories mainly include the entity categories ['B-reason', 'I-reason', 'O'], which is equivalent to classifying each word of the input comment. For each input word, the corresponding output last hidden layer state is taken out as a vector representation, and then the output vector is mapped to the entity category task through the fully connected layer, which is equivalent to multiplying the output vector by the weight matrix first, and then predicting the probability of the classification label through Softmax.
[0060] The calculation formula of loss function 2 is: Among them, m represents the predicted word size; E represents the total number of categories of a single training sample; y ie represents the symbolic function, which takes 1 when the true category of training sample i is equal to e, otherwise it takes 0; p ie represents the predicted probability that sample i belongs to category e, and the final loss function L = Lc +L e .
[0061] After multi-task fine-tuning and optimization training, the model can perform consumption motivation classification and entity extraction tasks on the input text at the same time. For example, given the comment "My friend recommended me to buy this mobile phone holder.", after fine-tuning, the model can identify the category of purchase motivation as the "friend recommendation" label; for the entity extraction task, the output is ['O','B-reason','I-reason','O','O','O','O','O','O','O','O','O'], that is, the corresponding entity is "friend".
[0062] It should be noted that if Figure 1 As shown in the figure, for the constructed motivation classification-entity extraction model, the model structure mainly includes four modules: Tokenization, Embedding, Transformer encoding and multi-task fine-tuning. Among them, multi-task fine-tuning is used for the optimization training of the model with the above training samples. The Tokenization module is the process of dividing the text into smaller units "token". These "tokens" can be words, subwords or characters. In the model, the subword-level Tokenization method based on WordPiece is adopted. The Tokenize process of the model includes the following steps:
[0063] S1. Input text: The text to be processed is taken as input, such as a user comment on an e-commerce platform.
[0064] S2. WordPiece Tokenization: The input text is divided into words or subwords. The model uses a WordPiece-based method for word segmentation, which splits words into smaller subwords, collectively called tokens. For example, "running" may be segmented into "run" and "##ning", where "##" represents a part of a subword.
[0065] S3. Add special tags: In the text after word segmentation, some special tags need to be added for the model to recognize and process. The special tags used in the model include:
[0066] [CLS]: Add a [CLS] tag at the beginning of the text to indicate the beginning of a sentence;
[0067] [SEP]: Add a [SEP] tag at the end of each sentence to indicate the end of the sentence;
[0068] [PAD]: If the length of the sentence is less than the maximum length of the model input, the [PAD] tag needs to be used for padding;
[0069] S4, Encoding: Convert the tokenized text into its corresponding integer encoding. The model uses a predefined vocabulary to map each token to a unique integer.
[0070] S5. Segmentation: For sentence pair tasks (such as question-answering tasks), the input needs to be divided into two sentences and a corresponding segmentation tag is added to each sentence. Usually, the tag of the first sentence is 0 and the tag of the second sentence is 1.
[0071] Finally, the Tokenize process of the motivation classification-entity extraction model converts the text into digital codes and forms a vocabulary index to prepare for the generation of text embedding. Combined with the current purchase motivation classification + entity extraction task, the Tokenization process uses the user review data of the e-commerce platform as input. After word segmentation and encoding, the output is a set of digital code sequences containing the input text information.
[0072] like Figure 2 As shown in the figure, the Embedding module is obtained by adding Token Embeddings, Segment Embeddings and Position Embeddings. Among them, Token Embeddings is a word vector, and the first word is the CLS mark, which indicates the starting position of the text and can be used for subsequent classification tasks.
[0073] The training samples input during model pre-training are two sentences. CLS indicates the starting position of the sample, and SEP indicates the ending position of a sentence. In addition to the language model, the pre-training task also includes the task of predicting the next sentence. Segment Embeddings is a segment vector used to distinguish two sentences. Position Embeddings is a position vector that indicates the position information of the current word in the sentence, which is used to make up for the word order information ignored by the Transformer structure.
[0074] The calculation process of Embedding is as follows:
[0075] The calculation formula for Token Embeddings is: t =I t +W t , where I t W represents the word vector matrix after the input text is segmented and converted into the word list index, and its size is (batch size, sequence length, word list size); tRepresents the vocabulary representation matrix, whose size is (vocabulary size, embedding vector size); finally, the first input text representation vector of size (batch size, sequence length, embedding vector size) is obtained. In this embodiment, the vocabulary size is 30522 and the embedding vector size is 768.
[0076] The calculation formula for Segment Embeddings is: s =I s +W s , where I s W represents the segment vector matrix after the input text is segmented and converted into the vocabulary index, with a size of (batch size, sequence length, classification type size); s Represents the vocabulary type representation matrix, whose size is (classification type size, embedding vector size); finally, a second input text representation vector of size (batch size, sequence length, embedding vector size) is obtained. In this embodiment, the classification type size is 2.
[0077] The calculation formula for Position Embeddings is: p =I p +W p , where I p W represents the position vector matrix after the input text is segmented and converted into the vocabulary index, with a size of (batch size, sequence length, maximum position encoding); p Represents the position representation matrix, the size of which is (maximum position encoding, embedding vector size); finally, a position representation vector of size (batch size, sequence length, embedding vector size) is obtained. In this embodiment, the maximum position encoding is 512.
[0078] Finally, add the output vectors of the above three to get the final input text vector representation E = E t +E s +E p .
[0079] In the Embedding module, each token is mapped to a high-dimensional embedding vector that captures the semantic information of the token. The motivation classification-entity extraction model uses a pre-trained embedding layer, in which each token corresponds to a pre-learned vector representation. These word embedding vectors are pre-trained using a large-scale corpus and have rich semantic information.
[0080] Combined with the current purchase motivation classification + entity extraction tasks, the Embedding process, the input is a digital code sequence after Tokenization, and the output is a word embedding vector representation that integrates the word semantics. At this time, the vector representation of each word does not integrate the information of other words in the sentence. Therefore, Transformer encoding is required to allow each word to integrate the semantic information of other words in the sentence and integrate its contextual semantic information.
[0081] For the Transformer encoding module, the motivation classification-entity extraction model is composed of multiple layers of Transformer encoders stacked together. Compared with CNN and RNN, the Transformer encoder is a bidirectional encoder based on the attention mechanism. When semantically representing the input text, it can better integrate the contextual semantic information of the text. The essence of the attention mechanism is to set different weight coefficients for different input information when extracting information, and then calculate the weighted sum, focusing on key information.
[0082] For example, input the comment "My friend recommended me to buy this mobile phone holder". After Tokenization and Embedding, it is input into the motivation classification-entity extraction model for semantic fusion. The output vector corresponding to the input [CLS] position can represent the semantic information of the entire sentence. Therefore, as the input vector representation of the purchase motivation classification task, this vector will focus on integrating the semantic vector information of words such as "My friend recommended me to buy it" to determine that its purchase motivation classification belongs to "Friend Recommendation", while ignoring other input text information.
[0083] The Transformer encoder is composed of six layers of identical sub-networks, each of which is as follows: Figure 3 As shown in the figure, it mainly consists of two sub-layers, the multi-head attention mechanism layer and the forward propagation layer. When each sub-layer is passed to the next layer, a residual network and layer normalization structure are added. The residual network is used to prevent the loss of part of the original input information after processing by the sub-layer, and the possible vanishing or exploding gradient. The original input information and the output information after processing by the sub-layer are combined as the output information. Layer normalization is to standardize the output information so that the network can converge better during training.
[0084] The multi-head self-attention mechanism in the first sub-layer can fuse the vector representations of other words in the sentence for each input word vector according to different levels of importance, so that the current word can integrate the semantic information of the context in the sentence.
[0085] When the model's self-attention mechanism runs, the following formula is executed:
[0086]
[0087]
[0088] MultiHead(Q,K,V)=Concat(head1,...,head h ) O (1-3).
[0089] Among them, Q (Query), K (Key) and V (Value) represent query vector, key vector and value vector respectively, and their functions are as follows:
[0090] Query (Q): represents the input vector of the current position, which is used as the query vector in the attention mechanism; Key (K): represents the vector of all positions in the input sequence, which is used to calculate the attention score of the current position; Value (V): represents the vector of all positions in the input sequence, which is used as the input of the attention mechanism at the current position.
[0091] Among them, K T represents the transpose of matrix K; d k represents the dimension of query vector and key vector, d k After taking the square root, the model can keep the correlation score within a reasonable range when processing input sequences of different lengths, avoiding excessive changes in gradients in different dimensions. This standardization operation can improve the stability of training and help the model better learn the semantic information of the input sequence.
[0092] For the multi-head self-attention mechanism in the model, assuming that the number of heads is h, first, as shown in Formula 1-2, Q, K, and V are multiplied by the corresponding weight matrix W through h groups of different linear transformations. Q , W k , W v , get h groups of different Q i , K i 、V i , In the multi-head self-attention mechanism, Q, K, and V are the same and are all input Embeddings.
[0093] Then, as shown in Formula 1-1, h groups of different Q i , K i , V i Through the Attention mechanism, h groups of head outputs are obtained.
[0094] Finally, as shown in Formula 1-3, the different head results are concatenated and multiplied by the output weight matrix W o , and get the output vector representation.
[0095] The second sub-layer, the forward propagation network is mainly used to introduce nonlinear transformations. The entire calculation process of the forward propagation network is equivalent to first mapping the input vector into a vector space of a larger dimension through linear changes, and then filtering the high-dimensional vector through the ReLU nonlinear transformation to remove some invalid redundant information, and finally restoring it to the original dimension through linear changes. It should be noted that after abandoning the LSTM structure, the ReLU in the forward propagation network has become the main unit in the Transformer that can provide nonlinear transformations.
[0096] The model in this embodiment is provided with 12 Transformer encoder sublayers, each layer has 12 Attentionheads. The Transformer encoding process can fuse the vector representations of other words in the sentence for each input word vector according to different importance levels, so that the output representation of the current word can focus on integrating the semantic information of the context in the sentence.
[0097] For example, the input comment "My friend recommended me to buy this mobile phone holder" is subjected to Tokenization and Embedding, and the input model performs semantic fusion. The output vector corresponding to the input [CLS] position can represent the semantic information of the entire sentence. Therefore, as the input vector representation of the purchase motivation classification task, the vector will focus on integrating the semantic vector information of the words "My friend recommended me to buy it" to determine that its purchase motivation classification belongs to "Friends Recommendation", while ignoring other input text information.
[0098] Combining the current purchase motivation classification + entity extraction tasks, the Transformer encoding process takes the Embedding of the comments as input and outputs a semantic vector that integrates the contextual semantic information with emphasis. At the same time, after multi-task fine-tuning learning, the Transformer encoding can combine the context and output a vector that is more suitable for the task.
[0099] After obtaining the multi-task optimization extraction model, the consumer motivation entities extracted by the multi-task optimization extraction model can also be subjected to a clustering and merging algorithm to generate statistical labels. Specifically, all extracted consumer motivation entities are subjected to word segmentation processing to obtain corresponding digital text data, and the digital text data is converted into vector representation data; all vector representation data are subjected to a clustering algorithm to obtain aggregated normalized data, and the aggregated normalized data are marked with standard labels.
[0100] Among them, the clustering algorithm processing includes the following steps: setting each vector representation data as a separate cluster, and calculating the initial similarity between each vector representation data; based on the calculated initial similarity, merging the most similar clusters, and updating the updated similarity between the merged clusters; repeating the step of merging the most similar clusters, and setting convergence conditions, and when the convergence conditions are reached, stopping the step of merging the most similar clusters to obtain aggregated normalized data, and calculating the similarity between each vector representation data includes: expressing the similarity between the vector representation data by calculating the Euclidean distance method.
[0101] More specifically, since the consumer motivation entities extracted by the multi-task optimization extraction model are often scattered, it is not conducive to statistical aggregation and comprehensive analysis. For example, the consumer motivation type is product function, and its extraction results are as follows:
[0102] - I bought it mainly because it can last for 20 days;
[0103] -I bought it mainly because it can last a long time and enjoy it non-stop;
[0104] -I bought it mainly because it can be charged once and keep you company;
[0105] -I bought it mainly because it is a master of electricity and pushes the limits;
[0106] -I bought it mainly because it can accompany you all the time without frequent charging;
[0107] -I bought it mainly because it keeps the battery charged and doesn't interrupt your life.
[0108] In the above comments, the consumer motivation is all the "super long standby" product function, but the expressions vary greatly. In order to facilitate comprehensive statistical analysis, it is necessary to merge them based on semantics through clustering; at the same time, since the semantics of such entities cover a wide range and the expressions vary greatly, they cannot be normalized and merged through clear rules before being extracted by the model. Therefore, normalization and merging are performed after the model is extracted.
[0109] The specific normalization and merging process is as follows: first, the input text (all extracted consumer motivation entities) is segmented, and then converted into digital form to form digital text data. Then, the digital text data is converted into vector representation data through the open source Embedding model, and then aggregated and normalized by adopting a hierarchical clustering algorithm.
[0110] Furthermore, the hierarchical clustering algorithm is used to hierarchically aggregate the samples in the data set into different clusters. The aggregation process is as follows:
[0111] S1, initialization: each vector representation data is considered as a separate cluster;
[0112] S2. Calculate similarity: Calculate the similarity or distance between each pair of vector representation data by using some example or similarity measurement algorithm. For example, the Euclidean distance calculation method is used, where the calculation formula of the Euclidean distance is:
[0113] X and Y represent two points in n-dimensional Euclidean space. i ,y i The tables represent the coordinates of X and Y in the i-th dimension respectively, and dist(X, Y) represents the Euclidean distance between X and Y;
[0114] S3. Merge the most similar clusters: Based on the results of the similarity or distance measurement, find the two clusters with the highest similarity (or the closest distance) and merge them into a new cluster;
[0115] S4, update similarity matrix: update the similarity matrix after merging clusters to reflect the similarity or distance between the newly merged cluster and other clusters;
[0116] S5, repeating steps S3 and S4, continuously merging the most similar clusters, and updating the similarity matrix until a convergence condition (stop condition) is met, which may be the number of clusters or a distance threshold between clusters;
[0117] S6. Obtain clustering results. In this embodiment, a minimum distance threshold is set to obtain the final clustering results.
[0118] After aggregation is completed, the sub-classification of each consumption reason will generate standard labels with good normalization effect, which is convenient for statistical viewing.
[0119] Embodiment 2
[0120] A consumer consumption motivation analysis system comprises a sample labeling unit, a training optimization unit and a clustering labeling unit; the sample labeling unit is used to label training samples, wherein the labeling content of the training samples includes the consumer's consumption motivation classification and the entity type corresponding to the consumption motivation; the training optimization unit is used to obtain a motivation classification-entity extraction model, and use the labeled training samples to train the motivation classification-entity extraction model to obtain a multi-task optimization extraction model; the clustering labeling unit is used to perform a clustering merging algorithm on the consumer motivation entities extracted by the multi-task optimization extraction model to generate statistical labels.
[0121] Since the analysis system in this embodiment is used to execute the consumer consumption motivation analysis method described in the first embodiment, it will not be repeated in this embodiment.
[0122] A computer-readable storage medium stores a computer program. When the computer program is executed by a processor, the method for analyzing consumer consumption motivations described in Example 1 is implemented.
[0123] More specific examples of computer-readable storage media may include, but are not limited to, an electrical connection having one or more conductor segments, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), optical fiber, a portable compact disk-read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0124] In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, apparatus, or device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in combination with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to: wireless segments, wire segments, optical cables, RF, etc., or any suitable combination of the above.
[0125] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of the modules, modules or units is only a logical function division, and there may be other division methods in actual implementation, for example, multiple units, modules or components can be combined or integrated into another device, or some features can be ignored or not executed.
[0126] The units may or may not be physically separated, and the components displayed as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0127] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0128] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments of the present disclosure include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part, and / or installed from a removable medium. When the computer program is executed by the central processing unit (CPU), the above-mentioned functions defined in the method of the present application are executed. It should be noted that the above-mentioned computer-readable medium of the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium can be, for example, but not limited to, a system, device or device of an electrical, magnetic, optical, electromagnetic, infrared segment, or semiconductor, or any combination of the above.
[0129] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0130] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A method for analyzing consumer consumption motivation, characterized in that: The following steps are involved: Labeling training samples, wherein the labeling content of the training samples includes the consumer's consumption motivation classification and the entity type extracted corresponding to the consumption motivation; Constructing a motivation classification-entity extraction model, and using the labeled training samples to train the motivation classification-entity extraction model to obtain a multi-task optimization extraction model, specifically including the following steps: converting the labeled training samples into a word segmentation sequence to obtain an input sequence; constructing a classification layer and an entity recognition layer in the motivation classification-entity extraction model, and the classification layer and the entity recognition layer are set in parallel, and the input sequence is input; calculating the final loss function of the final task learning of the motivation classification-entity extraction model; updating the parameters of the motivation classification-entity extraction model through the back propagation algorithm to obtain a multi-task optimization extraction model; A clustering and merging algorithm is performed on the consumer motivation entities extracted by the multi-task optimization extraction model to generate statistical labels.
2. A method for analyzing consumer consumption motivation according to claim 1, characterized in that: Calculating the final loss function of the final task learning of the motivation classification-entity extraction model includes the following steps: Calculating a loss function 1 of the classification layer and a loss function 2 of the entity recognition layer; A final loss function is calculated based on the loss function one and the loss function two, wherein the final loss function = loss function one + loss function two.
3. A method for analyzing consumer consumption motivation according to claim 2, characterized in that: The calculation formula of the loss function 1 is: ,in, n Indicates the batch sample size of the training samples; C Represents the total number of categories of a single training sample; represents the sign function, which takes 1 when the true category of training sample i is equal to c, otherwise it takes 0; represents the predicted probability that sample i belongs to category c.
4. A method for analyzing consumer consumption motivation according to claim 2, characterized in that: The calculation formula of the loss function 2 is: ,in, m Indicates the predicted word size; E Represents the total number of categories of a single training sample; represents the sign function, which takes 1 when the true category of training sample i is equal to e, otherwise it takes 0; represents the predicted probability that sample i belongs to category e.
5. A method for analyzing consumer consumption motivation according to claim 1, characterized in that: A clustering and merging algorithm is performed on the consumer motivation entities extracted by the multi-task optimization extraction model to generate statistical labels, including the following steps: Perform word segmentation on all the extracted consumer motivation entities to obtain corresponding digital text data, and convert the digital text data into vector representation data; All the vector representation data are processed by a clustering algorithm to obtain aggregated normalized data, and the aggregated normalized data are marked with standard labels.
6. A method for analyzing consumer consumption motivation according to claim 5, characterized in that: The clustering algorithm processing includes the following steps: Set each vector representation data as a separate cluster and calculate the initial similarity between each vector representation data; Based on the calculated initial similarity, merge the most similar clusters and update the updated similarity between the merged clusters; Repeat the step of merging the most similar clusters, set the convergence condition, and when the convergence condition is reached, stop the step of merging the most similar clusters to obtain aggregated normalized data.
7. A method for analyzing consumer consumption motivation according to claim 6, characterized in that: The method for calculating the similarity between the data represented by each vector includes: The similarity between vector representation data is expressed by calculating the Euclidean distance.
8. A consumer consumption motivation analysis system, characterized in that: It includes sample labeling unit, training optimization unit and cluster labeling unit; The sample labeling unit is used to label training samples, wherein the labeling content of the training samples includes the consumer's consumption motivation classification and the entity type extracted corresponding to the consumption motivation; The training optimization unit is used to obtain a motivation classification-entity extraction model, and use the labeled training samples to train the motivation classification-entity extraction model to obtain a multi-task optimization extraction model, which specifically includes the following steps: converting the labeled training samples into a word segmentation sequence to obtain an input sequence; constructing a classification layer and an entity recognition layer in the motivation classification-entity extraction model, and the classification layer and the entity recognition layer are set in parallel, and the input sequence is input; calculating the final loss function of the final task learning of the motivation classification-entity extraction model; updating the parameters of the motivation classification-entity extraction model through a back-propagation algorithm to obtain a multi-task optimization extraction model; The cluster label unit is used to perform a clustering merging algorithm on the consumer motivation entities extracted by the multi-task optimization extraction model to generate statistical labels.
9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the consumer consumption motivation analysis method described in any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Processing system and method for extracting fine-grained typical opinion data of user
CN111091000A
Text-based consumption intention analysis method
CN113095088A