Merge pull request #4533 from UsableMachines/nick/fix-granite-prompt-template

Fix Granite Prompt template
This commit is contained in:
Krish Dholakia
2024-07-03 18:45:25 -07:00
committed by GitHub
+6 -2
View File
@@ -531,6 +531,7 @@ def format_prompt_togetherai(messages, prompt_format, chat_template):
### IBM Granite
def ibm_granite_pt(messages: list):
"""
IBM's Granite models uses the template:
@@ -547,10 +548,13 @@ def ibm_granite_pt(messages: list):
},
"user": {
"pre_message": "<|user|>\n",
"post_message": "\n",
# Assistant tag is needed in the prompt after the user message
# to avoid the model completing the users sentence before it answers
# https://www.ibm.com/docs/en/watsonx/w-and-w/2.0.x?topic=models-granite-13b-chat-v2-prompting-tips#chat
"post_message": "\n<|assistant|>\n",
},
"assistant": {
"pre_message": "<|assistant|>\n",
"pre_message": "",
"post_message": "\n",
},
},