From 3f79f1d7121c0bab3b05632058eaf51d75fb7f21 Mon Sep 17 00:00:00 2001 From: teleprint-me <77757836+teleprint-me@users.noreply.github.com> Date: Mon, 2 Oct 2023 01:58:42 -0400 Subject: [PATCH] fix: Update Llama2 Formatting Template - Modify _system_template to better align system messages - Remove [INST] tag from system message format This change aims to fix the repetitive greeting issue in the conversational context by refining the message template used for Llama2. --- llama_cpp/llama_chat_format.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/llama_cpp/llama_chat_format.py b/llama_cpp/llama_chat_format.py index 9a09a28ee..8774d05f8 100644 --- a/llama_cpp/llama_chat_format.py +++ b/llama_cpp/llama_chat_format.py @@ -1,5 +1,6 @@ import dataclasses -from typing import Any, Dict, List, Optional, Tuple, Union, Protocol +from typing import Any, Dict, List, Optional, Protocol, Tuple, Union + from . import llama_types @@ -144,7 +145,7 @@ def format_llama2( messages: List[llama_types.ChatCompletionRequestMessage], **kwargs: Any, ) -> ChatFormatterResponse: - _system_template = "[INST] <>\n{system_message}\n<>\n\n" + _system_template = "<>\n{system_message}\n<>\n\n" _roles = dict(user="[INST]", assistant="[/INST]") _sep = "\n\n" system_message = _get_system_message(messages)