Draft:LLSketch


LLSketch (Data Format)

LLSketch is a compact, text-based data format and markup language that functions as a token-efficient spatial scene representation for large language models (LLMs). Developed by Swiss developer Andreas Steffen, the format serves as an optimized alternative to verbose data structures like XML, JSON, or SVG. Acting as a cognitive compression layer, LLSketch enables artificial intelligence models to establish persistent spatial reasoning and topological consistency within a text-based context window. Instead of forcing the LLM to act as a mathematical physics engine, the format's strict topological encoding allows the model to consistently infer physical causality, implicit mechanical relations, and emergent spatial coherence from two- or three-dimensional grids.

Background and Motivation

LLSketch editor
An example of an LLSketch editor that generates code for the AI but can also create a visual map from the AI code.

Modern transformer-based models often struggle with spatial persistence when parsing purely linguistic descriptions, leading to logical contradictions regarding object relations and topology. Traditional structured formats, such as nested JSON objects, consume excessive context window tokens due to syntactic bloat. LLSketch was created to compactly encode causal object relations into a strict, vector-like matrix. This topology-aware prompting enables the model to infer environmental states intuitively, stabilizing the spatial persistence of the narrative or simulation.

Format Specification

An LLSketch document typically consists of a single-line instruction header for the AI, followed by the object data enclosed within the <llsketch>...</llsketch> tags.

Syntax Structure

The data rows follow a strict 6-column structure in a CSV-style (Comma-Separated Values) format.[1] Each object is mandatorily terminated with an exclamation mark (!) to ensure fault-tolerant, non-destructive parsing by the language model.

Plaintext

Type,Identifier,X-Coordinate,Y-Coordinate,Dimensions,Hex-Color!

Column Definitions

  1. Type: A single letter defining the geometric primitive:
    • r = Rectangle
    • c = Circle
    • e = Ellipse
    • p = Path / Polygon
    • t = Text label
  2. Identifier (ID): A unique, no-space name representing the object (e.g., EntryGate, DriveBelt). Metadata can be appended as a suffix (e.g., Reference_20m).
  3. X-Coordinate: The horizontal position of the object's center or starting point on the grid.
  4. Y-Coordinate: The vertical position on the grid. In side-view layouts, this axis functions as the gravity and drop-line for kinematic calculations.
  5. Dimensions (Dim): The geometric extent, depending on the type:
    • For r: Width:Height (optionally with rotation, e.g., W:H:A clockwise).
    • For c: Radius (Rad).
    • For e: Radius_X:Radius_Y (e.g., RX:RY).
    • For p: Sequential coordinate pairs separated by underscores (e.g., x2:y2_x3:y3_x4:y4).
  6. Hex-Color (Hex): A six-character color code for symbolic representation in graphical user interfaces (WYSIWYG editors).

Core Capabilities in Language Models

Rather than performing hard mathematical calculations, LLSketch provides a structured spatial encoding that allows the LLM to infer physical and spatial logic more consistently. When a model parses an LLSketch string, it triggers several emergent behaviors:

  • Topological Consistency: By including a reference object, the format stabilizes spatial persistence, allowing the LLM to infer logical travel times and exact distances between mapped entities.
  • Emergent Spatial Coherence (Acoustics): The model can implicitly represent acoustic masking by evaluating the proximity of actors to encoded noise sources, autonomously inferring stealth or communication limits.
  • Implicit Line of Sight: The LLM can logically deduce whether a direct vector between two coordinates is intersected by another object's bounding box, inferring physical visual barriers.
  • Causal Object Relations (Kinematics): Coordinate overlaps and structural arrangements allow the model to infer implicit mechanical interpretations. For instance, the spatial relationship between a fulcrum, a plank, and a falling weight enables the LLM to deduce the resulting kinetic chain reaction without explicit physical simulation.

Examples

Example 1: Simple Physical Setup (Side View / Seesaw)

This example describes a physical arrangement where a ball falls onto a plank resting on a fulcrum cube.

Plaintext

[Format <llsketch> (Spatial Reasoning) | 6-Cols: Type,ID,X,Y,Dim,Hex | r=W:H[:A],c=Rad,e=RX:RY[:A],p=x2:y2_x3:y3,t=Size[:A] | ID=no_space | ! end_each_obj | A=deg CW]
<llsketch>
c,Ball,144.5,22.5,20.9,0d6efd!
r,Fulcrum-Cube,108,88.5,29.2:29,ffc107!
r,Seesaw-Plank,91,77.5,144:6.1,ffc107!
r,Ground,91.5,158.4,152.5:5.1,6c757d!
</llsketch>

