Introduction
Semantic search aims to retrieve documents based on their conceptual meaning rather than simple keyword matching. Current state-of-the-art approaches typically fall into two categories: bi-encoders and cross-encoders. Bi-encoders, such as BERT-based models, are highly efficient because they allow for independent query and document vectorization, enabling pre-computation and fast retrieval. However, they often lack the expressive power to capture complex interactions between queries and documents. Conversely, cross-encoders—often based on Large Language Models (LLMs)—achieve superior accuracy by performing deep cross-attention over the query-document pair, but their computational cost makes them impractical for real-time retrieval over large-scale datasets.
D2LLM (Decomposed and Distilled Large Language Models) is a novel framework designed to bridge this gap. By decomposing an LLM cross-encoder into a specialized student architecture and employing a multi-stage distillation process, D2LLM achieves the high-level reasoning of a cross-encoder while remaining efficient enough for real-time use.
Methodology: The Decompose and Distill Pipeline
The core of D2LLM lies in its two-stage approach: architectural decomposition and knowledge distillation.
Architectural Decomposition
The framework transforms a complex LLM cross-encoder (the Teacher) into a more efficient Student model. This student architecture introduces two critical components:
- Pooling by Multihead Attention (PMA): Unlike traditional mean pooling, PMA utilizes a learnable multi-head attention mechanism to aggregate token-level embeddings into a single representative vector. This allows the model to dynamically focus on the most salient information for a given search task.
- Interaction Emulation Module (IEM): To replace the standard but rigid cosine similarity metric, D2LLM uses a lightweight Multi-Layer Perceptron (MLP). The IEM features dual branches—one for symmetric tasks (e.g., question-to-question similarity) and another for asymmetric tasks (e.g., question-to-answer relevance). This design prevents cross-interference between different logical retrieval tasks.
Knowledge Distillation
To transfer the reasoning capabilities of the teacher to the student, D2LLM employs three distinct imitation losses:
- Contrastive Imitation: The student learns to distinguish relevant pairs from "hard negatives" by mimicking the teacher's confidence scores.
- Rank Imitation: The student is trained to produce a document ranking that aligns with the teacher's output.
- Feature Imitation: The student attempts to replicate the internal relational patterns of the teacher's embedding space, ensuring the student's representations capture similar semantic nuances.
Experimental Results
The D2LLM framework was evaluated on the Chinese Massive Text Embedding Benchmark (CMTEB), covering Natural Language Inference (NLI), Semantic Textual Similarity (STS), and Information Retrieval (IR) tasks.
Performance and Accuracy
D2LLM demonstrated significant performance gains across all benchmarks. Notably, in NLI tasks, it achieved a 14.39% improvement over the LLaRA baseline and a 6.45% lead over the heavily fine-tuned BGE model. In STS and IR tasks, D2LLM outperformed comparable models in the majority of test cases, proving its versatility across different semantic search scenarios. Furthermore, the authors observed that the size of the teacher model directly impacts student performance; a 7B parameter teacher produced a significantly better student than a 1.8B teacher.
Efficiency Analysis
A primary goal of D2LLM is maintaining retrieval speed. Runtime analysis shows that while D2LLM is slightly slower than a standard bi-encoder due to the IEM calculation, it is orders of magnitude faster than the LLM cross-encoder. This makes it highly suitable for real-time applications where low latency is critical.
Conclusion
D2LLM successfully addresses the long-standing trade-off between speed and accuracy in semantic search. By leveraging a "decompose and distill" strategy, it brings the reasoning power of large-scale cross-encoders to a deployable student architecture. Future work will focus on further closing the performance gap with full cross-encoders and exploring more parameter-efficient training methods to reduce the computational overhead of the distillation process.
Summary updated