Cannot get correct translation results (NLLB-200-distilled-600M)
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- cpp
调研方向
未识别出仓库文件或测试;从提供的 C++ 复现开始,检查 NLLB 模型输入和输出 token 的处理。检查编码后的输入、语言 token 设置、目标前缀和解码后的结果,然后将 CPU 行为和耗时与项目文档中记录的 C++ 用法进行比较。当可复现示例以预期速度生成正确翻译时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Hello, I am trying to use CTranslate2 to call the NLLB model, the program runs slowly and always returns rubbish results.
I compiled CTranslate2 and sentencepiece by Visual Studio 2022. Here are my codes:
#include <ctranslate2/translator.h>
#include <sentencepiece_processor.h>
#include <iostream>
#include <vector>
#include <string>
int main() {
std::string model_path = "F:/temp_work/LLM-models/nllb-200-distilled-600M-ct2-int8";
std::string sp_model_path = model_path + "/sentencepiece.bpe.model";
// Load the tokenize model
sentencepiece::SentencePieceProcessor processor;
const auto status = processor.Load(sp_model_path);
if (!status.ok()) {
std::cerr << status.ToString() << std::endl;
return -1;
}
// load the NLLB model
ctranslate2::Translator translator( model_path, ctranslate2::Device::CPU);
std::string input_text = u8"抽象代数重要的研究对象有:群、环和域。";
std::cout << input_text << std::endl;
// encode the string to token string
// You don't need to set what the language is.
std::vector<std::string> encoded_input_text;
processor.Encode(input_text, &encoded_input_text);
// encoded_input_text.insert(encoded_input_text.begin(), "zho_Hans");
//The input of the translation model should be a batch.
std::vector<std::vector <std::string>> input_batch = { encoded_input_text };
ctranslate2::TranslationOptions options;
options.max_decoding_length = 1024;
options.max_input_length = 512;
options.sampling_temperature = 0.7;
options.no_repeat_ngram_size = 0;
std::vector<std::vector<std::string>> target_prefix = { {"eng_Latn"} };
std::vector<ctranslate2::TranslationResult> results = translator.translate_batch(
input_batch,
target_prefix,
options);
std::vector<std::string> output = results[0].output();
std::string output_text;
processor.Decode(output, &output_text);
std::cout << "Translation: " << output_text << std::endl;
return 0;
}
- 主要语言
- C++
- 星标
- 4.8k
- 派生
- 557
- 平均合并
- 1 天 6 小时
- 30 天内合并 PR
- 24
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
OpenNMT/CTranslate2 的其他 Issue
-
MPS: GPT-2 produces NaN logits and invalid token IDs可能已有人在做 @TBO22 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 70/100
OpenNMT/CTranslate2#2154 · 1 条评论 ·
维护者通常 1 天内回复
-
Allow no-timestamp Whisper decoding beyond 224 tokens可能已有人在做 @Emre-Akgul 于 127 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
OpenNMT/CTranslate2#2074 ·
维护者通常 1 天内回复
-
T5Gemma fails on MPS: incorrect beam expansion with padded batches可能已有人在做 @TBO22 今天认领。 未关闭
难度 4/5 3-5 天 新手友好度 30/100
OpenNMT/CTranslate2#2153 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 8/100
OpenNMT/CTranslate2#2152 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 55/100
OpenNMT/CTranslate2#2149 ·
维护者通常 1 天内回复
查看 OpenNMT/CTranslate2 的全部 Issue
相似的 Issue
-
Documentation: Fix parameter markup, legacy branch link, and phrasing in Detachable Joints and Model Command tutorials可能已有人在做 @patelshivani2283-lab 今天认领。 未关闭
难度 1/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 82/100
-
难度 2/5 1-3 小时 新手友好度 75/100
Niko1221/Strata#6071 · 2 条评论 ·
维护者通常 4 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
KhronosGroup/Vulkan-Tutorial#551 ·
维护者通常 1 天内回复