Source-linked AI summary

Let Me Speak Freely? A Study on the Impact of Format Restrictions on Performance of Large Language Models

Zhi Rui Tam, Cheng-Kuang Wu, Yi-Lin Tsai, Chieh-Yen Lin, Hung-yi Lee, Yun-Nung Chen

arXiv:2408.02442v3cs.CL

TL;DR

The paper asks whether structured-format restrictions affect the quality of LLM-generated content, a question not answered by evaluations focused on format adherence. It empirically compares restricted and natural-language generation across common tasks and schemas. It reports reduced reasoning performance under restrictions, generally worsening as constraints become stricter, alongside improved classification accuracy in some settings.

  • Problem

    Prior work evaluated format adherence but did not establish whether format-restricting instructions affect the quality of generated content, a question relevant to industrial applications.

    Source: §1 · p. 2
  • Method

    The study empirically evaluates LLM performance across tasks under structured-generation strategies, including constrained decoding, format-restricting instructions, and natural-language-to-format conversion.

    Source: §1 · p. 2, §2 · p. 2
  • Results

    Format restrictions can hinder reasoning while enhancing classification accuracy, and looser restrictions generally improve reasoning performance and reduce its variance.

    Source: §1 · p. 2, §7 · p. 7
  • Takeaways & Limitations

    The findings point to balancing format adherence, reasoning capability, and cost efficiency in LLM applications.

    Source: §4.1 · p. 4, §7 · p. 7

    The experiments use simple schemas with one reasoning field and one answer field, leaving robustness to more complex output structures for future study.

    Source: §3.2 · p. 3

Abstract

from arXiv · show

Structured generation, the process of producing content in standardized formats like JSON and XML, is widely utilized in real-world applications to extract key output information from large language models (LLMs). This study investigates whether such constraints on generation space impact LLMs abilities, including reasoning and domain knowledge comprehension. Specifically, we evaluate LLMs performance when restricted to adhere to structured formats versus generating free-form responses across various common tasks. Surprisingly, we observe a significant decline in LLMs reasoning abilities under format restrictions. Furthermore, we find that stricter format constraints generally lead to greater performance degradation in reasoning tasks.

1 Introduction

The paper asks whether format restrictions affect generated-content quality, a gap left by format-adherence evaluations. It empirically studies common schemas and finds that restrictions can impair reasoning, with stricter constraints generally causing greater degradation.

1 Introduction

  • Prior evaluations emphasized format adherence but did not address whether format-restricting instructions affect generated-content quality, a question with business impacts.The paper frames this gap as important for industrial applications, where inconsistent formatting complicates parsing and undermines reliability.Source: §1 · pp. 1–2
  • The study evaluates JSON, XML, and YAML and tests constrained decoding, format-restricting instructions, and NL-to-Format strategies applicable to industrial settings.The authors describe their work as a systematic empirical investigation of how these restrictions relate to content quality.Source: §1 · p. 2
  • Format restrictions can reduce reasoning performance, and stricter constraints generally produce greater degradation on reasoning tasks.The paper also proposes simple mitigation approaches intended to preserve consistent formats and performance.Source: §1 · p. 2

2 Methodology for Structured Generation

The study compares three structured-generation strategies that impose different degrees of constraint. They range from enforcing a token space to separating natural-language answering from format conversion.

2 Methodology for Structured Generation

  • Constrained decoding limits the output to a predefined token space, with JSON mode used as an implementation available through OpenAI and Gemini APIs.The paper assumes these implementations resemble constrained-decoding methods described in prior work.Source: §2 · p. 2
  • Format-restricting instructions specify a schema in JSON, XML, or YAML without enforcing a predefined token space, making them more relaxed than constrained decoding.The instructions are intended to make outputs structured for extracting and evaluating final answers.Source: §2 · p. 2
  • NL-to-Format first elicits a natural-language answer and then converts it to the target schema, separating content generation from format adherence.The paper presents this as its most relaxed structured-generation strategy.Source: §2 · p. 2

3 Experiments

The experiments compare structured-generation strategies across reasoning and classification tasks, using several models, task-specific metrics, and prompt variations. The output schemas use a simple reasoning field and answer field, while more complex structures remain a future research direction.

3.1 Datasets

  • The datasets are grouped by the primary skills they assess, spanning reasoning and classification tasks across multiple domains.The paper introduces this skill-based organization before describing the datasets.Source: §3.1 · p. 2

