pub fn new(
        conversation_config: ConversationConfig,
    ) -> Result<ConversationModel, RustBertError> {
        let generate_config = GenerateConfig {
            model_resource: conversation_config.model_resource,
            config_resource: conversation_config.config_resource,
            merges_resource: conversation_config.merges_resource,
            vocab_resource: conversation_config.vocab_resource,
            min_length: conversation_config.min_length,
            max_length: conversation_config.max_length,
            do_sample: conversation_config.do_sample,
            early_stopping: conversation_config.early_stopping,
            num_beams: conversation_config.num_beams,
            temperature: conversation_config.temperature,
            top_k: conversation_config.top_k,
            top_p: conversation_config.top_p,
            repetition_penalty: conversation_config.repetition_penalty,
            length_penalty: conversation_config.length_penalty,
            no_repeat_ngram_size: conversation_config.no_repeat_ngram_size,
            num_return_sequences: conversation_config.num_return_sequences,
            device: conversation_config.device,
        };

        let model = GPT2Generator::new(generate_config)?;
        let eos_token_id = *model.get_eos_ids().as_ref().unwrap().first().unwrap();
        let max_allowed_length =
            conversation_config.max_length as u64 - conversation_config.min_length_for_response;
        Ok(ConversationModel {
            model,
            eos_token_id,
            max_allowed_context_length: max_allowed_length,
        })
    }
/// Build a new `ConversationModel`
///
/// # Arguments
///
/// * `conversation_config` - `ConversationConfig` object containing the resource references (model, vocabulary, configuration), conversation options and device placement (CPU/GPU)
///
/// # Example
///
/// ```no_run
/// # fn main() -> anyhow::Result<()> {
/// use rust_bert::pipelines::conversation::ConversationModel;
///
/// let conversation_model = ConversationModel::new(Default::default())?;
/// # Ok(())
/// # }
/// ```
Build a new `ConversationModel`
Build a new ` ConversationModel `
pub fn new(
        conversation_config: ConversationConfig,
    ) -> Result<ConversationModel, RustBertError> {
        let generate_config = GenerateConfig {
            model_resource: conversation_config.model_resource,
            config_resource: conversation_config.config_resource,
            merges_resource: conversation_config.merges_resource,
            vocab_resource: conversation_config.vocab_resource,
            min_length: conversation_config.min_length,
            max_length: conversation_config.max_length,
            do_sample: conversation_config.do_sample,
            early_stopping: conversation_config.early_stopping,
            num_beams: conversation_config.num_beams,
            temperature: conversation_config.temperature,
            top_k: conversation_config.top_k,
            top_p: conversation_config.top_p,
            repetition_penalty: conversation_config.repetition_penalty,
            length_penalty: conversation_config.length_penalty,
            no_repeat_ngram_size: conversation_config.no_repeat_ngram_size,
            num_return_sequences: conversation_config.num_return_sequences,
            device: conversation_config.device,
        };
        let model = GPT2Generator::new(generate_config)?;
        let eos_token_id = *model.get_eos_ids().as_ref().unwrap().first().unwrap();
        let max_allowed_length =
            conversation_config.max_length as u64 - conversation_config.min_length_for_response;
        Ok(ConversationModel {
            model,
            eos_token_id,
            max_allowed_context_length: max_allowed_length,
        })
    }
pub fn new ( conversation_config : ConversationConfig , ) -> Result < ConversationModel , RustBertError > { let generate_config = GenerateConfig { model_resource : conversation_config . model_resource , config_resource : conversation_config . config_resource , merges_resource : conversation_config . merges_resource , vocab_resource : conversation_config . vocab_resource , min_length : conversation_config . min_length , max_length : conversation_config . max_length , do_sample : conversation_config . do_sample , early_stopping : conversation_config . early_stopping , num_beams : conversation_config . num_beams , temperature : conversation_config . temperature , top_k : conversation_config . top_k , top_p : conversation_config . top_p , repetition_penalty : conversation_config . repetition_penalty , length_penalty : conversation_config . length_penalty , no_repeat_ngram_size : conversation_config . no_repeat_ngram_size , num_return_sequences : conversation_config . num_return_sequences , device : conversation_config . device , } ; let model = GPT2Generator :: new ( generate_config ) ? ; let eos_token_id = * model . get_eos_ids ( ) . as_ref ( ) . unwrap ( ) . first ( ) . unwrap ( ) ; let max_allowed_length = conversation_config . max_length as u64 - conversation_config . min_length_for_response ; Ok ( ConversationModel { model , eos_token_id , max_allowed_context_length : max_allowed_length , } ) }
Build a new `ConversationModel`
Build a new ` ConversationModel `
conversation_config
ConversationConfig
conversation_config
ConversationConfig
example
None
fn main() -> anyhow::result<()> {
use rust_bert::pipelines::conversation::ConversationModel.

let conversation_model = ConversationModel::new(Default::default())?.
use rust_bert :: pipelines :: conversation :: ConversationModel . let conversation_model = ConversationModel :: new ( Default :: default () ) ? .
ok(())
None
}
None