Views
No views yet
prompt_model function provided below demonstrates how the llama2 prompting method is implemented:1def llama_prompt(
2 message: str,
3 chat_history: list = None,
4 system: str = None
5) -> str:
6 do_strip = False
7 texts = [f"<s>[INST] <<SYS>>\n{system}\n<</SYS>>\n\n"] if system is not None else ["<s>[INST] "]
8 for user_input, response in chat_history:
9 user_input = user_input.strip() if do_strip else user_input
10 do_strip = True
11 texts.append(f"{user_input} [/INST] {response.strip()} </s><s>[INST] ")
12 message = message.strip() if do_strip else message
13 texts.append(f"{message} [/INST]")
14 return "".join(texts)prompt_model function takes a message as input, along with the chat_history and system_prompt. It generates a formatted text that includes the system prompt, user inputs, and the current message. This approach allows LinguaMatic to maintain context and provide more coherent and context-aware responses.