Discover how machines learn to both recognize and create, just like humans!
Generative vs discriminative models in Prompt Engineering / GenAI - When to Use Which
Imagine you want to sort thousands of photos into categories by hand, like "cats" or "dogs," and also create new photos that look like real animals. Doing this manually means looking at every photo carefully and trying to imagine new ones yourself.
Sorting photos by hand is slow and tiring. Trying to create new realistic photos manually is almost impossible and full of mistakes. You can't easily guess what new photos should look like or quickly decide which category a photo belongs to.
Generative and discriminative models help computers learn from examples to do these tasks automatically. Discriminative models learn to tell categories apart, like sorting photos quickly. Generative models learn how to create new examples that look real, like making new photos of animals.
if photo_has_cat(photo): label = 'cat' else: label = 'dog'
label = discriminative_model.predict(photo)
new_photo = generative_model.generate('cat')These models let machines understand and create data, making tasks like image recognition and content creation fast and accurate.
Apps that recognize your face to unlock your phone use discriminative models, while apps that create new art or deepfake videos use generative models.
Discriminative models focus on telling things apart.
Generative models focus on creating new, realistic data.
Together, they make powerful tools for understanding and generating information.