Skip to content

Comments

Set keep_trailing_newline=True to preserve the trailing newline when …#39

Open
abse4411 wants to merge 1 commit intoGen-Verse:mainfrom
abse4411:main
Open

Set keep_trailing_newline=True to preserve the trailing newline when …#39
abse4411 wants to merge 1 commit intoGen-Verse:mainfrom
abse4411:main

Conversation

@abse4411
Copy link

@abse4411 abse4411 commented Nov 10, 2025

Set keep_trailing_newline=True to preserve the trailing newline when rendering prompt templates

I noticed that the prompt Template of the paper contains a line break at the end,
Clipboard_Screenshot_1762746054
but the actual inference code will remove the line break by default when using the Jinja Template:

# obtain prompt
def get_prompt(data_i):
    return Template(system_prompts).render(problem = data_i["question"])

This can make a difference in the reproducibility of the experiment.
So I set keep_trailing_newline=True in the code to prevent this problem:

# obtain prompt
def get_prompt(data_i):
    return Template(system_prompts, keep_trailing_newline=True).render(problem = data_i["question"])

Here's my experimental results on the MATH500 dataset (using TraDo-8B-Instruct) :

Whether to remove the newline character ACC
No 75.46666666666667
Yes 74.86666666667

The experimental results with end-of-line breaks (75.46...) are very close to the reported value (75.5) ! I hope this PR can help others.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant