通过对比预训练学习文本和代码嵌入

Text and Code Embeddings by Contrastive Pre-Training

亚历克·拉德福德 Alec Radford · OpenAI · 2022-01-24 · arXiv:2201.10005 ↗ · 被引 601

打开互动全文版(逐段中英对照 + 图/公式 + 论文问答)→

摘要 · Abstract

文本嵌入在语义搜索和文本相似度计算等许多应用中都是有用的特征。以往的工作通常针对不同用例定制训练模型,在数据集选择、训练目标和模型架构上各不相同。在这项工作中,我们表明,在大规模无监督数据上进行对比预训练可以产生高质量的文本和代码向量表示。相同的无监督文本嵌入在线性探测分类中取得了新的最优结果,同时展现出令人印象深刻的语义搜索能力,有时甚至与微调模型竞争。在线性探测分类准确率上,平均 7 个任务,我们的最佳无监督模型相对于之前最佳的无监督和有监督文本嵌入模型分别实现了 4%和 1.8%的相对提升。相同的文本嵌入在大规模语义搜索评估中,在 MSMARCO、Natural Questions 和 TriviaQA 基准测试上,相对于之前最佳的无监督方法分别实现了 23.4%、14.7%和 10.6%的相对提升。与文本嵌入类似,我们在(文本,代码)对上训练代码嵌入模型,在代码搜索上相对于之前的最佳工作获得了 20.8%的相对提升。

Text embeddings are useful features in many applications such as semantic search and computing text similarity. Previous work typically trains models customized for different use cases, varying in dataset choice, training objective and model architecture. In this work, we show that contrastive pre-training on unsupervised data at scale leads to high quality vector representations of text and code. The same unsupervised text embeddings that achieve new state-of-the-art results in linear-probe classification also display impressive semantic search capabilities and sometimes even perform competitively with fine-tuned models. On linear-probe classification accuracy averaging over 7 tasks, our best unsupervised model achieves a relative improvement of 4% and 1.8% over previous best unsupervised and supervised text embedding models respectively. The same text embeddings when evaluated on large-scale semantic search attains a relative improvement of 23.4%, 14.7%, and 10.6% over previous best unsupervised methods on MSMARCO, Natural Questions and TriviaQA benchmarks, respectively. Similarly to text embeddings, we train code embedding models on (text, code) pairs, obtaining a 20.8% relative improvement over prior best work on code search.

核心贡献 · Key contributions

局限 · Limitations

论文章节 · Sections(共 13)

阅读逐段中英对照全文 →