LLM2Vec: I grandi modelli linguistici sono segretamente potenti encoder di testo
LLM2Vec: Large Language Models Are Secretly Powerful Text Encoders
April 9, 2024
Autori: Parishad BehnamGhader, Vaibhav Adlakha, Marius Mosbach, Dzmitry Bahdanau, Nicolas Chapados, Siva Reddy
cs.AI
Abstract
I grandi modelli linguistici basati esclusivamente su decoder (LLM) rappresentano lo stato dell'arte per la maggior parte dei compiti e benchmark odierni nell'ambito dell'elaborazione del linguaggio naturale (NLP). Tuttavia, la comunità sta adottando solo lentamente questi modelli per i compiti di embedding del testo, che richiedono rappresentazioni contestualizzate e ricche. In questo lavoro, introduciamo LLM2Vec, un semplice approccio non supervisionato in grado di trasformare qualsiasi LLM basato esclusivamente su decoder in un forte codificatore di testo. LLM2Vec consiste in tre semplici passaggi: 1) abilitazione dell'attenzione bidirezionale, 2) previsione mascherata del token successivo e 3) apprendimento contrastivo non supervisionato. Dimostriamo l'efficacia di LLM2Vec applicandolo a 3 LLM popolari, con un numero di parametri compreso tra 1,3B e 7B, e valutiamo i modelli trasformati su compiti a livello di parola e sequenza in inglese. Superiamo i modelli basati esclusivamente su encoder con un ampio margine nei compiti a livello di parola e raggiungiamo una nuova prestazione non supervisionata all'avanguardia sul Massive Text Embeddings Benchmark (MTEB). Inoltre, combinando LLM2Vec con l'apprendimento contrastivo supervisionato, otteniamo prestazioni all'avanguardia su MTEB tra i modelli che si addestrano solo su dati pubblicamente disponibili. I nostri solidi risultati empirici e l'analisi estesa dimostrano che gli LLM possono essere trasformati efficacemente in codificatori di testo universali in modo efficiente in termini di parametri, senza la necessità di adattamenti costosi o dati sintetici generati da GPT-4.
English
Large decoder-only language models (LLMs) are the state-of-the-art models on
most of today's NLP tasks and benchmarks. Yet, the community is only slowly
adopting these models for text embedding tasks, which require rich
contextualized representations. In this work, we introduce LLM2Vec, a simple
unsupervised approach that can transform any decoder-only LLM into a strong
text encoder. LLM2Vec consists of three simple steps: 1) enabling bidirectional
attention, 2) masked next token prediction, and 3) unsupervised contrastive
learning. We demonstrate the effectiveness of LLM2Vec by applying it to 3
popular LLMs ranging from 1.3B to 7B parameters and evaluate the transformed
models on English word- and sequence-level tasks. We outperform encoder-only
models by a large margin on word-level tasks and reach a new unsupervised
state-of-the-art performance on the Massive Text Embeddings Benchmark (MTEB).
Moreover, when combining LLM2Vec with supervised contrastive learning, we
achieve state-of-the-art performance on MTEB among models that train only on
publicly available data. Our strong empirical results and extensive analysis
demonstrate that LLMs can be effectively transformed into universal text
encoders in a parameter-efficient manner without the need for expensive
adaptation or synthetic GPT-4 generated data.