Hi,
Following the CTranslate2 documentation, I tried to use the C++ API to load converted models and translate tokens. However, it seems that when loading two models at the same time, the second translation becomes erroneous.
Namely, if we define
void f() {
ctranslate2::Translator translator("ende_ctranslate2/", ctranslate2::Device::CPU);
ctranslate2::TranslationResult result = translator.translate({"▁H", "ello", "▁world", "!"});
for (const auto& token : result.output())
std::cout << token << ' ';
std::cout << std::endl;
}
and then
void g() {
ctranslate2::Translator translator2("tests/data/models/v2/aren-transliteration", ctranslate2::Device::CPU);
ctranslate2::TranslationResult result = translator2.translate({"آ" ,"ت" ,"ز" ,"م" ,"و" ,"ن"});
for (const auto& token : result.output())
std::cout << token << ' ';
std::cout << std::endl;
}
Evaluating first f
then g
(in a main
function) I got
▁Hallo ▁Welt !
m u s t
as output, whereas evaluating first g
then f
I got
a t z m o n
▁Hallo !
It is strange that the first translation could impact the second one.
Could you please give some insight on this?
Thank you!