# McGill-NLP/llm2vec

Code for 'LLM2Vec: Large Language Models Are Secretly Powerful Text Encoders'

Repository: https://github.com/McGill-NLP/llm2vec
Canonical: https://ross.abutalabs.com/products/llm2vec
Homepage: https://mcgill-nlp.github.io/llm2vec/
Language: Python
License: MIT
License Family: permissive
Last push: 2026-04-04T14:53:36+00:00

## Health v2 (maintenance only)
Score: 49/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 75, release rhythm 8, longevity 63
- inputs: {"age_days": 882, "days_push": 151, "days_rel": 586, "gap_med": null, "n_releases_24m": 1}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 1712, forks 139 (observed 2026-08-28T04:05:25.856114+00:00)

## What it is
LLM2Vec is a Python library that converts decoder-only large language models into powerful text encoders via bidirectional attention, masked next token prediction, and unsupervised contrastive learning. It wraps HuggingFace models for sequence encoding and pooling, and ships pretrained checkpoints on HuggingFace.

## Use cases
- convert an LLM into a text embedding model
- generate sentence embeddings for semantic search
- build embeddings for RAG retrieval
- fine-tune a decoder-only LLM as a text encoder
- evaluate embeddings on MTEB benchmarks

## When to choose
- you want state-of-the-art text embeddings derived from open LLMs
- you need custom embedding models fine-tuned on your domain
- you want bidirectional encoders without training from scratch

## When to avoid
- you need a lightweight embedding model for CPU-only deployment
- you only need off-the-shelf embeddings without GPU training
- your stack does not support HuggingFace transformers and flash-attention

## Facets
- artifact type: library
- maturity: active
- function: machine-learning, llm-training, rag, nlp
- domain: large-language-models, machine-learning
- platform: python
- tags: text-embeddings, sentence-embeddings, contrastive-learning, huggingface, research, natural-language-processing, retrieval-augmented-generation, gpu

## Member repositories
- McGill-NLP/llm2vec (main) score 49

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:05:25.856114+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T03:34:45.973308+00:00, confidence not recorded.
  - readme: https://github.com/McGill-NLP/llm2vec (fetched 2026-08-28T04:05:25.856114+00:00, sha 4f71585a5e90)
  - homepage: https://mcgill-nlp.github.io/llm2vec/ (fetched 2026-08-29T11:10:46.684131+00:00, sha ad183eef78dd)
  - registry_pypi: https://pypi.org/pypi/llm2vec/json (fetched 2026-08-29T11:10:46.686440+00:00, sha 1f2071ca9cf9)
- Data as of 2026-08-30T08:39:29.467469+00:00.
