Skip to content

Commit 0eadcb7

Browse files
authored
load_model_tokenizer_for_generate should raise ValueError (#99)
This is what InstructionTextGenerationPipeline expects. Also same code used in: https://huggingface.co/databricks/dolly-v2-12b/blob/main/instruct_pipeline.py
1 parent dcef926 commit 0eadcb7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

training/generate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ def get_special_token_id(tokenizer: PreTrainedTokenizer, key: str) -> int:
5151
key (str): the key to convert to a single token
5252
5353
Raises:
54-
RuntimeError: if more than one ID was generated
54+
ValueError: if more than one ID was generated
5555
5656
Returns:
5757
int: the token ID for the given key
5858
"""
5959
token_ids = tokenizer.encode(key)
6060
if len(token_ids) > 1:
61-
raise RuntimeError(f"Expected only a single token for '{key}' but found {token_ids}")
61+
raise ValueError(f"Expected only a single token for '{key}' but found {token_ids}")
6262
return token_ids[0]
6363

6464

0 commit comments

Comments
 (0)