Power data recommendation method fusing theme information
Through deep learning technology, the LDA model is used to extract and the BERT model is used to embed topic information, and the LSTM model is combined for power data recommendation, which solves the problems of low data usage and recommendation homogeneity in the existing technology, and achieves a more efficient data recommendation effect. .
Patent Information
- Application Number
- CN202410737853.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-07
- Publication Date
- 2024-09-06
AI Technical Summary
Existing power data recommendation methods cannot effectively utilize topic-related information in massive data, resulting in low data utilization. Moreover, traditional methods have problems with recommendation homogeneity and inability to meet topic-oriented data needs.
Deep learning technology is used to extract topic information through the LDA model and embed it into the BERT pre-trained language model. It is combined with the LSTM model for feature extraction and prediction to achieve recommendation of topic-related data, avoiding the manual feature engineering steps in traditional methods.
It improves the accuracy and utilization of data recommendation, can better capture the topic correlation between data, meets users' topic-oriented data needs in actual application scenarios, and avoids the problem of recommendation homogeneity.
Smart Images

Figure BDA0004882318540000041 
Figure BDA0004882318540000111 
Figure BDA0004882318540000071
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of power system management, and in particular relates to a power data recommendation method integrating subject information. Background Art
[0002] With the development of power infrastructure, the collected power data is becoming more and more abundant. The potential information contained in a large amount of data can provide more help for power management departments in formulating policies and provide more perspectives when perceiving users. To generate value from data, the key is to retrieve the data that users need from the massive amount of data.
[0003] At present, the use of data is usually based on one's own needs. The field name or label and other text of the data are entered to match the data. The required data is filtered according to the returned matching results. The scope is narrowed by continuous screening until all the required data is found. This passive data search method is often suitable for vertical search in a single field, constantly narrowing the scope and excluding irrelevant data. However, the required data often does not appear alone, but appears in clusters related to the subject. These related data belonging to different fields can better help us make decisions. In other words, the data we need is often subject-oriented rather than field-oriented. When the subject changes, the field of the required data will also change. The field will switch with the different subjects. In a large amount of data, useful information may be missed through human search, and data cannot be used efficiently. Even if all the data is clearly perceived, searching for data in different fields is time-consuming and laborious.
[0004] In order to make up for the shortcomings of the above retrieval methods, data-active recommendation methods have been proposed. There are two main types of existing recommendation system technologies: content filtering-based methods, collaborative filtering-based methods, and hybrid recommendation methods that combine the two. Among the above recommendation methods: vertical data retrieval methods based on matching rules such as keywords and tags require manual design of complex rules, and in big data scenarios oriented to actual business needs, data exists in an isolated manner and the subject relevance of the data cannot be considered, resulting in low data utilization. Although active data recommendation methods have reduced data retrieval pressure and improved data utilization to a certain extent, similarity-based recommendation methods still have the problem of recommendation homogeneity, which is inconsistent with the subject-oriented data requirements in actual production environments.
[0005] Therefore, a new recommendation method is needed to solve the above technical problems. Summary of the invention
[0006] In order to solve the above technical problems, the present invention designs a power data recommendation method that integrates subject information. The method uses deep learning technology to learn power text and retrieval text, learns the subject information of the text, and actively recommends subject-related data to the required personnel. This data-inspired recommendation method is more in line with actual application scenarios and uses data more efficiently. It also uses end-to-end deep learning technology to avoid the manual feature engineering steps required by traditional machine learning methods, making model construction easier to implement.
[0007] In order to achieve the above technical effects, the present invention discloses a method for recommending electric power data integrating subject information, which specifically includes the following steps:
[0008] S1: Data acquisition: Obtain power text and data search text records from the power management system to form a text data set;
[0009] S2: Preprocess the dataset and split it into training set and test set: preprocessing includes text segmentation, vocabulary building, sequence filling, and text vectorization;
[0010] S3: Topic model construction (LDA model construction): Use power text and search text to train the topic model, learn potential topic information, obtain the topic distribution of power documents, and convert the topic distribution into a topic feature vector;
[0011] S4: Enhanced text semantics representation with topic information: A topic embedding layer is added after the word embedding layer and position embedding layer of the BERT pre-trained language model, and the language representation model with topic information is obtained after retraining using the mask task;
[0012] S5: Build an LSTM long short-term memory network model to learn the fused topic information text and obtain the topic text features; then use the stochastic gradient descent method for optimization, calculate the probability distribution of the next word, and return the word with the maximum probability as the predicted text;
[0013] S6: Search based on the predicted text and return the power data of related topics as recommendations.
[0014] Furthermore, in S3,
[0015] S3.1: Build an LDA model and train it; Determine the number of topics: Select the appropriate number of topics K through cross-validation or according to actual classification requirements;
[0016] S3.2: Initialization: For a corpus containing M documents, each containing N words, traverse each word in each document, randomly sample from a uniform distribution of [1~K] as the initial topic of each word, and then count the topic frequency of each article and the word frequency of each topic;
[0017] S3.2: Iterative training: For each document m in the corpus, and the word wi at the nth position in each document; remove word wi from document m, and count the word frequencies of each topic in document m after removing word wi. For each possible value k of the topic, calculate the conditional probability that the topic of word wi in a given document m is assigned to k:
[0018]
[0019] Among them, z i All topic assignments except word wi are the set of all words; n kv represents the count of the vth word in the kth topic minus the current word, n mk represents the count of the topic of the kth topic in the mth document minus the current word, α and β are pseudo counts; the above conditional probability is sampled to determine the new topic assignment of word w;
[0020] S3.3: Repeat the steps in S3.2 until the convergence condition is reached. The convergence condition is that the number of iterations and the change rate of topic allocation are less than the threshold; calculate the model parameters based on the obtained sample count:
[0021]
[0022] Where n kv represents the count of the vth word in the kth topic minus the current word, n mk represents the count of the topic of the kth topic in the mth document minus the current word, and α and β are pseudo counts; the above conditional probability is sampled to determine the new topic assignment of word w; finally, the topic assignment of each word and the topic distribution of the document are obtained, and the trained LDA topic model is obtained;
[0023] Furthermore, in S4,
[0024] S4.1: Apply the trained topic model in S3 to the text dataset to obtain its topic distribution, and convert the topic distribution into a topic vector, taking the probability of each topic as the element of the vector;
[0025] S4.2: Preprocess the text dataset according to the input format of the BERT model, including word segmentation, adding special tags, truncation, and padding; pass through the word embedding layer of the BERT model to obtain a dense word vector representation of the text, which contains the contextual semantic information of the input text; pass through the position embedding layer to encode the order of the text and obtain the position information of the text;
[0026] S4.3: Add a topic embedding layer, concatenate the topic vector with the input vector, and integrate the topic information of the text; use the word vector after three layers of embedding as the final input vector; input it into the subsequent network of the BERT model and train it using the mask task; obtain a pre-trained language representation model that integrates the topic information.
[0027] The beneficial effects of the present invention are:
[0028] The present invention constructs a method for extracting topic information through an LDA model, embedding the topic information into a BERT pre-trained language model for training to obtain a text representation of the fused topic information, constructing an LSTM model for feature extraction, predicting the next search text, and returning the power data related to the search text as recommended data. The recommendation system that integrates the topic information better conforms to the actual data application scenario, and improves the accuracy of data recommendation and the utilization rate of data; the specific LDA topic model can extract potential semantic topics from text data, and these topics represent the semantic information hidden in the data. By embedding the topic information obtained by the LDA model into the BERT model, the BERT model can not only extract surface text information when encoding text, but also consider these potential semantic topics, so as to better capture the topic relevance between data. By modeling the time series text data with the LSTM model, the evolution trend of user interests can be captured, and the user interest topic information provided by the LDA topic embedding layer can better understand the changes in user interests and make more accurate comprehensive recommendations. The problem of recommendation homogeneity and recommendation demand mismatch caused by the traditional recommendation system being overly dependent on the user's historical behavior or the similarity of text content and failing to fully consider the user's interest topics is solved. This method can better meet the user's needs for topic-oriented data recommendation in actual application scenarios. And by using end-to-end deep learning technology, it can avoid the manual design feature engineering steps required by traditional machine learning methods, making model construction and implementation easier. DETAILED DESCRIPTION
[0029] The present invention discloses a method for recommending electric power data by integrating subject information, comprising the following steps:
[0030] S1: Data acquisition: Obtain power text and data search text records from the power management system to form a text data set;
[0031] S2: Preprocess the data set and split it into a training set and a test set: Preprocessing includes text segmentation, vocabulary building, sequence filling, and text vectorization; specifically, use the segmentation tool to segment the document and remove stop words; index the words after segmentation and stop word removal, and build a word dictionary; use the word embedding method to convert text data into numerical vectors;
[0032] S3: Topic model construction: Use power text and search text to train the topic model, learn potential topic information, obtain the topic distribution of power documents, and convert the topic distribution into topic feature vectors; the specific subject model construction is LDA model training, including the following steps:
[0033] Determine the number of topics: select the appropriate number of topics K through cross-validation or according to actual classification requirements;
[0034] Initialization: For a corpus containing M documents, each containing N words, traverse each word in each document, randomly sample from a uniform distribution of [1 to K] as the initial topic of each word, and then count the topic frequency of each article and the word frequency of each topic;
[0035] Iterative training:
[0036] For each document m in the corpus, and the word wi at the nth position in each document: remove word wi from document m, and count the frequency of each topic after removing word wi from document m. For each possible value k (1 to K) of topic: calculate the conditional probability that the topic assignment of word wi in document m is k:
[0037]
[0038] The word wi at the nth position of the mth document is the vth word in the word set, and its topic z i is the kth topic in the topic set, representing all topic assignments except word wi, and is the set of all words, n kv represents the count of the vth word in the kth topic minus the current word, n mk represents the count of the topic of the kth topic in the mth document minus the current word. α and β are pseudo counts. Sampling is performed according to the above conditional probability to determine the new topic assignment of word w. Repeat the above steps until the convergence condition is reached (such as the number of iterations, the change rate of topic assignment is less than the threshold, etc.).
[0039] Calculate the model parameters using the obtained sample counts:
[0040]
[0041] Where n kv represents the count of the vth word in the kth topic minus the current word, n mk represents the count of the topic of the kth topic in the mth document minus the current word, and α and β are pseudo counts; the above conditional probability is sampled to determine the new topic assignment of word w; finally, the topic assignment of each word and the topic distribution of the document are obtained, and the trained LDA topic model is obtained;
[0042] Finally, the topic assignment of each word and the topic distribution of the document are obtained, and the trained LDA topic model is obtained.
[0043] S4: Enhanced text semantic representation integrating topic information: A new topic embedding layer is added after the word embedding layer and position embedding layer of the BERT pre-trained language model, and the language representation model integrating topic information is obtained after retraining using the mask task; the trained LDA topic model is applied to the text dataset to obtain its topic distribution, and the topic distribution is converted into a topic vector, and the probability of each topic is taken as the element of the vector; the text dataset is preprocessed according to the input format of the BERT model, including word segmentation, adding special tags, truncation or padding, etc.
[0044] After the word embedding layer of the BERT model, a dense word vector representation of the text is obtained, which contains the contextual semantic information of the input text; after the position embedding layer, the order of the text is encoded to obtain the position information of the text; a topic embedding layer is added to concatenate the topic vector with the input vector to integrate the topic information of the text; the word vector after three layers of embedding is used as the final input vector, input into the subsequent network of the BERT model, and trained using the mask task; a pre-trained language representation model that integrates the topic information is obtained. Although the traditional BERT model can learn the semantic information of the text, it does not consider the topic information of the text. By introducing the topic embedding layer, an additional way is provided to make the model consider the topic structure of the text when learning the text representation, and the representation of the text is richer and more accurate.
[0045] S5: Build an LSTM long short-term memory network model, learn the fused topic information text, and obtain the topic text features; and use the stochastic gradient descent method for optimization, calculate the probability distribution of the next word, and return the word with the maximum probability as the predicted text; specifically, the LSTM model construction process is as follows:
[0046] Input layer: The number of nodes in the LSTM model input layer is consistent with the number of BERT model outputs, which is 768 nodes.
[0047] Middle layer: includes input gate, forget gate, output gate, candidate memory, and memory unit. Each gate controls the flow and storage of information, allowing the LSTM model to effectively capture long-term dependencies.
[0048] Input gate: The input gate determines the extent to which the new input information updates the memory cell. It includes a sigmoid activation function that outputs a value between 0 and 1 to control the importance of the new input information. The role of the input gate is to selectively update the contents of the memory cell to ensure that only important information is added to the memory cell.
[0049] The calculation formula is as follows:
[0050]
[0051] in, is the output of the input gate, subscript 1 indicates the input gate, superscript t indicates the time, σ is the sigmoid activation function, X (t) Represents the data input to the middle layer at the current moment, Y (t-1) Represents the output data of the previous moment, W1 and V1 are the weight matrices of the input gate, and B1 is the bias vector.
[0052] Candidate memory: The candidate memory unit is used to calculate the candidate memory unit value of the current time step, which will be used by the input gate and the forget gate. By properly adjusting W1, V1, B1, W2, V2 and B2, the candidate memory can be added to the memory unit in an appropriate proportion.
[0053] The calculation formula is as follows:
[0054]
[0055] in, is the output of the candidate memory, the subscript 2 represents the candidate memory, the superscript t represents the time, tanh is the hyperbolic tangent activation function, X (t) Represents the data input to the middle layer at the current moment, Y (t-1) represents the output data of the previous moment, W2 and V2 are the weight matrices of the candidate memories, and B2 is the bias vector.
[0056] Forget gate: The forget gate determines the importance of past information in the memory unit at the current time step; the calculation formula is as follows:
[0057]
[0058] in, is the output of the forget gate, the subscript 3 represents the forget gate, the superscript t represents the time, σ is the sigmoid activation function, X (t) Represents the data input to the middle layer at the current moment, Y (t-1)represents the output data of the previous moment, W3 and V3 are the weight matrices of the forget gate, and B3 is the bias vector. The number of hidden layers can be determined by comparing the prediction results after training and prediction with small sample data with different numbers of layers. In this model, it is set to seven layers.
[0059] Output gate: The output gate determines how the content in the memory cell affects the output of the current time step; the calculation formula is as follows:
[0060]
[0061] in, is the output of the output gate, the subscript 4 represents the output gate, the superscript t represents the time, σ is the sigmoid activation function, X (t) Represents the data input to the middle layer at the current moment, Y (t-1) Represents the output data of the previous moment, W4 and V4 are the weight matrices of the output gate, and B4 is the bias vector.
[0062] Output layer: The number of nodes is consistent with the vocabulary. After the softmax function, the output is expressed as the probability distribution of the words that may be taken by the next word, and the word with the highest probability is used as the output.
[0063] Learning rate: The learning rate determines the adjustment range of the model parameters in each batch. Too large a learning rate may cause unstable training or failure to converge, while too small a learning rate may cause slow training or fall into a local optimum. As the number of training times increases, the model will gradually stabilize, and the range of parameter adjustment should be gradually reduced. The initial learning rate is set to 0.01, and the learning rate decay method is used for dynamic adjustment.
[0064] Optimization algorithm: Stochastic gradient descent randomly selects only one sample in each iteration to calculate the gradient and update the model parameters. This randomness can increase the training speed and help avoid local optimal solutions. The optimization algorithm of this model uses stochastic gradient descent.
[0065] Loss function: The loss function is used to measure the difference between the model's predicted value and the true value. The sum of squared errors is used in this model, and the calculation formula is as follows:
[0066]
[0067] Among them, k represents the number of samples, y k represents the true value of each sample, It represents the predicted value of the model, E represents the error, and the smaller the error, the better the fitting degree of the model.
[0068] After the LSTM model is trained, the next possible recommended text data can be predicted based on the input original text data, and the original text and recommended text are concatenated and input into the model to continuously generate new recommended text data. Through the recommended text retrieval that integrates the subject information, the relevant power data is returned as the recommended data.
[0069] S6: Search based on the predicted text and return the power data of related topics as recommendations.
[0070] The preferred embodiments of the present invention disclosed above are only used to help explain the present invention. The preferred embodiments do not describe all the details in detail, nor do they limit the invention to only the specific implementation methods described.
Claims
1. A method for recommending electric power data integrating subject information, characterized in that: The following steps are involved: S1: Data acquisition: Obtain power text and data search text records from the power management system to form a text data set; S2: Preprocess the dataset and split it into training set and test set: preprocessing includes text segmentation, vocabulary building, sequence filling, and text vectorization; S3: Topic model construction: Use power text and search text to train the topic model, learn potential topic information, obtain the topic distribution of power documents, and convert the topic distribution into a topic feature vector; S4: Enhanced text semantics representation with topic information: A topic embedding layer is added after the word embedding layer and position embedding layer of the BERT pre-trained language model, and the language representation model with topic information is obtained after retraining using the mask task; S5: Build an LSTM long short-term memory network model to learn the fused topic information text and obtain the topic text features; then use the stochastic gradient descent method for optimization, calculate the probability distribution of the next word, and return the word with the maximum probability as the predicted text; S6: Search based on the predicted text and return the power data of related topics as recommendations.
2. The method for recommending electric power data integrating subject information according to claim 1, characterized in that: In S3, S3.1: Build an LDA model and train it; Determine the number of topics: Select the appropriate number of topics K through cross-validation or according to actual classification requirements; S3.2: Initialization: For a corpus containing M documents, each containing N words, traverse each word in each document, randomly sample from a uniform distribution of [1~K] as the initial topic of each word, and then count the topic frequency of each article and the word frequency of each topic; S3.2: Iterative training: For each document m in the corpus, and the word wi at the nth position in each document; remove word wi from document m, and count the word frequencies of each topic in document m after removing word wi. For each possible value k of the topic, calculate the conditional probability that the topic of word wi in a given document m is assigned to k: Among them, z i is the set of all words except word wi for all topic assignments; n kv represents the count of the vth word in the kth topic minus the current word, n mk represents the count of the topic of the kth topic in the mth document minus the current word, α and β are pseudo counts; then sampling is performed according to the above conditional probability to determine the new topic assignment of word w; S3.3: Repeat the steps in S3.2 until the convergence condition is reached. The convergence condition is that the number of iterations and the change rate of topic allocation are less than the threshold; calculate the model parameters based on the obtained sample count: Where n kv represents the count of the vth word in the kth topic minus the current word, n mk represents the count of the topic of the kth topic in the mth document minus the current word, and α and β are pseudo counts; the above conditional probability is sampled to determine the new topic assignment of word w; finally, the topic assignment of each word and the topic distribution of the document are obtained, and the trained LDA topic model is obtained; Finally, the topic assignment of each word and the topic distribution of the document are obtained, and the trained LDA topic model is obtained.
3. The method for recommending electric power data integrating subject information according to claim 1, characterized in that: In S4, S4.1: Apply the trained topic model in S3 to the text dataset to obtain its topic distribution, and convert the topic distribution into a topic vector, taking the probability of each topic as the element of the vector; S4.2: Preprocess the text dataset according to the input format of the BERT model, including word segmentation, adding special tags, truncation, and padding; pass through the word embedding layer of the BERT model to obtain a dense word vector representation of the text, which contains the contextual semantic information of the input text; pass through the position embedding layer to encode the order of the text and obtain the position information of the text; S4.3: Add a topic embedding layer, concatenate the topic vector with the input vector, and integrate the topic information of the text; use the word vector after three layers of embedding as the final input vector; input it into the subsequent network of the BERT model and train it using the mask task; obtain a pre-trained language representation model that integrates the topic information.
Citation Information
Patent Citations
A social network short text recommendation method based on a word meaning topic model
CN109766431A
Text writing real-time recommendation method based on topic model and user behavior data
CN112989025A
