Abstract
Language models are typically applied at the sentence level, without access to the broader document context. We present a neural language model that incorporates document context in the form of a topic model-like architecture, thus providing a succinct representation of the broader document context outside of the current sentence. Experiments over a range of datasets demonstrate that our model outperforms a pure sentence-based model in terms of language model perplexity, and leads to topics that are potentially more coherent than those produced by a standard LDA topic model. Our model also has the ability to generate related sentences for a topic, providing another way to interpret topics.
Introduction
State-of-the-art language models (LMs) are essential for tasks like text generation and speech recognition. However, these models often suffer from "nearsightedness," operating primarily at the sentence level and lacking awareness of the broader document context. For instance, predicting the next word in a sentence like "The court ruled that..." requires knowing whether the document pertains to a legal trial or a sporting event to make an accurate prediction.
Conversely, traditional topic models, such as Latent Dirichlet Allocation (LDA), capture global document themes but are often "blind to order." They treat documents as a "bag of words," ignoring the local dependencies and syntax crucial for natural language. The Topically Driven Neural Language Model (TDLM) addresses this disconnect by proposing a unified neural architecture where global document themes guide local word predictions, and local syntax informs topic discovery.
Methodology
The TDLM integrates two main neural components trained jointly in a multi-task learning framework:
- Topic Model Component: Functioning as an auto-encoder, this component uses a Convolutional Neural Network (CNN) to process the document context and generate a document vector. An attention mechanism then compares this vector against learned topic embeddings to produce a document-topic representation ($s$), summarizing the document's global theme.
- Language Model Component: This component utilizes a standard Long Short-Term Memory (LSTM) network, enhanced with a gating unit. This gate allows the model to dynamically determine the influence of the global topic representation ($s$) on the hidden state at each time step.
Joint training ensures that the topic model identifies themes beneficial for word prediction, while the language model maintains thematic consistency.
Experimental Evaluation
The researchers evaluated TDLM across several diverse datasets, including APNEWS (Associated Press articles), IMDB (movie reviews), and the British National Corpus (BNC).
Key Results
The model demonstrated significant improvements in both language modeling and topic quality:
- Perplexity: TDLM consistently achieved lower (better) perplexity scores than vanilla LSTMs. On APNEWS, for example, TDLM reduced perplexity from ~59 to ~48, indicating that global context is more effective than just the preceding few sentences.
- Topic Coherence: Using the Normalized Pointwise Mutual Information (NPMI) metric, TDLM topics were found to be more coherent than those from other neural topic models and competitive with traditional LDA.
Discussion and Insights
A key finding is that compressing document context into a topic distribution is highly effective for language modeling. The joint training approach serves as a "secret sauce," optimizing the topic model to assist the language model in its primary task.
Furthermore, TDLM offers unique generative interpretability. It can generate sentences conditioned on specific topics, allowing researchers to "see" a topic's meaning through generated text rather than just word lists. For example, a topic represented by "court, judge, law" might generate "The judge sentenced the defendant to prison." The model's neural architecture also allows for easy extension, such as incorporating document labels or metadata to boost performance.
Limitations and Future Work
Despite its strengths, TDLM has limitations. It uses a fixed maximum document length, potentially truncating relevant context in very long documents. Additionally, the joint training of a CNN and LSTM is computationally more intensive than training separate models. The model's advantage in topic coherence also varied by dataset, showing less pronounced gains on the formal text of the BNC compared to news or reviews.
Future research may explore alternative attention mechanisms or apply TDLM to downstream tasks like machine translation and document summarization.
Summary updated