← Latest papers
💻 computer science

Self-Healing JSON Generation in Small Language Models: A Systematic Evaluation of Syntax Repair, Schema Coercion, and Validator Feedback

This paper presents a self-healing framework for small language models that combines syntax repair, schema-guided conversion, and validator feedback to significantly improve JSON validity from 16.7% to 78.1% without modifying model weights, while revealing that such syntactic corrections do not guarantee semantic accuracy.

Original author: Ahmad Abdelrahman

Published 2026-11-09
📖 5 min read🧠 Deep dive

Original author: Ahmad Abdelrahman

Original paper licensed under CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). ✨ This is an AI-generated explanation of the paper below. It is not written or endorsed by the author. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine a world where computers can read a messy handwritten note, a rambling email, or a spoken story and instantly pull out the key facts to fill a neat, organized form. This is the promise of turning free-flowing language into structured data, a task that powers everything from digital calendars to inventory systems. To do this, computers often use small, efficient versions of artificial intelligence that can run on ordinary devices without needing massive servers. These small models are cheap and private, but they have a flaw: when asked to write their answers in a strict format called JSON, they frequently make mistakes. They might forget a comma, wrap the answer in extra symbols, or invent a phone number that doesn't exist. If a computer program tries to read this broken answer, it crashes. For years, the solution was to force the computer to think in a very rigid way while it was writing, but this is difficult to set up and can sometimes make the computer less smart. A new study asks a simpler question: what if we let the computer write its answer freely, and then we gently fix the mistakes afterward?

Researchers set out to test a three-step process that acts like a repair crew for these digital answers. They took three different small artificial intelligence models and asked them to turn 120 different text descriptions into structured records, such as contact details or event schedules. The first step in their repair crew was a syntax fixer. This tool looked at the raw text and removed common formatting errors, like extra quotation marks or missing brackets, without needing to ask the computer to think again. The second step was a schema guide. This tool checked the content against the rules of the form. If the computer wrote a date as "October 8, 2025" but the form required "2025-10-08," the guide converted it. If the computer wrote "yes" instead of "true," the guide changed it. Crucially, this step never invented new information; it only reshaped what was already there. The third step was a feedback loop. If the answer still didn't fit the rules, the system showed the computer the specific errors and asked it to try again.

The results showed that the first two steps did the heavy lifting. Before any repair, only about one in six answers from the models were actually usable. After the syntax fixer and the schema guide did their work, the number of usable answers jumped to nearly two out of three, all without asking the computer to generate a single new response. For the most capable model in the study, this simple cleanup made almost every answer perfect. The researchers found that the computer's biggest problem was often just a habit of wrapping its answers in code symbols, like a triple-backtick fence, which confused the strict parsers but was easily removed by the repair tool. For the smallest, least capable model, the problem was deeper. It often misunderstood the structure of the request or copied the rules of the form itself instead of the data. In these cases, simply asking the computer to try again after seeing its errors helped, but only if the repair tools had already cleaned up the basic formatting first.

However, the study uncovered a surprising and important truth: just because an answer is formatted correctly does not mean it is true. Even after the repair crew fixed the syntax and the structure, nearly half of the valid answers still contained wrong information. The models would sometimes leave a field blank, invent a plausible-looking phone number, or pick the first option from a list of choices without checking if it was right. This happened even when the computer was told to try again. The researchers observed that the computer could satisfy the rules of the form perfectly while still failing the task of telling the truth. For instance, a model might correctly format a contact card but fill the phone number with a placeholder like "123-456-7890" because it didn't know the real number.

The study suggests that relying solely on whether an answer fits a format is not enough. To truly trust these small models, systems need to check if the information inside the answer matches the original text. The researchers concluded that the best approach is to use simple, automatic tools to fix the formatting and structure first, as this solves most problems for free. Only then should the system ask the computer to try again, and even then, it must verify that the new answer contains real facts, not just a perfect-looking shell. This work shows that while small models can be made much more reliable with a little post-processing, the goal of extracting accurate information remains a challenge that requires checking the content, not just the shape.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →