Skip to content

Commit

Permalink
Add answer prefill support to chat inference
Browse files Browse the repository at this point in the history
  • Loading branch information
ProbablyFaiz committed Jul 17, 2024
1 parent 519b81a commit c6c9a17
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion rl/llm/engines.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,11 @@ def _apply_chat_template(tokenizer, messages):
"there's no guarantee this will work."
)
_WARNED_GEMMA = True
# If it seems like the user is trying to prefill part of the assistant
# response, don't append another new assistant turn.
add_generation_prompt = messages[-1]["role"] != "assistant"
return tokenizer.apply_chat_template(
messages, add_generation_prompt=True, tokenize=False
messages, add_generation_prompt=add_generation_prompt, tokenize=False
)


Expand Down

0 comments on commit c6c9a17

Please sign in to comment.