[论文解读] StructuredRAG: JSON Response Formatting with Large Language Models
本论文提出了StructuredRAG,一个包含六个受RAG启发的任务的基准,用于评估大语言模型在零样本设置下生成结构化输出(特别是JSON格式)的能力。通过使用f-String和Follow the Format提示方法,结合Gemini 1.5 Pro与Llama 3 8B-instruct模型,报告了平均成功率为82.55%,但各任务间表现差异显著,范围从0%到100%不等,且发现生成复杂输出(如列表和复合对象)的可靠性显著更低。
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.
研究动机与目标
- 评估大语言模型在不使用结构化解码方法的情况下,零样本生成结构化JSON输出的能力。
- 识别在生成复杂结构化输出(如列表和复合对象)时的性能瓶颈。
- 比较两种提示策略(f-String与Follow the Format,简称FF)在不同大语言模型上的有效性。
- 评估模型选择(Gemini 1.5 Pro与Llama 3 8B-instruct)或提示策略是否对结构化输出成功率有显著影响。
- 展示提示优化技术(如OPRO)在提升结构化输出可靠性方面的潜力。
提出的方法
- 基于检索增强生成(RAG)工作流,开发了六个结构化输出任务的基准,测试多种JSON类型:原始值(字符串、整数、布尔值)、字符串列表(List[string])以及复合对象(如带有'answer'和'confidence'字段的AnswerWithConfidence)。
- 设计任务以隔离RAG系统中的生成部分,使用包含112个基于维基百科的问题的精选数据集(56个标题,每个标题包含可回答与不可回答的问题),以确保输入的一致性。
- 评估了两种大语言模型:通过API调用的Gemini 1.5 Pro,以及通过Ollama使用4-bit量化技术的Llama 3 8B-instruct,两者均被限制使用结构化解码,以评估基线零样本性能。
- 应用两种提示策略:f-String提示(将指令嵌入提示字符串中)和Follow the Format(FF)提示(显式格式指令)。
- 通过将大语言模型输出解析为有效JSON来衡量成功;仅当输出包含正确键和正确值类型时,响应才算通过。
- 对Llama 3 8B-instruct应用OPRO提示优化,以提升其在复杂任务上的表现,最终在列表型复合对象生成任务中实现100%的成功率。

实验结果
研究问题
- RQ1大语言模型在零样本生成结构化JSON输出方面表现如何,涵盖原始值、列表和复合对象等多种类型?
- RQ2不同提示策略(f-String与Follow the Format,简称FF)对结构化输出成功率有何影响?
- RQ3模型选择(Gemini 1.5 Pro与Llama 3 8B-instruct)如何影响结构化输出的可靠性?
- RQ4任务复杂度(特别是涉及列表或嵌套复合对象)在多大程度上影响生成性能?
- RQ5提示优化技术(如OPRO)是否能显著提升结构化输出成功率,而无需使用结构化解码?
主要发现
- 在24次实验中,平均成功率为82.55%,但表现差异显著:11项任务成功率为100%,2项低于25%,5项介于45%至75%之间。
- Gemini 1.5 Pro的平均成功率为93.4%,优于Llama 3 8B-instruct的71.7%,尽管Llama 3 8B-instruct在部分特定任务上表现具有竞争力。
- 在总体成功率方面,f-String与FF提示策略之间未发现显著差异。
- 在复杂输出任务上性能显著下降:列表型字符串与列表型复合对象任务的失败率最高,尤其对Llama 3 8B-instruct更为明显。
- OPRO提示优化使Llama 3 8B-instruct在具有挑战性的列表型复合对象任务中实现了100%的成功率,凸显了提示工程的价值。
- 本研究指出,结构化输出生成仍存在不一致且易出错的问题,尤其在复杂类型上,亟需进一步研究以实现可靠的零样本生成。

阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。