Trait llm_base::model::Model

source ·
pub trait Model: Send + Sync {
    // Required methods
    fn start_session(
        &self,
        params: InferenceSessionParameters
    ) -> InferenceSession;
    fn evaluate(
        &self,
        session: &mut InferenceSession,
        params: &InferenceParameters,
        input_tokens: &[TokenId],
        output_request: &mut EvaluateOutputRequest
    );
    fn vocabulary(&self) -> &Vocabulary;
    fn n_context_tokens(&self) -> usize;
    fn bot_token_id(&self) -> Option<TokenId>;
    fn eot_token_id(&self) -> TokenId;
    fn inference_params(&self) -> InferenceParameters;
    fn inference_prompt_params(&self) -> InferenceWithPromptParameters;
}
Expand description

A type-erased model to allow for interacting with a model without knowing its hyperparameters.

Required Methods§

source

fn start_session(&self, params: InferenceSessionParameters) -> InferenceSession

Starts a new InferenceSession for this model.

source

fn evaluate( &self, session: &mut InferenceSession, params: &InferenceParameters, input_tokens: &[TokenId], output_request: &mut EvaluateOutputRequest )

This function is called by the provided InferenceSession; it will use this model and the InferenceParameters to generate output by evaluating the input_tokens. The EvaluateOutputRequest is used to specify additional data to fetch from the model. For more information, refer to InferenceSession::infer_with_params

source

fn vocabulary(&self) -> &Vocabulary

Get the vocabulary (loaded from the GGML file) for this model.

source

fn n_context_tokens(&self) -> usize

Get the context size (configured with ModelParameters::n_context_tokens) used by this model.

source

fn bot_token_id(&self) -> Option<TokenId>

Get the beginning of text/beginning of string token ID, if available. This value is defined by model implementers.

source

fn eot_token_id(&self) -> TokenId

Get the end of text/end of string token ID. This value is defined by model implementers.

source

fn inference_params(&self) -> InferenceParameters

Get the default InferenceSessionParameters for this model (used by InferenceSession::infer). This value is configured through ModelParameters::inference_params.

source

fn inference_prompt_params(&self) -> InferenceWithPromptParameters

Get the default InferenceWithPromptParameters for this model (used by InferenceSession::infer). This value is configured through ModelParameters::inference_prompt_params.

Implementors§

source§

impl<H: Hyperparameters, M: KnownModel<Hyperparameters = H>> Model for M