HSR Sector 6 · Bangalore +91 96110 27980 Mon–Sat · 09:30–20:30
Chapter 1 of 25 — Generative AI Fundamentals
beginner Chapter 1 of 25

What Is Generative AI? Definition, Examples and How It Works

By Vikas Swami, CCIE #22239 | Updated Mar 2026 | Free Course

What Is Generative AI?

Generative AI is a category of artificial intelligence that creates content such as text, code, images, audio and video from patterns learned during training. Given an input such as a prompt, an image or an audio clip, a generative model produces an output that fits that input by generating it piece by piece or refining a rough representation into a finished result.

Suppose you ask a model to write a two-sentence notice about a college lab closing early. The model has learned patterns in notices, including where a date usually appears, how a closure is described and which phrases sound formal. If you supply the closing time, it can incorporate that detail. If you omit it, the model might supply a plausible time anyway. The ability to produce a convincing notice does not imply knowledge of the lab schedule.

When engineers say that a model learns a distribution, they mean it learns which outputs are more or less likely under different conditions. After the prompt “The opposite of hot is”, a text model will generally assign more probability to a continuation such as “ cold” than to “ square”. Changing the prompt to “Write a word that rhymes with hot:” changes which continuations fit. New outputs can combine learned patterns in new ways, but models can also repeat memorised material. Generation alone does not establish originality or factual accuracy.

AI vs ML vs DL: Where Does Generative AI Fit?

AI, machine learning and deep learning describe increasingly specific approaches to building systems. Generative AI describes what a system can produce. Keeping these two ideas separate helps explain why a deep neural network can classify an X-ray without generating an image, while a simple statistical model can generate a sentence without using deep learning.

A nested diagram shows deep learning inside machine learning and generative AI overlapping deep learning.
Many modern generative models use deep learning, while simpler generative models can work without a deep neural network.
TermWhat it meansExample
Artificial intelligence (AI)The broad field of building systems that perform tasks such as reasoning, planning, perception or language processing.A rule-based planner finds a route through a warehouse.
Machine learning (ML)Methods that fit a model to data rather than requiring a developer to write a rule for every possible case.A logistic regression model estimates whether an email is spam.
Deep learning (DL)A branch of ML that uses neural networks with multiple layers to learn representations.A convolutional neural network classifies images of components on an assembly line.
Generative AI (GenAI)Systems that generate content using learned patterns. Many modern systems use deep learning.A language model drafts an email, or a diffusion model generates an illustration.

Draw AI as the outer box, ML inside AI and DL inside ML. Within ML, draw a generative region that overlaps DL and extends beyond it. A modern language model belongs in the overlap. A statistical n-gram model, which can generate text by sampling the next word from counts of short word sequences, belongs outside DL. A deep spam classifier belongs in DL, outside the generative region.

For an engineering project, start with the output you need. If every support ticket must go into one of five categories, a classifier can produce a category and a score. If the task is to draft a response that addresses the details of each ticket, a generator produces a variable-length answer. One application can use both: a classifier routes the ticket, then a generator drafts a reply. The distinction is covered in more detail in generative vs discriminative models.

How Does Generative AI Work?

Training: learn parameters from examples

Consider a standard autoregressive language model. A tokenizer maps text into integer IDs. A token can represent a word, part of a word, punctuation or even a piece of a whitespace pattern, depending on the tokenizer. During training, the model predicts the next token at each position using the preceding tokens as context. The target is already in the training text, so developers do not need to label every next-token example by hand.

A language model converts a text prompt into token probabilities and appends a selected token before repeating.
An autoregressive language model predicts one next token at a time and uses each selected token as context for the next prediction.

If the model assigns probability p to the observed next token, the loss for that prediction is -ln(p). Assigning probability 0.80 gives a loss of about 0.223, while assigning 0.10 gives a loss of about 2.303. Backpropagation computes how the loss changes with the model's weights, and an optimiser uses those gradients to update the weights. Over many examples, the weights come to encode patterns useful for prediction. Some models receive additional training to follow instructions or produce preferred responses. See data, pretraining, training and inference for the full process.

Inference: generate with the trained model

At inference time, the model receives a prompt such as “The lab will close at”. It computes one score for each possible next token. These raw scores, called logits, are converted into probabilities using softmax when sampling. A decoding rule selects a token, appends it to the input sequence and repeats. The process ends when the model emits a stop token or the application reaches a stopping condition such as an output length limit. An ordinary prompt changes the context for prediction; it does not update the model's weights.

