Cannot get correct translation results (NLLB-200-distilled-600M)

オープン
#2,017 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
cpp

調査の方向性

リポジトリのファイルやテストは特定されていないため、提供された C++ の再現コードから始め、NLLB モデルの入力と出力トークンの処理を確認します。エンコードされた入力、言語トークンの設定、ターゲットプレフィックス、デコードされた結果を確認し、その後、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時間
マージ済み PR(30日)
24

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

OpenNMT/CTranslate2 のほかの issue

OpenNMT/CTranslate2 の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。