LLM 本身不能做到结构化输出, 它的结构化输出主要还是根据提示词告诉它要输出什么样子的格式

在早期 (gpt3.5 时代) 的 LLM 中结构化输出是比较弱的, 比如让它输出 Json 格式, 经常会出现格式错误的情况, 所以早期也诞生了很多 Json 修复工具。后来 LLM 对结构化输出做了优化之后才逐步稳定了下来

像 SpringAi 给 LLM 的结构化 Json 格式输出的提示词, 如下

Your response should be in JSON format.
				Do not include any explanations, only provide a RFC8259 compliant JSON response following this format without deviation.
				Do not include markdown code blocks in your response.
				Remove the ```json markdown from the output.
				Here is the JSON Schema instance your output must adhere to:				```%s```