Principle:Ggml org Llama cpp Chat Message Parsing
| Knowledge Sources | |
|---|---|
| Domains | Chat, Parsing |
| Last Updated | 2026-02-15 00:00 GMT |
Overview
Chat Message Parsing is the principle of extracting structured message components, tool calls, and metadata from raw chat model output text.
Description
This principle addresses the challenge of parsing unstructured or semi-structured text generated by chat models into well-defined message objects. Different models use different output formats for tool calls, function invocations, and multi-turn conversation markers. The parsing framework provides pluggable parsers (including XML-based and PEG-based approaches) that can handle various model-specific output conventions.
Usage
Apply this principle when processing chat model outputs that may contain tool calls, structured responses, or format-specific markers that need to be extracted into programmatic data structures.
Theoretical Basis
Chat message parsing employs multiple parsing strategies to handle the diversity of model output formats. XML-based parsers handle models that emit tool calls in XML tags. PEG (Parsing Expression Grammar) parsers provide a more formal grammar-based approach for models with complex output structures. The parser selection is driven by the chat template in use and the model's known output format. Each parser transforms raw text into a normalized message structure containing role, content, and optional tool call metadata.
Related Pages
- Implementation:Ggml_org_Llama_cpp_Chat_Parser
- Implementation:Ggml_org_Llama_cpp_Chat_Parser_Header
- Implementation:Ggml_org_Llama_cpp_Chat_Parser_Xml_Toolcall
- Implementation:Ggml_org_Llama_cpp_Chat_Parser_Xml_Toolcall_Header
- Implementation:Ggml_org_Llama_cpp_Chat_Peg_Parser
- Implementation:Ggml_org_Llama_cpp_Chat_Peg_Parser_Header
- Implementation:Ggml_org_Llama_cpp_Chat_Header