3.1.1 Reasoning Tasks

  • Reasoning evaluation uses GSM8K, Last Letter Concatenation, and Shuffled Objects to assess mathematical reasoning, symbolic reasoning, and inference about shuffled states.The experiments use the full Shuffled Objects validation set.Source: §3.1.1 · p. 2

3.1.2 Classification Tasks

  • Classification datasets include medical diagnosis, financial categories, sports plausibility, and stereotype classification.DDXPlus uses a StreamBench subset; Task 280 was included because prior work found formatting-related performance variation of up to 56%.Source: §3.1.2 · pp. 2–3
  • More relaxed prompts typically perform better on reasoning tasks, with JSON mode worst in most cases, followed by FRI, NL-to-Format, and natural language.The comparison covers GSM8K, Last Letter, and Shuffled Objects.Source: Figure 2 · p. 3

3.2 Output Format

  • Each output schema is limited to two key-value pairs for reasoning and answer, with field names permuted across prompts.The authors chose simple structures to isolate structural bias in reasoning and identify more complex output structures as future work.Source: §3.2 · p. 3

3.3 Model

  • The evaluated models include three commercial APIs and two open-weight instruction-tuned models.The named models are GPT-3.5 Turbo, Claude 3 Haiku, Gemini 1.5 Flash, LLaMA 3 8B Instruct, and Gemma 2 9B Instruct.Source: §3.3 · p. 3

3.4 Evaluation method

  • Classification uses accuracy and reasoning tasks use exact match, while an LLM-based perfect parser extracts final answers to reduce format-parsing errors.Prompt sensitivity is addressed with nine task-description and schema combinations and three natural-language prompt variations.Source: §3.4 · pp. 3–4
  • Figure 3 covers DDXPlus, Sports, Task 280, and MultiFin across different levels of format restriction.The caption identifies the plotted task scope but does not state the outcome of the comparisons.Source: Figure 3 · p. 4

4 Main Results

Format restrictions affected reasoning and classification differently: structured formats could disrupt reasoning, while JSON-mode was competitive or beneficial on classification tasks. The key factors included restriction level and whether reasoning remained separate from format adherence.

4.1 Impact of Format Restriction on Final Results

  • On Last Letter, 100% of GPT 3.5 Turbo JSON-mode responses placed the "answer" key before the "reason" key, resulting in zero-shot direct answering instead of zero-shot chain-of-thought reasoning; JSON-mode performed significantly worse than FRI (JSON).Source: §4.1 · p. 4
  • NL-to-Format produced nearly identical performance to unrestricted natural-language responses for most models, with a slight loss for LLaMA 3 8B Instruct from generation errors.Both approaches derive answers from the same initial natural-language response.Source: §4.1 · p. 4
  • The findings indicate that restriction degree and implementation matter, with key ordering and separating reasoning from format adherence emerging as important factors.The impact is task-dependent: stricter formats may hinder reasoning but improve classification accuracy when they constrain answer selection.Source: §4.1 · p. 4
  • JSON-mode was competitive across classification datasets and sometimes surpassed the other three methodologies; Gemini 1.5 Flash also showed a significant boost on DDXPlus.The authors note this classification trend differs from reasoning-task results.Source: §4.1 · p. 4

5 Discussion

The discussion examines schema strictness, format choice, parsing errors, and schema-enforced generation. It reports that relaxing schemas can improve reasoning-task performance, parsing errors do not explain most performance gaps, and natural language retains an edge on two of three reasoning datasets with JSON-Schema.

5.1 Impact on looser format restriction

  • Removing the prescribed schema while still requesting JSON improved average GSM8K scores and reduced prompt-perturbation standard deviations for Claude 3 Haiku, GPT-3.5 Turbo, and LLaMA 3 8B Instruct.The authors conclude that overly restrictive schemas may hinder performance, particularly on reasoning-intensive tasks.Source: §5.1 · p. 5, Table 1 · p. 5
  • For complex reasoning tasks, the authors recommend considering looser format restrictions to balance parseable structure with reasoning ability.Their example relaxes the schema by asking for JSON without specifying its key-value layout.Source: §5.1 · p. 5

5.2 Comparison Across Different Formats

  • No format’s consistency generalized across models; JSON was more consistent for Gemini, while JSON-mode helped classification but could hurt reasoning when key order failed.In the reported reasoning comparison, JSON-mode failed to preserve reasoning-before-answer order and caused a large performance drop.Source: §5.2 · p. 5

