Comment by simonw
1 year ago
Bits of this tutorial feel a little bit out-dated. The appendix on function calling for example - https://github.com/anthropics/courses/blob/master/prompt_eng... - shows how to implement function calling from scratch using XML-style tags - but Claude's API has had JSON schema-based function calling for a few months now: https://docs.anthropic.com/en/docs/build-with-claude/tool-us...
Oh, never mind - they have an entire separate course about tool use via the API here: https://github.com/anthropics/courses/blob/master/tool_use/0...
So they're using tools in that appendix purely to demonstrate how sophisticated you can get with raw prompting.
I ran through the whole tutorial and published some notes on tips I picked up from it here: https://simonwillison.net/2024/Aug/30/anthropic-prompt-engin...
The documentation still advocates using XML tags as a subset of prompt engineering despite the push for JSON-based structured I/O, confusingly: https://docs.anthropic.com/en/docs/build-with-claude/prompt-...
The structured output tutorial uses the XML tags to wrap user input instead of using system prompt engineering and then passing the user input as-is (IMO system prompt engineering is still better since it adds more control levers): https://github.com/anthropics/courses/blob/master/tool_use/0...
Personally, I prefer XML over JSON for prompts from a readability perspective.
I saw a talk recently from one of their prompt engineers where he encouraged XML-style tag use as well. Supported by the training datasets they use.
Was this in person or do you have a link by any chance? Would love to see it.
From my own experience XML tags are incredibly powerful — particularly for very large system prompts, with some markdown in there too.