pub fn new(language: Language, device: Device) -> TranslationConfig {
        let (model_resource, config_resource, vocab_resource, merges_resource, prefix, model_type) =
            match language {
                Language::EnglishToFrench => RemoteTranslationResources::ENGLISH2FRENCH,
                Language::EnglishToCatalan => RemoteTranslationResources::ENGLISH2CATALAN,
                Language::EnglishToSpanish => RemoteTranslationResources::ENGLISH2SPANISH,
                Language::EnglishToPortuguese => RemoteTranslationResources::ENGLISH2PORTUGUESE,
                Language::EnglishToItalian => RemoteTranslationResources::ENGLISH2ITALIAN,
                Language::EnglishToRomanian => RemoteTranslationResources::ENGLISH2ROMANIAN,
                Language::EnglishToGerman => RemoteTranslationResources::ENGLISH2GERMAN,
                Language::EnglishToRussian => RemoteTranslationResources::ENGLISH2RUSSIAN,

                Language::FrenchToEnglish => RemoteTranslationResources::FRENCH2ENGLISH,
                Language::CatalanToEnglish => RemoteTranslationResources::CATALAN2ENGLISH,
                Language::SpanishToEnglish => RemoteTranslationResources::SPANISH2ENGLISH,
                Language::PortugueseToEnglish => RemoteTranslationResources::PORTUGUESE2ENGLISH,
                Language::ItalianToEnglish => RemoteTranslationResources::ITALIAN2ENGLISH,
                Language::RomanianToEnglish => RemoteTranslationResources::ROMANIAN2ENGLISH,
                Language::GermanToEnglish => RemoteTranslationResources::GERMAN2ENGLISH,
                Language::RussianToEnglish => RemoteTranslationResources::RUSSIAN2ENGLISH,

                Language::EnglishToFrenchV2 => RemoteTranslationResources::ENGLISH2FRENCH_V2,
                Language::EnglishToGermanV2 => RemoteTranslationResources::ENGLISH2GERMAN_V2,

                Language::FrenchToGerman => RemoteTranslationResources::FRENCH2GERMAN,
                Language::GermanToFrench => RemoteTranslationResources::GERMAN2FRENCH,
            };
        let model_resource = Resource::Remote(RemoteResource::from_pretrained(model_resource));
        let config_resource = Resource::Remote(RemoteResource::from_pretrained(config_resource));
        let vocab_resource = Resource::Remote(RemoteResource::from_pretrained(vocab_resource));
        let merges_resource = Resource::Remote(RemoteResource::from_pretrained(merges_resource));
        let prefix = match prefix {
            Some(value) => Some(value.to_string()),
            None => None,
        };
        TranslationConfig {
            model_resource,
            config_resource,
            vocab_resource,
            merges_resource,
            min_length: 0,
            max_length: 512,
            do_sample: false,
            early_stopping: false,
            num_beams: 6,
            temperature: 1.0,
            top_k: 50,
            top_p: 1.0,
            repetition_penalty: 1.0,
            length_penalty: 1.0,
            no_repeat_ngram_size: 0,
            num_return_sequences: 1,
            device,
            prefix,
            model_type,
        }
    }
/// Create a new `TranslationCondiguration` from an available language.
///
/// # Arguments
///
/// * `language` - `Language` enum value (e.g. `Language::EnglishToFrench`)
/// * `device` - `Device` to place the model on (CPU/GPU)
///
/// # Example
///
/// ```no_run
/// # fn main() -> anyhow::Result<()> {
/// use rust_bert::pipelines::translation::{Language, TranslationConfig};
/// use tch::Device;
///
/// let translation_config =
///     TranslationConfig::new(Language::FrenchToEnglish, Device::cuda_if_available());
/// # Ok(())
/// # }
/// ```
Create a new `TranslationCondiguration` from an available language.
Create a new ` TranslationCondiguration ` from an available language .
pub fn new(language: Language, device: Device) -> TranslationConfig {
        let (model_resource, config_resource, vocab_resource, merges_resource, prefix, model_type) =
            match language {
                Language::EnglishToFrench => RemoteTranslationResources::ENGLISH2FRENCH,
                Language::EnglishToCatalan => RemoteTranslationResources::ENGLISH2CATALAN,
                Language::EnglishToSpanish => RemoteTranslationResources::ENGLISH2SPANISH,
                Language::EnglishToPortuguese => RemoteTranslationResources::ENGLISH2PORTUGUESE,
                Language::EnglishToItalian => RemoteTranslationResources::ENGLISH2ITALIAN,
                Language::EnglishToRomanian => RemoteTranslationResources::ENGLISH2ROMANIAN,
                Language::EnglishToGerman => RemoteTranslationResources::ENGLISH2GERMAN,
                Language::EnglishToRussian => RemoteTranslationResources::ENGLISH2RUSSIAN,
                Language::FrenchToEnglish => RemoteTranslationResources::FRENCH2ENGLISH,
                Language::CatalanToEnglish => RemoteTranslationResources::CATALAN2ENGLISH,
                Language::SpanishToEnglish => RemoteTranslationResources::SPANISH2ENGLISH,
                Language::PortugueseToEnglish => RemoteTranslationResources::PORTUGUESE2ENGLISH,
                Language::ItalianToEnglish => RemoteTranslationResources::ITALIAN2ENGLISH,
                Language::RomanianToEnglish => RemoteTranslationResources::ROMANIAN2ENGLISH,
                Language::GermanToEnglish => RemoteTranslationResources::GERMAN2ENGLISH,
                Language::RussianToEnglish => RemoteTranslationResources::RUSSIAN2ENGLISH,
                Language::EnglishToFrenchV2 => RemoteTranslationResources::ENGLISH2FRENCH_V2,
                Language::EnglishToGermanV2 => RemoteTranslationResources::ENGLISH2GERMAN_V2,
                Language::FrenchToGerman => RemoteTranslationResources::FRENCH2GERMAN,
                Language::GermanToFrench => RemoteTranslationResources::GERMAN2FRENCH,
            };
        let model_resource = Resource::Remote(RemoteResource::from_pretrained(model_resource));
        let config_resource = Resource::Remote(RemoteResource::from_pretrained(config_resource));
        let vocab_resource = Resource::Remote(RemoteResource::from_pretrained(vocab_resource));
        let merges_resource = Resource::Remote(RemoteResource::from_pretrained(merges_resource));
        let prefix = match prefix {
            Some(value) => Some(value.to_string()),
            None => None,
        };
        TranslationConfig {
            model_resource,
            config_resource,
            vocab_resource,
            merges_resource,
            min_length: 0,
            max_length: 512,
            do_sample: false,
            early_stopping: false,
            num_beams: 6,
            temperature: 1.0,
            top_k: 50,
            top_p: 1.0,
            repetition_penalty: 1.0,
            length_penalty: 1.0,
            no_repeat_ngram_size: 0,
            num_return_sequences: 1,
            device,
            prefix,
            model_type,
        }
    }
