pub struct StructureTokenEncoder { /* private fields */ }Expand description
Encodes backbone coordinates into discrete structure tokens via a 2-layer geometric mini-transformer followed by nearest-neighbour VQ codebook lookup.
Weight layout (in encoder checkpoint):
encoder.blocks.*— transformerpre_vq_proj.weight—(d_codebook, enc_d_model)codebook.embeddings—(n_codes, d_codebook)
Implementations§
Source§impl StructureTokenEncoder
impl StructureTokenEncoder
Sourcepub fn load(vb: VarBuilder<'_>, config: VqVaeConfig) -> Result<Self>
pub fn load(vb: VarBuilder<'_>, config: VqVaeConfig) -> Result<Self>
Load from esm3_structure_encoder_v0.pth.
Every prefix here was read off the real checkpoint rather than inferred
from the reference source: it roots at transformer (not encoder),
and pre_vq_proj carries a bias. Both were wrong before, and both
would have failed loudly — unlike the missing relative position
embedding, which simply left the encoder computing from zeros.
Sourcepub fn encode(
&self,
coords: &Tensor,
sequence_id: Option<&Tensor>,
) -> Result<Tensor>
pub fn encode( &self, coords: &Tensor, sequence_id: Option<&Tensor>, ) -> Result<Tensor>
Encode backbone coordinates into structure tokens.
coords—(B, L, 3, 3)backbone(N, CA, C)positions.sequence_id— optional(B, L)bin-packing ids.
Returns (B, L) u32 structure token indices.
§Why this is not a sequence transformer
This encoder is local. It does not run the transformer over the
chain; it runs it over each residue’s 16 nearest neighbours in space,
as (B*L, 16, d_model). The earlier port ran a full-sequence pass from
a zero hidden state, which is a different computation entirely — the
weights would load (once the prefixes were right) and the output would
be quietly meaningless.
Auto Trait Implementations§
impl !RefUnwindSafe for StructureTokenEncoder
impl !Send for StructureTokenEncoder
impl !Sync for StructureTokenEncoder
impl !UnwindSafe for StructureTokenEncoder
impl Freeze for StructureTokenEncoder
impl Unpin for StructureTokenEncoder
impl UnsafeUnpin for StructureTokenEncoder
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