Skip to content

Commit

Permalink
Better error messages for #62
Browse files Browse the repository at this point in the history
  • Loading branch information
johnml1135 committed Nov 20, 2023
1 parent d307a1b commit aad2600
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions machine/translation/huggingface/hugging_face_nmt_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,18 @@ def __init__(
and src_lang not in cast(Any, self._tokenizer).lang_code_to_id
and src_lang not in additional_special_tokens
):
raise ValueError(f"'{src_lang}' is not a valid language code.")
raise ValueError(
f"'{src_lang}' is not a valid language code. This error can happen when there is no matching training data and the language code is not in the NLLB-200."
)

if (
tgt_lang is not None
and tgt_lang not in cast(Any, self._tokenizer).lang_code_to_id
and tgt_lang not in additional_special_tokens
):
raise ValueError(f"'{tgt_lang}' is not a valid language code.")
raise ValueError(
f"'{tgt_lang}' is not a valid language code. This error can happen when there is no matching training data and the language code is not in the NLLB-200."
)

self._pipeline = _TranslationPipeline(
model=model,
Expand Down

0 comments on commit aad2600

Please sign in to comment.