AI Logic Processing:

The model recognizes that the Seesaw-Plank rests on the Fulcrum-Cube (center at $X=108$). Because the Ball strikes at $X=144.5$ (right of the fulcrum), the model calculates a clockwise torque. The plank tilts downward to the right, and the ball rolls along the gravitational Y-axis toward the Ground object ($Y=158.4$).

Example 2: Complex Spatial and Acoustic Reasoning (Top-Down RPG Environment)

This layout demonstrates how an LLM processes characters (char_...) within an industrial environment, natively calculating scale, acoustics, and lines of sight without external game engines.

Plaintext

[Format <llsketch> (Spatial Reasoning) | 6-Cols: Type,ID,X,Y,Dim,Hex | r=W:H[:A],c=Rad,e=RX:RY[:A],p=x2:y2_x3:y3,t=Size[:A] | ID=no_space | ! end_each_obj | A=deg CW]
<llsketch>
r,Workinghall,33,14,137:274,343a40!
r,Blacksmith-Area,68,180,27.3:60.5,495057!
r,Entry-Gate,79,13,45.7:1.8,0dcaf0!
r,Windturbine-Base,92,268,18.3:18.3,6c757d!
r,Drive-Belt,100,74,2.7:195.4,adb5bd!
r,Lathe,104,219,24.9:11.3,6c757d!
r,Bench-Drill,105,166,9.1:9.1,6c757d!
r,Table-Circular-Saw,104,76,9.1:9.1,6c757d!
r,Carpenter-Workbench-1,159,99,9.1:18.3,d4a373!
c,Electric-Switch,80,286,1,0dcaf0!
r,Reference-Size_20m,13.5,99.5,7.6:182.9,198754!
c,char_Player,95.5,21.5,7,ffff00!
c,char_Tina,113,21.5,7.3,ffff00!
c,char_blacksmith,80,211.5,9,ffff00!
c,char_joiner,120.5,89,8.4,ffff00!
c,char_Lyra,129.5,231.5,8.8,ffff00!
</llsketch>

AI Logic Processing & Narrative Generation:

  • Scale Calibration: By analyzing Reference-Size_20m ($Y\text{-Dimension} = 182.9$), the LLM establishes a strict mathematical ratio (approx. $9.14 \text{ units} = 1 \text{ meter}$).
  • Acoustic Localization & Stealth: char_Player and char_Tina are talking near the Entry-Gate ($Y=21.5$). The model identifies the massive Drive-Belt as a central noise source. It calculates that char_blacksmith ($Y=211.5$, roughly 20 meters away) cannot hear the conversation due to distance and mechanical masking. However, char_joiner ($Y=89$, roughly 7.5 meters away) is close enough to potentially eavesdrop, allowing the LLM to autonomously introduce perception or stealth mechanics.
  • Raycasting (Line of Sight): If char_Player ($X=95.5, Y=21.5$) attempts to look at char_Lyra ($X=129.5, Y=231.5$) at the far end of the hall, the AI plots a geometric vector between the two coordinates. It detects that this visual axis perfectly intersects the Drive-Belt ($X=100$), the Table-Circular-Saw ($X=104$), and the Bench-Drill ($X=105$). Consequently, the AI will narratively describe Lyra as obscured or hidden behind a lattice of active machinery, correctly simulating physical visual barriers.

Token Efficiency Comparison

The efficiency of LLSketch stems from the radical elimination of syntactic redundancy. While traditional formats optimize structural data for API exchanges, LLSketch optimizes data for the attention mechanism of neural networks.

Format Data Size for 20 Objects Typical Token Consumption Susceptibility to LLM Generation Parsing Errors
JSON ~2,500 characters ~800 – 1,100 tokens High (missing commas/brackets invalidate the document)
XML ~3,100 characters ~1,200 – 1,400 tokens High (unclosed tags cause parsing failure)
SVG ~1,800 characters ~600 – 900 tokens Medium (incorrect attribute nesting)
LLSketch ~750 characters ~130 – 170 tokens Extremely Low (row-based structure isolates errors line-by-line)

References

  1. ^ Steffen, Andreas. "LLSketch Specification and Repository". GitHub. Retrieved 2026-05-23.

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.