From ceff4026029e58530365e6d14929ce8f26eb2d7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9mentine=20Fourrier?= <22726840+clefourrier@users.noreply.github.com> Date: Tue, 24 Jun 2025 14:04:59 +0200 Subject: [PATCH] Fix system prompt concatenated with instruction in chat template --- src/lighteval/tasks/prompt_manager.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lighteval/tasks/prompt_manager.py b/src/lighteval/tasks/prompt_manager.py index 3ec959cb9..22fc9d502 100644 --- a/src/lighteval/tasks/prompt_manager.py +++ b/src/lighteval/tasks/prompt_manager.py @@ -310,10 +310,10 @@ def get_examples( # noqa: C901 # System prompt and instruction if use_chat_template: - if system_prompt is not None: # We add system prompt and instruction jointly if possible - examples.insert(0, {"role": "system", "content": system_prompt + instruction}) - else: # Else we add the instruction to the first example - examples[0]["content"] = instruction + examples[0]["content"] + # We add the instruction to the first example + examples[0]["content"] = instruction + examples[0]["content"] + if system_prompt is not None: # We add system prompt if available + examples.insert(0, {"role": "system", "content": system_prompt}) return examples else: system_prompt = system_prompt if system_prompt is not None else ""