1313# limitations under the License.
1414
1515import logging
16+ import warnings
1617from typing import Callable , Literal , Optional
1718
1819import datasets
@@ -41,7 +42,17 @@ def conversations_formatting_function(
4142 r"""
4243 return a callable function that takes in a "messages" dataset and returns a formatted dataset, based on the
4344 tokenizer apply chat template to the dataset along with the schema of the list of functions in the tools list.
45+
46+ .. deprecated:: 0.24.0
47+ `conversations_formatting_function` is deprecated and will be removed in version 0.27.
48+ Please use `tokenizer.apply_chat_template()` directly instead.
4449 """
50+ warnings .warn (
51+ "`conversations_formatting_function` is deprecated and will be removed in TRL 0.27. "
52+ "Please use `tokenizer.apply_chat_template()` directly instead." ,
53+ DeprecationWarning ,
54+ stacklevel = 2 ,
55+ )
4556
4657 def format_dataset (examples ):
4758 if isinstance (examples [messages_field ][0 ], list ):
@@ -61,7 +72,17 @@ def instructions_formatting_function(tokenizer: AutoTokenizer):
6172 r"""
6273 return a callable function that takes in an "instructions" dataset and returns a formatted dataset, based on the
6374 tokenizer apply chat template to the dataset
75+
76+ .. deprecated:: 0.24.0
77+ `instructions_formatting_function` is deprecated and will be removed in version 0.27.
78+ Please use `tokenizer.apply_chat_template()` directly instead.
6479 """
80+ warnings .warn (
81+ "`instructions_formatting_function` is deprecated and will be removed in TRL 0.27. "
82+ "Please use `tokenizer.apply_chat_template()` directly instead." ,
83+ DeprecationWarning ,
84+ stacklevel = 2 ,
85+ )
6586
6687 def format_dataset (examples ):
6788 if isinstance (examples ["prompt" ], list ):
@@ -99,7 +120,18 @@ def get_formatting_func_from_dataset(
99120
100121 Returns:
101122 Callable: Formatting function if the dataset format is supported else None
123+
124+ .. deprecated:: 0.24.0
125+ `get_formatting_func_from_dataset` is deprecated and will be removed in version 0.27.
126+ Please use `tokenizer.apply_chat_template()` directly instead.
102127 """
128+ warnings .warn (
129+ "`get_formatting_func_from_dataset` is deprecated and will be removed in TRL 0.27. "
130+ "Please use `tokenizer.apply_chat_template()` directly instead." ,
131+ DeprecationWarning ,
132+ stacklevel = 2 ,
133+ )
134+
103135 if isinstance (dataset , Dataset ):
104136 if "messages" in dataset .features :
105137 if dataset .features ["messages" ] == FORMAT_MAPPING ["chatml" ]:
0 commit comments