Neural Topic Modeling with Bidirectional Adversarial Training

Recent years have witnessed a surge of interests of using neural topic models for automatic topic extraction from text, since they avoid the complicated mathematical derivations for model inference as in traditional topic models such as Latent Dirichlet Allocation (LDA). However, these models either typically assume improper prior (e.g. Gaussian or Logistic Normal) over latent topic space or could not infer topic distribution for a given document. To address these limitations, we propose a neural topic modeling approach, called Bidirectional Adversarial Topic (BAT) model, which represents the first attempt of applying bidirectional adversarial training for neural topic modeling. The proposed BAT builds a two-way projection between the document-topic distribution and the document-word distribution. It uses a generator to capture the semantic patterns from texts and an encoder for topic inference. Furthermore, to incorporate word relatedness information, the Bidirectional Adversarial Topic model with Gaussian (Gaussian-BAT) is extended from BAT. To verify the effectiveness of BAT and Gaussian-BAT, three benchmark corpora are used in our experiments. The experimental results show that BAT and Gaussian-BAT obtain more coherent topics, outperforming several competitive baselines. Moreover, when performing text clustering based on the extracted topics, our models outperform all the baselines, with more significant improvements achieved by Gaussian-BAT where an increase of near 6% is observed in accuracy.


Introduction
Topic models have been extensively explored in the Natural Language Processing (NLP) community for unsupervised knowledge discovery. Latent Dirichlet Allocation (LDA) (Blei et al., 2003), the * corresponding author most popular topic model, has been extended (Lin and He, 2009;Zhou et al., 2014;Cheng et al., 2014) for various extraction tasks. Due to the difficulty of exact inference, most LDA variants require approximate inference methods, such as mean-field methods and collapsed Gibbs sampling. However, these approximate approaches have the drawback that small changes to the modeling assumptions result in a re-derivation of the inference algorithm, which can be mathematically arduous.
One possible way in addressing this limitation is through neural topic models which employ blackbox inference mechanism with neural networks. Inspired by variational autoencoder (VAE) (Kingma and Welling, 2013), Srivastava and Sutton (2017) used the Logistic-Normal prior to mimic the simplex in latent topic space and proposed the Neural Variational LDA (NVLDA). Moreover, they replaced the word-level mixture in NVLDA with a weighted product of experts and proposed the ProdLDA (Srivastava and Sutton, 2017) to further enhance the topic quality.
Although Srivastava and Sutton (2017) used the Logistic-Normal distribution to approximate the Dirichlet distribution, they are not exactly the same. An illustration of these two distributions is shown in Figure 1 in which the Logistic-Normal distribution does not exhibit multiple peaks at the vertices of the simplex as that in the Dirichlet distribution and as such, it is less capable to capture the multi-modality which is crucial in topic modeling (Wallach et al., 2009). To deal with the limitation, Wang et al. (2019a) proposed the Adversarialneural Topic Model (ATM) based on adversarial training, it uses a generator network to capture the semantic patterns lying behind the documents. However, given a document, ATM is not able to infer the document-topic distribution which is useful for downstream applications, such as text clustering. Moreover, ATM take the bag-of-words assumption and do not utilize any word relatedness information captured in word embeddings which have been proved to be crucial for better performance in many NLP tasks (Liu et al., 2018;Lei et al., 2018).
To address these limitations, we model topics with Dirichlet prior and propose a novel Bidirectional Adversarial Topic model (BAT) based on bidirectional adversarial training. The proposed BAT employs a generator network to learn the projection function from randomly-sampled documenttopic distribution to document-word distribution. Moreover, an encoder network is used to learn the inverse projection, transforming a document-word distribution into a document-topic distribution. Different from traditional models that often resort to analytic approximations, BAT employs a discriminator which aims to discriminate between real distribution pair and fake distribution pair, thereby helps the networks (generator and encoder) to learn the two-way projections better. During the adversarial training phase, the supervision signal provided by the discriminator will guide the generator to construct a more realistic document and thus better capture the semantic patterns in text. Meanwhile, the encoder network is also guided to generate a more reasonable topic distribution conditioned on specific document-word distributions. Finally, to incorporate the word relatedness information captured by word embeddings, we extend the BAT by modeling each topic with a multivariate Gaussian in the generator and propose the Bidirectional Adversarial Topic model with Gaussian (Gaussian-BAT).
The main contributions of the paper are: • We propose a novel Bidirectional Adversarial Topic (BAT) model, which is, to our best knowledge, the first attempt of using bidirectional adversarial training in neural topic modeling; • We extend BAT to incorporate the word re-latedness information into the modeling process and propose the Bidirectional Adversarial Topic model with Gaussian (Gaussian-BAT); • Experimental results on three public datasets show that BAT and Gaussian-BAT outperform the state-of-the-art approaches in terms of topic coherence measures. The effectiveness of BAT and Gaussian-BAT is further verified in text clustering.

