pub struct ESMCRunner { /* private fields */ }Expand description
Wraps a loaded ESMC model for sequence embedding inference.
Implementations§
Source§impl ESMCRunner
impl ESMCRunner
Sourcepub fn from_pretrained(model: ESMCModels, device: Device) -> Result<Self>
pub fn from_pretrained(model: ESMCModels, device: Device) -> Result<Self>
Download weights from HuggingFace and load the model.
Handles the ESMCForMaskedLM wrapper prefix (esmc.) transparently:
probes for esmc.embed.weight in the safetensors and sets the
VarBuilder root to vb.pp("esmc") when found, otherwise uses the
flat (unwrapped) layout.
Sourcepub fn from_pretrained_with(
model: ESMCModels,
opts: &LoadOptions,
) -> Result<Self>
pub fn from_pretrained_with( model: ESMCModels, opts: &LoadOptions, ) -> Result<Self>
Load with an explicit device and dtype.
ESMC6B is ~24 GB at F32 but ~12 GB at BF16 — its on-disk precision —
so reduced precision is the difference between loadable and not on a
32 GB machine. See tests/test_plm_dtype_parity.rs for the numerical
cost (ferritin-100.9).
Sourcepub fn embed_sequence(&self, sequence: &str) -> Result<Tensor>
pub fn embed_sequence(&self, sequence: &str) -> Result<Tensor>
Tokenize sequence and run a forward pass.
Returns per-residue embeddings with shape (1, L, d_model) where
L includes the BOS and EOS tokens added by the tokenizer.
Trait Implementations§
Source§impl PlmRunner for ESMCRunner
impl PlmRunner for ESMCRunner
Source§fn embed(&self, sequence: &str) -> Result<Tensor>
fn embed(&self, sequence: &str) -> Result<Tensor>
Delegate to embed_sequence, returning per-residue embeddings (1, L, d_model).
Source§fn special_tokens(&self) -> SpecialTokenLayout
fn special_tokens(&self) -> SpecialTokenLayout
ESMC::encode calls tokenize_sequence(.., true), which wraps the
sequence in BOS and EOS.
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).
ESM-C’s sequence_id is a where_cond predicate — 1 keeps a key,
0 replaces its score with -inf — so the U8 mask goes in as-is.
It is passed explicitly rather than relying on ESMC::forward’s
fallback (tokens.ne(pad_id)), which would happen to agree here but
ties correctness to the padding id rather than to the batch itself.
Source§fn model_name(&self) -> &str
fn model_name(&self) -> &str
Source§fn metadata(&self) -> ModelMetadata
fn metadata(&self) -> ModelMetadata
Source§fn residue_count(&self, sequence: &str) -> usize
fn residue_count(&self, sequence: &str) -> usize
sequence encodes. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for ESMCRunner
impl !Send for ESMCRunner
impl !Sync for ESMCRunner
impl !UnwindSafe for ESMCRunner
impl Freeze for ESMCRunner
impl Unpin for ESMCRunner
impl UnsafeUnpin for ESMCRunner
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