Inconsistency between the demo result and my result

#13
by qsn - opened

I apologize if the question seems silly, I am a complete newbie in AI and ML. I am running model.safetensors in the RUST language.

use rust_bert::pipelines::translation::{Language, TranslationModel, TranslationConfig};
use rust_bert::resources::LocalResource;
use rust_bert::pipelines::common::{ModelResource, ModelType};
use tch::Device;
use std::path::PathBuf;
use std::time::Instant;
use rust_bert::m2m_100::{M2M100SourceLanguages, M2M100TargetLanguages};

fn main() -> anyhow::Result<()> {
let model_resource = ModelResource::Torch(Box::new(LocalResource {
local_path: PathBuf::from("...small100//model.safetensors"),
}));

let config_resource = LocalResource {
    local_path: PathBuf::from("...//small100//config.json"),
};
let vocab_resource = LocalResource {
    local_path: PathBuf::from("...//small100//vocab.json"),
};
let source_spm_resource = LocalResource {
    local_path: PathBuf::from("...//small100//sentencepiece.bpe.model"),
};

let config = TranslationConfig::new(
    ModelType::M2M100,
    model_resource,
    config_resource,
    vocab_resource,
    Some(source_spm_resource),
    M2M100SourceLanguages::M2M100_418M,
    M2M100TargetLanguages::M2M100_418M,
    Device::cuda_if_available(),
);

let model = TranslationModel::new(config)?;

let source_sentence = "Geralt of Rivia, a monster hunter known as a Witcher, roams these lands seeking contracts to rid villages of monstrous threats.";

let start = Instant::now();
let output = model.translate(&[source_sentence], Language::French, Language::English)?;
let duration = start.elapsed();

println!("Result: {:?}", output);
println!("Duration {:?}", duration);

Ok(())

}

French
Demo result: "Geralt de Rivia, un chasseur de monstres connu sous le nom de sorcière, tourne ces terres à la recherche de contrats pour libérer les villages des menaces monstres."
My result: "teur Geralt de Rivia, un chasseur de monstres connu sous le nom de sorcière, tourne ces terres à la recherche de contrats pour libérer les villages des menaces monstres."

Russian
Demo result: "Геральт из Ривии, охотник на чудовища, известный как ведьма, бегает в эти земли в поисках контрактов для освобождения деревень от чудовищных угроз."
My result: "жек из Ривы, охотник на чудовища, известный как ведьма, бегает в эти земли в поисках контрактов, чтобы избавиться от монстральных угроз деревень."

What could be the cause? I haven't changed the configuration

Sign up or log in to comment