Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Principle:Ggml org Llama cpp Chat Message Parsing

From Leeroopedia
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

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment