D2LLM: Decomposed and Distilled Large Language Models for Semantic Search

Zihan Liao,Hang Yu,Jianguo Li,Jun Wang,Wei Zhang
2024-06-25
Abstract:The key challenge in semantic search is to create models that are both accurate and efficient in pinpointing relevant sentences for queries. While BERT-style bi-encoders excel in efficiency with pre-computed embeddings, they often miss subtle nuances in search tasks. Conversely, GPT-style LLMs with cross-encoder designs capture these nuances but are computationally intensive, hindering real-time applications. In this paper, we present D2LLMs-Decomposed and Distilled LLMs for semantic search-that combines the best of both worlds. We decompose a cross-encoder into an efficient bi-encoder integrated with Pooling by Multihead Attention and an Interaction Emulation Module, achieving nuanced understanding and pre-computability. Knowledge from the LLM is distilled into this model using contrastive, rank, and feature imitation techniques. Our experiments show that D2LLM surpasses five leading baselines in terms of all metrics across three tasks, particularly improving NLI task performance by at least 6.45%. The source code is available at <a class="link-external link-https" href="https://github.com/codefuse-ai/D2LLM" rel="external noopener nofollow">this https URL</a>.
Computation and Language
What problem does this paper attempt to address?
The paper aims to address the challenging issue of achieving both precision and efficiency in semantic search models. Specifically, existing BERT-style dual encoders, while efficient (as embeddings can be precomputed), fall short in capturing the nuances of search tasks. On the other hand, GPT-style large language models (LLMs), although capable of capturing these nuances, are computationally expensive and difficult to apply in real-time scenarios. Therefore, this paper proposes a method called D2LLM (Decomposed and Distilled Large Language Models), which combines the advantages of both approaches. D2LLM decomposes a cross-encoder into an efficient dual encoder (integrated with multi-head attention pooling) and an interaction simulation module, and distills the knowledge of the LLM into this model using techniques of contrastive, ranking, and feature simulation. Experimental results show that D2LLM outperforms five baseline methods on three tasks, with significant improvements particularly in the natural language inference (NLI) task.