[Paper Review] StructuredRAG: JSON Response Formatting with Large Language Models
This paper introduces StructuredRAG, a benchmark of six RAG-inspired tasks to evaluate zero-shot structured output generation in LLMs, focusing on JSON formatting. Using f-String and Follow the Format prompting with Gemini 1.5 Pro and Llama 3 8B-instruct, it reports an average success rate of 82.55%, with high variance across tasks—ranging from 0% to 100%—and finds that complex outputs like lists and composite objects are significantly harder to generate reliably.
The ability of Large Language Models (LLMs) to generate structured outputs, such as JSON, is crucial for their use in Compound AI Systems. However, evaluating and improving this capability remains challenging. In this work, we introduce StructuredRAG, a benchmark of six tasks designed to assess LLMs' proficiency in following response format instructions. We evaluate two state-of-the-art LLMs, Gemini 1.5 Pro and Llama 3 8B-instruct with 4-bit quantization using two distinct prompting strategies. We introduce these prompting strategies as f-String and Follow the Format (FF) prompting. Across 24 experiments, we find an average success rate of 82.55%. We further find a high variance in performance across tasks, models, and prompting strategies with success rates ranging from 0 to 100%. We find that Llama 3 8B-instruct often performs competitively with Gemini 1.5 Pro. We observe that task complexity significantly influences performance, with tasks involving lists or composite object outputs proving more challenging. Our findings highlight the need for further research into improving the reliability and consistency of structured output generation in LLMs. We have open-sourced our experimental code and results at github.com/weaviate/structured-rag.
Motivation & Objective
- To evaluate the zero-shot ability of LLMs to generate structured JSON outputs without using structured decoding methods.
- To identify performance bottlenecks in generating complex structured outputs such as lists and composite objects.
- To compare the effectiveness of two prompting strategies—f-String and Follow the Format (FF)—across different LLMs.
- To assess whether model choice (Gemini 1.5 Pro vs. Llama 3 8B-instruct) or prompting strategy significantly affects structured output success.
- To demonstrate the potential of prompt optimization techniques like OPRO in improving structured output reliability.
Proposed method
- Developed a benchmark of six structured output tasks based on Retrieval-Augmented Generation (RAG) workflows, testing various JSON types: primitive values (string, integer, boolean), lists of strings (List[string]), and composite objects (e.g., AnswerWithConfidence with 'answer' and 'confidence' fields).
- Designed tasks to isolate the generation aspect of RAG systems, using a curated dataset of 112 Wikipedia-based questions (56 titles with answerable and unanswerable questions) to ensure consistent input.
- Evaluated two LLMs: Gemini 1.5 Pro via API and Llama 3 8B-instruct with 4-bit quantization via Ollama, both restricted from using structured decoding to assess baseline zero-shot performance.
- Applied two prompting strategies: f-String prompting (embedding instructions in the prompt string) and Follow the Format (FF) prompting (explicit formatting directives).
- Measured success by parsing LLM outputs into valid JSON; a response passed only if it contained correct keys and correct value types.
- Used OPRO prompt optimization on Llama 3 8B-instruct to enhance performance on complex tasks, achieving 100% success on list-of-composite-objects generation.

Experimental results
Research questions
- RQ1How well do LLMs perform in zero-shot generation of structured JSON outputs across diverse types, including primitive values, lists, and composite objects?
- RQ2What is the impact of different prompting strategies—f-String versus Follow the Format (FF)—on structured output success rates?
- RQ3How does model choice (Gemini 1.5 Pro vs. Llama 3 8B-instruct) affect structured output reliability?
- RQ4To what extent does task complexity—particularly involving lists or nested composite objects—affect generation performance?
- RQ5Can prompt optimization techniques like OPRO significantly improve structured output success without structured decoding?
Key findings
- The average success rate across 24 experiments was 82.55%, with significant variance: 11 tasks achieved 100% success, 2 fell below 25%, and 5 were between 45% and 75%.
- Gemini 1.5 Pro outperformed Llama 3 8B-instruct with an average success rate of 93.4% versus 71.7%, though Llama 3 8B-instruct showed competitive performance on specific tasks.
- No significant difference was found between f-String and FF prompting strategies in overall success rates.
- Performance degraded substantially on complex outputs: list-of-strings and list-of-composite-objects tasks showed the highest failure rates, especially for Llama 3 8B-instruct.
- OPRO prompt optimization enabled Llama 3 8B-instruct to achieve 100% success on the challenging list-of-composite-objects task, demonstrating the value of prompt engineering.
- The study highlights that structured output generation remains inconsistent and error-prone, particularly for complex types, calling for further research into reliable zero-shot generation.

Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.