A model that repeatedly predicts the next token is called autoregressive. The probability of a complete continuation is the product of its next-token probabilities, each conditioned on the prompt and the tokens already generated. This dependence matters: once a model writes an incorrect date, it can continue with a sentence that is consistent with that date rather than checking it against a calendar.

Image generation can use a different process

A common text-to-image diffusion system starts from random noise in a compressed image representation called a latent. During training, a model can learn to estimate the noise added to examples at different noise levels. At inference, a sequence of denoising updates turns the noisy latent into one that matches the text conditioning. A decoder then converts that latent into pixels. Some image and audio generators use other methods, including token prediction. The guide to types of generative AI models compares these approaches.

Worked Example: How Does a Text Model Pick the Next Token?

Suppose the prompt is “The lab opens at” and a toy model has only three possible next tokens: “ 9”, “ 10” and “ noon”. It assigns them logits of 2.0, 1.0 and 0.0. At temperature 1, softmax exponentiates the logits and divides each result by their sum. The exponentials are approximately 7.389, 2.718 and 1.000. Dividing by 11.107 gives probabilities of 0.665, 0.245 and 0.090.

Greedy decoding picks “ 9” because it has the largest logit. Sampling can pick any of the three, in proportion to their probabilities. A random draw of 0.80 falls after the first token's cumulative probability of 0.665 and before the second token's cumulative probability of 0.910, so it selects “ 10”. The next input is now “The lab opens at 10”. The model must compute a fresh distribution, which could favour a continuation such as “ am”.

import math

def softmax(logits, temperature=1.0):
    if temperature <= 0:
        raise ValueError("Temperature must be positive")
    peak = max(logits)
    weights = [math.exp((x - peak) / temperature) for x in logits]
    total = sum(weights)
    return [weight / total for weight in weights]

tokens = [" 9", " 10", " noon"]
logits = [2.0, 1.0, 0.0]
probs = softmax(logits)
print([round(p, 3) for p in probs])  # [0.665, 0.245, 0.09]

draw = 0.80
cumulative = 0.0
for token, prob in zip(tokens, probs):
    cumulative += prob
    if draw < cumulative:
        print("The lab opens at" + token)  # The lab opens at 10
        break

Subtracting the largest logit before exponentiating leaves the probabilities unchanged and avoids overflow from large positive logits. With temperature 0.5, the same logits give approximately 0.867, 0.117 and 0.016. The most likely token becomes even more likely. Lower temperature changes how the system chooses tokens; it does not tell the model what time the lab actually opens.

To compare the toy calculation with a pretrained model, run the following in an environment with torch and transformers installed. The first run downloads DistilGPT2. The example takes the logits at the final prompt position and prints the five tokens with the highest probabilities. DistilGPT2 is a base completion model, so treat its outputs as continuations rather than answers from a chat assistant.

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

name = "distilgpt2"
tokenizer = AutoTokenizer.from_pretrained(name)
model = AutoModelForCausalLM.from_pretrained(name).eval()
inputs = tokenizer("The lab opens at", return_tensors="pt")

with torch.inference_mode():
    logits = model(**inputs).logits[0, -1, :]
    probs = torch.softmax(logits.float(), dim=-1)
    values, ids = torch.topk(probs, k=5)

for prob, token_id in zip(values.tolist(), ids.tolist()):
    print(repr(tokenizer.decode([token_id])), round(prob, 4))

Here, the model returns logits for each position in the input. Indexing with [0, -1, :] selects the first example in the batch, its final position and every token in the vocabulary. Softmax runs over the entire vocabulary before topk selects five results, so the five printed probabilities generally sum to less than one. Using repr makes any leading spaces visible.

Generative AI Examples: What Can It Create?

Generative systems differ in both their inputs and their outputs. A speech generator can accept text and return sound. An image editor can accept a source image, a prompt and a mask that identifies the region to edit. Products can combine several models behind one interface, so a product name does not necessarily identify a single model or a fixed set of features.

OutputTypical tasksExamples
Text and codeQuestion answering, drafting, summarisation, translation, code completion and test generation.ChatGPT is an application; Llama, Gemini and Claude are model or product families used for text tasks.
ImagesText-to-image generation, masked editing, and rendering an existing scene in a different style.DALL-E, Stable Diffusion and Midjourney.
AudioMusic generation, text-to-speech, and voice reproduction with the speaker's consent.MusicGen generates music; Bark is an example of a text-to-audio model that can produce speech.
VideoText-to-video, image animation, editing, and enhancement such as predicting intermediate frames.Sora is an example of video generation; Runway, Pika and Luma provide tools in this category.

