pub struct SmolVlmModel<B: Backend> { /* private fields */ }Expand description
SmolVLM (Idefics3): SigLIP + connector + Llama-family text decoder.
Trait Implementations§
Source§impl<B: Backend> GenerativeModel<B> for SmolVlmModel<B>
impl<B: Backend> GenerativeModel<B> for SmolVlmModel<B>
Source§fn metadata(&self) -> &ModelMetadata
fn metadata(&self) -> &ModelMetadata
Metadata this model was built from.
Source§fn load(source: &dyn ModelSource, device: &Device<B>) -> Result<Self>
fn load(source: &dyn ModelSource, device: &Device<B>) -> Result<Self>
Loads all weights from a
ModelSource onto device.Source§fn create_kv_cache(&self, config: &CacheConfig) -> Box<dyn KVCache<B>>
fn create_kv_cache(&self, config: &CacheConfig) -> Box<dyn KVCache<B>>
Creates a fresh KV cache for a new generation session, sized and
implemented according to
config (paged arena vs contiguous
baseline).Source§fn embed(&self, tokens: Tensor<B, 2, Int>) -> Tensor<B, 3>
fn embed(&self, tokens: Tensor<B, 2, Int>) -> Tensor<B, 3>
Embeds token ids:
[batch, seq] -> [batch, seq, hidden].Source§fn embed_multimodal(
&self,
tokens: Tensor<B, 2, Int>,
images: &[Tensor<B, 4>],
) -> Result<Tensor<B, 3>>
fn embed_multimodal( &self, tokens: Tensor<B, 2, Int>, images: &[Tensor<B, 4>], ) -> Result<Tensor<B, 3>>
Embeds token ids, splicing vision-tower features into the image-token
spans.
images are preprocessed pixel batches [1, channels, H, W],
one per image-token span, in order. Text-only models keep the default
impl, which rejects non-empty media and otherwise defers to embed.Source§fn prefill(
&mut self,
input: Tensor<B, 3>,
cache: &mut dyn KVCache<B>,
pos: Range<u32>,
) -> Tensor<B, 2>
fn prefill( &mut self, input: Tensor<B, 3>, cache: &mut dyn KVCache<B>, pos: Range<u32>, ) -> Tensor<B, 2>
Runs (a chunk of) the prompt through the model, filling the KV cache
for positions
pos. pos.end - pos.start must equal the input
sequence length, and pos.start must equal the cache’s current
length (dense contiguous chunks). Returns the logits of the last
position, shape [batch, vocab].Source§fn decode(
&mut self,
input: Tensor<B, 3>,
cache: &mut dyn KVCache<B>,
) -> Tensor<B, 2>
fn decode( &mut self, input: Tensor<B, 3>, cache: &mut dyn KVCache<B>, ) -> Tensor<B, 2>
Runs one decode step (single new position at the end of the cache).
Returns the logits of that position, shape
[batch, vocab].Runs (a chunk of) the prompt and returns the final-norm hidden
states for those positions, shape
[1, seq, hidden] — the
embeddings path. Same cache/position contract as
GenerativeModel::prefill. Models that cannot expose hidden
states keep the default error.Whether
GenerativeModel::prefill_hidden is implemented — the
capability flag /v1/model/info advertises as embeddings.Source§fn prefill_all_logits(
&mut self,
input: Tensor<B, 3>,
cache: &mut dyn KVCache<B>,
pos: Range<u32>,
) -> Result<Tensor<B, 3>>
fn prefill_all_logits( &mut self, input: Tensor<B, 3>, cache: &mut dyn KVCache<B>, pos: Range<u32>, ) -> Result<Tensor<B, 3>>
Runs (a chunk of) the prompt and returns logits for every
position, shape
[1, seq, vocab] — the perplexity / speculative-
decode path. Same cache/position contract as
GenerativeModel::prefill. Memory scales with seq × vocab, so
callers chunk accordingly. Default: unsupported.Source§fn decode_all_logits(
&mut self,
_input: Tensor<B, 3>,
_cache: &mut dyn KVCache<B>,
) -> Result<Tensor<B, 3>>
fn decode_all_logits( &mut self, _input: Tensor<B, 3>, _cache: &mut dyn KVCache<B>, ) -> Result<Tensor<B, 3>>
Decodes
n tokens at the cache tail and returns logits for every
position ([1, n, vocab]), not just the last row — the seam
multi-token verification needs. Architectures without it never take
the speculative path.Source§fn supports_decode_all_logits(&self) -> bool
fn supports_decode_all_logits(&self) -> bool
Whether
GenerativeModel::decode_all_logits is implemented.Auto Trait Implementations§
impl<B> !RefUnwindSafe for SmolVlmModel<B>
impl<B> !UnwindSafe for SmolVlmModel<B>
impl<B> Freeze for SmolVlmModel<B>where
<B as BackendTypes>::FloatTensorPrimitive: Freeze,
<B as BackendTypes>::QuantizedTensorPrimitive: Freeze,
impl<B> Send for SmolVlmModel<B>
impl<B> Sync for SmolVlmModel<B>
impl<B> Unpin for SmolVlmModel<B>where
<B as BackendTypes>::FloatTensorPrimitive: Unpin,
<B as BackendTypes>::QuantizedTensorPrimitive: Unpin,
impl<B> UnsafeUnpin for SmolVlmModel<B>where
<B as BackendTypes>::FloatTensorPrimitive: UnsafeUnpin,
<B as BackendTypes>::QuantizedTensorPrimitive: UnsafeUnpin,
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