pub struct ESM3Runner { /* private fields */ }Expand description
Wraps a loaded ESM3 model for sequence embedding and multi-track inference.
§HuggingFace access
The ESM3 model is gated. Before calling from_pretrained the user must:
- Accept the Cambrian Non-Commercial license at https://huggingface.co/EvolutionaryScale/esm3-sm-open-v1
- Run
huggingface-cli login(or setHF_TOKENenv var)
Implementations§
Source§impl ESM3Runner
impl ESM3Runner
Sourcepub fn from_pretrained(variant: ESM3Models, device: Device) -> Result<Self>
pub fn from_pretrained(variant: ESM3Models, device: Device) -> Result<Self>
Download the ESM3 weights from HuggingFace and load the model.
The .pth checkpoint is loaded directly via candle_core::pickle::PthTensors.
Sourcepub fn from_pretrained_with(
variant: ESM3Models,
opts: &LoadOptions,
) -> Result<Self>
pub fn from_pretrained_with( variant: ESM3Models, opts: &LoadOptions, ) -> Result<Self>
Load with an explicit device and dtype (ferritin-100.9).
Sourcepub fn embed_sequence(&self, sequence: &str) -> Result<Tensor>
pub fn embed_sequence(&self, sequence: &str) -> Result<Tensor>
Tokenize sequence and return per-residue embeddings (1, L, d_model).
Only the sequence track is provided; all other tracks are None.
Embeddings are the pre-norm transformer hidden states (raw activations).
Trait Implementations§
Source§impl PlmRunner for ESM3Runner
impl PlmRunner for ESM3Runner
Source§fn special_tokens(&self) -> SpecialTokenLayout
fn special_tokens(&self) -> SpecialTokenLayout
embed_sequence calls tokenize_sequence(.., true), which prepends
SEQUENCE_BOS_TOKEN and appends SEQUENCE_EOS_TOKEN.
Source§fn logits(&self, sequence: &str) -> Result<Tensor>
fn logits(&self, sequence: &str) -> Result<Tensor>
Sequence-track logits (1, L + 2, d_sequence_vocab).
Only the sequence track is supplied; the other tracks are None.
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-3 reuses ESM-C’s MultiHeadAttention, so sequence_id is the same
where_cond predicate (1 keeps a key). Unlike ESM-C, ESM3::forward
has no fallback that derives one from the tokens: passing None — which
is what every single-sequence path here does — means no masking at all,
so a batch must supply it or the padding silently changes the real
residues’ embeddings.
Source§fn embed(&self, sequence: &str) -> Result<Tensor>
fn embed(&self, sequence: &str) -> Result<Tensor>
sequence and return raw per-residue embeddings. Read moreSource§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 ESM3Runner
impl !Send for ESM3Runner
impl !Sync for ESM3Runner
impl !UnwindSafe for ESM3Runner
impl Freeze for ESM3Runner
impl Unpin for ESM3Runner
impl UnsafeUnpin for ESM3Runner
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