Views
No views yet
prompt_model function provided below demonstrates how the llama2 prompting method is implemented:1def prompt_model(message: str, chat_history,
2 system_prompt: str) -> str:
3 do_strip = False
4 texts = [f'<s>[INST] <<SYS>>\n{system_prompt}\n<</SYS>>\n\n']
5 for user_input, response in chat_history:
6 user_input = user_input.strip() if do_strip else user_input
7 do_strip = True
8 texts.append(f'{user_input} [/INST] {response.strip()} </s><s>[INST] ')
9 message = message.strip() if do_strip else message
10 texts.append(f'{message} [/INST]')
11 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.