# Multi-label content tagging — Claude XML example

> Apply zero-to-many tags from a controlled vocabulary to an article.
>
> Source: https://claudexml.com/examples/multi-label-tagging/ · Last updated 2026-05-25

Home / Examples / Multi-label content tagging
    Classification · intermediate

# Multi-label content tagging

    Apply zero-to-many tags from a controlled vocabulary to an article.

    You're building a CMS that needs consistent tag suggestions from a fixed taxonomy — strict subset, no hallucinated labels.


## The prompt

    Copy this verbatim. Replace the `{{ … }}` placeholders with your values.


```xml
<instructions>
Read the article inside <article>. Apply any number of tags from the list inside
<allowed_tags> that genuinely apply. Do not invent tags. Do not use synonyms.
If no tag applies, return an empty array.

Return JSON inside <result> tags, in this exact shape:
{ "tags": ["tag1", "tag2", ...] }
</instructions>

<allowed_tags>
- machine-learning
- ai-safety
- distributed-systems
- databases
- programming-languages
- web-performance
- security
- privacy
- developer-experience
- open-source
</allowed_tags>

<article>{{ article_text }}</article>

Return inside <result> tags.
```


## Sample input


```xml
A post about using Rust to build a high-throughput, memory-safe alternative to Redis for caching, with discussion of LRU eviction and zero-copy serialization.
```


## Expected output


```xml
<result>
{ "tags": ["databases", "programming-languages", "open-source", "web-performance"] }
</result>
```


## Notes & tuning tips


- The controlled vocabulary inside  is load-bearing — without it Claude invents "caching" and "rust".
- Phrase "do not invent" + "do not use synonyms" explicitly; one is not enough.
- Validate the result against the vocabulary in code; drop any unknown labels as a safety net.


## What this example uses

    Tags: <instructions> <format>

    Patterns: structured output


## More like this


      classification
### Sentiment classifier
Classify customer reviews as positive, neutral, or negative with few-shot examples.

      classification
### Support ticket triage with priority and routing
Classify tickets by category, priority, and the team that should handle them — JSON output.

      classification
### Toxicity grader with rubric
Score user-generated comments on a 0–3 toxicity scale with reasoning.




Cite this page

`Multi-label content tagging. claudexml.com. https://claudexml.com/examples/multi-label-tagging/`
