pub fn new(
        config: SequenceClassificationConfig,
    ) -> Result<SequenceClassificationModel, RustBertError> {
        let config_path = config.config_resource.get_local_path()?;
        let vocab_path = config.vocab_resource.get_local_path()?;
        let weights_path = config.model_resource.get_local_path()?;
        let merges_path = if let Some(merges_resource) = &config.merges_resource {
            Some(merges_resource.get_local_path()?)
        } else {
            None
        };
        let device = config.device;

        let tokenizer = TokenizerOption::from_file(
            config.model_type,
            vocab_path.to_str().unwrap(),
            merges_path.as_deref().map(|path| path.to_str().unwrap()),
            config.lower_case,
            config.strip_accents,
            config.add_prefix_space,
        )?;
        let mut var_store = VarStore::new(device);
        let model_config = ConfigOption::from_file(config.model_type, config_path);
        let sequence_classifier =
            SequenceClassificationOption::new(config.model_type, &var_store.root(), &model_config);
        let label_mapping = model_config.get_label_mapping();
        var_store.load(weights_path)?;
        Ok(SequenceClassificationModel {
            tokenizer,
            sequence_classifier,
            label_mapping,
            var_store,
        })
    }
/// Build a new `SequenceClassificationModel`
///
/// # Arguments
///
/// * `config` - `SequenceClassificationConfig` object containing the resource references (model, vocabulary, configuration) and device placement (CPU/GPU)
///
/// # Example
///
/// ```no_run
/// # fn main() -> anyhow::Result<()> {
/// use rust_bert::pipelines::sequence_classification::SequenceClassificationModel;
///
/// let model = SequenceClassificationModel::new(Default::default())?;
/// # Ok(())
/// # }
/// ```
Build a new `SequenceClassificationModel`
Build a new ` SequenceClassificationModel `
pub fn new(
        config: SequenceClassificationConfig,
    ) -> Result<SequenceClassificationModel, RustBertError> {
        let config_path = config.config_resource.get_local_path()?;
        let vocab_path = config.vocab_resource.get_local_path()?;
        let weights_path = config.model_resource.get_local_path()?;
        let merges_path = if let Some(merges_resource) = &config.merges_resource {
            Some(merges_resource.get_local_path()?)
        } else {
            None
        };
        let device = config.device;
        let tokenizer = TokenizerOption::from_file(
            config.model_type,
            vocab_path.to_str().unwrap(),
            merges_path.as_deref().map(|path| path.to_str().unwrap()),
            config.lower_case,
            config.strip_accents,
            config.add_prefix_space,
        )?;
        let mut var_store = VarStore::new(device);
        let model_config = ConfigOption::from_file(config.model_type, config_path);
        let sequence_classifier =
            SequenceClassificationOption::new(config.model_type, &var_store.root(), &model_config);
        let label_mapping = model_config.get_label_mapping();
        var_store.load(weights_path)?;
        Ok(SequenceClassificationModel {
            tokenizer,
            sequence_classifier,
            label_mapping,
            var_store,
        })
    }
pub fn new ( config : SequenceClassificationConfig , ) -> Result < SequenceClassificationModel , RustBertError > { let config_path = config . config_resource . get_local_path ( ) ? ; let vocab_path = config . vocab_resource . get_local_path ( ) ? ; let weights_path = config . model_resource . get_local_path ( ) ? ; let merges_path = if let Some ( merges_resource ) = & config . merges_resource { Some ( merges_resource . get_local_path ( ) ? ) } else { None } ; let device = config . device ; let tokenizer = TokenizerOption :: from_file ( config . model_type , vocab_path . to_str ( ) . unwrap ( ) , merges_path . as_deref ( ) . map ( | path | path . to_str ( ) . unwrap ( ) ) , config . lower_case , config . strip_accents , config . add_prefix_space , ) ? ; let mut var_store = VarStore :: new ( device ) ; let model_config = ConfigOption :: from_file ( config . model_type , config_path ) ; let sequence_classifier = SequenceClassificationOption :: new ( config . model_type , & var_store . root ( ) , & model_config ) ; let label_mapping = model_config . get_label_mapping ( ) ; var_store . load ( weights_path ) ? ; Ok ( SequenceClassificationModel { tokenizer , sequence_classifier , label_mapping , var_store , } ) }
Build a new `SequenceClassificationModel`
Build a new ` SequenceClassificationModel `
config
SequenceClassificationConfig
config
SequenceClassificationConfig
example
None
fn main() -> anyhow::result<()> {
use rust_bert::pipelines::sequence_classification::SequenceClassificationModel.

let model = SequenceClassificationModel::new(Default::default())?.
use rust_bert :: pipelines :: sequence_classification :: SequenceClassificationModel . let model = SequenceClassificationModel :: new ( Default :: default () ) ? .
ok(())
None
}
None