Protein Families, Profile HMMs against a Protein Language Model
Given a protein sequence only distantly related to the known members of its family, which method puts it in the right family? Profile HMMs placed 95% correctly in 9 seconds on a CPU. Protein language-model embeddings, used the simple way, placed 18% under the same false-alarm limit.
- Our team has new protein sequences and wants to know which known families they belong to. Protein language models are the new tool everyone talks about. Do they beat the profile search that has done this job for 25 years, especially for distant relatives, and what does each cost to run?
- On 12,667 test sequences from 1,000 Pfam families, with 2,760 decoys from families the system had never seen, profile HMMs placed 95% of the distant relatives (under 30% identity) in the right family; nearest-sequence search 85%; ESM-2 embeddings 18% at the same decoy limit. The HMMs gave a family to 6.9% of decoys, over the 5% limit set before the test; a third of those were real relatives from the same Pfam clan.
- For family assignment, profile HMMs remain the tool to use: most accurate, cheapest (a CPU, seconds), and the only method that stays silent on most unknown sequences. Raw language-model embeddings with a nearest-neighbour search are not a replacement. Their value lies in methods built for them, which this Lab did not test. Decoy thresholds need checking on held-out families, not just setting once.
When a lab sequences a new protein, one of the first questions is which known family it belongs to: the family says what the protein probably does. For 25 years the standard answer has been a profile hidden Markov model (HMM): a statistical summary of a family’s aligned members, searched with HMMER. That is how Pfam, the main family database, works. Protein language models such as Meta’s ESM-2 now turn any sequence into a vector, and near vectors are said to mean related proteins. The question here: for sequences only distantly related to anything known, which assigns the right family, which wrongly assigns sequences from families it has never seen, and what does each cost?
The test
- Data: Pfam 38.2 seed alignments (public, CC0). 1,000 families with at least 20 seed members form the index; 200 other families supply decoys, sequences that should get no family at all. At most 40 members per family, half used to build the index, half as test queries.
- Difficulty, by identity to the nearest known member: each query’s highest identity to any training member of its own family, on the seed alignment: easy (50% or more), medium (30–50%), hard (under 30%). Below 30% identity, a simple sequence comparison starts to fail. Queries overlapping too little to measure were left out (315).
- Methods:
- Profile HMM: a profile built from each family’s training members (pyhmmer, HMMER 3.4); each query goes to its best-scoring profile.
- Nearest sequence: phmmer, each query against every single training sequence, as a BLAST-style search would.
- ESM-2, nearest neighbour: the 650-million-parameter model’s average embedding of each sequence; each query goes to the family of the most similar training sequence.
- ESM-2, family centroid: the same embeddings, against each family’s average.
- Combined: the HMM’s call when its score is high enough, otherwise ESM-2’s nearest neighbour.
- Decoys and thresholds: each method gets a score threshold below which it says “no family”. It is set on 30% of the families (dev), as the lowest score that gives a family to at most 5% of dev decoys. Results are on the other 70% (test).
- Pre-set pass: the best method at or above 90% right on the hard band, with at most 5% of test decoys given a family.
Results
- of distant relatives placed in the right family by profile HMMs
- 95%
- by ESM-2 embeddings, at the same decoy limit
- 18%
- of test decoys given a family by the HMM (dev: 4.9%)
- 6.9%
- to search 21,909 sequences on a CPU
- 9 s
| Easy (≥ 50% identity) | Medium (30–50%) | Hard (< 30%) | Decoys given a family | Wrong family (count) | |
|---|---|---|---|---|---|
| Profile HMM (hmmsearch) | 100.0% | 99.7% | 95.1% | 6.9% | 8 |
| Nearest sequence (phmmer) | 100.0% | 99.5% | 85.1% | 3.3% | 13 |
| ESM-2, nearest neighbour | 72.3% | 34.7% | 17.7% | 5.9% | 311 |
| ESM-2, family centroid | 53.5% | 29.5% | 15.7% | 5.6% | 402 |
| HMM, then ESM-2 fallback | 100.0% | 99.7% | 95.3% | 6.9% | 6 |
The pass bar was missed, narrowly, and on decoys. Profile HMMs placed 95.1% of the hard band correctly, well above 90%, but gave a family to 6.9% of test decoys against 4.9% on dev. Nearest-sequence search stayed inside the decoy limit (3.3%) but placed only 85.1% of the hard band. On easy and medium queries both classic methods are essentially perfect.
ESM-2 embeddings did far worse: 72% on easy queries and 18% on hard ones, with hundreds of queries sent to the wrong family. Adding ESM-2 as a fallback to the HMM changed one hard query in 886.
Why the embeddings fell behind
With threshold (≤ 5% dev decoys)
- Profile HMM (hmmsearch)95.1%
- Nearest sequence (phmmer)85.1%
- ESM-2, nearest neighbour17.7%
- ESM-2, family centroid15.7%
No threshold
- Profile HMM (hmmsearch)95.1%
- Nearest sequence (phmmer)89.3%
- ESM-2, nearest neighbour81.0%
- ESM-2, family centroid74.8%
Without any threshold, ESM-2’s nearest neighbour does place 81% of the hard band correctly. The embeddings do carry family information. The problem is telling a relative from a stranger. Among 18,000 training sequences, a decoy almost always finds one whose embedding is as close as a distant relative’s would be. A cut that rejects 95% of decoys also rejects most true relatives.
| Easy (≥ 50% identity) | Medium (30–50%) | Hard (< 30%) | Decoys given a family | |
|---|---|---|---|---|
| Profile HMM (hmmsearch) | 100.0% | 99.7% | 95.1% | 7.5% |
| Nearest sequence (phmmer) | 100.0% | 99.7% | 89.3% | 21.2% |
| ESM-2, nearest neighbour | 93.5% | 86.1% | 81.0% | 100.0% |
| ESM-2, family centroid | 88.6% | 82.4% | 74.8% | 100.0% |
The profile HMM behaves differently: with no threshold at all, it reports no match for over 90% of decoys. It was built to say “nothing here”.
This is the simplest way to use a protein language model, and it is how embeddings are often tried first: average the residues, compare by cosine. Methods built for this job, such as aligning the per-residue embeddings or models fine-tuned to separate families, report much better results. They were not tested here.
What went wrong on decoys
Of the 190 test decoys the HMM gave a family to, 62 went to a family in the same Pfam clan as their own. Pfam groups families it believes share an ancestor into clans, so these are real distant relatives, arguably correct matches. Without them the rate is 4.6%. That is an explanation found after the test, not a rescoring: the bar was set on all decoys, and it was missed.
Many of the rest pair families of long, repetitive helices, such as coiled coils and spectrin repeats, which profile search is known to over-match. The threshold could not fix this: these false matches score well above it. Whether a sample of decoy families contains such look-alikes is lumpy. The hits came from 24 of the 62 dev decoy families and 63 of the 138 test ones, so 4.9% on dev became 6.9% on test.
Cost
| Step | Time | Per 1,000 sequences | |
|---|---|---|---|
| Profile HMM | build 1,000 profiles | 33 s | — |
| Profile HMM | search 21,909 queries | 9 s | 0.4 s |
| Nearest sequence (phmmer) | search 21,909 queries | 168 s | 7.6 s |
| ESM-2 650M | embed 40,296 sequences (GPU) | 284 s | 7.0 s |
Searching 21,909 sequences against 1,000 profiles took 9 seconds on 8 CPU threads, about 0.4 seconds per 1,000 sequences. Building the profiles took 33 seconds, once. ESM-2 needed a GPU and about 7 seconds per 1,000 sequences, and the embeddings are only the first step. On this task the established tool is cheaper by more than an order of magnitude, as well as more accurate.
What this means in practice
- Assigning families to new sequences: use profile HMMs (HMMER with Pfam). They run on an ordinary CPU, handle distant relatives and stay silent on most unknown proteins.
- Do not swap in raw language-model embeddings for this job. Averaged ESM-2 embeddings with a nearest-neighbour search find the family of close relatives, not distant ones, and cannot reliably say “no family”.
- Check false-alarm thresholds on families held out from tuning, as here. A threshold that holds on one sample of families can drift on another, and repetitive families are where it drifts.
- Where language models may help: the hardest cases profile HMMs miss, through methods built for embeddings. That is a separate test.
Method and environment
- data
Pfam-A.seed release 38.2 (EBI, CC0): 1,000 index families and 200 decoy families with at least 20 seed members, sampled with a fixed seed; at most 40 members per family, half for training, half as queries- difficulty
each query's highest identity to any training member of its family, on aligned columns where both have a residue (at least 30): easy ≥ 50%, medium 30–50%, hard < 30%; queries with too little overlap left out- split
dev and test by family hash (30% dev); thresholds and the combined method's settings chosen on dev only- methods
pyhmmer 0.12.3 (HMMER 3.4): hmmbuild from training members, hmmsearch of all queries against 1,000 profiles, bit score; phmmer of each query against all training members, bit score; ESM-2 650M (facebook/esm2_t33_650M_UR50D via transformers), mean of last-layer residue embeddings, cosine to nearest training member or to family centroid; combined: HMM call above its threshold, else ESM-2 nearest neighbour above its own- threshold
per method, the lowest score that gives a family to at most 5% of dev decoys- pilot
HMM and phmmer on 400 queries, ESM-2 on 120 sequences (CPU), before the full run- environment
gpu: RTX 4070 12 GB · cpu: desktop CPU, 8 threads for HMMER- measured
- 2026-10-26
Limits
Pfam seed members are curated, well-aligned family members, so these numbers are better than on raw sequencing output. Difficulty bands come from Pfam’s own alignment, which favours the HMM a little: the profiles are built from the same alignment. Queries are single domains cut to Pfam’s boundaries; whole proteins with several domains are harder. ESM-2 was used in its simplest form (mean embedding, cosine); per-residue alignment and fine-tuned models were not tested. The model was the 650-million-parameter ESM-2, not the largest. The pipeline was piloted on 400 queries (HMMER) and 120 sequences (ESM-2, on the CPU) before the full run. Sequences and families: Pfam 38.2, CC0. The code is in labs/protein-families in this site’s repository.
New Lab results by email
A short email when a new measurement is published, a few times a year. No newsletter fluff, reply to unsubscribe.