Set your Publisher ID in src/config/ads.ts to display live ads.
Introduction to Generative AI & Foundation Models
Discriminative vs Generative modeling, foundation models, and emergent abilities
Generative AI models learn the joint probability distribution of training data to synthesize novel, high-fidelity artifacts such as natural language, code, images, audio, and protein structures.
Discriminative vs Generative Paradigms
Discriminative Models calculate conditional probability P(Y|X): Given an input image or text, what is its class? (e.g., distinguishing a spam email from a valid one).
Generative Models estimate the joint probability distribution P(X, Y) or P(X): Given a prompt or latent vector, synthesize realistic samples that look like they came from the training distribution.
Foundation Models (such as GPT-4, Claude 3.5, Gemini 1.5, Llama 3) are massive neural networks trained on broad web-scale datasets via self-supervised next-token prediction, demonstrating zero-shot and few-shot task adaptation.
import json
def build_completion_payload(prompt_text, temperature=0.2):
"""Generates standard OpenAI/Gemini API completion request schema."""
return {
"model": "gpt-4o-mini",
"messages": [
{"role": "system", "content": "You are a senior full-stack software engineer."},
{"role": "user", "content": prompt_text}
],
"temperature": temperature,
"response_format": {"type": "json_object"}
}
payload = build_completion_payload("Generate a JSON schema for a user profile.")
print(json.dumps(payload, indent=2))Set your Publisher ID in src/config/ads.ts to display live ads.
Test Yourself With Exercise
What is the primary difference between discriminative and generative AI models?