← all repositories

McGill-NLP/llm2vec

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

1.7k stars Python Language ModelsML Frameworks
llm2vec
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.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.