pub struct Model {
pub language_model: TextModel,
pub vision_tower: VisionTower,
pub embed_vision: MultimodalEmbedder,
pub audio_tower: Option<AudioModel>,
pub embed_audio: Option<MultimodalEmbedder>,
pub cfg: Gemma4Config,
}Expand description
Full Gemma4 multimodal model.
Fields§
§language_model: TextModel§vision_tower: VisionTower§embed_vision: MultimodalEmbedder§audio_tower: Option<AudioModel>§embed_audio: Option<MultimodalEmbedder>§cfg: Gemma4ConfigImplementations§
Source§impl Model
impl Model
pub fn new(cfg: &Gemma4Config, vb: VarBuilder<'_>) -> Result<Self>
Sourcepub fn forward(
&mut self,
input_ids: &Tensor,
seqlen_offset: usize,
) -> Result<Tensor>
pub fn forward( &mut self, input_ids: &Tensor, seqlen_offset: usize, ) -> Result<Tensor>
Text-only forward pass.
Sourcepub fn forward_multimodal(
&mut self,
input_ids: &Tensor,
pixel_values: Option<&[Tensor]>,
audio_mel: Option<&Tensor>,
audio_mel_mask: Option<&Tensor>,
seqlen_offset: usize,
) -> Result<Tensor>
pub fn forward_multimodal( &mut self, input_ids: &Tensor, pixel_values: Option<&[Tensor]>, audio_mel: Option<&Tensor>, audio_mel_mask: Option<&Tensor>, seqlen_offset: usize, ) -> Result<Tensor>
Forward with multimodal inputs.
pixel_values: optional batch of images, each (1, C, H, W).
audio_mel: optional (batch, time, mel_bins) mel spectrogram.
audio_mel_mask: optional (batch, time) mask (1.0 = padding).
pub fn clear_kv_cache(&mut self)
Auto Trait Implementations§
impl !RefUnwindSafe for Model
impl !UnwindSafe for Model
impl Freeze for Model
impl Send for Model
impl Sync for Model
impl Unpin for Model
impl UnsafeUnpin for Model
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
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,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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>
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 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>
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