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§
sourcefn start_session(&self, params: InferenceSessionParameters) -> InferenceSession
fn start_session(&self, params: InferenceSessionParameters) -> InferenceSession
Starts a new InferenceSession for this model.
sourcefn evaluate(
&self,
session: &mut InferenceSession,
params: &InferenceParameters,
input_tokens: &[TokenId],
output_request: &mut EvaluateOutputRequest
)
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
sourcefn vocabulary(&self) -> &Vocabulary
fn vocabulary(&self) -> &Vocabulary
Get the vocabulary (loaded from the GGML file) for this model.
sourcefn n_context_tokens(&self) -> usize
fn n_context_tokens(&self) -> usize
Get the context size (configured with ModelParameters::n_context_tokens) used by this model.
sourcefn bot_token_id(&self) -> Option<TokenId>
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.
sourcefn eot_token_id(&self) -> TokenId
fn eot_token_id(&self) -> TokenId
Get the end of text/end of string token ID. This value is defined by model implementers.
sourcefn inference_params(&self) -> InferenceParameters
fn inference_params(&self) -> InferenceParameters
Get the default InferenceSessionParameters for this model (used by InferenceSession::infer). This value is configured through ModelParameters::inference_params.
sourcefn inference_prompt_params(&self) -> InferenceWithPromptParameters
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.