P

Discriminative Model: Definition and Examples

A discriminative model is a type of machine learning model that learns to distinguish and classify data by directly modeling the decision boundary between different classes.

Full definition

A discriminative model (or discriminant model) is an approach in machine learning that focuses on learning the relationship between input data and output labels. Unlike generative models that seek to understand how data is produced, a discriminative model directly learns the conditional probability P(y|x), i.e., the probability that an output y corresponds to a given input x.

Concretely, these models draw decision boundaries in the data space to separate different categories. For example, a discriminative model trained to distinguish spam emails from legitimate ones will learn the characteristics that differentiate these two classes, without trying to model how an email is composed in general. This targeted approach often makes them more performant for pure classification tasks.

Among the most well-known examples of discriminative models are logistic regression, support vector machines (SVMs), classic neural networks used for classification, random forests, and convolutional neural networks (CNNs) for image recognition. These models are ubiquitous in industrial AI applications.

In the context of prompt engineering, understanding the distinction between discriminative and generative models helps to better grasp the capabilities and limitations of large language models (LLMs). LLMs like Claude are fundamentally generative models, but they can perform discriminative tasks (classification, sentiment analysis) when guided properly through well-crafted prompts.

Etymology

The term 'discriminative' comes from the Latin 'discriminare' meaning 'to separate, to distinguish'. In machine learning, it was adopted to describe models that 'discriminate' between classes, i.e., that learn to draw decision boundaries. The formal distinction between discriminative and generative models was popularized by Andrew Ng and Michael Jordan in their 2002 paper comparing the two approaches.

Concrete examples

Sentiment classification with an LLM used in discriminative mode

Analyze the sentiment of the following customer review and classify it as POSITIVE, NEGATIVE, or NEUTRAL. Answer only with the class.

Review: "The product arrived late but the quality is excellent, I am overall satisfied."

Spam detection by leveraging the discriminative capabilities of a generative model

You are an expert spam filter. Examine the following email and determine whether it is SPAM or LEGITIMATE. Explain the 3 main criteria that motivate your decision.

Subject: "Congratulations! You have won €10,000"
Body: "Click here to claim your prize..."

Educational comparison between discriminative and generative approaches

Explain to me like I'm 10 years old the difference between a discriminative model and a generative model in AI. Use an analogy with animals to illustrate your explanation.

Practical usage

In prompt engineering, one leverages the discriminative capabilities of LLMs by formulating clear classification tasks with well-defined categories. To obtain the best results, it is recommended to provide examples of each class (few-shot prompting) and to ask the model to justify its classification before giving the final answer, which improves accuracy through chain-of-thought reasoning.

Related concepts

Generative ModelClassificationSupervised LearningNeural Network

FAQ

What is the difference between a discriminative model and a generative model?
A discriminative model learns to distinguish classes by modeling P(y|x), the probability of a label given the data. A generative model learns how data is produced by modeling P(x|y) or P(x,y), which also allows it to generate new data. In practice, discriminative models are often more accurate for classification, while generative models are more versatile.
Are large language models like Claude discriminative models?
No, LLMs like Claude are generative models: they learn to predict the next token in a sequence. However, through prompt engineering, they can be effectively used for discriminative tasks like text classification, sentiment detection, or data sorting by framing these tasks as text generation problems.
What are the most used discriminative models in practice?
The most common discriminative models are logistic regression (simple and interpretable), SVMs (effective in high dimensions), random forests and gradient boosting (XGBoost, LightGBM) for tabular data, and deep neural networks (CNNs, fine-tuned transformers) for images and text. The choice depends on the data type, volume, and deployment constraints.

See also

How to use this prompt

  1. Copy the prompt with the button above.
  2. Paste it into ChatGPT, Claude or your favorite AI assistant.
  3. Replace the bracketed variables with your details, then refine the result.

About Prompt Guide

Prompt Guide is a free library of 2500+ ready-to-use prompts for ChatGPT, Claude and other AIs, with guides to learn prompting and tools to build and optimize your own prompts.

More definitions

Get new prompts every week

Join our newsletter.