Zero-with-Dot (Oleg Żero): Tex... Note

Zero-with-Dot (Oleg Żero): Text-to-Diagram for AI Systems: Designing a DSL an LLM Gets Right

This text introduces Gnomon, a solution to communication breakdowns in software development, where different stakeholders interpret system descriptions differently. The author, with diverse experience, highlights how terms like "fix" in "We are building an agent to fix invoices" lead to divergent understandings and project failures. The rise of large language models (LLMs) exacerbates this by generating plausible but potentially inaccurate architectural drawings.Gnomon addresses this by providing a small language, gnomocode, and a compiler that validates statements against an ontology. An LLM translates natural language into gnomocode, the compiler checks its validity, and the output can be visualized, queried, or converted back into prose. The compiler, written in Python, uses Lark, rdflib, and pySHACL.The motivation behind Gnomon is to bridge the gap between spoken words and actionable diagrams, ensuring consistency and accountability. It aims to work in both directions: from conversation to model and from code/diagrams to readable text. The forward direction, from conversation to model, is the primary focus of the article.Key requirements for Gnomon include unambiguous terms, native support for modern architectural elements (LLMs, memory, tools), readability for humans and models, multiple views from a single model, version control, and the ability to express uncertainty. The approach evolved from trying simpler methods like directly asking LLMs or using structured objects, which failed to address the complexity of architectural graphs and missing information.Existing notations like UML or C4 were also found insufficient due to their fixed symbols, lack of "maybe" statements, and limited semantic checking. The custom language with a compiler proved to be the most viable solution. The compiler provides localized errors and feedback to the LLM for correction.The core of Gnomon is its ontology, built upon existing RDF vocabularies like SKOS, PROV-O, and DPV. This kernel of 57 terms and twelve modules defines relationships and rules, ensuring consistency. The ontology dictates the lexicon, compiler error messages, prose generation, and diagram views.Gnomocode itself is designed for readability and precision, using a syntax that borrows from Markdown, Python, and graph query languages. It supports concepts like declarations, property assignments, actions, and flows. A crucial feature is the ability to express confidence levels for facts, allowing the system to identify information requiring further confirmation.The compiler, written in Python, uses Lark for parsing. Its grammar is generated directly from the ontology, meaning extending the language involves modifying data, not code. This modular design allows for flexible vocabulary expansion without altering core parsing rules.
CdXz5zHNQW_IUf3kDkWHC.png