pub fn new ( language : Language , device : Device ) -> TranslationConfig { let ( model_resource , config_resource , vocab_resource , merges_resource , prefix , model_type ) = match language { Language :: EnglishToFrench => RemoteTranslationResources :: ENGLISH2FRENCH , Language :: EnglishToCatalan => RemoteTranslationResources :: ENGLISH2CATALAN , Language :: EnglishToSpanish => RemoteTranslationResources :: ENGLISH2SPANISH , Language :: EnglishToPortuguese => RemoteTranslationResources :: ENGLISH2PORTUGUESE , Language :: EnglishToItalian => RemoteTranslationResources :: ENGLISH2ITALIAN , Language :: EnglishToRomanian => RemoteTranslationResources :: ENGLISH2ROMANIAN , Language :: EnglishToGerman => RemoteTranslationResources :: ENGLISH2GERMAN , Language :: EnglishToRussian => RemoteTranslationResources :: ENGLISH2RUSSIAN , Language :: FrenchToEnglish => RemoteTranslationResources :: FRENCH2ENGLISH , Language :: CatalanToEnglish => RemoteTranslationResources :: CATALAN2ENGLISH , Language :: SpanishToEnglish => RemoteTranslationResources :: SPANISH2ENGLISH , Language :: PortugueseToEnglish => RemoteTranslationResources :: PORTUGUESE2ENGLISH , Language :: ItalianToEnglish => RemoteTranslationResources :: ITALIAN2ENGLISH , Language :: RomanianToEnglish => RemoteTranslationResources :: ROMANIAN2ENGLISH , Language :: GermanToEnglish => RemoteTranslationResources :: GERMAN2ENGLISH , Language :: RussianToEnglish => RemoteTranslationResources :: RUSSIAN2ENGLISH , Language :: EnglishToFrenchV2 => RemoteTranslationResources :: ENGLISH2FRENCH_V2 , Language :: EnglishToGermanV2 => RemoteTranslationResources :: ENGLISH2GERMAN_V2 , Language :: FrenchToGerman => RemoteTranslationResources :: FRENCH2GERMAN , Language :: GermanToFrench => RemoteTranslationResources :: GERMAN2FRENCH , } ; let model_resource = Resource :: Remote ( RemoteResource :: from_pretrained ( model_resource ) ) ; let config_resource = Resource :: Remote ( RemoteResource :: from_pretrained ( config_resource ) ) ; let vocab_resource = Resource :: Remote ( RemoteResource :: from_pretrained ( vocab_resource ) ) ; let merges_resource = Resource :: Remote ( RemoteResource :: from_pretrained ( merges_resource ) ) ; let prefix = match prefix { Some ( value ) => Some ( value . to_string ( ) ) , None => None , } ; TranslationConfig { model_resource , config_resource , vocab_resource , merges_resource , min_length : 0 , max_length : 512 , do_sample : false , early_stopping : false , num_beams : 6 , temperature : 1.0 , top_k : 50 , top_p : 1.0 , repetition_penalty : 1.0 , length_penalty : 1.0 , no_repeat_ngram_size : 0 , num_return_sequences : 1 , device , prefix , model_type , } }
Create a new `TranslationCondiguration` from an available language.
Create a new ` TranslationCondiguration ` from an available language .
language
Language
device
Device
language
Language
device
Device
example
None
fn main() -> anyhow::result<()> {
use rust_bert::pipelines::translation::{Language, TranslationConfig};
use tch::Device.

let translation_config
TranslationConfig::new(Language::FrenchToEnglish, Device::cuda_if_available()).
use rust_bert :: pipelines :: translation :: { Language TranslationConfig } ; use tch :: Device . let translation_config TranslationConfig :: new ( Language :: FrenchToEnglish Device :: cuda_if_available () ) .
ok(())
None
}
None