MCPcopy Index your code
hub / github.com/abetlen/llama-cpp-python / format_llama3

Function format_llama3

llama_cpp/llama_chat_format.py:1067–1080  ·  view source on GitHub ↗
(
    messages: List[llama_types.ChatCompletionRequestMessage],
    **kwargs: Any,
)

Source from the content-addressed store, hash-verified

1065# https://github.com/meta-llama/llama3/blob/main/llama/tokenizer.py#L202-L229
1066@register_chat_format("llama-3")
1067def format_llama3(
1068 messages: List[llama_types.ChatCompletionRequestMessage],
1069 **kwargs: Any,
1070) -> ChatFormatterResponse:
1071 _roles = dict(
1072 system="<|start_header_id|>system<|end_header_id|>\n\n",
1073 user="<|start_header_id|>user<|end_header_id|>\n\n",
1074 assistant="<|start_header_id|>assistant<|end_header_id|>\n\n",
1075 )
1076 _sep = "<|eot_id|>"
1077 _messages = _map_roles(messages, _roles)
1078 _messages.append((_roles["assistant"], None))
1079 _prompt = _format_no_colon_single("", _messages, _sep)
1080 return ChatFormatterResponse(prompt=_prompt, stop=_sep)
1081
1082
1083@register_chat_format("alpaca")

Callers

nothing calls this directly

Calls 4

_map_rolesFunction · 0.85
_format_no_colon_singleFunction · 0.85
appendMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…