Claude With Amazon Bedrock
← All lessons
Lesson 23Claude With Amazon Bedrock

Structure with XML tags

Summary audio

Spoken summary — press play to read along: the line being spoken stays near the top.

Study notes
  • Purpose of XML Tags: XML tags are used to provide explicit structure within a prompt, helping the AI (like Claude) understand how content is grouped and what the nature of that content is.
  • Problem with Large Prompts: When a prompt contains a large volume of data (e. g. , many pages of records), the AI can struggle to determine the correct structure and meaning of the text.
  • Function of Tags: Tags act as labels (e. g. , <sales_records>) that give the AI insight into the content contained within them, making the prompt's structure obvious.
  • Resolving Ambiguity: Tags clarify the role of different content chunks. For example, instead of relying on implied context ("debug my code below"), wrapping content in tags (e. g. , <my_code> and <docs>) makes it clear which input is code and which is documentation.
  • Application: Even for small, interpolated data (like height or weight), using tags (e. g. , <athlete_information>) can clearly delineate external input and improve the quality of the AI's output.
  • Outcome: Structuring a prompt with XML tags can lead to a measurable improvement in the quality of the AI's response.

Takeaways

  • XML tags provide explicit structure and labels to help the AI understand how content is grouped.
  • They resolve ambiguity by clearly defining the role of different content chunks (e. g. , code versus documentation).
  • Structuring prompts with tags improves the quality of the AI's response, especially when dealing with large volumes of data.
  • Tags can be used to delineate external input, even for small data points.
Flashcards 7 cards
Question
click to reveal · ←/→
Answer
click to flip back
Export to Anki (.tsv) ↓
Knowledge check 6 questions