Skip to main content

CausalModel

Trait CausalModel 

Source
pub trait CausalModel<S> {
    type Tensor: Tensor;
    type Input<'a>: Copy;
    type Error;

    // Required methods
    fn prefill_input_logits(
        &mut self,
        input: Self::Input<'_>,
        state: &mut S,
        context: &<Self::Tensor as Tensor>::Context,
    ) -> Result<Self::Tensor, Self::Error>;
    fn decode_logits(
        &mut self,
        input_tokens: &Self::Tensor,
        state: &mut S,
        context: &<Self::Tensor as Tensor>::Context,
    ) -> Result<Self::Tensor, Self::Error>;

    // Provided method
    fn adjust_prefill_logits(
        &mut self,
        logits: Self::Tensor,
        _state: &mut S,
        _context: &<Self::Tensor as Tensor>::Context,
    ) -> Result<Self::Tensor, Self::Error> { ... }
}
Expand description

Monomorphized causal model used by generation sessions.

Required Associated Types§

Source

type Tensor: Tensor

Backend-native tensor handle containing logits and decode token ids.

Source

type Input<'a>: Copy

Borrowed, tokenizer/media-prepared prefill input.

Source

type Error

Concrete model or backend failure.

Required Methods§

Source

fn prefill_input_logits( &mut self, input: Self::Input<'_>, state: &mut S, context: &<Self::Tensor as Tensor>::Context, ) -> Result<Self::Tensor, Self::Error>

Computes initial logits and updates mutable state.

Source

fn decode_logits( &mut self, input_tokens: &Self::Tensor, state: &mut S, context: &<Self::Tensor as Tensor>::Context, ) -> Result<Self::Tensor, Self::Error>

Computes logits for decode tokens using existing mutable state.

Provided Methods§

Source

fn adjust_prefill_logits( &mut self, logits: Self::Tensor, _state: &mut S, _context: &<Self::Tensor as Tensor>::Context, ) -> Result<Self::Tensor, Self::Error>

Adjusts prefill logits before backend-native sampling.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§