pub struct ClipTextConfig {
pub vocab_size: usize,
pub n_ctx: usize,
pub width: usize,
pub depth: usize,
pub n_heads: usize,
pub mlp_ratio: usize,
pub embed_dim: usize,
pub eot_token: usize,
}Expand description
Hyper-parameters for the CLIP text Transformer.
Fields§
§vocab_size: usizeVocabulary size (number of distinct token ids).
n_ctx: usizeMaximum context length (number of positional embeddings).
width: usizeTransformer width (token embedding / residual-stream dimension).
depth: usizeNumber of transformer blocks.
n_heads: usizeNumber of attention heads. Must divide width.
mlp_ratio: usizeMLP hidden-dim multiplier (mlp_dim = mlp_ratio * width).
embed_dim: usizeOutput joint-embedding dimension (after the text projection).
eot_token: usizeId used as the end-of-text marker. When pooling, the position of the
last occurrence of this id (or, if absent, the highest id present) is
used. CLIP itself uses argmax over ids because <|endoftext|> is the
largest BPE id; we follow that convention via Self::eot_token.
Implementations§
Source§impl ClipTextConfig
impl ClipTextConfig
Sourcepub fn new(
vocab_size: usize,
n_ctx: usize,
width: usize,
depth: usize,
n_heads: usize,
mlp_ratio: usize,
embed_dim: usize,
eot_token: usize,
) -> VisionResult<Self>
pub fn new( vocab_size: usize, n_ctx: usize, width: usize, depth: usize, n_heads: usize, mlp_ratio: usize, embed_dim: usize, eot_token: usize, ) -> VisionResult<Self>
Validate and construct a config.
§Errors
VisionError::InvalidEmbedDimifwidth == 0orembed_dim == 0.VisionError::InvalidNumHeadsifn_heads == 0.VisionError::HeadDimMismatchifn_headsdoes not dividewidth.VisionError::Internalifvocab_size,n_ctx, ordepthis 0.
Trait Implementations§
Source§impl Clone for ClipTextConfig
impl Clone for ClipTextConfig
Source§fn clone(&self) -> ClipTextConfig
fn clone(&self) -> ClipTextConfig
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ClipTextConfig
impl Debug for ClipTextConfig
Source§impl PartialEq for ClipTextConfig
impl PartialEq for ClipTextConfig
Source§fn eq(&self, other: &ClipTextConfig) -> bool
fn eq(&self, other: &ClipTextConfig) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for ClipTextConfig
Auto Trait Implementations§
impl Freeze for ClipTextConfig
impl RefUnwindSafe for ClipTextConfig
impl Send for ClipTextConfig
impl Sync for ClipTextConfig
impl Unpin for ClipTextConfig
impl UnsafeUnpin for ClipTextConfig
impl UnwindSafe for ClipTextConfig
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