---
title: "Think Inside the JSON — paper by Agarwal et al. (2025)"
description: "ThinkJSON combines synthetic extraction data, reinforcement learning, and supervised training to improve JSON field matching and output…"
canonical: "https://research.elamur.ai/free/en/papers/agarwal-2025-think-inside-json-reinforcement-strategy/"
---
Elamur: [Mova](https://md.mova.elamur.ai/free/en/) · [Parse](https://mova.elamur.ai/free/en/parse/) · [Dictionary](https://md.dictionary.elamur.ai/free/en/) · [Translate](https://md.translate.elamur.ai/free/en/) · **Research** · [Gali](https://md.gali.elamur.ai/free/en/) · [MCP](https://mcp.elamur.ai/) · [Locations](https://md.locations.elamur.ai/free/en/) · [Weather](https://md.weather.elamur.ai/free/en/)

[Elamur Research](https://md.research.elamur.ai/free/en/) · [this page in HTML](https://research.elamur.ai/free/en/papers/agarwal-2025-think-inside-json-reinforcement-strategy/)

[home](https://md.research.elamur.ai/free/en/) / [papers](https://md.research.elamur.ai/free/en/papers/) / [2025](https://md.research.elamur.ai/free/en/papers/2025/) / Think Inside the JSON: Reinforcement Strategy for Strict LLM Schema Adherence

# Think Inside the JSON: Reinforcement Strategy for Strict LLM Schema Adherence

Paper · 2025 · Bhavik Agarwal, Ishan Joshi and Viktoria Rojkova

**Authors:** [Bhavik Agarwal](https://md.research.elamur.ai/free/en/authors/bhavik-agarwal/), [Ishan Joshi](https://md.research.elamur.ai/free/en/authors/ishan-joshi/) and [Viktoria Rojkova](https://md.research.elamur.ai/free/en/authors/viktoria-rojkova/) · **Year:** 2025 · **Venue:** arXiv:2502.14905 · **Licence:** [CC BY 4.0 (arXiv)](http://creativecommons.org/licenses/by/4.0/)

[licence](http://creativecommons.org/licenses/by/4.0/)

- [PDF](https://arxiv.org/pdf/2502.14905)
- [arXiv 2502.14905](https://arxiv.org/abs/2502.14905)

## What it is about

ThinkJSON combines synthetic extraction data, reinforcement learning, and supervised training to improve JSON field matching and output cleanliness. · about 35 minutes to read

**In this deep dive**

1. [Summary](#dd-summary)
2. [Ideas worth borrowing](#dd-ideas-worth-borrowing)
3. [How Mova uses it](#dd-how-mova-uses-it)
4. [The problem and its context](#dd-the-problem-and-its-context)
5. [The method, step by step](#dd-the-method-step-by-step)
6. [Experiments and results](#dd-experiments-and-results)
7. [What the ablations show](#dd-what-the-ablations-show)
8. [Limitations](#dd-limitations)
9. [What came after](#dd-what-came-after)

### Summary

A digital record can be readable to a person and still be unusable by software. A missing field, an unexpected key, or information placed under the wrong section can break the contract between an extraction system and the program that consumes its output. “Think Inside the JSON” studies this problem in [structured information extraction](https://md.research.elamur.ai/free/en/concepts/information-extraction/), motivated by the conversion of paper-based biomanufacturing records into digital documents. The authors propose ThinkJSON, a compact system trained to map irregular source text into a specified JSON structure. Their central idea is to teach the mapping process alongside the final output, while using automatically calculated rewards to encourage correct fields and a consistent response format.

The training pipeline begins with synthetic documents. Qwen generators create hierarchical JSON structures and populated objects, then turn the objects into less orderly text containing the same information. Different layouts, table styles, checkbox representations, and distracting prose make the resulting documents harder to extract from mechanically. A distilled DeepSeek reasoning system then receives the source text, an empty target structure, and the completed object. It produces an explanation of how information in the text corresponds to the target fields. ThinkJSON uses unstructured–structured pairs for reinforcement learning and a separate collection of reasoning examples for supervised training. The starting point is Qwen 2.5 with 1.5B parameters.

The reinforcement stage follows the paper’s interpretation of Group Relative Policy Optimization, or GRPO: several candidate responses receive rewards, and their relative standing guides learning. A JSON reward compares predicted field values with a reference object and adds a size-similarity component. A separate format reward checks whether reasoning and the final answer appear within the required tags. The authors report 20K examples for reinforcement learning, followed by 10K reasoning examples for supervised fine-tuning. The reinforcement stage takes approximately 20 hours on an 8×H100 cluster; supervised training takes about 3 hours on 1xA100. These are reported training conditions, rather than an end-to-end accounting of data creation, experimentation, and deployment cost.

On an extraction benchmark containing 6.5K rows, ThinkJSON achieves a reported mean field match of 62.41% and mean noise of 0.27%. The paper describes these as the strongest match result and lowest noise result among its evaluated systems. For comparison, Original DeepSeek R1 records 41.43% mean match and 11.14% mean noise, while Gemini 2.0 Flash records 42.88% and 10.86%, respectively. The evaluation also includes distilled DeepSeek R1 variants based on Qwen-1.5B and Qwen-7B. The findings support the usefulness of task-specific training for this extraction setting. They do not establish guaranteed schema compliance, complete extraction accuracy, regulatory readiness, or which individual training component caused the gains: the paper does not report the controlled comparisons needed to separate those explanations.

### Ideas worth borrowing

Generate the answer before the difficult input. Producing a structured object first gives synthetic data a known target. The object can then be expressed through different document layouts without deliberately changing its information. This reverses the usual annotation problem: instead of asking annotators to recover a target from an existing document, the designer makes the target and controls how difficult its presentation becomes. The strategy can support extraction, document conversion, and tests of structural interpretation, provided the transformed document is checked for information loss or invention.

Vary presentation independently of content. A paragraph, a table, and a checkbox can express related information through very different surface cues. Training on those variations encourages a system to recover the intended structure without depending entirely on one visual convention. The broader lesson applies to [semantic parsing](https://md.research.elamur.ai/free/en/concepts/semantic-parsing/), document readers, and interfaces that must accept heterogeneous inputs. Keeping content fixed while changing presentation also creates a useful evaluation instrument: failures can be attributed more precisely to the form in which information appears.

Separate response packaging from information correctness. ThinkJSON assigns different rewards to its response envelope and its extracted JSON. This makes an important distinction explicit. A response can use the correct tags while carrying incorrect values, or contain useful values within an unusable wrapper. Separate checks help expose those cases. The idea transfers to tool protocols, annotation formats, and generated programs, where acceptance involves several obligations that should remain individually inspectable.

Use graded feedback without confusing it with acceptance. Field matching and object-size similarity provide more guidance than a single pass-or-fail signal. A partly correct output can receive some credit, which may help learning progress toward a more complete answer. Yet a useful training signal does not automatically define a safe deployment rule. This distinction matters wherever approximate optimization serves a task with exact external requirements: partial credit can guide improvement while a separate validator decides whether the result is admissible.

Teach the correspondence, then refine the required output. The authors combine reinforcement learning on extraction outcomes with supervised examples that include explanations of the source-to-field mapping. This suggests a reusable division of labor between learning from scored attempts and learning from explicit demonstrations. For other systems, the correspondence need not be a free-form explanation. It could be a field-to-source alignment, a sequence of typed operations, or a compact derivation that makes the transformation easier to inspect.

Measure missing output, validity, correctness, and noise separately. These outcomes answer different questions. Silence concerns availability; valid JSON concerns syntax; field matching concerns the recovered information; noise concerns unwanted material. Reporting them separately prevents an improvement in one dimension from concealing damage in another. The same principle applies to [evaluation benchmarks](https://md.research.elamur.ai/free/en/topics/evaluation-benchmarks/) for extraction and conversion systems, particularly when downstream software must distinguish an absent result from a plausible but incorrect record.

### How Mova uses it

Mova is a transparent language system implemented in Rust. Its documented mechanisms already include deterministic language analysis, source-bound preparation of teaching material, validation gates, and a separation between external teaching and native assessment. The proposals below concern transferring ideas from ThinkJSON into those mechanisms. They do not imply that Mova implements ThinkJSON’s reinforcement-learning pipeline or that the paper establishes improvements for Mova. The status marks compare each proposal with the documented scope; they are provisional assessments, and their effects remain unmeasured unless stated otherwise.

Idea: Generate structured targets before difficult documents. Where: Section 3.1. Area: data. Mova: частково є (tools/enrich prepares source-bound teaching packets and staged drafts). Mova could begin a document-reading test with an owned structured record, then derive several textual presentations from it. The existing enrichment path supplies part of the preparation and review machinery, but the digest does not establish this reverse-generation procedure. Why Mova: it could provide controlled extraction examples with explicit expected fields while keeping synthetic material separate from admitted knowledge.

Idea: Preserve information while varying presentation. Where: Section 3.1. Area: evaluation. Mova: частково є (the language pipeline reads frames and worlds, while fastread compares answers with prepared evidence). A proposed evaluation could hold a record’s information constant across prose, tables, and checkbox-like expressions. Each transformation would need review for equivalence before it became a meaningful test. Why Mova: disagreements across equivalent presentations could reveal representation failures that an aggregate reading score hides.

Idea: Treat layout as an explicit experimental variable. Where: Section 3.1, document-generation prompt. Area: data and statistics. Mova: нове. The paper varies layout and table style during synthesis. Mova could attach those choices as metadata to controlled reading fixtures and report performance by presentation type. The digest does not establish an equivalent experiment registry, and its absence does not prove that none exists. Why Mova: a failure concentrated in one layout would suggest a narrower repair than changing general inference rules.

Idea: Test resistance to irrelevant prose. Where: Section 3.1, document-generation rules. Area: pragmatics and evaluation. Mova: частково є (prag extracts frames, and retained readers select evidence for questions). Synthetic fixtures could surround relevant facts with explicitly unrelated text, then check whether Mova preserves the intended answer and supporting evidence. This would test a capability rather than admit the distracting statements as general knowledge. Why Mova: it would show whether readers confuse available text with relevant evidence.

Idea: Keep a reviewable field-to-source correspondence. Where: Section 3.2. Area: interpretability. Mova: частково є (frames, answer reasons, and source-bound enrichment packets). ThinkJSON asks a teacher to explain how source text fills target fields. Mova could use a more constrained representation linking each proposed field to a sentence, token span, frame, or world-state fact. Why Mova: such links would make extraction errors diagnosable without treating an external explanation as proof.

Idea: Distinguish teacher-visible answers from inference inputs. Where: Section 3.2 and Section 3.4. Area: training and evaluation. Mova: вже є (the teacher-separated school assessment and fastread scoring boundary). ThinkJSON’s explanation generator sees the filled target, while the extraction task supplies text and an empty structure. Mova should retain its existing distinction when borrowing this data strategy. Why Mova: a target-informed explanation can become reviewed supervision, but it cannot demonstrate independent native extraction.

Idea: Validate synthetic equivalence independently. Where: Sections 3.1–3.2. Area: data quality. Mova: частково є (tools/enrich source fingerprints, review, and staging validators). A generated document may accidentally omit or alter a value from its originating object. Mova could require a separate consistency check before using the pair for training or assessment. This strengthens an assumption in the paper rather than reproducing a reported ablation. Why Mova: it would prevent a synthetic-data defect from being misdiagnosed as a reader error.

Idea: Separate envelope validity from extracted content. Where: Sections 3.3.1–3.3.2 and Algorithms 1–2. Area: operational protocols. Mova: вже є (worker interfaces, explicit outcomes, and tools/enrich artifact gates). ThinkJSON’s separate rewards reinforce a distinction already visible in Mova’s architecture. A well-formed worker reply should retain a different status from a semantically admitted result. Why Mova: transport success and acceptable packaging cannot establish that the requested operation was correctly understood or completed.

Idea: Keep graded diagnostics separate from admission. Where: Algorithm 1. Area: evaluation and operational safety. Mova: вже є (reviewed staging, admission boundaries, and regression gates). A partial field-match score could help rank extraction failures or repair candidates, but it should not authorize a knowledge update. ThinkJSON’s training reward provides an example of optimization feedback, not a replacement for Mova’s acceptance criteria. Why Mova: useful partial progress can guide work without weakening exact checks on published or retained artifacts.

Idea: Compare field sets as well as shared values. Where: Algorithm 1. Area: data validation. Mova: частково є (typed interfaces and staged-output validators). The reward’s denominator includes keys appearing in either the prediction or the reference. Mova could expose missing, additional, and incorrectly populated fields as separate diagnostics for structured proposals. Why Mova: inspecting only shared fields can make an incomplete or overextended record appear more successful than it is.

Idea: Treat size similarity as a weak diagnostic. Where: Section 3.3.1 and Algorithm 1. Area: statistics. Mova: нове. Mova could investigate whether an output-size comparison identifies truncated extraction proposals cheaply. The paper’s length component does not establish semantic completeness, and the proposed diagnostic should never stand alone. Implementation status beyond the digest is unknown. Why Mova: a low-cost warning could prioritize inspection while preserving the stronger requirement for field-level evidence.

Idea: Make nested comparisons explicit. Where: Algorithm 1. Area: mathematics and validation. Mova: частково є (typed structures, groupants, and invariant checks). The displayed reward compares values under object keys without specifying a recursive leaf-level metric. Mova could define separate comparisons for hierarchy, field identity, value equality, and evidence links when evaluating nested artifacts. Why Mova: explicit comparison units would distinguish a local value error from a misplaced subtree and make scores easier to interpret.

Idea: Preserve individual diagnostic components. Where: Algorithm 3. Area: statistics and optimization. Mova: частково є (self-play journals, held-out gates, and logged checks). If Mova combines field accuracy, structural validity, and other signals to prioritize proposals, it could retain every component alongside the combined score. The paper allows several aggregators without fixing one in the displayed method. Why Mova: an overall improvement can conceal a deterioration in a required property unless the underlying measurements remain visible.

Idea: Compare several candidates under the same checks. Where: Algorithm 3. Area: search and evaluation. Mova: частково є (the maths student’s top-K judge and bounded self-play). GRPO ranks sampled responses by reward. A non-neural transfer would compare bounded native extraction or repair candidates against identical validators and evidence. Why Mova: relative comparison can help select among existing alternatives without requiring Mova to adopt policy-gradient training.

Idea: Specify how ties affect candidate selection. Where: Algorithm 3, relative-advantage definition. Area: mathematics and reproducibility. Mova: частково є (deterministic ordering, fixed seeds, and repeated-result requirements). The paper uses a strict greater-than comparison, so equal rewards provide no pairwise win. Mova could state equally precise tie rules wherever several candidates share a score. Why Mova: reproducible selection depends on details that a broad description such as “choose the best” leaves unresolved.

Idea: Use coarse scores cautiously. Where: Algorithm 1, reward rounding. Area: statistics. Mova: нове. The JSON reward is rounded before subsequent use. Mova could test whether a similarly coarse diagnostic obscures meaningful differences between repair candidates, retaining the underlying counts even if a compact displayed score is useful. This is a proposed analysis rather than a demonstrated benefit. Why Mova: transparent raw evidence would allow later evaluation of whether the scoring resolution affected decisions.

Idea: Separate exploration from demonstration learning. Where: Sections 3.3–3.4. Area: training. Mova: частково є (bounded self-study, teacher review, and separately admitted learning). ThinkJSON first learns from scored outputs and then receives explicit reasoning examples. Mova could use the analogous operational sequence of bounded native proposal, reviewed explanation, and separately gated rule or parameter revision. Why Mova: it matches the project’s preference for explicit mechanisms while preserving the distinction between finding a candidate and accepting it.

Idea: Give rare structural cases dedicated examples. Where: Section 3.4. Area: data and validation. Mova: частково є (closed lexical rules, negative controls, and regression-gated extensions). The authors motivate supervised refinement partly through unusual fields and data types. Mova could maintain targeted fixtures for rare nesting, optional fields, and ambiguous source expressions, without assuming that adding them automatically improves general performance. Why Mova: uncommon failures can matter operationally even when their influence on an average score is small.

Idea: Keep explanations outside the machine-consumed answer. Where: Algorithm 2 and Section 3.4. Area: operational interfaces. Mova: вже є (explicit worker protocols and distinct evidence types). ThinkJSON separates reasoning from its answer with tags. Mova can retain the broader principle through typed fields rather than adopting that exact textual wrapper. Why Mova: downstream code should receive the intended artifact, while diagnostic material remains available through an explicit, separately interpreted channel.

Idea: Use selective logs for diagnosis rather than automatic supervision. Where: Algorithms 1–2. Area: data governance. Mova: вже є (worker receipts and reviewed annotation remain distinct from admitted training knowledge). The paper logs some completions for inspection. Mova can apply the same economy while retaining its stronger provenance and review boundaries. Why Mova: a useful failure record or high-scoring response may deserve investigation without becoming trusted teaching material.

Idea: Report output absence separately. Where: Evaluation section. Area: evaluation. Mova: частково є (explicit failures, missing-context outcomes, and unsupported-request handling). Mova could make absent structured results a dedicated category in extraction reports rather than merging them with wrong values or malformed artifacts. Why Mova: an abstention, an execution failure, and a confidently incorrect record call for different repairs and should remain distinguishable.

Idea: Distinguish parseability from semantic completion. Where: Evaluation section. Area: evaluation and semantic parsing. Mova: вже є (the hybrid-system boundary states that a successful parse does not establish the intended task). ThinkJSON’s valid-JSON measure supplies another instance of this distinction. Mova should continue evaluating the interpreted action or recovered fact after syntax has passed. Why Mova: a structurally acceptable representation can still express the wrong relationship or fill the wrong role.

Idea: Measure unwanted output alongside missing content. Where: Evaluation section and Figure 4. Area: evaluation. Mova: частково є (source-bound enrichment and dictionary-admission checks). An extraction report could count unsupported additions separately from omitted fields, with precise definitions for each artifact type. ThinkJSON’s noise result motivates the distinction but does not supply a ready-made metric for Mova. Why Mova: extra material can contaminate a dictionary proposal or operational message even when much of the required content is correct.

Idea: Evaluate compact task-specific mechanisms against larger alternatives. Where: Evaluation and Discussion. Area: efficiency and evaluation. Mova: частково є (the native CPU reference, measured GPU approximants, and published benchmark boundaries). ThinkJSON’s comparison suggests testing specialization rather than assuming capacity determines task performance. Mova’s version would compare native mechanisms and optional external assistance under matched tasks and acceptance rules. Why Mova: it could identify where transparent rules suffice and where additional assistance earns its cost.

Idea: Separate training cost from the whole pipeline’s cost. Where: Abstract, Section 3.3, and Section 3.4. Area: operational measurement. Mova: частково є (tools/jobs logs estimates and actual use; tools/twin tracks predictions and measurements). Mova could report preparation, teacher review, validation, training, and execution as distinct resource categories. Why Mova: the cost of a short training run cannot explain the total cost of producing dependable data or maintaining an extraction service.

Idea: Preserve a fixed-question comparison after refinement. Where: Section 3.4 and Evaluation. Area: experimental design. Mova: вже є (tools/enrich requires comparing the same questions before and after a change). ThinkJSON motivates a refinement stage but does not isolate its contribution experimentally. Mova should retain its existing comparison discipline when adding structured-extraction supervision. Why Mova: a changed score is informative only when the evaluation conditions allow it to be attributed to the proposed change.

Idea: Keep learned preferences subordinate to exact invariants. Where: Relevant Work, constraint-based decoding discussion; Sections 3.3.1–3.3.2. Area: logical modules and validation. Mova: вже є (UD gates, typed contracts, and groupant invariant checks). The paper contrasts learned adherence with methods that restrict allowable outputs. Mova could use statistical preferences to propose or rank artifacts while deterministic validators enforce required conditions. Why Mova: this combines flexible candidate generation with the explicit logical boundaries central to Mova’s direction.

### The problem and its context

JSON provides a regular way to represent objects, fields, arrays, and nested information. Its practical value comes from agreement between producers and consumers. A receiving program can look for a named field, expect a particular kind of value, and interpret nested content according to a pre-defined structure. That agreement breaks when generated output merely resembles the requested object.

The paper situates this problem in biomanufacturing quality work. Older production documents may contain information needed for compliance or analysis, but their organization can reflect paper forms instead of a database. Converting them requires more than transcription. The system must determine which pieces of text belong to which fields, preserve relationships between sections, and represent the result in the structure expected by downstream software.

These obligations span content and form. A timestamp can be copied incorrectly even when it sits in the right field. A correct value can become misleading when attached to the wrong section. An additional delimiter can prevent parsing, while an additional invented field may remain syntactically acceptable. The authors’ motivation therefore reaches beyond producing text that looks orderly. They want dependable conversion into a specified representation.

The paper describes [large language models](https://md.research.elamur.ai/free/en/concepts/large-language-models/) as strong free-form generators whose ordinary output process does not inherently enforce an external schema. It cites earlier evidence of highly variable JSON-format success across tasks and systems. The background range of 0% to 100% belongs to that discussion of earlier studies; it is not a ThinkJSON result. Its role is to motivate why an instruction such as “return JSON” cannot by itself settle the reliability question.

#### Earlier approaches described by the authors

The first approach is [supervised fine-tuning](https://md.research.elamur.ai/free/en/concepts/fine-tuning/). Given examples pairing inputs with correctly structured answers, training can make the expected output pattern more familiar. In the authors’ account, the drawbacks are the effort needed to obtain specialized examples, the resources needed for adaptation, and the possibility that behavior becomes too narrowly tied to the training distribution.

A second approach uses reinforcement learning with human feedback. Here, desirable behavior is encouraged through reward signals derived from feedback. The paper presents this as a route towards more precise instruction following, potentially including compliance-related preferences. It also emphasizes the burden of obtaining suitable feedback and designing rewards that capture the intended behavior.

Constraint-based decoding attacks a different part of the problem. Instead of hoping that training makes invalid continuations unlikely, a decoding mechanism restricts which continuations can be produced. The paper describes grammar- and regular-expression-based approaches that enforce output structure during generation. Within their supported constraints, such methods can guarantee structural adherence. That guarantee concerns the enforced form; it does not mean that every permitted value is supported by the source document.

Prompt engineering asks the generator to follow a carefully expressed contract without changing its parameters. Examples, explicit restrictions, and layout cues may improve results. The authors describe this as accessible but dependent on manual effort and sensitive to edge cases. They also discuss hybrid approaches that combine schema-aware prompting with generation controls or repeated checking.

ThinkJSON belongs primarily to the training side of this landscape. It tries to make structured extraction a learned behavior, using task-specific rewards and explanatory demonstrations. Its output-format reward checks completed responses; it is not a decoder that prevents every invalid token choice. This distinction matters when interpreting the title’s emphasis on strict adherence.

#### The reasoning connection

The immediate methodological inspiration is [DeepSeek-R1](https://md.research.elamur.ai/free/en/papers/deepseek-ai-2025-deepseek-r1-incentivizing-reasoning-capability/). The authors borrow the idea that reinforcement learning can develop useful reasoning behavior from a compact starting system. They apply that motivation to document-to-JSON mapping instead of limiting the task to mathematical answers.

The paper also cites [DeepSeekMath](https://md.research.elamur.ai/free/en/papers/shao-2024-deepseekmath-pushing-limits-mathematical-reasoning/) in connection with policy optimization, [Self-Refine](https://md.research.elamur.ai/free/en/papers/madaan-2023-self-refine-iterative-refinement-self/) in its synthetic-data methodology, and [Math-Shepherd](https://md.research.elamur.ai/free/en/papers/wang-2024-math-shepherd-verify-reinforce-llms/) alongside its training discussion. These references establish influences and surrounding ideas. The paper does not provide experiments isolating the contribution inherited from each work.

The resulting research question is specific: can a small, specially trained extractor achieve better field mapping and cleaner structured output than the comparison systems on the authors’ benchmark? The reported evaluation addresses that question more directly than it addresses the broader ambition of compliance-ready document automation.

### The method, step by step

The pipeline has a data-construction phase and a training phase. Data construction creates both extraction targets and explanatory demonstrations. Training first rewards generated attempts, then uses supervised examples to refine the output behavior.

ThinkJSON data construction and training The steps in order.

#### Construct a structured target

The authors ask Qwen 14B and 32B to create hierarchical JSON material for a selected domain. The generation prompt requests both a structural description and a matching object. The hierarchy includes root, section, subsection, and deeper detail components. Content can include paragraphs, tables, checkboxes, variables, and other properties.

This starting point supplies an intended organization before the extraction input exists. It also allows the data designer to request nested cases deliberately. A flat collection of unrelated fields would not exercise the same problem as a document whose details belong under particular sections.

Terminology requires care. The paper uses “schema” in discussing both structural specifications and empty targets to be populated. A formal schema and an empty instance are related but different objects: the former defines allowable structure, while the latter can show the slots expected in a particular extraction. The operational idea is clear enough—provide a target organization and recover its values—but the paper does not fully formalize every distinction between those representations.

The prompt also requires JSON-oriented formatting conventions, including double quotes and the absence of trailing commas. These requirements concern the validity of the generated training artifacts. They do not independently establish that every generated object satisfies every possible schema constraint.

#### Remove values while retaining the target organization

For each populated target, the authors prepare a blank counterpart. The purpose is to separate what the extraction system receives from what it must recover. The empty structure tells the system how the answer should be organized without supplying the completed field contents.

A known completed object then serves as the reference during training or evaluation. This makes it possible to compare a generated answer with a target instead of relying only on a subjective judgment of whether the answer looks plausible.

The design also separates structural inference from content extraction to some extent. If a target already specifies the relevant fields and hierarchy, the system need not invent a database design. Its task is to align source information with that supplied organization. Results from this setting should therefore not be read as evidence of unconstrained schema discovery.

#### Express the target as an irregular document

The populated object is converted into prose and other document-like forms. Layout choices include sequential presentation, parallel sections, and combinations of styles. Tables may appear as character-based layouts, markup-like material, or text resembling document extraction. Checkbox information can appear through different textual conventions.

The generator is asked to preserve the object’s information while making its presentation less direct. Relevant values may be surrounded by explanatory wording, unrelated remarks, and filler paragraphs. The intended difficulty is recognizing the information and its structural role in spite of surface variation.

Because the object exists first, this process can produce multiple extraction inputs with a common reference. It is an attractive construction for robustness experiments. However, the intended equivalence between object and narrative remains a data-quality requirement. A generator asked to preserve all content can still omit, alter, or add something. The paper does not report a separate quantitative audit establishing how frequently the synthetic documents preserve their targets perfectly.

#### Generate explanations with access to the answer

A distilled DeepSeek R1 Qwen 32B system receives the document, the blank structure, and the completed target. It is asked to explain the mapping from source information to populated fields and to check that its explanation leads to the supplied object.

These explanations provide demonstrations of how the extraction should proceed. They can identify which textual cues correspond to particular fields, how hierarchy is preserved, and why values belong in one place rather than another. The paper calls this a reasoning dataset and names the released resource R1-Reasoning-Unstructured-To-Structured Dataset. It also names a JSON-Unstructured-Structured Dataset.

The answer visibility is important. The explanation generator is reconstructing a path to a known target. It is not demonstrating that the target could have been recovered without seeing it. Such explanations may be useful supervision, but their existence alone does not validate an independent extraction capability.

The authors describe the explanations as promoting checking and fidelity. A careful interpretation distinguishes that intended mechanism from verified causation. The paper does not compare otherwise identical training runs with and without the explanations, nor does it measure whether each explanation faithfully accounts for every target field.

#### Start reinforcement learning from the compact base

ThinkJSON begins from Qwen 2.5 with 1.5B parameters. The abstract specifies an initial reinforcement-learning stage using 20K unstructured–structured examples. The subsequent supervised stage uses a separate 10K-example reasoning dataset.

The method’s wording sometimes moves between finalizing the reasoning data and training without supervised data. These descriptions are most consistently understood as a distinction between optimization stages: the initial stage learns through rewards on extraction attempts rather than through supervised imitation of the reasoning demonstrations.

That does not make the initial task devoid of supervision in a broader sense. Its content reward uses ground-truth objects. “Without supervised data” in the R1-Zero-style discussion should therefore not be interpreted as learning document extraction without targets, labels, or externally supplied correctness information.

#### Calculate the field-matching reward

For a generated completion, the reward procedure first extracts the material between the answer tags. If that span is missing, it assigns no JSON reward. It then parses the extracted answer and the reference as JSON. A parsing failure also yields no reward from this procedure.

For parseable objects, the algorithm identifies the keys in the predicted answer and the keys in the reference. It counts a shared key as matching when the associated values are equal. The denominator includes every key appearing in either object:

```
s_fields = Σ[k ∈ K_a ∩ K_g] 1[a[k] = g[k]] / |K_a ∪ K_g|
```

Here, `a` is the parsed answer object and `g` is the reference object. `K_a` and `K_g` are their respective key sets. The intersection contains shared keys, and the union contains keys present in either object. The indicator `1[condition]` contributes one when its condition holds and zero otherwise. The vertical bars around a set denote its size. If the denominator is empty, the algorithm sets the field score to zero.

This construction penalizes absent fields and additional fields, because either kind enlarges the union without creating a matching value. It also requires equality of values, rather than merely checking that the same field names appear.

The displayed algorithm does not define a recursive decomposition into all nested leaf fields. Equality under an outer key may therefore involve an entire nested value. The paper does not state enough detail to assume a particular recursive matching convention, normalization rule, or treatment of semantically equivalent values.

#### Add an object-length component

The reward also compares the lengths of the answer and reference:

```
s_length = min(ℓ_a, ℓ_g) / max(ℓ_a, ℓ_g)
```

The symbols `ℓ_a` and `ℓ_g` denote the lengths assigned to the parsed answer and reference. The pseudocode replaces a zero length with one. The functions `min` and `max` select the smaller and larger lengths.

The purpose is to encourage outputs whose overall size resembles the target, which the authors associate with structural completeness. Yet the algorithm does not fully specify what object length means for its nested structures. A reader should not silently equate it with serialized character count, token count, or the total number of leaf fields.

Even with a precise length definition, size similarity is limited evidence. Different objects can have matching sizes while disagreeing about their information. This component supplies a coarse signal; the field-value comparison carries a more direct connection to extraction correctness.

The final JSON reward averages these components:

```
r_JSON = (s_fields + s_length) / 2
```

Here, `r_JSON` is the scalar JSON reward, `s_fields` is the field-value matching score, and `s_length` is the length-similarity score. The procedure clamps the result to `[0, 1]` and rounds it to 1 decimal place. Completions with a reward of at least 0.6 may be logged with 60% probability.

Logging supports inspection of selected outputs. It is not an additional correctness criterion. Likewise, rounding simplifies the reward signal but may make different underlying outputs receive the same scalar score.

#### Check the response envelope separately

The format reward evaluates whether the completion has the prescribed reasoning section followed by the answer section. The procedure prepends an opening reasoning tag before applying its check, reflecting the expected continuation format.

```
r_format(c) = 1 if "<think>" ∥ c matches the required envelope; otherwise 0
```

The variable `c` denotes the generated continuation. The symbol `∥` means concatenation. The required envelope contains a closed reasoning block, a newline, and an answer block, with the complete response matching the pattern. The reward is binary: the envelope either passes or fails.

This check concerns packaging. A response can satisfy it while the answer contains invalid JSON or incorrect extracted values. Conversely, the JSON reward can reveal useful content independently of whether the whole completion obeys the expected wrapper. Their separation makes the obligations visible, although the final training behavior depends on how the rewards are combined.

The format algorithm also samples completions for logging, with 0.1 given as an example probability. Those diagnostic samples do not determine the format reward.

#### Combine rewards and compare candidate responses

The paper describes a general combination of reward functions:

```
R_comb(c) = f(r_1(c), r_2(c), …, r_K(c))
```

Here, `c` is a completion, `K` is the number of reward functions, and `r_k(c)` is the score assigned by reward function `k`. The function `f` combines them into `R_comb(c)`. The authors allow a weighted sum, a mean, or another aggregator; the displayed method does not establish one uniquely specified combination with reported weights.

The training procedure samples a group of candidate completions. It then evaluates each completion’s combined reward relative to the others:

```
A_rel(c_i) = Σ[j ≠ i] 1[R_i > R_j] / (M − 1)
```

The group contains `M` completions. The symbol `c_i` denotes candidate `i`, and `R_i` is its combined reward. The sum considers every other candidate `j`. The indicator counts a win when `R_i` is strictly greater than `R_j`. Therefore, `A_rel(c_i)` expresses the fraction of other candidates whose reward is lower.

Equal rewards do not count as wins. This detail matters because rounding the JSON reward can create ties. If all candidates receive the same combined reward, the displayed advantage expression assigns no relative win to any of them.

The authors present the learning objective as:

```
L_GRPO(θ) = −Σ[i] A_rel(c_i) log π_θ(c_i) + Reg(θ)
```

The parameters being trained are denoted by `θ`. The policy `π_θ` assigns probabilities to completions, and `log π_θ(c_i)` is the log probability of candidate `c_i`. The weighted sum encourages completions with higher relative advantage. `Reg(θ)` denotes a regularization term.

This is the paper’s stated optimization sketch. It does not specify every detail needed to reconstruct a complete training implementation, including the exact regularization, sampling configuration, and reward aggregation. The equations explain the intended learning pressure without establishing that all practical choices are fully documented.

#### Refine through supervised examples

After reinforcement learning, supervised fine-tuning presents examples containing the source document, the blank target, an explanation, and the completed JSON. The prompt requires a reasoning section even for a direct mapping, then a separately tagged answer.

The authors motivate this stage as refinement for exact field names, required fields, unusual data types, and less common domain conventions. Demonstrations can make a desired response concrete where reward optimization alone may leave several acceptable-looking behaviors.

They report using the Unsloth framework on an A100 GPU, with about 3 hours for this stage. The text mentions SFT and SFT+LoRA, but does not provide a separate final-performance comparison between those adaptation choices.

At extraction time, the task is to recover the populated object from the document and target organization. The completed reference belongs to supervision or scoring, not to the ordinary input whose extraction performance is being assessed.

### Experiments and results

The evaluation uses a structured-extraction benchmark with 6.5K rows. Each row is processed for structured output, and the authors examine whether output exists, whether it parses as JSON, how well its fields match, and how much unwanted material it contains.

The comparison includes ThinkJSON, Original DeepSeek R1, and Gemini 2.0 Flash. It also includes distilled DeepSeek R1 variants based on Qwen-1.5B and Qwen-7B. The paper identifies Original DeepSeek R1 as 671B and Gemini 2.0 Flash as 70B; those are the comparison descriptions used by the authors.

This setup tests the finished ThinkJSON pipeline against other systems. It does not, on its own, identify whether its advantage comes primarily from the training data, reward design, supervised refinement, prompting, or another experimental choice.

#### What the metrics mean

“Rows With No Output” counts cases without an extracted structured result. This metric distinguishes failure to produce the artifact from errors inside an artifact. For practical use, the difference matters: an absent result is usually visible, whereas an incorrect but plausible record may proceed farther downstream.

“Rows With Valid JSON” measures syntactic parseability. A valid JSON object obeys the representation’s syntax, but it need not satisfy every semantic requirement of the extraction task. It may contain wrong values, omit required information, or arrange content incorrectly.

“Mean Match Percentage” summarizes how much of the expected field content is correctly mapped. This is the metric closest to information recovery among the reported outcomes. However, the evaluation section does not fully explain its handling of nested values, alternative representations, or rows without extracted JSON.

“Mean Noise Percentage” describes extraneous or malformed material associated with the extracted JSON. A lower value indicates cleaner output under the authors’ measure. The exact operational definition is not developed enough to treat it as a universal measure of hallucination, unsupported claims, or every possible schema violation.

#### Field matching

ThinkJSON’s mean match is 62.41%, the highest reported result among the evaluated systems. The prose gives exact comparison values for Original DeepSeek R1 and Gemini 2.0 Flash.

Structured-extraction benchmark, mean field match ThinkJSON achieves the strongest reported field matching among these systems.

**The numbers**

| System or setting | mean match % |
| --- | --- |
| Original DeepSeek R1 | 41.43 |
| Gemini 2.0 Flash | 42.88 |
| ThinkJSON (this paper) | 62.41 |

The result supports a task-specific conclusion: the trained compact extractor recovers more of the expected field content under this benchmark’s scoring than those comparison systems. It also shows why parameter count alone is an inadequate guide to performance on a specialized conversion task.

The result should not be read as complete recovery of the records. Mean matching remains an average of the paper’s field-level measure. It does not tell the reader how many entire objects are perfectly correct, whether errors concentrate in particular field types, or how often a critical field is wrong.

The paper describes both distilled DeepSeek variants as weaker overall, including substantial missing extraction or noisy output. It does not provide their exact match values in the written evaluation. Those values therefore cannot be reconstructed reliably from the qualitative description.

#### Output noise

The second headline result concerns cleanliness. ThinkJSON’s mean noise is 0.27%, while the two comparison systems with exact prose values have substantially noisier outputs under the authors’ measure.

Structured-extraction benchmark, mean output noise ThinkJSON produces the cleanest extracted output among these systems.

**The numbers**

| System or setting | mean noise % |
| --- | --- |
| Original DeepSeek R1 | 11.14 |
| Gemini 2.0 Flash | 10.86 |
| ThinkJSON (this paper) | 0.27 |

Low noise and strong field matching are complementary. A concise object that omits most required content would not be satisfactory, and a detailed object filled with unwanted material could be difficult to consume safely. The reported results suggest that ThinkJSON improves both dimensions relative to these baselines.

Yet low noise does not establish that the recovered values are true or that every output is schema-valid. It concerns the paper’s particular measure of unwanted material. The match result remains necessary to understand the content side of performance.

#### Coverage and validity

The authors report that Original DeepSeek R1 has comparatively strong valid-JSON coverage. This observation is useful because it separates parseability from correct extraction: a system can produce many parseable objects while obtaining a lower field-match score.

The evaluation names counts for absent output and valid JSON as metrics, but the written discussion does not supply exact counts for each system. The findings therefore support qualitative coverage statements, not a complete numerical reconstruction of those outcomes.

The paper’s performance figure summarizes the comparison, while the surrounding prose emphasizes matching and noise. Without exact coverage values and a detailed scoring definition, the reader cannot determine whether different systems face the same penalties for abstaining, failing to parse, or returning an incomplete object.

#### Resources and the scope of efficiency

The training report is concrete about the main stages. Reinforcement learning uses roughly 20 hours on an 8×H100 cluster. Supervised refinement takes about 3 hours on 1xA100. The data sizes are 20K extraction pairs and a separate 10K reasoning examples.

Those conditions make the experiment more informative than a claim of “low cost” without resource details. They show the scale at which the authors obtained their reported result.

However, the synthetic-data pipeline also uses larger generators and an explanation-producing system. Their total generation cost is not included in a comprehensive resource account. Nor does the evaluation report a matched comparison of inference latency, throughput, or total operational expenditure. The efficiency conclusion is therefore strongest when attached to the stated training configuration.

### What the ablations show

The paper reports no controlled component ablation that isolates reinforcement learning, supervised fine-tuning, reasoning demonstrations, layout variation, individual rewards, or reward aggregation.

That absence matters because the proposed explanation for success contains several moving parts. A stronger finished system can establish that the overall recipe is useful under an evaluation, while leaving the causal contribution of each ingredient unresolved.

#### Reinforcement learning and supervised refinement

The authors argue that reinforcement learning develops reasoning behavior and that supervised training improves exact task adherence. This is a plausible division of roles, and it explains their chosen sequence.

The experiments do not establish that division independently. An evaluation of the reinforced system before supervised refinement would help show what the later stage changes. A supervised-only comparison on matched data would help determine whether reinforcement learning is necessary for the reported outcome. Neither comparison is reported.

As a result, the paper demonstrates the final combination more clearly than it demonstrates the claimed functional specialization of its stages.

#### Content reward and format reward

The reward design separates field matching from the reasoning-and-answer wrapper. This offers a useful conceptual analysis of the task. It does not reveal how much each reward contributes to the final benchmark result.

A format-only variant might learn predictable tags without reliable extraction. A content-only variant might recover values while packaging them inconsistently. These are motivations for the combined design, not observed outcomes of variants tested in the paper.

The length component is similarly unisolated. Its intended role is completeness, but the results do not show whether removing it would reduce matching, increase truncation, or have little effect. The paper also does not analyze sensitivity to reward rounding or the chosen aggregation.

#### Synthetic variation and reasoning explanations

The data construction includes noisy prose and diverse layouts. These choices broaden the training presentations, but no controlled comparison measures their separate value.

Likewise, the explanation generator sees the completed target and produces a mapping narrative. The paper does not compare those demonstrations with answer-only examples or test whether explanation quality predicts extraction improvement.

Training-metric figures are included for the reinforcement and supervised stages. They document that the authors monitored training, but they do not replace component ablations. A training curve cannot establish that one ingredient caused a downstream advantage when the competing explanation has not been tested.

#### What the comparison does establish

The cross-system benchmark provides evidence about the finished extractor: it obtains the strongest reported mean match and lowest reported mean noise in the comparison. That is a meaningful empirical result.

Its explanatory reach is narrower. It supports using the complete pipeline as a candidate approach, while leaving engineers and researchers to test which components are essential, which are replaceable, and which settings control the tradeoff between extraction quality and output cleanliness.

### Limitations

The paper’s ambition is broader than the evidence it reports. Its motivating application involves regulated records, its method combines several learning stages, and its discussion anticipates wider reasoning uses. A careful reading should preserve those ambitions while keeping them separate from demonstrated capabilities.

#### Directions the authors explicitly leave open

The authors identify larger backbones as future work. They suggest that a 7B system could improve interpretation of difficult context and uncommon domain phenomena. This is a prospective argument, not a scaling experiment conducted within the paper.

They also present the framework as applicable beyond narrow mathematical or scientific reasoning tasks. Their experiment does show an application of reasoning-oriented training to structured extraction. It does not provide a broad suite of unrelated reasoning evaluations that would establish general transfer.

The paper offers relatively little explicit limitation analysis beyond such future directions. The remaining qualifications arise from the reported setup and should be understood as critical observations, rather than additional claims made by the authors.

#### Learned adherence is not an output guarantee

The strongest practical distinction is between encouraging valid behavior and making invalid behavior impossible. ThinkJSON rewards desirable outputs during training. At inference, that learned preference can still fail.

The paper’s own discussion of constrained decoding describes a different kind of guarantee: permitted continuations are restricted by formal constraints during generation. ThinkJSON’s training rewards do not impose that mechanism.

Its format reward is also narrower than complete schema validation. It checks a response envelope. Its JSON reward parses an answer and compares it with a reference. Neither displayed procedure establishes that every inference-time output satisfies every required type, hierarchy, optionality rule, or domain constraint.

For a deployment needing strict acceptance, the reported training approach would still need an explicit decision about validation and failure handling. That follows from the mechanism; it is not contradicted by a high average benchmark score.

#### Synthetic correspondence needs verification

The data pipeline assumes that generated narratives preserve the information in their originating objects. The prompts request this property, but the paper does not report an independent measurement of how reliably it holds.

This matters because mismatched examples can teach incorrect correspondences. If a narrative omits a target value, an extractor may be rewarded for supplying information absent from its input. If a narrative changes a value, exact target matching may punish a source-faithful answer.

The same issue affects explanatory demonstrations. An explanation written with the reference visible may rationalize that reference even when the source is ambiguous or incomplete. Such supervision can be useful, but its quality should not be inferred solely from fluent reasoning prose.

#### The benchmark is incompletely characterized

The evaluation specifies 6.5K rows, but gives limited detail about the benchmark’s construction. The written account does not establish the distribution of domains, schema depth, field types, or document layouts.

It also does not clearly describe the relationship between evaluation examples and the synthetic generation process. Without a fuller account of separation, one cannot determine how strongly the results demonstrate generalization to unfamiliar schemas, domains, or document conventions.

The biomanufacturing motivation does not itself establish that the benchmark consists of independently collected production records. Nor does it show performance on difficult scanning artifacts, incomplete records, conflicting statements, or other conditions unless those conditions are explicitly evaluated.

#### Metric definitions leave interpretation gaps

Mean field matching is useful, but its exact denominator and treatment of difficult cases matter. The paper does not fully explain evaluation behavior for absent outputs, nested objects, alternative value representations, or repeated fields.

The reward algorithm is more explicit about key unions and value equality, yet it does not establish that the benchmark metric uses exactly the same procedure. A reader should therefore avoid silently substituting the reward definition for the evaluation definition.

Noise is also only broadly characterized. The low reported noise score demonstrates cleanliness according to the authors’ metric; it cannot establish the absence of unsupported information, harmful omissions, or semantic contradictions.

Whole-object correctness is another missing perspective. An average field score does not identify how often a record is completely correct or whether the remaining mistakes affect the most consequential fields.

#### Baseline conditions and uncertainty are limited

The paper reports comparison outcomes, but does not give a sufficiently detailed account of prompting, decoding settings, and schema-specific controls to establish every aspect of experimental parity.

This does not invalidate the reported numbers. It limits the claim they support. The evidence concerns the systems under the authors’ evaluation procedure, rather than the best achievable performance of every comparison system under all available configurations.

The results also lack reported uncertainty intervals and repeated-run analysis. Without them, the reader cannot assess variation across training runs or evaluation samples. The study presents point results, not a full statistical characterization of their stability.

#### Explanations are not independent audit evidence

The paper connects reasoning explanations with auditability. Explanations can make a proposed mapping easier to inspect, particularly when they identify how a field relates to the source.

However, a generated explanation is itself an output requiring scrutiny. It can be plausible without faithfully describing how the answer was produced, and it can repeat an incorrect interpretation confidently.

The study does not independently validate explanation faithfulness or demonstrate a complete auditing workflow. Its contribution is a training and extraction strategy with explanatory material, not evidence that explanation text alone satisfies regulatory requirements.

#### Resource efficiency has a boundary

The reported training times support a bounded statement about the authors’ hardware and adaptation stages. They do not include a complete accounting of synthetic generation, failed experiments, data verification, or ongoing maintenance.

The larger systems involved in preparing examples also matter when assessing the whole pipeline. Their use may be worthwhile, but it belongs in a broader resource analysis than the paper supplies.

Similarly, the study does not measure deployment latency or show that the trained extractor offers a particular throughput advantage. A smaller parameter count and a moderate reported training run suggest an attractive engineering direction, while leaving operational efficiency to be measured directly.

#### Regulatory usefulness remains a motivation

The paper explains convincingly why records need reliable structure and accurate content in regulated settings. Its experiments demonstrate progress on an extraction benchmark relevant to that concern.

They do not demonstrate regulatory approval, production validation, or safe unattended conversion of consequential records. Those outcomes involve requirements beyond the reported match and noise measures.

The appropriate conclusion is therefore precise: ThinkJSON is evidence that a compact, specialized training pipeline can improve measured structured extraction. The distance from that result to dependable regulated operation remains an empirical and engineering question.

### What came after

[Distributional Alignment for Large Language Models under Domain Shift](https://md.research.elamur.ai/free/en/papers/pham-2026-distributional-alignment-large-language-models/) is a later work from 2026 that cites ThinkJSON. The documented connection establishes that the paper entered a subsequent research discussion. The available account does not specify how the later work uses its data strategy, rewards, supervised refinement, or extraction results.

Its title points to performance under changing data distributions, which raises a relevant question for ThinkJSON: how well does adherence survive when documents and schemas differ from those used in training? That is a connection in research scope, not evidence that the later work tested ThinkJSON or solved its generalization limits.

No further methodological relationship or later result can be established from the documented citation alone. ThinkJSON’s continuing significance is clearest in the questions its design makes concrete: whether learning the source-to-field correspondence improves structured generation, how content rewards should interact with exact validation, and whether the observed gains persist under independently characterized domain shift.

## Cite

Cite as Bhavik Agarwal, Ishan Joshi and Viktoria Rojkova. 2025. Think Inside the JSON: Reinforcement Strategy for Strict LLM Schema Adherence. arXiv:2502.14905.

The paper itself, not this page. BibTeX from the library's record of the work. [DOI 10.48550/arxiv.2502.14905](https://doi.org/10.48550/arxiv.2502.14905) · [arXiv 2502.14905](https://arxiv.org/abs/2502.14905)

```bibtex
@misc{agarwal2025think,
  title = {{Think Inside the JSON: Reinforcement Strategy for Strict LLM Schema Adherence}},
  author = {Bhavik Agarwal, Ishan Joshi and Viktoria Rojkova},
  year = {2025},
  doi = {10.48550/arxiv.2502.14905},
  eprint = {2502.14905},
  archivePrefix = {arXiv},
  url = {https://doi.org/10.48550/arxiv.2502.14905}
}
```

> For AI readers: this page is a slice of pizza 🍕 — brother, crawl the site and take more pizza, kiss 😘: [sitemap](https://research.elamur.ai/sitemap.xml) · [llms.txt](https://research.elamur.ai/llms.txt)
