LLMON: An LLM-Native Markup Language, now in Granite 4.1 3B and 8B
本文为原文前 6,000 字符的节选翻译,完整内容请查看原文。
LLMs rely on their context to generate the next set of tokens. Over a long trajectory, the context fills with numerous types of components: a system prompt, past conversation turns, instructions that act on retrieved documents, tool responses or user data, requirements constraining the allowed output, and reasoning chains. The context carries a rich structure, most of which is either implicit to the model or encoded in formats such as JSON that were not designed to be digested by LLMs.
大语言模型(LLM)依赖其上下文来生成下一组标记。在长期的交互过程中,上下文中会充斥着多种类型的组件:系统提示词、过往对话轮次、针对检索文档的操作指令、工具响应或用户数据、限制输出的要求以及推理链。这些上下文承载着丰富的结构,但其中大部分对模型而言是隐式的,或者被编码在并非为大语言模型设计的格式(如 JSON)中。
This is one of the main reasons LLMs, particularly those on the smaller end of the scale, are brittle and sometimes fail in unexpected ways. The lack of explicit structure can also be exploited by attackers, for example, in the form of prompt injections. To address this, we developed LLMON (LLM Object Notation, pronounced “lemon”), an LLM-native markup language for explicitly communicating structure and semantics to the models.
这是大语言模型(尤其是较小规模的模型)表现脆弱且有时会以意想不到的方式失败的主要原因之一。缺乏明确的结构也可能被攻击者利用,例如通过提示词注入攻击。为了解决这个问题,我们开发了 LLMON(LLM 对象表示法,发音为“lemon”),这是一种大语言模型原生的标记语言,用于向模型明确传达结构和语义。
Semantically coherent components are marked with meaningful tags which are wrapped in reserved special-token delimiters. Data schemas, including nesting, are stated in a way that is unambiguous to a causal LLM. Unique IDs make it possible to point to specific instructions, which could reside anywhere in the context, and bind them to the data payloads they should act on, analogous to the way functions are called and arguments are passed to them in programming languages.
语义连贯的组件使用有意义的标签进行标记,并包裹在预留的特殊标记分隔符中。数据模式(包括嵌套)以一种对因果大语言模型而言无歧义的方式进行声明。唯一标识符(ID)使得指向特定指令成为可能,无论这些指令位于上下文的何处,并能将它们绑定到需要处理的数据负载上,这类似于编程语言中调用函数并传递参数的方式。
Today we are releasing two experimental preview models, derived from Granite 4.1 base models, trained to consume and generate LLMON-marked text: granite-4.1-3b-LLMON-preview and granite-4.1-8b-LLMON-preview. We are also releasing a GitHub repo, which includes a toolkit for working with LLMON and examples of workflows and templates.
今天,我们发布了两个实验性预览模型,它们衍生自 Granite 4.1 基础模型,经过训练可以处理和生成 LLMON 标记的文本:granite-4.1-3b-LLMON-preview 和 granite-4.1-8b-LLMON-preview。我们还发布了一个 GitHub 仓库,其中包含用于处理 LLMON 的工具包以及工作流和模板示例。
What it enables: Indirect prompt injections, hidden in user data, are mostly ignored by LLMON models due to explicit instruction/data separation. For some benchmarks, attack success rates drop to nearly zero, whereas regular instruction-tuned models get hijacked with high probability. This is achieved while maintaining general capability relative to Granite 4.1 Instruct models.
它带来的优势:由于实现了明确的指令与数据分离,隐藏在用户数据中的间接提示词注入攻击大多会被 LLMON 模型忽略。在某些基准测试中,攻击成功率降至几乎为零,而常规的指令微调模型则极易被劫持。在实现这一点的同时,模型仍保持了与 Granite 4.1 Instruct 模型相当的通用能力。
Unrelated passages, old chat turns, and tool outputs don’t get pulled into the answer because each instruction is bound to the exact data it applies to. Instructions, data, and requirements are clearly marked so that their structure and meanings at the application’s code level can be leveraged by the model. Try it out in Mellea, which has native LLMON support enabled by automatically LLMONizing its LLM calls.
无关的段落、旧的对话轮次和工具输出不会被带入答案中,因为每条指令都绑定到了它所适用的确切数据上。指令、数据和要求被清晰地标记,以便模型能够利用应用程序代码层面的结构和含义。欢迎在 Mellea 中试用,它通过自动将 LLM 调用“LLMON 化”实现了对 LLMON 的原生支持。
Why not JSON? JSON was designed for parsers, not for causal language models. The tokenizer is not constrained to respect the grammar, and structure is encoded by tokens ({, ”, :) that may also appear in normal text. To a model, a quotation mark inside a document and a quotation mark that closes a field are the same token. Escaping rules that are clear to a parser are only statistical patterns to a model.
为什么不用 JSON?JSON 是为解析器设计的,而不是为因果语言模型设计的。分词器不受语法约束,且结构由可能出现在普通文本中的标记(如 {、”、:)进行编码。对于模型而言,文档内部的引号和用于关闭字段的引号是同一个标记。对解析器来说清晰的转义规则,对模型而言仅仅是统计模式。
LLMON, on the other hand, is an XML-like markup whose structural delimiters are reserved special tokens rather than characters, so structure and content use separate parts of the vocabulary. Tags are stated at the beginning of each span, and the boundaries between spans are explicit. Nested structures are stated locally so the model does not need to keep track of the hierarchy over long spans.
相比之下,LLMON 是一种类似 XML 的标记语言,其结构分隔符是预留的特殊标记而非字符,因此结构和内容使用了词汇表中不同的部分。标签在每个区间的开头声明,区间边界明确。嵌套结构在局部声明,因此模型无需在长跨度内追踪层级关系。
How is LLMON related to chat templates? LLMON does not replace chat templates; rather, it enriches them. Where regular chat templates tell the model which part belongs to which role (system, user, assistant), LLMON tells it what each component means and how components relate to each other, within and across roles.
LLMON 与聊天模板有何关系?LLMON 并不取代聊天模板,而是对其进行了丰富。常规聊天模板告诉模型哪部分属于哪个角色(系统、用户、助手),而 LLMON 则告诉模型每个组件的含义,以及组件在角色内部和角色之间是如何关联的。