arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2408.08073cs.CLcs.IRcs.LGstat.ML

从预训练 Transformer 模型中提取句子嵌入

Extracting Sentence Embeddings from Pretrained Transformer Models

Faculty of Informatics, Kaunas University of Technology(考纳斯理工大学信息学院)

Lukas Stankevičius, Mantas Lukoševičius

AI总结:

本文系统评估并扩展预训练 Transformer 的句子嵌入提取方法,结合 token 聚合、后处理与 Wikitext 补充,在 STS、聚类和分类任务上验证其显著提升。

摘要:

预训练 transformer 模型在许多自然语言处理任务中表现出色,因此被期望能够承载输入句子或文本含义的表示。这些句子级嵌入在检索增强生成中也很重要。但是,常用的简单平均或提示模板是否足以捕获并表示潜在含义?在全面回顾现有句子嵌入提取与精化方法之后,我们在预训练模型上彻底测试了最有前景方法的不同组合以及我们自己的原始扩展。具体而言,在给定 110M 参数、BERT 多层隐藏表示和许多 token 的情况下,我们尝试了多种提取最优句子嵌入的方法。我们测试了各种 token 聚合和表示后处理技术。我们还测试了使用通用 Wikitext 数据集补充 BERT 句子嵌入的多种方式。所有方法均在 8 项语义文本相似度(STS)任务、6 项短文本聚类任务和 12 项分类任务上进行测试。我们还在其他静态模型(包括随机 token 表示)上评估了表示塑形技术。所提出的表示提取方法提升了所有被考察模型在 STS 和聚类任务上的性能。基于静态 token 的模型获得了非常高的提升,尤其是用于 STS 任务的随机嵌入,几乎达到了源自 BERT 的表示性能。我们的工作表明,表示塑形技术能够显著改善从基于 BERT 的模型和简单基线模型中提取的句子嵌入。

英文摘要:

Pre-trained transformer models shine in many natural language processing tasks and therefore are expected to bear the representation of the input sentence or text meaning. These sentence-level embeddings are also important in retrieval-augmented generation. But do commonly used plain averaging or prompt templates sufficiently capture and represent the underlying meaning? After providing a comprehensive review of existing sentence embedding extraction and refinement methods, we thoroughly test different combinations and our original extensions of the most promising ones on pretrained models. Namely, given 110 M parameters, BERT's hidden representations from multiple layers, and many tokens, we try diverse ways to extract optimal sentence embeddings. We test various token aggregation and representation post-processing techniques. We also test multiple ways of using a general Wikitext dataset to complement BERT's sentence embeddings. All methods are tested on eight Semantic Textual Similarity (STS), six short text clustering, and twelve classification tasks. We also evaluate our representation-shaping techniques on other static models, including random token representations. Proposed representation extraction methods improve the performance on STS and clustering tasks for all models considered. Very high improvements for static token-based models, especially random embeddings for STS tasks, almost reach the performance of BERT-derived representations. Our work shows that the representation-shaping techniques significantly improve sentence embeddings extracted from BERT-based and simple baseline models.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