Skip to main content

ModelLimits

Struct ModelLimits 

Source
#[non_exhaustive]
pub struct ModelLimits { pub context_tokens: Option<u32>, pub max_images: Option<u32>, pub image_tokens: Option<u32>, pub image_patch: Option<u32>, pub image_edge: Option<u32>, pub audio_max_seconds: Option<u32>, pub audio_tokens_per_minute: Option<u32>, pub audio_chunk_seconds: Option<u32>, pub audio_chunk_tokens: Option<u32>, pub video_max_seconds: Option<u32>, pub video_max_bytes: Option<u64>, pub max_request_bytes: Option<u64>, }
Expand description

Media and request limits for one model. See the module docs.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§context_tokens: Option<u32>

The context in tokens the model runs with on this node (per slot: llama.cpp’s --ctx-size divided by --parallel), not the context it was trained for.

§max_images: Option<u32>

Most images one request may carry.

§image_tokens: Option<u32>

Tokens one image costs. With image_patch set, the most one image costs; otherwise every image costs this much.

§image_patch: Option<u32>

For models whose image cost grows with size: the edge in pixels of the square one image token covers. Absent: a fixed cost per image.

§image_edge: Option<u32>

The longest image edge in pixels the model uses; larger images are scaled down to it.

§audio_max_seconds: Option<u32>

Longest audio input in seconds.

§audio_tokens_per_minute: Option<u32>

Tokens one minute of audio costs.

§audio_chunk_seconds: Option<u32>

Audio is encoded in pieces this many seconds long, the last one padded, so a short clip costs a whole piece (audio_chunk_tokens).

§audio_chunk_tokens: Option<u32>

Tokens one piece of audio_chunk_seconds costs.

§video_max_seconds: Option<u32>

Longest video the model takes whole, in seconds (models that read video natively).

§video_max_bytes: Option<u64>

Largest video the model takes whole, in bytes.

§max_request_bytes: Option<u64>

Largest request body in bytes the serving side accepts.

Implementations§

Source§

impl ModelLimits

Source

pub const UNKNOWN: Self

No limits known.

Source

pub fn new() -> Self

Source

pub fn is_unknown(&self) -> bool

Whether no limit is known.

Source

pub fn with_context_tokens(self, tokens: u32) -> Self

Source

pub fn with_max_images(self, n: u32) -> Self

Source

pub fn with_image_tokens(self, tokens: u32) -> Self

Every image costs tokens (or at most that, with with_image_patch).

Source

pub fn with_image_patch(self, patch: u32) -> Self

The image cost grows with size: one token per patch x patch pixels.

Source

pub fn with_image_edge(self, pixels: u32) -> Self

Source

pub fn with_audio_max_seconds(self, seconds: u32) -> Self

Source

pub fn with_audio_tokens_per_minute(self, tokens: u32) -> Self

Source

pub fn with_audio_chunks(self, seconds: u32, tokens: u32) -> Self

Audio is encoded in seconds-long pieces of tokens each; sets audio_tokens_per_minute to match.

Source

pub fn with_video_max_seconds(self, seconds: u32) -> Self

Source

pub fn with_video_max_bytes(self, bytes: u64) -> Self

Source

pub fn with_max_request_bytes(self, bytes: u64) -> Self

Source

pub fn audio_tokens_per_second(&self) -> Option<f64>

Source

pub fn image_cost(&self, width: u32, height: u32) -> Option<u32>

What one width x height image costs in tokens, if known: the fixed cost, or with image_patch the patches after scaling down to image_edge, capped at image_tokens.

Source

pub fn scaled(&self, width: u32, height: u32) -> (u32, u32)

width x height scaled down (aspect kept) so the longer edge fits image_edge; unchanged when it fits or no edge is known.

Source

pub fn audio_cost(&self, millis: u64) -> Option<u64>

What millis of audio costs in tokens, if known: whole pieces when the model encodes audio in pieces (audio_chunk_seconds), else the per-minute rate rounded up.

Source

pub fn or(self, fallback: Self) -> Self

Each field from self when known, else from fallback: operator settings over measured ones (operator.or(measured)).

Source

pub fn tightest(self, other: Self) -> Self

The stricter of two copies, field by field: less context, fewer images, a smaller edge, shorter audio and video, fewer request bytes, a smaller patch and higher token costs. A field known on one side only keeps that side’s value; a field neither side knows stays absent.

Trait Implementations§

Source§

impl Clone for ModelLimits

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 Copy for ModelLimits

Source§

impl Debug for ModelLimits

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for ModelLimits

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for ModelLimits

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for ModelLimits

Source§

impl Hash for ModelLimits

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for ModelLimits

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for ModelLimits

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ModelLimits

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> 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.