liveBook · Manning

Llm classification

As explained in AI Agents and Applications

LLM classification is the use of a large language model to assign an input to one of several specified categories.

LLM classification assigns an input to one of several specified categories, then uses the decision to select a tool, data source, or workflow. In query routing, it can distinguish vector-store, SQL, and graph questions; in a guardrail, it can reject requests outside an assistant’s domain. section 10.8 section 14.2.1

Build a practical classifier by defining clear categories and connecting its decision to deterministic application logic:

  • Describe each category in the prompt and provide few-shot examples, such as routing a revenue question to a vector store and a units-sold question to SQL. section 10.8
  • Return a structured decision when consistency matters; a Pydantic model can expose a boolean classification and a brief reason. section 14.2.1
  • Use the result before downstream work: route an in-scope request to the appropriate agent or retriever, and send an out-of-scope request to a refusal path. section 10.8 section 14.2.1
  • Add fallback behavior when the selected source returns nothing, such as trying an alternative source for structured results. section 10.8

Travel-domain guardrail

A lightweight classifier receives the user’s last message and returns whether it concerns destinations, attractions, lodging, prices, availability, or weather in Cornwall or England. A non-travel request receives a fixed refusal and exits through a guardrail_refusal node before downstream agents run. For example, “Can you give me the latest results of Inter Milan?” is refused. section 14.2.1

How AI Agents and Applications covers it

How deep it goes
Explains prompts, few-shot examples, structured outputs, routing, fallbacks, and early exits without detailing classifier evaluation.
Examples
Demonstrates revenue, sales, reporting-line, travel-domain, and unrelated sports questions as classification cases.
What you can do after
Apply it via an LLM, structured schema, retriever or tool router, and LangGraph early-exit path.
How it connects
Connects LLM classification with query routing, RAG, vector stores, SQL databases, graph databases, guardrails, and LangGraph.

Related concepts

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