arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2402.14776cs.CLcs.LG
收藏

二维套娃句子嵌入

2D Matryoshka Sentence Embeddings

The Hong Kong Polytechnic University(香港理工大学);Lingnan University(岭南大学)

Xianming Li, Zongxi Li, Jing Li, Haoran Xie, Qing Li

AI总结:

针对固定句子嵌入在维度与Transformer层数上缺乏弹性的问题,提出2DMSE,实现嵌入尺寸和层数双重可调,并在STS及下游任务中验证其灵活性与效率。

摘要:

常见方法依赖语言模型生成的固定长度嵌入向量作为句子嵌入,用于语义文本相似度(STS)等下游任务。由于不同应用中的计算约束和预算未知,这类方法在灵活性上受到限制。Matryoshka Representation Learning(MRL)以更细的粒度(即更低的嵌入维度)编码信息,以自适应地满足临时任务需求。使用更小的嵌入尺寸可以达到相近的准确率,从而加快下游任务速度。尽管效率有所提升,MRL仍需遍历所有Transformer层才能获得嵌入,而这仍是时间和内存消耗的主要因素。这促使人们思考:固定的Transformer层数是否会影响表示质量,以及使用中间层进行句子表示是否可行。本文提出一种名为Two-dimensional Matryoshka Sentence Embedding(2DMSE)的新型句子嵌入模型(代码见https://github.com/SeanLee97/AnglE/blob/main/README_2DMSE.md)。该模型同时支持嵌入尺寸和Transformer层数的弹性设置,比MRL具有更高的灵活性和效率。我们在STS任务和下游应用上开展了大量实验。结果表明,所提模型能够有效动态支持不同嵌入尺寸和Transformer层数,从而高度适应多种场景。

英文摘要:

Common approaches rely on fixed-length embedding vectors from language models as sentence embeddings for downstream tasks such as semantic textual similarity (STS). Such methods are limited in their flexibility due to unknown computational constraints and budgets across various applications. Matryoshka Representation Learning (MRL) \cite{aditya2022matryoshka} encodes information at finer granularities, i.e., with lower embedding dimensions, to adaptively accommodate \emph{ad hoc} tasks. Similar accuracy can be achieved with a smaller embedding size, leading to speedups in downstream tasks. Despite its improved efficiency, MRL still requires traversing all Transformer layers before obtaining the embedding, which remains the dominant factor in time and memory consumption. This prompts consideration of whether the fixed number of Transformer layers affects representation quality and whether using intermediate layers for sentence representation is feasible. In this paper, we introduce a novel sentence embedding model called \textit{Two-dimensional Matryoshka Sentence Embedding} (2DMSE)\footnote{Our code is available at \url{https://github.com/SeanLee97/AnglE/blob/main/README_2DMSE.md}.}. It supports elastic settings for both embedding sizes and Transformer layers, offering greater flexibility and efficiency than MRL. We conduct extensive experiments on STS tasks and downstream applications. The experimental results demonstrate the effectiveness of our proposed model in dynamically supporting different embedding sizes and Transformer layers, allowing it to be highly adaptable to various scenarios.

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

↑