用提示工程+轻量对比微调,让大模型高效生成文本嵌入
Resource-Efficient Adaptation of Large Language Models for Text Embeddings via Prompt Engineering and Contrastive Fine-tuning
- 通过提示工程和合成正样本对比微调,提升大模型文本嵌入能力
- 在MTEB英文聚类任务中表现媲美专用模型,仅需少量计算资源
- 适合需要高性能嵌入但算力有限的研究与应用
大型语言模型(LLMs)在自然语言处理中已成为核心,其标记级表征捕捉了丰富的语义信息。然而,将这些向量池化为文本嵌入会丢失关键细节。尽管如此,许多非生成下游任务如聚类、分类或检索仍依赖准确且可控的句子或文档级嵌入。本文探索了几种预训练解码器型LLM的适应策略:(i) 多种标记嵌入聚合方法,(ii) 面向任务的提示工程,(iii) 通过对比微调进行文本层级增强。结合这些组件,在大规模文本嵌入基准(MTEB)的英文聚类赛道上取得了有竞争力的表现。注意力图分析显示,微调后模型关注点从提示词转移到语义相关词汇,表明更有效地将语义压缩至最终隐藏状态。实验表明,通过提示工程与资源高效的对比微调结合,可有效将LLMs适配为文本嵌入模型。
原文摘要 · Abstract (English)
Large Language Models (LLMs) have become a cornerstone in Natural Language Processing (NLP), achieving impressive performance in text generation. Their token-level representations capture rich, human-aligned semantics. However, pooling these vectors into a text embedding discards crucial information. Nevertheless, many non-generative downstream tasks, such as clustering, classification, or retrieval, still depend on accurate and controllable sentence- or document-level embeddings. We explore several adaptation strategies for pre-trained, decoder-only LLMs: (i) various aggregation techniques for token embeddings, (ii) task-specific prompt engineering, and (iii) text-level augmentation via contrastive fine-tuning. Combining these components yields competitive performance on the English clustering track of the Massive Text Embedding Benchmark (MTEB). An analysis of the attention map further shows that fine-tuning shifts focus from prompt tokens to semantically relevant words, indicating more effective compression of meaning into the final hidden state. Our experiments demonstrate that LLMs can be effectively adapted as text embedding models through a combination of prompt engineering and resource-efficient contrastive fine-tuning on synthetically generated positive pairs.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。