Skip to content

Commit b392165

Browse files
committed
add apply_chat_template method
Signed-off-by: Alexandros Koumparoulis <[email protected]>
1 parent 03eb746 commit b392165

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

Diff for: nemo/collections/common/tokenizers/huggingface/auto_tokenizer.py

+4
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,10 @@ def text_to_ids(self, text):
312312
ids = self.tokens_to_ids(tokens)
313313
return ids
314314

315+
def apply_chat_template(self, *args, **kwargs):
316+
""" Appies chat template and tokenizes results """
317+
return self.tokenizer.apply_chat_template(*args, **kwargs)
318+
315319
def ids_to_text(self, ids, remove_special_tokens=True):
316320
"""
317321
Converts token IDs back to text.

Diff for: nemo/collections/common/tokenizers/tokenizer_spec.py

+4
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ def ids_to_text(self, ids):
5151
def add_special_tokens(self, special_tokens: List[str]):
5252
raise NotImplementedError("To be implemented")
5353

54+
def apply_chat_template(self, *args, **kwargs):
55+
""" Appies chat template and tokenizes results """
56+
raise NotImplementedError("To be implemented")
57+
5458
@property
5559
def name(self):
5660
return type(self).__name__

0 commit comments

Comments
 (0)