Topic Modeling Method Based on Wasserstein Autoencoder and Gaussian Mixture Distribution as Prior
Through the combination of Wasserstein autoencoder and Gaussian mixture distribution, maximum mean difference MMD is used to optimize latent variable generation, which solves the problems of insufficient semantic information and KL divergence collapse of traditional topic modeling methods, and achieves more accurate and coherent topic construction. mold.
Patent Information
- Application Number
- CN202111482375.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-06
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2041-12-06
AI Technical Summary
Traditional topic modeling methods have less than ideal topic recognition rates due to insufficient semantic information when the number of predictions is small or the text length is short, and the neural network-based variational autoencoder is prone to KL divergence mode collapse during the training process. problem.
Wasserstein autoencoder and Gaussian mixture distribution are used as prior, and the gap between prior and posterior is minimized through maximum mean difference MMD to generate latent variables. Supervision information is not used during the training process, and the generation is more diverse and coherent. Sexual themes.
It improves the representation ability and accuracy of topic modeling, solves the problem of KL divergence mode collapse, and obtains a more diverse and coherent topic distribution.
Smart Images

Figure CN114417852B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of natural language processing, and in particular to a topic modeling method based on Wasserstein autoencoder and Gaussian mixture distribution as priors. Background Art
[0002] Topic modeling is an important task in natural language processing. Traditional topic detection methods mainly use words as basic features and calculate the probability between topics by counting the co-occurrence relationship between words. It is widely used in many scenarios such as topic identification, spam detection and sentiment classification. However, when the number of expected data is small or the text is short, this method of topic assignment based solely on word frequency statistics often results in a suboptimal topic recognition rate due to insufficient semantic information.
[0003] In recent years, deep learning and machine learning have made great progress in natural language processing. Studies have shown that neural network-based models perform better in topic modeling tasks than traditional models (such as Naive Bayes). Typical neural network-based topic models are also based on words, but they usually use the words in the target document as the input of the model, map the words into a continuous vector space (word embedding), and combine these vectors to capture the semantics of the document through methods such as summation, averaging, convolutional neural networks (CNN) or recurrent neural networks (RNN).
[0004] In addition to the above methods, another feasible way is to use the inference of the topic model improved by the variational autoencoder based on the neural network, which aims to use the neural network to characterize the text generation process containing potential topic information. This type of model generally uses the document bag of words (BOW) as input. The difference from the traditional model is that the traditional topic model mainly involves Gibbs sampling or variational inference. These methods will cause the algorithm to be re-derived with a slight change in the modeling assumptions. This makes the variational autoencoder, which obtains latent variables through encoding and then simulates the observed variables by latent variables, outstanding. The parameters of this type of model are trained by neural networks, and the parameters involved are relatively few. The disadvantage of this type of model is that it involves the problem of KL divergence mode collapse during training. Summary of the invention
[0005] In view of the above problems, the purpose of the present invention is to disclose a topic modeling method based on Wasserstein autoencoder and Gaussian mixture distribution as priors, which generates observable words by fitting appropriate latent variables through Gaussian mixture priors based on Wasserstein autoencoder, and optimizes the model by minimizing the gap between the prior and the posterior with maximum mean difference (MMD). Without using supervised information during the training process, a series of more diverse and coherent topics can be obtained.
[0006] Specifically, the topic modeling method based on Wasserstein autoencoder and Gaussian mixture distribution as a priori of the present invention comprises the following steps:
[0007] S1: The text dataset is represented as a bag-of-words model BOW as the input of the Wasserstein autoencoder and the dataset is preprocessed;
[0008] S2: Use Wasserstein autoencoder to pass the data through the encoder to obtain the topic distribution θ;
[0009] S3: Use Gaussian mixture distribution as the prior distribution of latent features to generate a latent vector representation θ′;
[0010] S4: Decode the topic distribution θ obtained in step S2 and map it to the output layer of V units to obtain the probability distribution of words in the vocabulary Compute the reconstruction loss and calculate the difference between the two distributions;
[0011] S5: Iterate and update model parameters to optimize the generated model.
[0012] Furthermore, in the step S1, when the text dataset is represented as a bag-of-words model BOW, all words in a document are represented as:
[0013] D(W)={w 1 ,w 2 ,...,w D}.
[0014] Among them, w D Represents the Dth word in the document.
[0015] Furthermore, in step S2, the expression formula of topic distribution θ is:
[0016] θ=enc(w).
[0017] Further, the S3 step specifically includes:
[0018] S31: Gaussian mixture model obtains latent variables {z′ by initialization i}, the expression formula is as follows:
[0019] {z′ i}~N(μ,σ 2 I)
[0020] S32: A document assumes topics θ′ and z′ i The relationship expression formula is as follows:
[0021] θ′={z′ i}
[0022] Among them, θ′ is the implicit topic distribution of the document assumed by Gaussian mixture distribution, i.e., the potential vector, z′ i represents a certain topic of the hypothetical document, μ represents the mean difference in the Gaussian mixture distribution, σ 2 Represents the variance in Gaussian mixture distribution, which is fitted by neural network respectively.
[0023] Further, the S4 step specifically includes:
[0024] S41: Decode the topic distribution θ obtained in step S2 to obtain Represents the probability distribution of words in the vocabulary, and the calculation formula is as follows:
[0025]
[0026] in, represents the probability distribution of the i-th word, β is the matrix of the topic word vector in LDA, b is the offset vector, and h i 、h j represents the output of a neuron, and h represents the linear calculation formula.
[0027] S42: Calculate the reconstruction loss of the autoencoder, which is the bag-of-words BOW model w and The negative cross entropy between is calculated as follows:
[0028]
[0029] S43: MMD calculates the prior distribution P when using m samples θ With encoder Q θ The difference in the introduced distribution is calculated as follows:
[0030]
[0031] Among them, k is the kernel function, z i ,z j Respectively represent the i-th topic and the j-th topic encoded by the encoder, z′ i ,z′ j They represent the i-th topic and the j-th topic sampled from the Gaussian prior distribution respectively.
[0032] S44: Calculate the total model loss, which is used to iteratively update model parameters:
[0033]
[0034] Beneficial effects of the present invention:
[0035] The present invention discloses a topic modeling method based on Wasserstein autoencoder and Gaussian mixture distribution as priors, which utilizes Gaussian mixture model and Wasserstein autoencoder to encode appropriate latent variables to represent the potential semantic information of the full text, further obtains the document topic vector matrix θ of the relevant document, and simultaneously uses Gaussian mixture distribution to assume the potential document topic distribution θ′, obtains the observed variables during decoding to calculate the reconstruction loss, and simultaneously calculates the distribution difference between the latent variables generated by the encoder and the assumed variables, and obtains the algorithm loss update model by the two, the model uses Gaussian mixture distribution to improve the representation ability of the model, and uses maximum mean difference (MMD) to calculate the distribution difference, so as to model the document topic more reliably and accurately. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 is a flow chart of an embodiment of the present invention;
[0037] Figure 2 A network structure diagram of a topic modeling method based on Wasserstein autoencoder and Gaussian mixture distribution as a priori provided by the present invention. DETAILED DESCRIPTION
[0038] The present invention will be described in detail below with reference to specific embodiments:
[0039] The topic modeling method based on Wasserstein autoencoder and Gaussian mixture distribution as a priori adopts Figure 1 The processing flow shown in the figure uses the 20NewsGroup and NYtimes datasets. The Gaussian mixture model is used as a prior distribution to fit the globally related hypothetical latent variables, and then the latent variables encoded by the encoder are used as the input of the decoding module to participate in the generation of observable words. While improving the coherence of the topic, it also solves the problem of KL divergence mode collapse to a certain extent. The details are as follows:
[0040] S1: The text dataset is represented as the traditional bag-of-words model BOW as the input of the autoencoder, and the dataset is preprocessed. When the text features are represented by the bag-of-words (BOW) model, only simple preprocessing of the dataset is required, and all words in a document are represented as follows:
[0041] D(W)={w 1 ,w 2 ,...,w D}
[0042] Among them, w D Represents the Dth word in the document.
[0043] S2: Use the Wasserstein autoencoder to pass the data through the encoder to obtain the topic vector θ, which is actually obtained through a 3-layer shallow neural network. The expression formula of the topic distribution θ in the model is as follows:
[0044] θ=enc(w).
[0045] S3: Abandoning the traditional Dirichlet distribution, we use Gaussian mixture distribution as the prior distribution of potential features to generate potential vector representation θ′, which can better improve the expression of the model; specifically:
[0046] S31: Gaussian mixture model obtains latent variables {z′ by initialization i}, the expression formula is as follows:
[0047] {z′ i}~N(μ,σ 2 I)
[0048] S32: A document assumes topics θ′ and z′ i The relationship expression formula is as follows:
[0049] θ′={z′ i}
[0050] Among them, θ′ is the implicit topic distribution of the document assumed by Gaussian mixture distribution, i.e., the potential vector, z′ i represents a certain topic of the hypothetical document, μ represents the mean difference in the Gaussian mixture distribution, σ 2 Represents the variance in Gaussian mixture distribution, which is fitted by neural network respectively.
[0051] S4: Decode the topic distribution θ obtained in step S2 and map it to the output layer of V units to obtain , calculate the reconstruction loss and compute the difference between the two distributions;
[0052] The specific sub-steps to implement S4 are as follows:
[0053] S41: Decode the topic distribution θ obtained in step S2 to obtain Represents the probability distribution of words in the vocabulary, and the calculation formula is as follows:
[0054]
[0055] in, represents the probability distribution of the i-th word, β is the matrix of the topic word vector in LDA, b is the offset vector, and h i 、h j represents the output of a neuron, and h represents the linear calculation formula.
[0056] S42: Calculate the reconstruction loss of the autoencoder, which is the bag-of-words BOW model w and The negative cross entropy between . The calculation formula is as follows:
[0057]
[0058] S43: MMD calculates the prior distribution P when using m samples θ With encoder Q θ The difference in the introduced distribution is calculated as follows:
[0059]
[0060] Among them, in calculating the MMD distribution, k is the kernel function, z i ,z j Respectively represent the i-th topic and the j-th topic encoded by the encoder, z′ i ,z′ j They represent the i-th topic and the j-th topic sampled from the Gaussian prior distribution respectively.
[0061] S44: Calculate the total model loss for iterative updating of model parameters:
[0062]
[0063] The above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit the present invention. Although the present invention is described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the purpose and scope of the technical solutions of the present invention, which should be included in the scope of the claims of the present invention. The techniques, shapes, and structural parts not described in detail in the present invention are all known technologies.
Claims
1. A topic modeling method based on Wasserstein autoencoder and Gaussian mixture distribution as a priori, characterized in that: The steps include: S1: The text dataset is represented as a bag-of-words model BOW as the input of the Wasserstein autoencoder and the dataset is preprocessed; S2: Use Wasserstein autoencoder to pass the data through the encoder to obtain the topic distribution θ; S3: Use Gaussian mixture distribution as the prior distribution of latent features to generate a latent vector representation θ′; S4: Decode the topic distribution θ obtained in step S2 and map it to the output layer of V units to obtain the probability distribution of words in the vocabulary Compute the reconstruction loss and calculate the difference between the two distributions; S5: Iteration, updating model parameters to optimize the generated model; In the step S1, when the text dataset is represented as a bag-of-words model BOW, all words in a document are represented as follows: D(W)={w1,w2,...,w D } Among them, w D represents the Dth word in the document; In the step S2, the expression formula of topic distribution θ is: θ = enc(w); The S3 step specifically includes: S31: Gaussian mixture model obtains latent variables {z′ by initialization i }, the expression formula is as follows: {z′ i }~N(μ,σ 2 I) S32: A document assumes topics θ′ and z′ i The relationship expression formula is as follows: θ′={z′ i } Among them, θ′ is the implicit topic distribution of the document assumed by Gaussian mixture distribution, i.e., the potential vector, z′ i represents a certain topic of the hypothetical document, μ represents the mean difference in the Gaussian mixture distribution, σ 2 represents the variance in Gaussian mixture distribution, which is fitted by neural network respectively; The S4 step specifically includes: S41: Decode the topic distribution θ obtained in step S2 to obtain Represents the probability distribution of words in the vocabulary, and the calculation formula is as follows: h=βθ+b in, represents the probability distribution of the i-th word, β is the matrix of the topic word vector in LDA, b is the offset vector, and h i 、h j represents the output of a neuron, and h represents the linear calculation formula; S42: Calculate the reconstruction loss of the autoencoder, where the reconstruction loss is the bag-of-words BOW model w and The negative cross entropy between is calculated as follows: S43: MMD calculates the prior distribution P when using m samples θ The distribution Q introduced by the encoder θ The difference is calculated as follows: Among them, k is the kernel function, z i ,z j They represent the i-th topic and the j-th topic encoded by the encoder, respectively, and z i ′ ,z j ′ They represent the i-th topic and the j-th topic sampled from the Gaussian prior distribution respectively; S44: Calculate the total model loss, which is used to iteratively update model parameters:
Citation Information
Patent Citations
Sparse coding algorithm suitable for multi-modal information and application thereof
CN104765878A
Cross-domain text sentiment classification method based on domain confrontation self-adaption
CN109492099A
A Gaussian LDA optimization solving method based on word embedding
CN109597875A
Dialogue model training method and device, computer equipment and storage medium
CN111680123A
Natural language generation using pinned text and multiple discriminators
US20190236139A1