Related work
Our work is related to two lines of research, which are adversarial training and neural topic modeling.

Adversarial Training
Adversarial training, first employed in Generative Adversarial Network (GAN) (Goodfellow et al., 2014), has been extensively studied from both theoretical and practical perspectives. Theoretically,  and Gulrajani (2017) proposed the Wasserstein GAN which employed the Wasserstein distance between data distribution and generated distribution as the training objective. To address the limitation that most GANs (Goodfellow et al., 2014;Radford et al., 2015) could not project data into a latent space, Bidirectional Generative Adversarial Nets (Bi-GAN) (Donahue et al., 2016) and Adversarially Learned Inference (ALI) (Dumoulin et al., 2016) were proposed.
Adversarial training has also been extensively used for text generation. For example, Seq-GAN (Yu et al., 2017) incorporated a policy gradient strategy for text generation. RankGAN (Lin et al., 2017) ranked a collection of human-written sentences to capture the language structure for improving the quality of text generation. To avoid mode collapse when dealing with discrete data, MaskGAN (Fedus et al., 2018) used an actor-critic conditional GAN to fill in missing text conditioned on the context.

Neural Topic Modeling
To overcome the challenging exact inference of topic models based on directed graph, a replicated softmax model (RSM), based on the Restricted Boltzmann Machines was proposed in (Hinton and Salakhutdinov, 2009). Inspired by VAE, Miao et al. (2016) used the multivariate Gaussian as the prior distribution of latent space and proposed the fake distribution pair   (Miao et al., 2017) which constructs the topic distribution using a Gaussian distribution followed by a softmax transformation was proposed based on the NVDM. Likewise, to deal with the inappropriate Gaussian prior of NVDM, Srivastava and Sutton (2017) proposed the NVLDA which approximates the Dirichlet prior using a Logistic-Normal distribution. Recently, the Adversarial-neural Topic Model (ATM) (Wang et al., 2019a) is proposed based on adversarial training, it models topics with Dirichlet prior which is able to capture the multi-modality compared with logistic-normal prior and obtains better topics. Besides, the Adversarial-neural Event (AEM) (Wang et al., 2019b) model is also proposed for open event extraction by representing each event as an entity distribution, a location distribution, a keyword distribution and a date distribution.

Encoder Network(E)
Despite the extensive exploration of this research field, scarce work has been done to incorporate Dirichlet prior, word embeddings and bidirectional adversarial training into neural topic modeling. In this paper, we propose two novel topic modeling approaches, called BAT and Gaussian-BAT, which are different from existing approaches in the following aspects: (1) Unlike NVDM, GSM, NVLDA and ProdLDA which model latent topic with Gaussian or logistic-normal prior, BAT and Gaussian-BAT explicitly employ Dirichlet prior to model topics; (2) Unlike ATM which could not infer topic distribution of a given document, BAT and Gaussian-BAT uses a encoder to generate the topic distribution corresponding to the document; (3) Unlike neural topic models that only utilize word co-occurrence information, Gaussian-BAT models topic with multivariate Gaussian and incorporates the word relatedness into modeling process.

