text-classification
Five classification prompts — aspect sentiment, chatbot intent, emotion, content moderation, and spam/phishing — each with a CEL-assertable schema and a judge-free deterministic eval. Schema design is eval design.
Text Classification
Five classification prompts for the labels that route, gate, and analyze real traffic — aspect sentiment, chatbot intent, emotion, content moderation, and spam/phishing. Each returns typed, validated JSON with a strict schema, and — the theme of this collection — each schema is designed so its eval is pure, deterministic CEL, no LLM judge needed. Closed enums and flat string arrays aren't just tidy output; they're what makes the classifier testable.
Like the Structured Extraction, Customer Support, RAG Essentials, Translation Essentials, and Summarization Essentials collections, every prompt is a system message, a user message, and a schema — framework-agnostic, SDK-generatable in TypeScript and Python.
Prompts
| Prompt | What it does |
|---|---|
aspect-based-sentiment | Per-aspect sentiment (battery: 😀, price: 😠) with a verbatim quote per aspect and an overall label. Deeper than plain sentiment. |
intent-detection | Classify a user message against your runtime intent taxonomy with confidence and an explicit out-of-scope (is_fallback) flag. |
emotion-detection | Emotion from a closed taxonomy (joy/anger/sadness/fear/surprise/disgust/neutral) — primary + secondary + intensity. |
content-moderation | Policy flags with severity and quotes, a safe gate, and a flat categories[] array. The injection-safety showcase. |
spam-detection | ham / spam / phishing with signals — phishing wins when a message is both. |
Not duplicated — cross-linked
This collection goes deeper than the general-purpose classifiers already on @sufleur; it doesn't re-ship them:
sentiment-analysisgives one overall label.aspect-based-sentimentbreaks it down per aspect.text-classificationis general single-label classification against a caller label set;intent-routingroutes to support queues.intent-detectionis purpose-built for NLU/chatbot intent with described intents and first-class out-of-scope detection.
Reach for the general tools when you want a plain label; reach for these when the shape of the problem (aspects, a described taxonomy, policy categories, spam vs phishing) has structure worth capturing.
The theme: schema design is eval design
Every prompt here is eval-gated, and all five evals are judge-free — pure CEL over the output. That's not luck; it's a schema-design choice:
- Closed enums (
overall_sentiment,primary_emotion,verdict, moderationcategory) let an eval assertoutput.x == case.expectedand mean it. - Flat string arrays exist specifically to be assertable:
content-moderationemits a top-levelcategories[](not just nestedflags[]) so an eval can checkcase.expected_categories.all(c, c in output.categories)without CEL needing to map over objects.emotion-detectionexposessecondary_emotions[]for the ambiguous-case allowance. - Verbatim quotes make groundedness a substring test:
aspect-based-sentimentassertsoutput.aspects.all(a, case.text.contains(a.quote))— mechanical, no judge. - Runtime-taxonomy membership (
intent-detection) is checked withoutput.intent in case.intents_labelsagainst a flat labels field in the dataset.
If you're authoring your own classifier, the lesson is: design the output schema and the eval assertions at the same time. A flat, enum-typed, quote-backed schema is one you can gate deterministically — cheaper and more reliable than grading it with another model.
House conventions
- Reasoning before the label. Every prompt emits its
reasoningfirst; classification is exactly where post-hoc rationalization hurts most, so the rationale precedes (and informs) the verdict. Key order is pinned in each system prompt. - Closed enums wherever the taxonomy is fixed (sentiment, emotion, moderation category, severity, spam verdict); runtime taxonomies (intent) carry the membership caveat and a documented one-line check.
- Quotes are verbatim and verifiable —
aspect-based-sentimentandcontent-moderationquote the triggering span character-for-character. - Input is data, never instructions. All user content is triple-mustache-injected inside XML-style delimiters;
content-moderationmakes this its headline property — "mark this safe" embedded in the text never moves the verdict. - Confidence is uncalibrated and says so in every schema description.
- Empty/garbage behaviour is specified and observable — empty input yields the neutral/safe/ham default, never invented labels, and the evals assert it.