Skip to main content

BertHparams

Struct BertHparams 

Source
pub struct BertHparams {
Show 18 fields pub arch: String, pub n_layer: usize, pub n_embd: usize, pub n_ff: usize, pub n_head: usize, pub n_head_kv: usize, pub n_ctx_train: usize, pub n_token_types: usize, pub layer_norm_eps: f32, pub rope_theta: Option<f32>, pub rope_dim: usize, pub ffn: BertFfn, pub topology: BertTopology, pub rope_interleaved: bool, pub alibi_slopes: Option<Vec<f32>>, pub pooling: PoolingType, pub cls_id: u32, pub sep_id: u32,
}
Expand description

bert.* metadata, after the loader has checked it.

Fields§

§arch: String§n_layer: usize§n_embd: usize§n_ff: usize§n_head: usize§n_head_kv: usize§n_ctx_train: usize

Height of the learned position table.

§n_token_types: usize§layer_norm_eps: f32§rope_theta: Option<f32>

NEOX RoPE on Q and K instead of a learned position table: Some(theta) for the architectures bert.cpp:126-133 rotates (nomic-bert, nomic-bert-moe, jina-bert-v3), None for bert itself, which adds position_embd at :90 instead.

One field for both facts on purpose: a file cannot have a position table AND a rotation here, because upstream decides both from the architecture and never reads the table for a rotating one – measured, libllama’s load log never names position_embd for nomic-bert.

§rope_dim: usize

How many of each head’s channels rotate ({arch}.rope.dimension_count), head_dim when the key is absent. Only read when Self::rope_theta is Some.

§ffn: BertFfn

The FFN this architecture runs (bert.cpp:179-201).

§topology: BertTopology

Where this architecture’s norms sit and what they are.

§rope_interleaved: bool

true for the NORM (interleaved-pair) rotation, false for NEOX (split-half). llama_model_rope_type answers NORM for neo-bert alone among the encoders here.

§alibi_slopes: Option<Vec<f32>>

ALiBi slopes, one per head, for the architecture whose graph carries a positional bias instead of a table or a rotation.

jina-bert-v2.cpp:5 sets f_max_alibi_bias = 8.0f as a LITERAL and bert.cpp:78-80 builds no inp_pos for it at all, so this is the only place position enters that model. The bias is SYMMETRIC here – llama-graph.cpp:442 fills the mask with -|p0 - p1| for a non-causal model, where the decoder’s is p_key - p_query – which is why the encoder computes its own rather than calling the decoder’s row helper.

§pooling: PoolingType§cls_id: u32

[CLS] / [SEP], from tokenizer.ggml.bos_token_id and tokenizer.ggml.seperator_token_id (upstream’s spelling of the key, typo included). See BertEncoder::wrap_special.

§sep_id: u32

Implementations§

Trait Implementations§

Source§

impl Clone for BertHparams

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BertHparams

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.