Methodology
Our proposed neural topic models are based on bidirectional adversarial training (Donahue et al., 2016) and aim to learn the two-way non-linear projection between two high-dimensional distributions. In this section, we first introduce the Bidirectional Adversarial Topic (BAT) model that only employs the word co-occurrence information. Then, built on BAT, we model topics with multivariate Gaussian in the generator of BAT and propose the Bidirectional Adversarial Topic model with Gaussian (Gaussian-BAT), which naturally incorporates word relatedness information captured in word embeddings into modeling process.

Bidirectional Adversarial Topic model
As depicted in Figure 2, the proposed BAT consists of three components: (1) The Encoder E takes the V -dimensional document representation d r sampled from text corpus C as input and transforms it into the corresponding K-dimensional topic distribution θ r ; (2) The Generator G takes a random topic distribution θ f drawn from a Dirichlet prior as input and generates a V -dimensional fake word distribution d f ; (3) The Discriminator D takes the real distribution pair p r = [ θ r ; d r ] and fake distribution pair p f = [ θ f ; d f ] as input and discriminates the real distribution pairs from the fake ones. The outputs of the discriminator are used as supervision signals to learn E, G and D during adversarial training. In what follows, we describe each component in more details.

Encoder Network
The encoder learns a mapping function to transform document-word distribution to document-topic distribution. As shown in the top-left panel of Figure 2, it contains a V -dimensional document-word distribution layer, an S-dimensional representation layer and a K-dimensional document-topic distribution layer, where V and K denote vocabulary size and topic number respectively.
More concretely, for each document d in text corpus, E takes the document representation d r as input, where d r is the representation weighted by TF-IDF, and it is calculated by: where n i,d denotes the number of i-th word appeared in document d, |C| represents the number of documents in the corpus, and |C i | means the number of documents that contain i-th word in the corpus. Thus, each document could be represented as a V -dimensional multinomial distribution and the i-th dimension denotes the semantic consistency between i-th word and the document. With d r as input, E firstly projects it into an S-dimensional semantic space through the representation layer as follows: where W e s ∈ R S×V and b e s are weight matrix and bias term of the representation layer, h e s is the state vector normalized by batch normalization BN(·), leak denotes the parameter of LeakyReLU activation and o e s represents the output of representation layer.
Then, the encoder transforms o e s into a Kdimensional topic space based on the equation below: where W e t ∈ R K×S is the weight matrix of topic distribution layer, b e t represents the bias term, θ r denotes the corresponding topic distribution of the input d r and the k-th (k ∈ {1, 2, ..., K}) dimension θ k r represents the proportion of k-th topic in document d.

Generator network
The generator G is shown in the bottom-left panel of Figure 2. Contrary to encoder, it provides an inverse projection from document-topic distribution to document-word distribution and contains a K-dimensional document-topic layer, an S-dimensional representation layer and a Vdimensional document-word distribution layer.
As pointed out in (Wallach et al., 2009), the choice of Dirichlet prior over topic distribution is important to obtain interpretable topics. Thus, BAT employs the Dirichlet prior parameterized with α to mimic the multi-variate simplex over topic distribution θ f . It can be drawn randomly based on the equation below: where α is the K-dimensional hyper-parameter of Dirichlet prior, K is the topic number that should be set in BAT, θ k f ∈ [0, 1], follows the constrain that K k=1 θ k f = 1, represents the proportion of the k-th topic in the document, and normalization term .
To learn the transformation from documenttopic distribution to document-word distribution, G firstly projects θ f into an S-dimensional representation space based on equations: where W g s ∈ R S×K is weight matrix of the representation layer, b g s represents bias term, h g s is the state vector normalized by batch normalization, Eq. 6 represents the LeakyReLU activation parameterized with leak, and o g s is the output of the representation layer.
Then, to project o g s into word distribution d f , a subnet contains a linear layer and a softmax layer is used and the transformation follows: where W g w ∈ R V ×S and b g w are weight matrix and bias of word distribution layer,

