You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
hi,
I am writing a program using qt. and When I call the function translate_batch, the program not stopping, my code is below:
I found the solution in the documentation and other references, but not find useful information. please help me to solve the problem, thanks.
int main()
{
SetConsoleOutputCP(CP_UTF8);
sentencepiece::SentencePieceProcessor processor;
const auto status = processor.Load("./spm.model");
std::vector<std::string> tokens;
processor.Encode("我参加了毕业典礼", &tokens);
for (const std::string &token : tokens) {
std::cout << token << std::endl;
}
std::vector<std::vector<std::string>> batch;
std::vector<std::string>::iterator it;
it = tokens.begin();
tokens.insert(it, "zho_Hans");
it = tokens.end();
tokens.insert(it, "</s>");
batch.push_back(tokens);
ctranslate2::Translator translator("./nllb", ctranslate2::Device::CPU);
std::vector<std::vector<std::string>> target_prefix;
for (int i = 0; i < batch.size(); i++) {
target_prefix.push_back({"eng_Latn"});
}
TranslationOptions options1 = TranslationOptions();
//options1.beam_size = 1;
std::vector<ctranslate2::TranslationResult> results = translator.translate_batch(batch, target_prefix, options1, 1, BatchType::Tokens);
for (const auto& translatedTokens : results) {
std::string text;
processor.Decode(translatedTokens.output(), &text);
//std::string result = tokenizer.detokenize(translatedTokens.output());
text = text.substr(9);
std::cout << text << ' ';
std::cout << std::endl;
}
return 1;
}
The text was updated successfully, but these errors were encountered:
hi,
I am writing a program using qt. and When I call the function translate_batch, the program not stopping, my code is below:
I found the solution in the documentation and other references, but not find useful information. please help me to solve the problem, thanks.
int main()
{
SetConsoleOutputCP(CP_UTF8);
sentencepiece::SentencePieceProcessor processor;
const auto status = processor.Load("./spm.model");
}
The text was updated successfully, but these errors were encountered: