McGill-NLP/llm2vec
A recipe to convert decoder-only LLMs into bidirectional text encoders through attention masking and contrastive fine-tuning.

Velocity · 7d
+2.1
★ / day
Trend
→steady
star history
LLM2Vec provides code to transform standard decoder-only language models into bidirectional text encoders. The approach involves three steps: enabling bidirectional attention, training with masked next token prediction, and applying unsupervised contrastive learning. The resulting encoders can be fine-tuned further for various natural language understanding tasks, achieving competitive performance on embedding benchmarks.