pub struct MtmdInputChunks {
pub chunks: NonNull<mtmd_input_chunks>,
}Expand description
Safe wrapper around mtmd_input_chunks.
This is a collection of input chunks created from tokenizing text and media. The chunks represent the tokenized input that can be processed by the model, with text chunks containing tokens and media chunks containing embeddings.
Fields§
§chunks: NonNull<mtmd_input_chunks>Raw pointer to the underlying mtmd_input_chunks.
Implementations§
Source§impl MtmdInputChunks
impl MtmdInputChunks
Sourcepub fn new() -> Result<Self, MtmdInputChunksError>
pub fn new() -> Result<Self, MtmdInputChunksError>
Create a new empty input chunks collection.
§Errors
Returns MtmdInputChunksError::ChunksCreationFailed if the underlying llama.cpp function
returns null.
§Examples
use llama_cpp_bindings::mtmd::MtmdInputChunks;
let chunks = MtmdInputChunks::new().unwrap();
assert_eq!(chunks.len(), 0);
assert!(chunks.is_empty());Sourcepub fn get(&self, index: usize) -> Option<MtmdInputChunk>
pub fn get(&self, index: usize) -> Option<MtmdInputChunk>
Get a chunk by index
Sourcepub fn total_tokens(&self) -> usize
pub fn total_tokens(&self) -> usize
Get total number of tokens across all chunks.
Sourcepub fn total_positions(&self) -> i32
pub fn total_positions(&self) -> i32
Get total position count across all chunks.
Sourcepub fn eval_chunks(
&self,
mtmd_ctx: &MtmdContext,
llama_ctx: &LlamaContext<'_>,
start_position: llama_pos,
seq_id: llama_seq_id,
n_batch: i32,
logits_last: bool,
) -> Result<llama_pos, MtmdEvalError>
pub fn eval_chunks( &self, mtmd_ctx: &MtmdContext, llama_ctx: &LlamaContext<'_>, start_position: llama_pos, seq_id: llama_seq_id, n_batch: i32, logits_last: bool, ) -> Result<llama_pos, MtmdEvalError>
Evaluate chunks using the multimodal context and LLAMA context.
§Errors
Returns MtmdEvalError::EvalFailure if any encoding or decoding operation fails.
Trait Implementations§
Source§impl Debug for MtmdInputChunks
impl Debug for MtmdInputChunks
Source§impl Drop for MtmdInputChunks
impl Drop for MtmdInputChunks
Auto Trait Implementations§
impl Freeze for MtmdInputChunks
impl RefUnwindSafe for MtmdInputChunks
impl !Send for MtmdInputChunks
impl !Sync for MtmdInputChunks
impl Unpin for MtmdInputChunks
impl UnsafeUnpin for MtmdInputChunks
impl UnwindSafe for MtmdInputChunks
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
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