Discriminator network
The discriminator D is constituted by three layers (a V + K-dimensional joint distribution layer, an S-dimensional representation layer and an output layer) as shown in the right panel of Figure 2. It employs real distribution pair p r and fake distribution pair p f as input and then outputs D out to identify the input sources (fake or real). Concretely, a higher value of D out represents that D is more prone to predict the input as real and vice versa.

BAT with Gaussian (Gaussian-BAT)
In BAT, the generator models topics based on the bag-of-words assumption as in most other neural topic models. To incorporate the word relatedness information captured in word embeddings (Mikolov et al., 2013a,b;Pennington et al., 2014;Joulin et al., 2017;Athiwaratkun et al., 2018) into the inference process, we modify the generator of BAT and propose Gaussian-BAT, in which G models each topic with a multivariate Gaussian as shown in Figure 3.  Concretely, Gaussian-BAT employs the multivariate Gaussian N ( µ k , Σ k ) to model the k-th topic. Here, µ k and Σ k are trainable parameters, they represent mean and covariance matrix respectively. Following its probability density, for each word v ∈ {1, 2, ..., V }, the probability in the k-th topic φ k,v is calculated by: where e v means the word embedding of v-th word, V is the vocabulary size, |Σ k | = det Σ k is the determinant of covariance matrix Σ k , D e is the dimension of word embeddings, p( e v |topic = k) is the probability calculated by density, and φ k is the normalized word distribution of k-th topic. With randomly sampled topic distribution θ f and the calculated topic-word distributions { φ 1 , φ 2 , ..., φ K }, the fake word distribution d f corresponding to θ f can be obtained by: where θ k is the topic proportion of the k-th topic.
Then, θ f and d f are concatenated to form the fake distribution pair p f as shown in Figure 3. And encoder and discriminator of Gaussian-BAT are same as BAT, shown as Figure 2. In our experiments, the pre-trained 300-dimensional Glove (Pennington et al., 2014) embedding is used.

Objective and Training Procedure
In Figure 2, the real distribution pair p r = [ θ r ; d r ] and the fake distribution pair p f = [ θ f ; d f ] can be viewed as random samples drawn from two (K + V )-dimensional joint distributions P r and P f , each of them comprising of a K-dimensional Dirichlet distribution and a V -dimensional Dirichlet distribution. The training objective of BAT and Gaussian-BAT is to make the generated joint distribution P f close to the real joint distribution P r as much as possible. In this way, a two-way projection between document-topic distribution and document-word distribution could be built by the learned encoder and generator. To measure the distance between P r and P f , we use the Wasserstein-distance as the optimization objective, since it was shown to be more effective compared to Jensen-Shannon divergence : where D(·) represents the output signal of the discriminator. A higher value denotes that the discriminator is more prone to consider the input as a real distribution pair and vice versa. In addition, we use weight clipping which was proposed to ensure the Lipschitz continuity  of D.
Algorithm 1 Training procedure for BAT and Gaussian-BAT Input: K, c, n d , m, α 1 , β1, β2 Output: The trained encoder E and generator G.

Topic Generation and Cluster Inference
After model training, learned G and E will build a two-way projection between document-topic distribution and document-word distribution. Thus, G and E could be used for topic generation and cluster inference.
To generate the word distribution of each topic, we use ts (k) , a K-dimensional vector, as the onehot encoding of the k-th topic. For example, ts 2 = [0, 1, 0, 0, 0, 0] T in a six topic setting. And the word distribution of the k-th topic is obtained by: Likewise, given the document representation d r , topic distribution θ r obtained by BAT/Gaussian-BAT could be used for cluster inference based on: where c r denotes the inferred cluster of d r .

Experiments
In this section, we first present the experimental setup which includes the datasets used and the baselines, followed by the experimental results.

