Stop Using JSON Mode for Structured Output. XML Tags Win 4 of 5 Cases.
Developers are advised to use structured XML tags instead of JSON mode for LLM outputs, as XML offers better resilience against model migrations and streaming issues. This approach provides a more robust contract between the prompt and the model, ensuring consistency in data extraction and formatting. The author suggests a specific XML skeleton structure for prompts, detailing sections for role, format, refusal policies, and examples, which can be more reliable than prose-based instructions. AI
IMPACT Adopting XML tags for LLM outputs can improve data extraction reliability and streaming performance, leading to more robust AI applications.