One distinction beginners often miss is the direction of a task. Whisper is primarily a speech recognition model: audio goes in and a transcript comes out. It generates text tokens in its decoder, but it does not perform text-to-speech. In text-to-speech, written text goes in and an audio waveform comes out. Similarly, an image classifier returns a label such as “bus”, while a text-to-image generator can render a new picture of a bus.

Where Is Generative AI Used in Real Projects?

  • Customer support and office productivity: A virtual assistant can draft replies, summarise a long email thread or turn meeting notes into action items. If an owner or deadline is missing, ask the system to mark the field as unknown rather than invent it.
  • Software development: A coding assistant can draft a function or unit tests. Run the tests, check edge cases against the specification and verify library calls against the actual installed version. Code that looks idiomatic can still produce incorrect results.
  • Design, marketing and media: Teams can generate layout variants, storyboard clips, campaign drafts or background music. Review outputs for factual claims, rights to source material and consistency between video frames before publishing.
  • Synthetic data: A team can simulate invoice layouts to expand training data for a document parser. Evaluate the parser on a separate set of real invoices. Strong performance on synthetic examples may only show that the parser handles the generator's repeated patterns.
  • Scientific research: Generative models can propose candidate molecules or protein structures for investigation. A generated candidate is a hypothesis. Its appearance or model score alone cannot establish efficacy, safety or experimental validity.

For a beginner project, build an assistant that answers questions about a public college handbook. Retrieve relevant passages before asking the model to answer, include the section identifiers in its input and require it to cite them. This pattern is called retrieval-augmented generation (RAG). Test it with a question whose answer appears in one section, a question that requires combining two sections and a question the handbook does not answer. Check both whether the system retrieved the right passages and whether its final answer is supported by them.

What Can Generative AI Get Wrong?

A hallucination is a plausible-looking output that is false or unsupported. For example, a model may produce a believable section number for an attendance rule that does not exist. A correctly formatted citation is not evidence: open the cited section and check whether it supports the exact claim. The guide to LLM hallucination, evaluation and safety explains how to test this behaviour systematically.

Models can also reproduce biases from training data, generate inconsistent details and repeat parts of training examples. Inputs introduce a separate privacy concern: do not send student records, customer identifiers or production logs containing secrets to an unapproved service. For a classroom demo, use public or synthetic inputs and inspect generated content before sharing it.

Choose a check that matches the task. For a summary, compare dates, names and quantities with the source. For code, run tests that could expose a wrong assumption. For a fee calculation, put the arithmetic and policy rules in deterministic code, then let the model explain the verified result if a natural-language response is useful. Keeping the calculation outside the generator makes incorrect totals easier to trace and fix.

Key Takeaways

  • Generative AI creates content using patterns learned from data, often conditioned on a prompt or another input.
  • Deep learning describes a modelling approach; generation describes a capability. The categories overlap.
  • Training changes model weights. Ordinary inference uses those weights to produce an output.
  • Autoregressive text models extend a sequence one token at a time. Many image generators instead use iterative denoising.
  • Softmax converts logits to probabilities; a decoding rule determines which token is appended.
  • Evaluate generated outputs against evidence, tests or explicit requirements before relying on them.

Frequently Asked Questions

What is generative AI in simple words?

Generative AI is software that uses patterns learned from examples to make content. You can give it a request, such as drafting an email about a delayed delivery, and it can produce a response suited to that request. It may still introduce errors if the delivery details are missing or unclear.

Is all deep learning generative AI?

No. Deep learning describes how a model is built, using a neural network with multiple layers. A deep network that labels photos by category is a classifier. A deep network that creates images from text is generative. Simpler statistical models can also generate content without a deep network.

Is ChatGPT the same thing as generative AI?

ChatGPT is an application that uses generative models. Generative AI is the wider category, which includes systems that produce images, music, video or code as well as chat responses. The features of a particular application depend on the models and tools it provides, so they can differ across products and configurations.

Does a generative AI model search the internet for every answer?

No. A model can generate an answer from the prompt and patterns encoded in its weights, without performing a web search. Some applications give the model a search or retrieval tool. Even then, check what information was retrieved and whether it supports the answer, especially for recent facts and policies.

How should a beginner practise generative AI?

Start with a small task you can check, such as extracting deadlines from public notices. Collect examples with clear dates and examples with no deadline. Compare the generated dates against the notices and record when the model invents a date. Then revise the prompt and test it again on new notices.

Ready to Master Generative AI Fundamentals?

Join 45,000+ students at Networkers Home. CCIE-certified trainers, 24x7 real lab access, and Placement Guarantee* — structured interview support until placed.

Explore Course