pub struct ESM2Runner { /* private fields */ }Implementations§
Source§impl ESM2Runner
impl ESM2Runner
Sourcepub fn from_pretrained(
modeltype: ESM2Models,
device: Device,
) -> Result<ESM2Runner>
pub fn from_pretrained( modeltype: ESM2Models, device: Device, ) -> Result<ESM2Runner>
Load model from HuggingFace hub at F32, downloading config.json, tokenizer files, and weights.
Use from_pretrained_with to load at F16
or BF16 — T36_3B and T48_15B are not loadable at F32 on most
machines (~12 GB and ~60 GB respectively).
Sourcepub fn load_model(modeltype: ESM2Models, device: Device) -> Result<ESM2Runner>
👎Deprecated since 0.4.0: renamed to from_pretrained
pub fn load_model(modeltype: ESM2Models, device: Device) -> Result<ESM2Runner>
renamed to from_pretrained
Renamed to from_pretrained (ferritin-100.8).
Sourcepub fn load_model_with(
modeltype: ESM2Models,
opts: &LoadOptions,
) -> Result<ESM2Runner>
👎Deprecated since 0.4.0: renamed to from_pretrained_with
pub fn load_model_with( modeltype: ESM2Models, opts: &LoadOptions, ) -> Result<ESM2Runner>
renamed to from_pretrained_with
Renamed to from_pretrained_with (ferritin-100.8).
Sourcepub fn from_pretrained_with(
modeltype: ESM2Models,
opts: &LoadOptions,
) -> Result<ESM2Runner>
pub fn from_pretrained_with( modeltype: ESM2Models, opts: &LoadOptions, ) -> Result<ESM2Runner>
Load model with an explicit device and dtype.
Reduced precision halves the memory footprint but changes the numerics;
see tests/test_plm_dtype_parity.rs for the tolerance each dtype
actually achieves against the Python reference (ferritin-100.9).
pub fn run_forward(&self, prot_sequence: &str) -> Result<ESM2Output>
Sourcepub fn predict_contacts(&self, prot_sequence: &str) -> Result<Tensor>
pub fn predict_contacts(&self, prot_sequence: &str) -> Result<Tensor>
Predict residue-residue contact probabilities for a single protein sequence.
Returns a (seq_len, seq_len) contact probability matrix (BOS/EOS stripped,
so dimensions equal the number of amino acids in prot_sequence).
pub fn decode_logits(&self, output: ESM2Output) -> Result<String>
Sourcepub fn get_pseudo_probabilities(
&self,
prot_sequence: &str,
) -> Result<Vec<PseudoProbability>>
pub fn get_pseudo_probabilities( &self, prot_sequence: &str, ) -> Result<Vec<PseudoProbability>>
Run ESM2 and return per-residue pseudo-probabilities for the 20 standard amino acids.
BOS and EOS tokens are stripped before softmax is applied. Only amino acid / position pairs with probability > 0.01 are included in the result.
Trait Implementations§
Source§impl PlmRunner for ESM2Runner
impl PlmRunner for ESM2Runner
Source§fn embed(&self, sequence: &str) -> Result<Tensor>
fn embed(&self, sequence: &str) -> Result<Tensor>
Run the ESM2 transformer and return per-residue embeddings (pre-LM-head).
Shape: (1, L, hidden_size) where L includes BOS and EOS tokens.
Source§fn special_tokens(&self) -> SpecialTokenLayout
fn special_tokens(&self) -> SpecialTokenLayout
ESM-2 wraps sequences in <cls> and <eos>; encode_with_special
adds them because the bundled tokenizer.json has no post-processor.
Source§fn residue_count(&self, sequence: &str) -> usize
fn residue_count(&self, sequence: &str) -> usize
SaProt reads two characters per residue; stock ESM-2 reads one.
Source§fn embed_batch(&self, sequences: &[&str]) -> Result<Tensor>
fn embed_batch(&self, sequences: &[&str]) -> Result<Tensor>
One batched forward pass over right-padded sequences (ferritin-100.12).
Padding is config.pad_token_id, which matters twice over: ESM-1b and
ESM-1v number their absolute positions by counting non-pad tokens, and
the (batch, seq_len) mask handed to ESM2::embed both keeps padded
keys out of self-attention and supplies the per-row sequence length that
token-dropout compensation divides by.
Source§fn model_name(&self) -> &str
fn model_name(&self) -> &str
Source§fn metadata(&self) -> ModelMetadata
fn metadata(&self) -> ModelMetadata
Auto Trait Implementations§
impl !RefUnwindSafe for ESM2Runner
impl !UnwindSafe for ESM2Runner
impl Freeze for ESM2Runner
impl Send for ESM2Runner
impl Sync for ESM2Runner
impl Unpin for ESM2Runner
impl UnsafeUnpin for ESM2Runner
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more