Skip to content

Commit c3acb64

Browse files
authored
Fixed system message in chat mode. (#2343)
When system message is not in the history tokenizer inserts default system message during applying of chat template. Adding to the history empty system message breaks this logic which leads to empty system message in the resulting model input. This affects chat accuracy. Ticket: CVS-169085
1 parent 035b591 commit c3acb64

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/cpp/src/visual_language/pipeline.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,9 @@ class VLMPipeline::VLMPipelineImpl : public VLMPipelineBase{
312312
m_history.clear();
313313
}
314314
m_inputs_embedder->start_chat(system_message);
315+
if (system_message.empty()) {
316+
return;
317+
}
315318
m_history = {{{"role", "system"}, {"content", system_message}}};
316319
}
317320

@@ -324,6 +327,7 @@ class VLMPipeline::VLMPipelineImpl : public VLMPipelineBase{
324327
m_language.get_tensor("attention_mask").set_shape({0, 0});
325328
// clear all chat history
326329
m_inputs_embedder->finish_chat();
330+
m_history.clear();
327331
}
328332

329333
Tokenizer get_tokenizer() const override {

0 commit comments

Comments
 (0)