Skip to main content

BaseLanguageModel

Trait BaseLanguageModel 

Source
pub trait BaseLanguageModel<Input: Send + Sync + 'static, Output: Send + Sync + 'static>: Runnable<Input, Output> {
    // Required methods
    fn model_name(&self) -> &str;
    fn get_num_tokens(&self, text: &str) -> usize;
    fn with_temperature(self, temp: f32) -> Self
       where Self: Sized;
    fn with_max_tokens(self, max: usize) -> Self
       where Self: Sized;

    // Provided methods
    fn temperature(&self) -> Option<f32> { ... }
    fn max_tokens(&self) -> Option<usize> { ... }
}
Expand description

语言模型基础 trait

所有语言模型包装器都继承自这个基类。 它继承自 Runnable 接口,提供统一的调用方式。

Required Methods§

Source

fn model_name(&self) -> &str

获取模型名称

Source

fn get_num_tokens(&self, text: &str) -> usize

计算文本的 token 数量

§参数
  • text - 要计算的文本
§返回

token 数量

Source

fn with_temperature(self, temp: f32) -> Self
where Self: Sized,

设置温度参数

Source

fn with_max_tokens(self, max: usize) -> Self
where Self: Sized,

设置最大 token 数

Provided Methods§

Source

fn temperature(&self) -> Option<f32>

获取温度参数

Source

fn max_tokens(&self) -> Option<usize>

获取最大 token 数

Implementors§