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

Đang mở
#2,017 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
cpp
Lĩnh vực
machine-learning

Hướng nghiên cứu

Không xác định được tệp nào trong repository hoặc bài kiểm thử nào; hãy bắt đầu với bản tái hiện C++ được cung cấp và xem xét cách xử lý đầu vào của mô hình NLLB và các token đầu ra. Kiểm tra đầu vào đã mã hóa, thiết lập token ngôn ngữ, tiền tố đích và kết quả đã giải mã, sau đó so sánh hành vi và thời gian chạy trên CPU với cách sử dụng C++ được ghi lại của dự án. Được xem là hoàn tất khi một ví dụ có thể tái hiện tạo ra bản dịch chính xác ở tốc độ mong đợi.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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;
}

Ngôn ngữ chính
C++
Star
4.8k
Fork
557
Merge trung bình
1 ngày 6 giờ
Pull request đã merge (30 ngày)
24

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của OpenNMT/CTranslate2

Tất cả issue của OpenNMT/CTranslate2

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.