Experimental Setup
We evaluate BAT and Gaussian-BAT on three datasets for topic extraction and text clustering, 20Newsgroups 1 , Grolier 2 and NYTimes 3 . Details are summarized below: 20Newsgroups (Lang, 1995) is a collection of approximately 20,000 newsgroup articles, partitioned evenly across 20 different newsgroups. Grolier is built from Grolier Multimedia Encycopedia, which covers almost all the fields in the world.
NYTimes is a collection of news articles published between 1987 and 2007, and contains a wide range of topics, such as sports, politics, education, etc. We use the full datasets of 20Newsgroups 1 and Grolier 2 . For the NYTimes dataset, we randomly select 100,000 articles and remove the low frequency words. The final statistics are shown in  We choose the following models as baselines: LDA (Blei et al., 2003) extracts topics based on word co-occurrence patterns from documents. We implement LDA following the parameter setting suggested in (Griffiths and Steyvers, 2004). NVDM (Miao et al., 2016) is an unsupervised text modeling approach based on VAE. We use the original implementation of the paper 4 .  GSM (Miao et al., 2017) is an enhanced topic model based on NVDM, we use the original implementation in our experiments 5 . NVLDA (Srivastava and Sutton, 2017), also built on VAE but with the logistic-normal prior. We use the implementation provided by the author 6 .
ProdLDA (Srivastava and Sutton, 2017), is a variant of NVLDA, in which the distribution over individual words is a product of experts. The original implementation is used. ATM (Wang et al., 2019a), is a neural topic modeling approach based on adversarial training, we implement the ATM following the parameter setting suggested in the original paper.

Topic Coherence Evaluation
Topic models are typically evaluated with the likelihood of held-out documents and topic coherence. However, Chang et al. (2009) showed that a higher likelihood of held-out documents does not correspond to human judgment of topic coherence. Thus, we follow (Röder et al., 2015) and employ four topic coherence metrics (C P, C A, NPMI and UCI) to evaluate the topics generated by various models. In all experiments, each topic is represented by the top 10 words according to the topic-word probabilities, and all the topic coherence values are calculated using the Palmetto library 7 . We firstly make a comparison of topic coherence vs. different topic proportions. Experiments are 5 https://github.com/linkstrife/NVDM-GSM 6 https://github.com/akashgit/autoencoding vi for topic models 7 https://github.com/dice-group/Palmetto  conducted on the datasets with five topic number settings [20,30,50,75,100]. We calculate the average topic coherence values among topics whose coherence values are ranked at the top 50%, 70%, 90%, 100% positions. For example, to calculate the average C P value of BAT @90%, we first compute the average C P coherence with the selected topics whose C P values are ranked at the top 90% for each topic number setting, and then average the five coherence values with each corresponding to a particular topic number setting.
The detailed comparison is shown in Figure 4. It can be observed that BAT outperforms the baselines on all the coherence metrics for NYTimes datasets. For Grolier dataset, BAT outperforms all the baselines on C P, NPMI and UCI metrics, but

