Contacts from a masked LM's attention, the way ESM predicts them: one forward pass over <cls> + the sequence + <eos>, every head's map turned into ContactFeatures, then combined. Each map is used as its layer finishes, so a pass holds one layer's at a time. Sequences are run one at a time, with no padding.
More...
#include <protein_contacts.hpp>
|
| | ContactPredictor (EncoderLM &model, const TextTokenizer &tokenizer, DeviceBackend *backend, ContactOptions options={}) |
| |
| ContactMap | predict (std::string_view sequence, const EsmContactHead &head) |
| | ESM's contact head: contact probabilities, L x L, symmetric. Matches transformers' EsmForMaskedLM.predict_contacts.
|
| |
| ContactMap | average_heads (std::string_view sequence, const std::vector< AttentionHead > &heads) |
| | The mean of heads' ContactFeatures: an unsupervised predictor with no regression. Scores rank pairs; they aren't probabilities. Pick the heads with RankContactHeads.
|
| |
| void | for_each_head (std::string_view sequence, const std::function< void(AttentionHead, const ContactMap &)> &visit) |
| | Calls visit with every head's ContactFeatures, layer by layer, from one pass.
|
| |
Contacts from a masked LM's attention, the way ESM predicts them: one forward pass over <cls> + the sequence + <eos>, every head's map turned into ContactFeatures, then combined. Each map is used as its layer finishes, so a pass holds one layer's at a time. Sequences are run one at a time, with no padding.
◆ ContactPredictor()
- Parameters
-
| backend | Where the model runs. The model, tokenizer and backend must outlive this. |
◆ average_heads()
| ContactMap pulsatrix::ContactPredictor::average_heads |
( |
std::string_view |
sequence, |
|
|
const std::vector< AttentionHead > & |
heads |
|
) |
| |
The mean of heads' ContactFeatures: an unsupervised predictor with no regression. Scores rank pairs; they aren't probabilities. Pick the heads with RankContactHeads.
- Exceptions
-
| std::invalid_argument | as predict(), or for no heads or one outside the model. |
◆ for_each_head()
| void pulsatrix::ContactPredictor::for_each_head |
( |
std::string_view |
sequence, |
|
|
const std::function< void(AttentionHead, const ContactMap &)> & |
visit |
|
) |
| |
Calls visit with every head's ContactFeatures, layer by layer, from one pass.
◆ predict()
ESM's contact head: contact probabilities, L x L, symmetric. Matches transformers' EsmForMaskedLM.predict_contacts.
- Exceptions
-
| std::invalid_argument | for an empty sequence, a character the tokenizer doesn't know, a head that doesn't fit the model, or a pass over max_pass_bytes. |
The documentation for this class was generated from the following file: