Urgent.News

What's breaking now, across thousands of outlets.

AI

XML Tagging in Prompts: The Secret to Getting Better Output from Claude and GPT

XML Tagging in Prompts: The Secret to Getting Better Output from Claude and GPT A simple structuring trick that turns messy, unpredictable LLM outputs into clean, reliable ones. If you've spent any time writing prompts for Claude, GPT, or any other large language model, you've probably hit this wall: your prompt works fine for a simple ask, but the moment you pack in multiple instructions — some…

XML tagging is a simple trick that can help improve the output from large language models like Claude and GPT. When writing prompts for these models, it can be challenging to get accurate results when multiple instructions, context, examples, formatting rules, and the actual task are included. The issue arises because the model struggles to distinguish between different sections of the prompt, leading to incorrect answers or ignoring formatting instructions.

The solution is to wrap prompt sections in XML tags, which creates clear boundaries for the model to work with. This method leverages the fact that LLMs are trained on code, documentation, and markup, making them adept at recognizing XML syntax. Anthropic recommends using tags such as instructions, context, example, output_format, thinking, document, or article to structure the prompt.

By doing so, the model gains a precise understanding of the task, resulting in cleaner, more reliable outputs.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in AI

Node Date's epoch millisecond pit + using MCP to stuff the conversion into the AI stream

Node Date 的 epoch 毫秒坑 + 用 MCP 把转换塞进 AI 流 作者是 Node.js / JS 时间 方向的开发者。这篇不是广告,是踩坑记录 + 顺手做的工具。 背景 做 Node.js / JS 时间 时,时间戳转换是最常被低估的雷区。16 个时间戳工具(Unix 转换/时区/ISO8601/Cron/Duration…) 已覆盖日常;但每个语言/框架的坑都不一样,所以又补了…

More from Monday 3 August →