5.3 Structure Format and Parsing Error Rates

  • 0.148% JSON parsing error on LLaMA 3 8B’s Last Letter task coexisted with a 38.15% performance gap, indicating parsing errors were not the primary factor.Gemini 1.5 Flash and GPT-3.5 Turbo also had near-zero parsing failures across all three formats.Source: §5.3 · p. 5
  • A corrective prompt that reformatted outputs with parsing errors improved JSON and YAML scores for Claude 3 Haiku and LLaMA 3 8B.The authors describe this as a simple mitigation for parsing errors when they occur.Source: §5.3 · p. 5

5.4 Study on Structure Generation with Context-free Grammars

  • The newer JSON-Schema API guarantees schema adherence, yet natural language slightly outperformed JSON-Schema on two of three reasoning datasets.The comparison used gpt-4o-mini-2024-07-18 across three reasoning datasets.Source: §5.4 · pp. 5–6, Table 2 · p. 6

6 Related Work

The related work covers two strands: LLM reasoning ability and instruction-following with format specifications. Prior format-following benchmarks evaluate adherence, while the paper frames downstream performance under format instructions as an unaddressed question.

7 Conclusion

The study finds that structured generation affects performance across tasks: restrictive formats can hinder reasoning while improving classification accuracy, and looser formats generally improve reasoning performance and reduce variance. It recommends exploring a wider range of task difficulties and training data containing varied format instructions.

7 Conclusion

  • Format restrictions can hinder reasoning while enhancing classification accuracy, and looser restrictions generally improve reasoning performance and reduce variance.Parsing errors are not the primary cause of performance differences and can be mitigated through corrective prompting.Source: §7 · p. 7
  • Future work should examine how restrictive formats affect reasoning tasks of varying difficulty, from intensive to simple.The study focuses on reasoning-intensive tasks.Source: §7 · p. 7
  • Future studies should include more training data containing instructions in varied restrictive formats for local LLMs.Source: §7 · p. 7

A Limitation

The study’s limitations are its exclusion of more powerful models and the limited scope of its evaluation dataset.

A Limitation

  • Cost constraints prevented evaluation of more powerful models, including LLaMA 70B and GPT-4o.Source: A Limitation · p. 8
  • Including those models could provide additional insights into performance scaling with model size and architecture.Source: A Limitation · p. 8
  • The evaluation dataset is limited in scope; broader tasks and domains could provide a more comprehensive assessment of effectiveness and generalizability.Source: A Limitation · p. 9

B Choosing which LLMs as answer extraction

The study validates GPT-4-turbo as an answer parser, compares parser agreement, reports format-related costs, and evaluates additional models on format-prompt variations.

B Choosing which LLMs as answer extraction

C Cost Comparison Across Different Formats

D Additional models

  • Mistral-7B-v0.3 and GPT-4o-mini-2024 were also evaluated on format-prompt variations across seven tasks, with results shown in Figure 8.Source: D Additional models · p. 9

E Comparison between using regex and LLM as answer parser in GSM8K

The GSM8K comparison shows a substantial gap between strict regex matching and LLM answer parsing. The study also reports near-perfect alignment between GPT-4-turbo and human-parsed answers.

E Comparison between using regex and LLM as answer parser in GSM8K

F Averaged numbers for all datasets

The section reports results across formats and tasks, alongside the prompt templates and variations used in the evaluation.

F.1 Zero shot prompting comparing Text, JSON, XML, YAML

  • The section identifies score summaries across four formats for classification and reasoning tasks, plus JSON-mode results across six datasets and a comparison of answer-parsing methods.The supplied passages describe Table 10, Table 11, Table 9, and Table 8, but do not provide their cell values.Source: §F.1 · pp. 10–11, Table 9 · p. 11, Table 8 · p. 11
  • GPT-4o is described as quite consistent under format restrictions, while Mistral-7B-v0.3 scores are very close to 0% on Last Letter across all four formats.The figure covers GSM8K, Last Letter, Shuffled Object, Sports Understanding, MultiFin, NL Task 280, and DDXPlus.Source: Figure 8 · p. 11

G.1 Prompt Format

  • The evaluation uses a fixed template, varies task, format, few-shot examples, and question text, and tests three variations per description slot for nine prompt combinations.Models are prompted with all nine combinations to calculate sensitivity and variance; reasoning tasks include zero-shot chain-of-thought prompting.Source: §G.1 · pp. 11–12

G.2 Prompt Variations

  • For reasoning tasks, the authors use three prompt-format variations and create three answering-format variations for both reasoning and direct-answer tasks.The variations are shown in Figures 16–21.Source: §G.2 · pp. 12–13
Loading 2408.02442v3…