Building with AI

Granite 4.1 models adopt LLMON to block prompt injections

Hugging Face releases Granite 4.1 3B and 8B preview models trained on LLMON, a markup language that separates instructions from data to prevent indirect prompt injections.

A glass cube with organized tagged layers beside tangled paper strips
Illustration generated for this article

Hugging Face has released two experimental preview models, granite-4.1-3b-LLMON-preview and granite-4.1-8b-LLMON-preview, designed to handle structured context more robustly than traditional large language models. These models, derived from the Granite 4.1 base, are trained to consume and generate LLMON (LLM Object Notation), a new markup language that explicitly separates instructions from data payloads. The release aims to address brittleness in smaller models and mitigate security risks like indirect prompt injection by enforcing clear semantic boundaries within the model's context window.

What happened

The core issue addressed by this release is the structural ambiguity inherent in how LLMs process context. Standard models receive a mix of system prompts, conversation history, retrieved documents, and tool outputs, often encoded in formats like JSON that were designed for parsers, not causal language models. To a transformer, the tokens representing JSON structure are statistically similar to content tokens, making it difficult for the model to distinguish between a command and data, especially over long contexts. This ambiguity leads to unexpected failures and makes models vulnerable to attacks where malicious instructions are hidden within user-provided data.

To solve this, developers created LLMON, an LLM-native markup language that uses reserved special-token delimiters to mark semantically coherent components. Unlike JSON, where structure is inferred from characters like braces and quotes, LLMON uses explicit tags wrapped in unique tokens that do not appear in normal text. This allows the model to clearly identify which parts of the context are instructions, which are data, and which are requirements. The new Granite 4.1 preview models are the first to be trained specifically to understand and generate this format, learning to bind instructions to specific data payloads via unique IDs, similar to function calls in programming.

The release includes not just the models but also a GitHub repository with a toolkit for working with LLMON, conversion tools for translating JSON to LLMON losslessly, and example workflows. Hugging Face emphasizes that these are experimental previews intended for exploration and evaluation rather than production deployment. They invite the community to test the models, report findings, and explore use cases through GitHub Discussions, noting that while the models show strong resistance to static indirect prompt injections, work on adaptive attacks is ongoing.

How it works

LLMON operates by enriching standard chat templates rather than replacing them. When a developer constructs a message list, they can name parts of a turn as instruction, data, or requirement, and mark them as executable or non-executable. The chat template then renders these components into LLMON blocks using reserved single tokens for delimiters and two-character block IDs. An execution block at the end of the rendered output explicitly states which instruction to run, on which data, subject to which requirements, and where to place the output. This ensures the model only follows instructions that are explicitly bound to the relevant data, ignoring unrelated passages or decoy instructions present in the context.

The training process involved re-serializing a conventional instruction-tuning corpus into LLMON format, ensuring every prompt component became an addressable block. The models were further augmented with decoy instructions and data blocks that were deliberately left unbound, teaching the model to ignore any content not referenced in the execution block. This behavior was reinforced through five stages of GRPO reinforcement learning and a final DPO stage using preference pairs built from injection attempts. As a result, the model learns a privilege rule where only instructions reached through an execution block are authoritative, while everything else is treated as read-only material.

Key details

  • Models released: granite-4.1-3b-LLMON-preview and granite-4.1-8b-LLMON-preview, derived from Granite 4.1 base checkpoints.
  • Security improvement: On the OPI benchmark, LLMON models avoided 47% more attacks than the best frontier model tested and 95% more than the best open-source model.
  • Performance parity: The LLMON models maintain general capability on par with standard Granite 4.1 Instruct models across standard benchmark categories.
  • Conversion tools: A library is provided to convert existing JSON structures to LLMON losslessly, preserving nested structures as typed, addressable blocks.
  • Extensibility: Developers can define custom tag names and structures for their domain and fine-tune a LoRA adapter on top of the LLMON models, as demonstrated with the ScienceWorld benchmark.
  • Visualization: An LLMON Attention Visualization tool is available on Hugging Face Spaces to observe how the model processes structured blocks in its attention layers.

Why it matters

For engineers building AI agents and RAG systems, the inability to reliably separate instructions from data is a major source of instability and security risk. Indirect prompt injections, where malicious commands are embedded in retrieved documents or user inputs, can hijack model behavior with high probability in standard architectures. By adopting a format that enforces strict separation at the token level, LLMON offers a structural defense that reduces attack success rates to nearly zero on static benchmarks. This allows developers to build more robust applications without relying solely on heuristic guardrails or complex prompt engineering tricks that often fail under pressure.

Furthermore, the move away from JSON for internal context representation addresses a fundamental mismatch between parser-oriented data formats and probabilistic language models. JSON’s reliance on counting brackets and escaping characters is a known weakness for transformers, particularly in long contexts. LLMON’s use of reserved tokens for structure means the model does not need to infer hierarchy statistically, reducing cognitive load and improving accuracy in following complex, multi-part instructions. This shift could lead to more reliable tool calling and better adherence to constraints in smaller, cost-effective models.

What you can do

  • Download and test the granite-4.1-3b-LLMON-preview and granite-4.1-8b-LLMON-preview models from Hugging Face for non-production evaluation.
  • Use the provided LLMON-converters library to translate your existing JSON-based pipelines into LLMON format without losing structural information.
  • Experiment with the Mellea framework, which has native LLMON support enabled, to automatically LLMONize your LLM calls and observe the effects.
  • Explore the GitHub repository to access example notebooks, including one that demonstrates fine-tuning a LoRA adapter for custom vocabularies using the ScienceWorld benchmark.
  • Visualize the model’s attention mechanisms using the LLMON Attention Visualization demo on Hugging Face Spaces to understand how it processes structured blocks.
  • Join the GitHub Discussions to share your findings, report bugs, and suggest use cases to help shape the future development of LLMON.
  • #llm security
  • #prompt injection
  • #granite models
  • #llmon
  • #ai architecture

Tools from the Bytechap store

Keep reading

All stories