liveBook · Manning

Classifier

As explained in Generative AI in Action

Text classification is the assignment of text to one or more predefined categories.

A classifier assigns text to a predefined category or intent so an application can route, filter, or moderate requests and responses. In a GenAI architecture, it can place a fast first-pass decision before an expensive model or screen generated content before delivery. section 10.5.1 section 10.6

Common application roles include:

  • Route questions to a capable model only when a lightweight classifier identifies the relevant intent. section 10.5.1
  • Detect and filter malicious prompts before they reach an LLM, and suspicious outputs after generation. section 6.6
  • Screen responses for accuracy, bias, appropriateness, sensitive details, formatting, and compliance risks. section 10.6

Dog-question intent gate

A local Phi-2 model receives a question and is prompted to answer only “yes” or “no” to whether it concerns dogs. A positive result can trigger GPT-4 for a detailed answer; a negative result avoids the more expensive call. The implementation uses Transformers and PyTorch, with explicit output parsing and model-generation configuration. section 10.5.1

Policy-constrained intent classification

A classifier can return one of a small set of labels for a product-support request while enforcing rules about scope, proprietary information, competitors, formatting, and harmful or illegal requests.

How Generative AI in Action covers it

How deep it goes
Explains routing and filtering roles with implementation examples, but stops short of mathematical classifier internals.
Examples
Demonstrates dog-question routing with Phi-2, policy-constrained product intents, and postgeneration screening.
What it assumes
Assumes familiarity with LLM applications and prompts while demonstrating classification through concrete model and API patterns.
What you can do after
Apply it via lightweight models, API classifiers, and response-processing layers to route, moderate, and constrain GenAI behavior.
How it connects
Connects classifiers to intent detection, model routing, prompt injection, response filtering, content moderation, and responsible AI.

Also explained in

Compare how 31 books explain classifier →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Generative AI in Action. The section links point to the parts of the book it draws on.