Uni-Encoder: A Fast and Accurate Response Selection Paradigm for Generation-Based Dialogue Systems

Chiyu Song, Hongliang He, Haofei Yu, Pengfei Fang, Leyang Cui, Zhenzhong Lan

Abstract

The Uni-Encoder is a novel response selection paradigm designed to overcome the long-standing trade-off between accuracy and efficiency in dialogue systems. By integrating a specialized "Arrow Attention" mechanism and shared positional embeddings, the Uni-Encoder achieves the high accuracy characteristic of Cross-Encoders while maintaining the computational efficiency of Poly-Encoders. Experimental results demonstrate state-of-the-art performance across multiple benchmarks, including a 4x inference speedup over traditional Cross-Encoder architectures.

Introduction: The Accuracy-Efficiency Trade-off

Modern dialogue systems often employ a "sample-and-rank" strategy where a generator produces candidate responses that are subsequently ranked by a selection model. Historically, this ranking task has been dominated by two paradigms: Bi-Encoders and Cross-Encoders.

Bi-Encoders are efficient because they encode context and candidates independently, allowing for pre-computation. However, they lack "full attention" between context and response, limiting their accuracy. Conversely, Cross-Encoders provide full interaction through joint encoding but are computationally expensive as they must re-process the dialogue context for every candidate.

Comparison of dialogue ranking paradigms showing the Uni-Encoder's balance of full attention and efficiency.

The Uni-Encoder addresses this gap by enabling full interaction without redundant context recomputation, effectively combining the strengths of both previous approaches.

Methodology: The Uni-Encoder Framework

The Uni-Encoder processes the dialogue context and multiple candidate responses within a single forward pass. This is made possible through two primary architectural innovations:

Shared Positional Embeddings

In standard transformer models, each token receives a unique position ID. The Uni-Encoder deviates from this by assigning the same starting position ID to all candidate responses, immediately following the context. This "parallel" positioning informs the model that each candidate is an independent, coequal continuation of the conversation, preventing bias based on sequence order.

Uni-Encoder input representation featuring shared positional embeddings for candidate responses.

Arrow Attention

To prevent information leakage between independent candidates in the same sequence, the authors introduced "Arrow Attention." This specialized attention mask allows the context to attend to itself and each candidate to attend to both the context and itself. Crucially, it forbids candidates from attending to one another, ensuring that the evaluation of one response does not influence the scoring of another.

Experimental Results

The Uni-Encoder was evaluated on four major benchmarks: Ubuntu Dialogue Corpus (V1 & V2), PersonaChat, and the Douban Conversation Corpus.

Performance and Speed

The model achieved state-of-the-art accuracy across nearly all metrics. On the Ubuntu V2 dataset, it improved the R10@1 metric (the probability that the correct answer is ranked #1 out of 10) by 2.9% over the standard Cross-Encoder. More impressively, it achieved this while being approximately 4x faster during inference. This speedup stems from the model's ability to process candidates in parallel, better utilizing GPU resources compared to the serial processing required by Cross-Encoders.

Qualitative Analysis

Case studies indicate that the Uni-Encoder is more adept at selecting specific, contextually relevant responses. While baseline models often favor generic "safe" replies, the Uni-Encoder's full-attention mechanism allows it to identify nuanced connections between the dialogue history and the proposed candidates.

Conclusion and Future Work

The Uni-Encoder represents a significant step forward in dialogue modeling, effectively unifying disparate ranking paradigms into a single, efficient framework. While it is primarily optimized for small-to-medium candidate pools (10–100), its efficiency makes it a strong candidate for real-time applications and as a reward model in Reinforcement Learning from Human Feedback (RLHF) pipelines. Future research may focus on adapting the training objective for multi-label datasets like Douban, where multiple "correct" responses exist simultaneously.

Summary updated

BibTeX
@inproceedings{song2023uni,
  author = {Chiyu Song and Hongliang He and Haofei Yu and Pengfei Fang and Leyang Cui and Zhenzhong Lan},
  title = {{Uni-Encoder: A Fast and Accurate Response Selection Paradigm for Generation-Based Dialogue Systems}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2023},
  doi = {10.18653/v1/2023.findings-acl.388},
}
Figure