OpenNMT / OpenNMT/CTranslate2

opus-mt-en-zh does not respect the end token

Open
#1,694 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
4.7k
Forks
536
Avg merge
12h 12m
Merged PRs (30d)
4

Description

Using the code here (but in c++): https://opennmt.net/CTranslate2/guides/opus_mt.html

auto translationOptions = ctranslate2::TranslationOptions();
translationOptions.beam_size = 1;
translationOptions.return_scores = false;

const std::vector<std::vector<std::string>> batch = {pieces};
const std::vector<ctranslate2::TranslationResult> results = translators[modelPathStr]->translate_batch(batch, translationOptions);

Translating something simple like "Hello", gives the chinese characters "你好" again and again (up to 256 times), which I believe is the max sequence length. Interestingly, translating "Hello, World!" gives the expected result.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked Opus-MT guide and reproduce the C++ translation using "Hello" and "Hello, World!". Compare the generated sequences and inspect how end-token handling differs between the two inputs; done means the short input terminates at the end token instead of repeating until the maximum length.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.