How LLM2Vec works: The 3-step recipe
mainLLM2Vec converts decoder-only LLMs into text encoders using a three-step process:
- Enabling bidirectional attention: Modifying the model to allow bidirectional connections.
- MNTP training: Training with Masked Next Token Prediction.
- Unsupervised contrastive learning: Using objectives like SimCSE to refine embeddings.
This process allows decoder-only models to function as powerful text encoders for tasks like retrieval, classification, and clustering.