ElemedexA pocket encyclopedia of AI architectures

Glossary (TM) › Machine learning fundamentals

TM014

Generative vs discriminative models

Also: generative model, discriminative model, generative AI

In Spanish: Modelos generativos vs discriminativos

The distinction between models that learn to separate classes (discriminative) and models that learn how the data are distributed and can produce new examples (generative).

A discriminative model learns the relation between input and answer directly: the conditional probability p(class | data) or, without probabilities, a decision boundary. Logistic regression, support vector machines and AlexNet are discriminative: they can tell cats from dogs, but they cannot draw a cat.

A generative model learns how the data themselves are distributed, p(data) or p(data, class). Since it defines a full probability distribution, it can be used to generate new examples by sampling from it (Witten et al., 2017, p. 371). Curiously, a generative model can also classify: Naive Bayes models what an email of each class looks like and, with Bayes' theorem, inverts that information to decide whether a new email is spam (in the Pokédex it is typed as discriminative because of how it is used). GAN combines both: a generator that manufactures examples and a discriminator that tries to catch them (Goodfellow et al., 2014).

In the era of language models, "generative" has come to mean "producing text or images." Alammar & Grootendorst (2024) reserve the name for decoder models such as GPT and call encoders such as BERT, which produce embeddings rather than text, representation models (2024, p. 20). In Elemedex, the Generative and Discriminative types follow this broad distinction.

The linguist will hear an echo of generative grammar: for Chomsky (1957), a grammar is a device that generates all the grammatical sentences of a language and none of the ungrammatical ones. A language model also "generates" a language, but differently: it does not separate the grammatical from the ungrammatical; it assigns every sequence a probability. And generating is not understanding: that a system produces well-formed sentences says nothing about how they relate to the world (see form vs meaning).

Sources