pub struct EncoderConfig {
pub d: usize,
pub inter: usize,
pub heads: usize,
pub layers: usize,
pub vocab: usize,
pub global: Vec<bool>,
pub window: usize,
pub rope_global: f64,
pub rope_local: f64,
pub norm_eps: f64,
}Expand description
The encoder’s shape, from encoder/config.json (a HF ModernBERT config).
Fields§
§d: usizeHidden size.
inter: usizeGeGLU inner size. mlp.Wi has twice as many rows.
heads: usizeAttention heads.
layers: usizeEncoder layers.
vocab: usizeVocabulary size, the rows of the embedding table.
global: Vec<bool>Whether each layer attends globally, false meaning the sliding window.
window: usizeSliding window width in tokens, 128 for both published encoders.
rope_global: f64RoPE base on global layers.
rope_local: f64RoPE base on sliding window layers.
norm_eps: f64LayerNorm epsilon.
Implementations§
Source§impl EncoderConfig
impl EncoderConfig
Sourcepub fn from_json(v: &Value) -> Result<Self, Error>
pub fn from_json(v: &Value) -> Result<Self, Error>
Reads a HF ModernBERT config. Both the transformers 5 layout (layer_types,
rope_parameters) and the older one (global_attn_every_n_layers, global_rope_theta,
local_rope_theta) are accepted, since checkpoints in the wild have either.
§Errors
Error::Format naming the missing or bad field.
Trait Implementations§
Source§impl Clone for EncoderConfig
impl Clone for EncoderConfig
Source§impl Debug for EncoderConfig
impl Debug for EncoderConfig
Source§impl PartialEq for EncoderConfig
impl PartialEq for EncoderConfig
impl StructuralPartialEq for EncoderConfig
Auto Trait Implementations§
impl Freeze for EncoderConfig
impl RefUnwindSafe for EncoderConfig
impl Send for EncoderConfig
impl Sync for EncoderConfig
impl Unpin for EncoderConfig
impl UnsafeUnpin for EncoderConfig
impl UnwindSafe for EncoderConfig
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
Mutably borrows from an owned value. Read more