@@ -185,7 +185,25 @@ def apply_chat_template(
185
185
"tools": [], # Function call definitions
186
186
"documents": [] # RAG context documents
187
187
}
188
+
189
+ Note: The legacy PaddleFormers `add_generation_prompt` default was True.
190
+ For backward compatibility, we changed the default behavior of the HuggingFace
191
+ `apply_chat_template` function from False to True.
192
+
193
+ In future usage, explicitly pass the `add_generation_prompt` parameter
194
+ to clearly specify the intended behavior.
188
195
"""
196
+ if "add_generation_prompt" not in kwargs :
197
+ logger .warning_once (
198
+ "Warning: apply_chat_template() called without explicit `add_generation_prompt` "
199
+ "parameter. Current default=True differs from Hugging Face's default=False. "
200
+ "Always specify this parameter to ensure consistent behavior across versions."
201
+ )
202
+
203
+ # Changed the default behavior:
204
+ # Original HF default was False, but we set it to True for compatibility
205
+ add_generation_prompt = kwargs .pop ("add_generation_prompt" , True )
206
+
189
207
if isinstance (conversation , dict ):
190
208
messages = conversation .get ("messages" , None )
191
209
tools = conversation .get ("tools" , None )
@@ -202,12 +220,14 @@ def apply_chat_template(
202
220
chat_template = chat_template ,
203
221
tools = tools ,
204
222
documents = documents ,
223
+ add_generation_prompt = add_generation_prompt ,
205
224
** kwargs ,
206
225
)
207
226
else :
208
227
return super ().apply_chat_template (
209
228
conversation = conversation ,
210
229
chat_template = chat_template ,
230
+ add_generation_prompt = add_generation_prompt ,
211
231
** kwargs ,
212
232
)
213
233
0 commit comments