Abstract
Building production-ready chatbots from raw, unlabelled historical chatlogs presents significant challenges, including data noise, response selection, and strict latency requirements. This paper presents an end-to-end framework for developing retrieval-based chatbots using a hierarchical RNN architecture and self-supervised contrastive learning. Our system, centered on the contrastLSTM model, avoids the need for manual labeling and outperforms traditional supervised models. Deployed in a large-scale telecommunications environment, the system supports over 1,000 customer service agents, with up to 30% of responses in specific channels being model-generated.
Introduction
While academic research often focuses on optimizing response selection models using curated datasets like the Ubuntu Dialogue Corpus, industrial applications face a "cold start" problem. Engineers must typically navigate millions of unlabelled chatlogs, define a list of "canned responses" from scratch, and ensure models can perform inference on standard CPU hardware within milliseconds.
This paper details a comprehensive blueprint to bridge this gap, addressing four critical hurdles: extracting high-quality responses from raw data, creating training sets without manual intervention, designing an efficient matching architecture, and managing the "None" response problem (determining when the model should remain silent).
Methodology
Canned Response Extraction
To generate a library of possible responses, the authors utilized a skip-thought model to embed frequent agent utterances from historical logs. These embeddings were grouped using K-means clustering to identify core "intents." To ensure brand safety and legal compliance, the resulting clusters were vetted by business teams to finalize a set of standardized canned responses.
The contrastLSTM Architecture
Traditional models often flatten conversation history into a single string, which is computationally expensive for long dialogues. The proposed contrastLSTM employs a hierarchical structure consisting of three modules:
- Word Embeddings: Processing individual tokens.
- Utterance-level LSTM: Encoding individual turns in the conversation.
- Context-level LSTM: Encoding the sequence of utterances.
This hierarchy allows the system to cache intermediate utterance embeddings. As a conversation progresses, the model only needs to compute the embedding for the newest turn, significantly reducing latency during real-time inference.
Self-Supervised Training
The model is trained using a self-supervised approach with a max-margin triplet ranking loss. By treating the actual historical response as a "positive" and randomly sampled utterances as "negatives," the model learns to minimize the distance between the conversation context and the correct response in vector space. This contrastive learning approach allows the model to learn general similarity functions, meaning new canned responses can be added to the system post-training without requiring a full model retrain.
Experimental Results
Performance Metrics
The framework was evaluated against an internal corpus of 3.5 million conversations from an Australian telecommunications provider. The contrastLSTM achieved a Top-3 accuracy of 93.42%, outperforming both binary classifiers (90.13%) and multi-class classifiers (90.12%). Notably, it also surpassed the state-of-the-art Deep Attention Matching (DAM) network, which struggled with the noise inherent in unlabelled, real-world data.
Production Impact
The system was deployed on AWS using a tiered caching strategy (Redis and LRU caches) to handle approximately 50,000 chats per week. In a deployment involving over 1,000 agents, the model demonstrated high utility: 18% of all agent responses across the enterprise were selected directly from the model’s suggestions. In more structured domains, such as "prepaid mobile" support, this adoption rate rose to 30%.
Discussion and Insights
Self-Supervision vs. Weak Supervision
A key finding was that self-supervised models trained on the full raw dataset outperformed supervised models trained on "weakly labelled" data (mapped via regex). This suggests that the scale and diversity of raw data are more critical for model robustness than the precision of automated labels.
The Confidence Trade-off
While the contrastive model provided the highest accuracy, it produced a relatively "flat" confidence profile, making it difficult to set thresholds for when the model should remain silent. In contrast, multi-class classifiers produced "sharper" confidence spikes. This suggests a potential for hybrid models that combine the accuracy of contrastive learning with the decision-making clarity of classification heads.
Inference Efficiency
The authors emphasize that model selection for industry must prioritize inference speed. Sophisticated attention-based models often fail in production because they do not support the utterance-level caching necessary for low-latency CPU deployment. The hierarchical LSTM provides a necessary balance between semantic depth and operational efficiency.
Conclusion
This end-to-end framework provides a scalable solution for transforming raw chatlogs into a functional retrieval-based chatbot. By prioritizing hierarchical architectures and self-supervised learning, organizations can deploy effective agent-assist tools that adapt to new data without the prohibitive costs of manual labeling or specialized hardware.
Summary updated