Model Topics
Gaussian-BAT voter campaign poll candidates democratic election republican vote presidential democrat song album music band rock pop sound singer jazz guitar film movie actor character movies director series actress young scenes flight airline passenger airlines aircraft shuttle airport pilot carrier planes BAT vote president voter campaign election democratic governor republican black candidates album band music rock song jazz guitar pop musician record film actor play acting role playing character father movie actress flight airline delay airlines plane pilot airport passenger carrier attendant LDA voter vote poll election campaign primary candidates republican race party music song band sound record artist album show musical rock film movie character play actor director movies minutes theater cast flight plane ship crew air pilot hour boat passenger airport ATM voter vote poll republican race primary percent election campaign democratic music song musical album jazz band record recording mp3 composer film movie actor director award movies character theater production play jet flight airline hour plane passenger trip plan travel pilot Table 3: Topic examples extracted by models, italics means out-of-topic words. These topics correspond to 'election', 'music', 'film' and 'airline' respectively, and topic examples of other models are omitted due to poor quality.
gives slightly worse results compared to ATM on C A. For 20Newsgroups dataset, BAT performs the best on C P and NPMI, but gives slightly worse results compared to ProdLDA on C A, and LDA on UCI. By incorporating word embeddings through trainable Gaussian distribution, Gaussian-BAT outperforms all the baselines and BAT on four coherence metrics, often by a large margin, across all the three datasets except for Grolier dataset on C A when considering 100% topics. This may be attribute to the following factors: (1) The Dirichlet prior employed in BAT and Gaussian-BAT could exhibit a multi-modal distribution in latent space and is more suitable for discovering semantic patterns from text; (2) ATM does not consider the relationship between topic distribution and word distribution since it only carry out adversarial training in word distribution space; (3) The incorpora-tion of word embeddings in Gaussian-BAT helps generating more coherent topics. We also compare the average topic coherence values (all topics taken into account) numerically to show the effectiveness of proposed BAT and Gaussian-BAT. The results of numerical topic coherence comparison are listed in Table 2 and each value is calculated by averaging the average topic coherences over five topic number settings. The best coherence value on each metric is highlighted in bold. It can be observed that Gaussian-BAT gives the best overall results across all metrics and on all the datasets except for Grolier dataset on C A. To make the comparison of topics more intuitive, we provide four topic examples extracted by models in Table 3. It can be observed that the proposed BAT and Gaussian-BAT can generate more coherent topics. Moreover, to explore how topic coherence varies with different topic numbers, we also provide the comparison of average topic coherence vs. different topic number on 20newsgroups, Grolier and NYTimes (all topics taken into account). The detailed comparison is shown in Figure 5. It could be observed that Gaussian-BAT outperforms the baselines with 20, 30, 50 and 75 topics except for Grolier dataset on C A metric. However, when the topic number is set to 100, Gaussian-BAT performs slightly worse than LDA (e.g., UCI for 20Newsgroups and C A for NYTimes). This may be caused by the increased model complexity due to the larger topic number settings. Likewise, BAT can achieve at least the second-best results among all the approaches in most cases for NYTimes dataset. For Grolier, BAT also performs the second-best except on C A metric. However, for 20newsgroups, the results obtained by BAT are worse than ProdLDA (C A) and LDA (UCI) due to the limited training documents in the dataset, though it still largely outperforms other baselines.

Text Clustering
We further compare our proposed models with baselines on text clustering. Due to the lack of document label information in Grolier and NYTimes, we only use 20Newsgroups dataset in our experiments. The topic number is set to 20 (ground-truth categories) and the performance is evaluated by accuracy (ACC): where N t is the number of documents in the test set, ind(·) is the indicator function, l i is the groundtruth label of i-th document, c i is the category assignment, and map ranges over all possible oneto-one mappings between labels and clusters. The optimal map function can be obtained by the Kuhn-Munkres algorithm (Kuhn, 1955  The comparison of text clustering results on 20Newsgroups is shown in Table 4. Due to the poor performance of NVDM in topic coherence evaluation, its result is excluded here. Not surprisingly, NVLDA and ProdLDA perform worse than BAT and Gaussian-BAT that model topics with the Dirichlet prior. This might be caused by the fact that Logistic-Normal prior does not exhibit multiple peaks at the vertices of the simplex, as depicted in Figure 1. Compared with LDA, BAT achieves a comparable result in accuracy since both models have the same Dirichlet prior assumption over topics and only employ the word co-occurrence information. Gaussian-BAT outperforms the second best model, BAT, by nearly 6% in accuracy. This shows that the incorporation of word embeddings is important to improve the semantic coherence of topics and thus results in better consistency between cluster assignments and ground-truth labels.

Conclusion
In this paper, we have explored the use of bidirectional adversarial training in neural topic models and proposed two novel approaches: the Bidirectional Adversarial Topic (BAT) model and the Bidirectional Adversarial Topic model with Gaussian (Gaussian-BAT). BAT models topics with the Dirichlet prior and builds a two-way transformation between document-topic distribution and document-word distribution via bidirectional adversarial training. Gaussian-BAT extends from BAT by incorporating word embeddings into the modeling process, thereby naturally considers the word relatedness information captured in word embeddings. The experimental comparison on three widely used benchmark text corpus with the existing neural topic models shows that BAT and Gaussian-BAT achieve improved topic coherence results. In the future, we would like to devise a nonparametric neural topic model based on adversarial training. Besides, developing correlated topic modelsis another promising direction.