Abstract
We propose a novel model for a topic-aware chatbot by combining the traditional Recurrent Neural Network (RNN) encoder-decoder model with a topic attention layer based on Nonnegative Matrix Factorization (NMF). After learning topic vectors from an auxiliary text corpus via NMF, the decoder is trained so that it is more likely to sample response words from the most correlated topic vectors. One of the main advantages in our architecture is that the user can easily switch the NMF-learned topic vectors so that the chatbot obtains desired topic-awareness. We demonstrate our model by training on a single conversational data set which is then augmented with topic matrices learned from different auxiliary data sets. We show that our topic-aware chatbot not only outperforms the non-topic counterpart, but also that each topic-aware model qualitatively and contextually gives the most relevant answer depending on the topic of question.
Introduction
Standard sequence-to-sequence chatbots, typically based on Recurrent Neural Networks (RNNs), frequently suffer from the "generic response" problem. When faced with diverse inputs, they tend to default to safe but uninformative answers like "I don't know" or "That's cool." This behavior stems from a lack of high-level subject matter understanding. While previous attempts have utilized Latent Dirichlet Allocation (LDA) to inject topic awareness, this research proposes Nonnegative Matrix Factorization (NMF) as a more efficient and flexible alternative for creating contextually relevant conversational agents.
The RNN-NMF Architecture
The proposed architecture, dubbed the RNN-NMF chatbot, integrates generative sequence modeling with interpretable topic extraction. It consists of three primary components: a standard RNN encoder-decoder, an NMF-based topic representation, and a novel Topic Attention layer.
In this framework, NMF is used to factorize a "Word $\times$ Document" matrix from an auxiliary corpus into a "Word $\times$ Topic" dictionary ($W$) and a "Topic $\times$ Doc" code matrix ($H$). When a user provides an input, the model calculates a "topic code" by measuring the correlation between the input and the pre-learned NMF topic vectors. This code then biases the decoder’s probability distribution, mathematically pushing the model to favor words associated with the relevant topic over generic high-probability filler words.
To maintain computational efficiency during training and inference with large vocabularies, the system employs Metropolis-Hastings (MCMC) sampling. This allows the model to approximately sample response words without calculating the full probability distribution across the entire vocabulary at every step.
Experimental Setup and Datasets
The researchers adopted a modular training approach. The core conversational structure was learned using the Cornell Movie Dialogue dataset. To provide the "topic filters," three distinct auxiliary datasets were utilized:
- DeltaAir: Customer support records from Delta Airlines.
- Shakespeare: The complete works of William Shakespeare.
- 20NewsGroups: A collection of newsgroup documents covering diverse subjects like technology and politics.
This "plug-and-play" design allows the chatbot's knowledge base to be swapped by simply changing the NMF topic vectors, avoiding the need to retrain the underlying RNN.
Key Results
The topic-aware models demonstrated significant improvements over non-topic baselines in both quantitative and qualitative evaluations:
- Quantitative Performance: The topic-aware models achieved lower training loss (measured via KL-divergence). For instance, the Shakespeare-enhanced model reached a loss of 0.1708, compared to 0.2847 for the baseline model.
- Qualitative Relevance: In side-by-side comparisons, the topic-aware models provided more specific answers. When asked about a lost item, the DeltaAir-flavored model suggested checking a monitor, whereas the baseline gave a generic prompt to "go on."
Conclusion and Future Work
By combining the generative flexibility of RNNs with the structural interpretability of NMF, this research provides a path toward chatbots that are both contextually aware and easily customizable. Future work may explore using Online NMF to allow chatbots to learn new topics from real-time data streams or integrating more advanced transformer-based architectures for dynamic topic switching.
Summary updated