Skip to content

Commit

Permalink
Support single token decode for CodeGenTokenizer (#28628)
Browse files Browse the repository at this point in the history
convert token id to list in .decode()
  • Loading branch information
cmathw authored and Ita Zaporozhets committed May 14, 2024
1 parent f946b1e commit a81e4c8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/transformers/models/codegen/tokenization_codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import numpy as np
import regex as re

from ...utils import is_tf_available, is_torch_available, logging
from ...utils import is_tf_available, is_torch_available, logging, to_py_obj


if TYPE_CHECKING:
Expand Down Expand Up @@ -352,6 +352,9 @@ def decode(
Returns:
`str`: The decoded sentence.
"""

token_ids = to_py_obj(token_ids)

decoded_text = super()._decode(
token_ids=token_ids,
skip_special_tokens=skip_special_tokens,
Expand Down

0 comments on commit a81e4c8

Please sign in to comment.