Avatar LogoJeff Thomas

AI, ML & GenAI Demystified Series: Training Day

written byJeff Thomas

Artificial Intelligence|Machine Learning|Series

Published: July 22, 2025

61 min read |
AI, ML & GenAI Demystified Series: Training Day

Photo by: Jason Leung

Introduction

Welcome to Part 4 of our AI, ML & GenAI Demystified Series—Training Day. If you've been following along, you've already stocked the pantry and sharpened your knives. In Part 1: Foundations of AI, we unpacked what AI, ML, and Generative AI really are. Part 2: Should AI Solve This? asked whether the dish you're about to cook is even worth making with AI. And in Part 3: Good Data Beats Clever Models, we sorted, cleaned, and prepped our ingredients—because no great dish starts with rotten tomatoes.

Now, it's time to cook.

In this post, we enter the heart of the machine learning kitchen. We'll explore how to choose the right kind of model for your recipe, how different models "learn" from your data, and what it really means to train a system. From learning paradigms like supervised and reinforcement learning to modern architectures like transformers and diffusion models, we'll walk through how today's machines go from clueless to capable.

We'll also break down terms like tokenization, embeddings, attention, and context windows so that you can finally understand how systems like GPT-4 and Claude do their magic—and why it matters whether they're encoder-only or decoder-based. By the end, you'll know the difference between baking a batch of predictions and crafting a gourmet generative model.

Let's turn up the heat.

Learning Paradigms

Now that we've talked about the ingredients (data), let's get into how AI systems actually learn from them. Think of this like cooking styles—baking, sautéing, slow-cooking—all different methods to turn ingredients into something useful. Machine learning (ML) has its own "cooking styles," and they fall into five main paradigms: supervised learning, semi-supervised learning, self-supervised learning, unsupervised learning, and reinforcement learning.

Each of these learning types tells the model how to make sense of the world. Are we feeding it answers and asking it to generalize? Letting it find patterns on its own? Or putting it in a game-like environment to learn through trial and error?

Here's the big picture:

ParadigmHow It LearnsCommon ML TasksLabeled?Example Use Cases
Supervised LearningLearns from labeled data with known answersClassification, Regression, Forecasting YesSpam detection (spam/not spam), image classification (cat/dog), sentiment analysis (positive/neutral/negative)
Semi-Supervised LearningUses small labeled + large unlabeled dataClassification, Regression PartialFace recognition, search ranking, voice assistants with minimal manual labeling
Self-Supervised LearningLearns by generating its own labels/tasksRepresentation Learning, Pretraining, Classification (labels generated)Masked word prediction (LLMs), image patch recovery (ViTs)
Unsupervised LearningFinds hidden patterns in unlabeled dataClustering, Dimensionality Reduction, Anomaly Detection NoCustomer segmentation, topic modeling, fraud detection
Reinforcement LearningLearns by trial and error via rewards/penaltiesPolicy Optimization, Sequential Decision Making No (uses rewards)Game-playing agents, robotics, autonomous systems

Let's break them down a bit.

  • Supervised learning is like training a student with an answer key. You show the model examples—emails labeled "spam" or "not spam," or photos labeled "cat" or "dog"—and it learns to map inputs to correct outputs. This is powerful for classification and regression problems but requires lots of labeled data.
  • Semi-supervised learning is like teaching with just a few answer key examples and a whole lot of guesswork. The model gets a small amount of labeled data and a larger pile of unlabeled data, learning from both. It's often used when labeling is expensive or time-consuming—like training a voice assistant using a few transcribed conversations and many more raw ones.
  • Self-supervised learning is even more hands-off. The model generates its own learning tasks from the data—like covering part of a sentence and asking itself to fill in the blank. It's the secret behind how large language models and vision transformers pretrain on massive datasets without needing manual labels.
  • Unsupervised learning is a bit more curious. There's no answer key; instead, the model looks for hidden patterns or natural groupings. It's what powers clustering in customer segmentation or anomaly detection in high-volume security logs.
  • Reinforcement learning is less common in day-to-day business analytics, but it shines in domains that require sequential decision-making. The model learns by taking actions and receiving feedback—like a robot learning to walk or a trading agent adjusting a portfolio over time. Think of it like training a pet: treat when it does well, correction when it doesn't.

💡 Training Loop Vocabulary

When you train a model—especially in supervised learning—you often hear terms like epoch, batch size, and iteration. Here's what they mean:

  • Epoch: One full pass through the entire training dataset.
  • Batch Size: The number of samples processed at once before the model updates its weights.
  • Iteration: A single update step; if you have 1,000 samples and a batch size of 100, that's 10 iterations per epoch.

Most models are trained over multiple epochs, meaning they cycle through the data again and again, each time adjusting the weights to reduce error. This repetition helps the model improve—but too many epochs can cause overfitting, where it memorizes instead of generalizing.

Each of these paradigms solves different types of problems. But in practice, real-world systems often blend them. A modern AI assistant might use self-supervised learning to pretrain its knowledge, supervised learning to fine-tune on specific tasks, and reinforcement learning to align with human preferences. So don't think of these paradigms as rigid boxes—think of them as modular techniques you can mix and match depending on the task at hand.

Before we dive deeper into architectures and model types, it's helpful to connect these learning paradigms to the practical ways AI is delivered today—especially in the cloud. After all, not every project starts with training a model from scratch.

Let's take a look at how these learning styles map to real-world ML pathways—from plug-and-play APIs to fully custom models.

ML Tasks

Now that we've explored how machines learn, let's shift focus to what they're learning to do. Think of this as moving from cooking styles (baking vs. frying) to dishes (soufflé vs. stew). In machine learning, we call these tasks—the specific kinds of problems a model is trained to solve.

Tasks are like the blueprint for your AI project. Are you trying to classify emails as spam or not? Forecast next month's sales? Spot anomalies in a network? Your choice of task determines what kind of model to use, what data format to feed it, and how to evaluate success.

Here's a breakdown of common ML tasks, the learning paradigms they align with, typical algorithms used, and some familiar use cases:

ML TaskLearning Paradigm(s)Common AlgorithmsDescriptionExample Use Cases
ClassificationSupervised, Semi-, Self-SupervisedLogistic Regression, Decision Trees, SVM, BERTPredicts a category label from input dataSpam detection, image recognition, sentiment analysis
RegressionSupervised, Semi-SupervisedLinear Regression, XGBoost, Random ForestPredicts a continuous numeric valueHousing prices, energy consumption, stock price prediction
Time Series ForecastingSupervisedARIMA, LSTM, Prophet, Transformer-based modelsPredicts future numeric values based on temporal patternsSales forecasting, demand planning
ClusteringUnsupervisedK-means, DBSCAN, Hierarchical ClusteringGroups data points into similar clustersCustomer segmentation, behavior analysis
Dimensionality ReductionUnsupervised, Self-SupervisedPCA, t-SNE, UMAP, AutoencodersCompresses high-dimensional data to fewer featuresVisualization, feature selection, noise reduction
Anomaly DetectionUnsupervised, Semi-SupervisedIsolation Forest, One-Class SVM, AutoencodersIdentifies rare or unusual data pointsFraud detection, intrusion detection
Policy OptimizationReinforcement LearningQ-Learning, PPO, DQNLearns best actions to maximize reward over timeGame-playing agents, robotics, automated trading
Sequence Decision MakingReinforcement LearningActor-Critic, Transformer + RL, Imitation LearningChooses a sequence of actions in an environmentChatbots, self-driving cars, recommendation engines
Representation LearningSelf-SupervisedAutoencoders, Contrastive Learning, SimCLRLearns useful internal features or embeddingsLLM pretraining, speech/audio encoders, personalization

💡 Task vs. Paradigm?

  • Paradigms (supervised, unsupervised, etc.) define how learning happens.
  • Tasks (classification, clustering, etc.) define what the model is trying to do.
    You can solve the same task using different paradigms or algorithms depending on your constraints.

For example, you might solve a classification problem (like predicting whether a review is positive or negative) using:

  • Supervised learning with labeled training data
  • Self-supervised learning with masked text prediction
  • Or even an LLM API where you're just prompting a pretrained model with examples

Let's break down the key machine learning tasks from the table above so you can see how they show up in the real world—and why they matter.

  • Classification is about sorting things into categories. Is this email spam or not? What breed of dog is in this photo? What sentiment does this review carry—positive, neutral, or negative? If your answer options are discrete (yes/no, A/B/C), you're doing classification.

💡 Confidence Scores in Classification

In classification problems, models often don't just predict a class—they also output a confidence score (a probability between 0 and 1, often shown as a percentage). This represents how sure the model is about its prediction. For example, a model might say "This email is spam with 92% confidence."


This confidence score can be useful for threshold tuning. You might decide to only flag an email as spam if confidence is above 90%, or to escalate a medical prediction for human review if confidence is low. But beware: high confidence doesn't always mean the prediction is correct—especially in models prone to overconfidence or trained on biased data.


Calibration techniques (like Platt scaling) can be used to align confidence scores with real-world likelihood. A well-calibrated model that says it's 70% confident should be right about 70% of the time.

  • Regression predicts numeric values. If you're estimating house prices, forecasting temperature, or predicting how many units you'll sell next quarter, you're doing regression. A special subtype is time series forecasting, where the data's order matters—because tomorrow depends on today.

💡 Clarifying the Confusion: Logistic vs. Linear Regression

The names can be misleading, so let's set the record straight:

  • Linear regression is a true regression algorithm. It predicts continuous numeric values like house prices, temperatures, or revenue.
  • Logistic regression, on the other hand, is actually a classification algorithm. It predicts discrete class labels, most often in binary classification scenarios like spam detection or yes/no decisions.

🔍 The key difference? Linear regression outputs numbers, while logistic regression outputs probabilities that are converted into class predictions using a sigmoid function.

  • Time Series Forecasting is all about predicting the future using temporal patterns. Unlike standard regression, this task has a time axis. Think demand planning, weather forecasting, or predicting CPU usage over the next hour. Specialized models like ARIMA, LSTM, and Prophet are often used here.
  • Clustering is used when you want the model to find natural groupings in the data—without predefined labels. For example, marketers might ask, "How many types of customers do we really have?" and let the model group them based on purchase behavior, geography, or engagement.
  • Dimensionality Reduction helps simplify messy, high-dimensional data. Imagine a spreadsheet with 500 columns—many of which are redundant or noisy. This task compresses that complexity into fewer, more meaningful features. It's commonly used for visualization, denoising, or speeding up downstream models.
  • Anomaly Detection is like teaching a model to spot the weird stuff. You train it on "normal" examples and then ask it to flag outliers—transactions that look fraudulent, devices behaving oddly, or network logs that don't match past patterns. It's critical in cybersecurity, finance, and IoT monitoring.
  • Policy Optimization is central to reinforcement learning. Instead of making one prediction at a time, the model learns how to act—choosing actions that maximize long-term rewards. Think game-playing agents like AlphaGo, warehouse robots deciding which package to pick up next, or a digital assistant learning to respond better over time.
  • Sequence Decision Making is a broader category of reinforcement learning where the model's goal isn't just to pick the next best action, but to build a smart sequence of actions in an environment. This powers everything from route planning in self-driving cars to chatbot response chains and multi-step recommendations.
  • Representation Learning is the backbone of modern deep learning. Instead of learning just to predict an output, the model learns useful internal structures—called embeddings—that represent meaning. This is what lets a model understand that "dog" is semantically closer to "puppy" than to "banana." It's foundational to tasks like transfer learning, personalization, and generative AI.

Because the task you choose shapes everything that follows: the kind of data you collect, how you process it, the type of model you train, and how you measure success. It's the difference between saying "We need AI" and saying "We need a model that forecasts product demand next quarter with 85% accuracy."

Clarity about your task unlocks the rest of the journey.

📋 Need Help Picking an Algorithm?

Microsoft offers a great Machine Learning Algorithm Cheat Sheet that visually guides you through which model to try based on your data and problem type. It's a handy tool whether you're doing classification, regression, or clustering.

Understanding the task helps shape all your next steps: data formatting, algorithm selection, model architecture, and how you'll judge if your model is any good.

And speaking of next steps… once you've picked your task and paradigm, how do you build that model? Do you grab an off-the-shelf API, fine-tune a foundation model, or roll up your sleeves and write your own neural net?

Let's walk through that landscape next.

ML Pathways

Now that you know what your model needs to do and how it can learn, the next decision is about how much you want to build, versus how much you want to borrow.

In machine learning, there's no single starting point—there's a spectrum of approaches, ranging from fully managed APIs to custom model development. We call these ML Pathways.

Just like cooking, some people want the convenience of a meal delivery kit, while others want to forage, prep, and cook it all themselves. Your choice depends on timeline, expertise, budget, and how specific your needs are.

PathwayEffort LevelCustomizationControlTechnical Skill NeededSpeed to DeployExample Tools / Services
1. Pretrained APIsVery Low Minimal🔒 Closed Low🚀 InstantAWS Rekognition, Azure Form Recognizer, Google Vision
2. Foundation Model APIsLow⚠️ Prompt-based🔒 Semi-Closed Low to Medium FastGPT-4, Claude, Gemini, Bedrock, Azure OpenAI
3. Fine-Tuned FMsMedium High🔓 Moderate Medium Fast to ModerateHugging Face Transformers, OpenAI FT, Vertex AI
4. AutoMLMedium Moderate🔓 Partial Medium ModerateVertex AI AutoML, SageMaker Autopilot, Azure AutoML
5. Custom MLHigh Full🔓 Full🔴 High🐢 SlowerPyTorch, TensorFlow, Scikit-learn, Keras

Let's walk through each option with its ideal use cases, strengths, and trade-offs.

  1. Pretrained APIs (Managed ML Services)
    "Just heat and serve."
    These are the fastest to adopt—you send in data via an API and get a prediction back, no training required. These services are built on models that already know how to handle common tasks like sentiment analysis, OCR, or object detection. Best for simple, well-scoped use cases, they offer plug-and-play speed with minimal effort. Not great for domain-specific nuance or applications that require brand tone or deeper customization. Think of them for classifying support tickets or labeling product images—quick wins where accuracy is "good enough."
  2. Foundation Model APIs
    "Asking a super-smart intern."
    These let you interact with powerful language and vision models via prompting, without the need for training or infrastructure. You're essentially steering a highly capable generalist using natural language. Best for prototyping, multi-use tooling, and content generation across diverse applications. Not great for scenarios requiring guaranteed accuracy, predictability, or long-term cost efficiency. They shine in chatbots, summarizers, or code assistants—flexible tools where creativity matters more than precision.
  3. Fine-Tuned Foundation Models
    "Same model, more your style."
    Here you start with a powerful base model and adapt it using your labeled data. This approach gives you a balance between power and control, allowing you to encode your domain expertise, brand tone, or specialized vocabulary. Best for high-accuracy use cases, regulated environments, or situations where general models fall short. Not great for teams without labeled data or the skills to manage fine-tuning pipelines. Common applications include legal clause extraction, industry-specific assistants, or internal knowledge retrieval tools.
  4. AutoML Model Building
    "Meal kits with smart instructions."
    This is like using a meal kit: you bring your own ingredients (data), and the platform helps you cook the dish by selecting the algorithm, preprocessing steps, and training configuration. Best for structured data teams who want customized models without deep ML knowledge. Not great for edge cases or unconventional problem types where the system's choices might fall short. It's well suited for problems like churn prediction, demand forecasting, or dynamic pricing models—where your data is clear, and you just want the best model fast.
  5. Custom ML (Full Control with Code)
    "From raw ingredients to five-star meal."
    This is the full kitchen—from scratch, with your own knives and recipe. You build, train, and optimize your model architecture by hand using ML frameworks like PyTorch or TensorFlow. Best for expert teams working on R&D, edge deployment, or applications with strict requirements and unique constraints. Not great for fast-moving product teams or generalized business workflows. This path is used in custom fraud detection systems, real-time medical imaging tools, or optimized models deployed to hardware-constrained devices.

Most teams don't stick to just one pathway. You might prototype with a foundation model API, then fine-tune it for production. Or start with AutoML and eventually rebuild using PyTorch for performance. These pathways are tools—not silos.

💡 ML Pathways ≠ Learning Paradigms

Your pathway defines how much you build. Your learning paradigm defines how the model learns. You can build a supervised model using any of these approaches, depending on the level of control you want.

Next, we'll zoom in on modeling strategies and training approaches—how models are structured, trained, and generalized, whether you're using a pretrained LLM or building from scratch.

Modeling Strategies & Training Approaches

Once you've chosen your ML pathway—whether you're using a foundation model or building from scratch—the next step is deciding how your model will actually learn, adapt, and generalize. This is where modeling strategies come into play.

Some models are trained all at once on a fixed dataset. This is known as batch learning, and it's ideal when your data is stable and plentiful. Think of it like preparing for a standardized test: you study everything first, then perform once. But batch learning doesn't adapt easily to change—when new data arrives, you may need to retrain the whole model.

In contrast, online learning trains models incrementally, updating weights as new data streams in. It's more like learning on the job. This approach is useful for systems that need to adapt in real time—like personalization engines, stock prediction models, or fraud detection systems.

Another key distinction is how models apply what they've learned. Some use instance-based learning, where predictions are made by comparing new inputs to stored examples—like k-nearest neighbors (k-NN). Others are model-based, learning a general function that maps inputs to outputs. Most modern systems, especially those using neural networks, fall into this latter category.

Beyond how models are trained and generalized, there are a number of strategies that make machine learning more efficient, flexible, or scalable.

StrategyWhat It DoesUse Cases / Benefits
Transfer LearningStarts with a pretrained model and fine-tunes it on new dataDomain adaptation, low-data scenarios
Ensemble MethodsCombines multiple models for better performanceIncreases accuracy, reduces overfitting (e.g., random forests)
Federated LearningTrains across decentralized devices without sharing raw dataPrivacy-preserving, good for mobile or IoT deployments
Meta-Learning"Learns how to learn" by training across many tasksFew-shot/zero-shot learning, rapid adaptation

These strategies don't define whether a model is supervised, unsupervised, or reinforcement-based. Instead, they sit alongside your learning paradigm and architecture choices—shaping how flexible, reusable, or resilient your system becomes.

For example, a supervised model like BERT can be used in transfer learning. A classification system can be boosted by combining it in an ensemble. A neural network deployed across phones can use federated learning. These aren't mutually exclusive—they're complementary layers you can mix and match.

To summarize:

  • Batch learning is static and retrained periodically.
  • Online learning updates continuously with new data.
  • Instance-based learning makes decisions based on stored examples.
  • Model-based learning abstracts and generalizes patterns.
  • Transfer learning, ensembles, federated learning, and meta-learning help improve performance, scalability, or adaptability without reinventing the wheel.

Understanding and applying these strategies will make your ML systems more robust and responsive to real-world challenges. But even the most clever strategies rely on the underlying machinery of learning: the model architecture itself.

Next, we'll dive into neural networks and transformers—the engines that power everything from recommendation systems to ChatGPT.

Neural Networks & Transformers

If learning paradigms explain how models learn, and ML tasks explain what they learn, then neural networks explain who is doing the learning—especially in today's most powerful AI systems.

At their core, neural networks are mathematical systems inspired by the brain. They process inputs by passing them through layers of artificial "neurons" that perform simple computations. These layers are stacked: data flows from an input layer, through one or more hidden layers, to an output layer. With just a few layers, a network can learn basic patterns. But stack dozens—or hundreds—and the model can learn to recognize complex features, like sarcasm in a tweet or a tumor in an MRI scan.

This deep stacking is what gives us deep learning—a subfield of ML where networks learn increasingly abstract representations of data. It powers image classifiers, speech recognition, and most of today's generative systems.

🔍 ML vs. DL vs. GenAI — Know the Difference

  • Traditional ML often uses models like decision trees, linear/logistic regression, or k-means, and works best with structured data.
  • Deep Learning is a subset of ML that uses multilayered neural networks to handle complex inputs like images, audio, or language.
  • Generative AI is powered by large deep learning models—especially transformers—that not only analyze but also create new content (text, code, images, video, etc.).

📘 Most exams draw this distinction early: Traditional ML is about predictions and patterns, while GenAI is about generation and creativity.

As deep learning evolved, different neural network architectures emerged for different types of data.

  • Convolutional Neural Networks (CNNs) specialize in images. They use filters that scan over pixel grids to detect spatial features like edges and textures—like visual building blocks.
  • Recurrent Neural Networks (RNNs) were designed for sequences like text or time series. They carry memory from one step to the next, making them useful for language modeling and speech recognition. But they struggle with long-term dependencies and can't process in parallel.

That's what transformers changed.

Attention Is All You Need

Transformers process sequences in parallel and use a mechanism called self-attention, which allows the model to dynamically weigh how important each part of the input is in relation to every other part.

For example, in the sentence:

"The animal didn't cross the street because it was too tired."

A transformer can determine that "it" refers to "the animal" because it evaluates all the words at once, measuring relevance between them.

📄 "Attention Is All You Need" (2017)

This landmark paper by Vaswani et al. introduced the transformer architecture and changed the direction of modern AI. By eliminating recurrence and relying entirely on self-attention, it enabled models to process sequences in parallel—dramatically improving speed, scalability, and performance.


It's the foundation for nearly every generative AI model in use today, including GPT, BERT, T5, and more.


You can read the original paper here, but fair warning—it's a dense one.

This mechanism gives transformers the power to model complex relationships and long-range context in language, vision, and beyond.

Anatomy of a Transformer

Transformers are typically built using encoder and decoder blocks:

ComponentRole
EncoderIngests the full input and creates contextual representations (embeddings)
DecoderGenerates outputs step-by-step, using previous tokens and attention
Encoder-DecoderCombines both for tasks like translation, summarization, Q&A

Popular model types and their examples include:

Model TypeExamplesTypical Use Cases
Encoder-onlyBERT, RoBERTaClassification, search, embeddings
Decoder-onlyGPT, Claude, GeminiText generation, chat, reasoning
Encoder-decoderT5, BART, FLAN-T5Translation, summarization, RAG

A simplified view of the transformer pipeline:

Input → Tokenization → Embedding → [Encoder/Decoder + Self-Attention] → Output

Transformers are modular, scalable, and adaptable. While originally built for language, they've now expanded to handle images, audio, code, and even biological data. This versatility is what makes them the backbone of modern AI systems.

Many of the most powerful models today—including those behind generative AI—are built on transformer architecture. These models are pre-trained on massive datasets and serve as general-purpose engines for a wide range of downstream tasks. We'll explore them in more detail next, as we step into the world of foundation models—and what happens when scale and structure converge.

Foundation Models

If transformers gave us the architecture, foundation models gave us the platform. These are massive neural networks—usually transformer-based—trained on vast, diverse datasets and built to generalize across tasks. They're called "foundation" models because you can build many applications on top of them: language generation, code completion, document summarization, image synthesis, and more.

Unlike traditional models that are trained for a single narrow task, foundation models are pretrained on broad, unstructured data like web text, source code, images, or speech. After that, they can be:

  • Prompted to perform tasks in-context (zero-shot or few-shot)
  • Fine-tuned on a specific domain or format
  • Augmented with retrieval systems to incorporate external knowledge
  • Aligned using reinforcement learning or safety tuning

This flexibility makes them incredibly powerful across industries—from customer support and software development to scientific discovery and marketing automation.

A few things set foundation models apart from traditional AI systems:

FeatureDescription
ScaleTrained on massive datasets with billions or trillions of parameters
GeneralizationPerform many tasks without retraining from scratch
TransferabilityCan be adapted across domains via prompting or fine-tuning
MultimodalitySome support text, code, images, audio, and more—all in one model
Emergent AbilitiesUnexpected skills arise at large scale (e.g., reasoning, tool use)

Popular examples include:

ModelCreatorPrimary ModalityNotable Capabilities
GPT-4OpenAITextReasoning, summarization, code, chat
ClaudeAnthropicTextAlignment, instruction following
GeminiGoogle DeepMindMultimodalText, images, code, cross-modal Q&A
LLaMA 2MetaText (open source)Local deployment, fine-tuning flexibility
DALL·EOpenAIImage generationText-to-image synthesis

They're not magic. And they're not perfect.

Foundation models aren't "plug-and-play AI brains." They still require careful tuning, context, guardrails, and evaluation. While they're general-purpose, they don't inherently know your company's tone, policies, or systems—unless you teach them.

They're also compute-intensive and opaque: interpreting their decisions, understanding limitations, and managing drift over time are active areas of research.

🚨 Frontier Models vs. Foundation Models

  • Foundation Models are general-purpose, pretrained models that can be adapted for many tasks.
  • Frontier Models are at the bleeding edge of scale and capability—like GPT-4, Claude 3 Opus, Gemini 1.5 Pro, and future successors.

Frontier models often:

  • Have trillions of parameters
  • Exhibit emergent behaviors (e.g., chain-of-thought reasoning, tool use)
  • Require safety layers like RLHF, moderation APIs, and red-teaming

They hold immense potential—and carry significant responsibility. Think of them as the experimental edge of GenAI.

Every foundation model operates on one or more modalities—the type of input/output it understands:

ModalityInput / Output TypeModel ExamplesUse Cases
TextLanguageGPT, Claude, Gemini, LLaMAChatbots, summarization, content generation
CodeProgramming languagesCodex, CodeWhisperer, Gemini CodeCode generation, debugging, doc creation
ImageStatic visual dataDALL·E, Stable Diffusion, ImagenImage synthesis, editing, captioning
AudioSound, voice, musicWhisper, Bark, AudioLMTranscription, speech synthesis
VideoTime-sequenced visual dataVeo, Sora (early)Generative video, animation
MultimodalMix of text + other inputsGemini, GPT-4V, Claude 3 OpusVisual Q&A, guided image generation

Some models (like GPT) are text-only but incredibly capable. Others are truly multimodal—capable of analyzing an image while answering a question about it, or generating code to manipulate it.

💡 Traditional AI vs. Generative AI

Before foundation models, most AI systems were built for narrow, highly specific tasks—think of a model trained just to detect fraud or forecast sales. These are examples of traditional AI. In contrast, foundation models enable generative AI: systems that can produce entirely new content, adapt to a variety of problems, and understand broader context. Here's how they differ:

FeatureTraditional AIGenerative AI
Primary GoalPredict or classifyGenerate new content
Input/OutputStructured input → label/numberPrompt → text, image, audio, etc.
Training StyleTask-specific modelsFoundation models with broad pretraining
AdaptabilityNarrow, fixed-purposeFlexible, multi-purpose
ExamplesSpam filter, fraud detection, sales forecastChatGPT, DALL·E, Gemini, Claude
Techniques UsedDecision trees, regression, clusteringTransformers, diffusion models, RAG, fine-tuning
User InteractionMostly backend/invisibleDirect and interactive via chat, visuals, and prompts

Traditional AI models are like custom-built machines—efficient at one thing. Foundation models, on the other hand, are generalists. They're more like adaptable interns or creative collaborators who can tackle a range of tasks with the right instructions.

Large Language Models

Large language models (LLMs) are the driving force behind the generative AI revolution. If foundation models are the platform, LLMs are the engine—specifically designed to work with language: writing it, translating it, summarizing it, answering questions about it, and sometimes even reasoning with it.

LLMs are massive neural networks—usually transformers—that are trained on vast amounts of text data from the internet, books, codebases, and more. During training, they compress everything they've read into billions of parameters: floating-point numbers that collectively form the model's "knowledge."

You can think of an LLM like a zip file of the internet—only instead of unzipping it to read a website, you interact with it by giving it a sentence and asking: What comes next?

That's really the core of what these models do: they predict the next word—or more precisely, the next token—based on the input they've been given. Whether it's writing an email or summarizing a report, every output is the result of predicting one token at a time, over and over.

For example:
Input: "The dog chased the"
Prediction: "cat"

It's not recalling a fact—it's generating a likely continuation based on everything it's learned. That simple trick, scaled up with billions of parameters and clever prompting, enables everything from chatbots to coding copilots.

Behind the scenes, building these models is a two-part process. First, there's pretraining, where the model reads billions of words and learns to predict the next token in each sequence. This stage teaches it about language structure, facts, logic, and patterns—essentially compressing its knowledge into parameters.

Then comes post-training or alignment, where the pretrained model is shaped to behave like a helpful assistant. This may involve techniques like supervised fine-tuning (SFT), reinforcement learning from human feedback (RLHF), or constitutional AI. This is where tone, safety, and usefulness are instilled.

To do all this requires massive resources. Training a modern LLM can involve:

  • 10+ TB of text data
  • Thousands of GPUs
  • Millions of dollars
  • Weeks of training time

In the end, what you get is a single file (often 50-150GB) filled with billions of parameters—a compressed "brain" that can reason, write, explain, and explore.

💡 For a brilliant visual walkthrough of how this all works, see LLM Visualization by Ben Bycroft and Andrej Karpathy's 1-hour Intro to Large Language Models.

Once the model is trained, you interact with it through a process called inference—feeding it input tokens and asking it to predict the next ones. This is far cheaper than training, and can be done via API or on your own hardware (if the model is small enough).

What actually happens during inference? The input is first tokenized—broken into pieces and converted to numbers. The model then uses those numbers to generate completion tokens (output), one at a time. A sampling strategy is applied to decide which token comes next.

Common sampling strategies include:

StrategyDescription
GreedyAlways picks the most likely next token
Top-KPicks from the top K most likely tokens
Top-P (nucleus)Picks from tokens making up P% of total probability mass
TemperatureAdds randomness (higher = more creative, lower = more focused)

Changing these settings can make a model more creative, more factual, or more concise depending on your use case.

📚 For a quick intro to to using LLMs, watch Karpathy's "How I use LLMs".

At the heart of every LLM are parameters—billions of internal weights that guide the model's decisions. More parameters generally mean more capacity to learn and remember patterns, more nuance in responses, and higher compute costs during inference.

Model SizeTypical UseTradeoffs
1-7B parametersLocal deployment, fast responseLess nuanced understanding
13-30B parametersFine-tuned assistants, enterpriseBetter reasoning, higher latency
70B+ parametersBest-in-class chat, coding, RAGRequires GPUs or cloud-scale resources

You don't always need the biggest model. In fact, many enterprise apps use smaller open-source models fine-tuned on specific domains.

Now, it's important to understand that LLMs are not oracles—they're statistical machines. They generate responses by stacking probabilities, not by retrieving truths. That's why they can hallucinate, contradict themselves, or even appear to reason without actually reasoning.

Researchers are trying to peek inside these black boxes. They're exploring how certain neurons correspond to real-world concepts, how models plan and structure responses, and whether we can improve interpretability to make LLMs more predictable and trustworthy.

🔬 See Anthropic's "Tracing Thoughts of a Language Model" and their write-up on Golden Gate Claude for cutting-edge examples of LLM introspection.

LLMs are at the heart of today's generative systems—powering assistants, copilots, analyzers, and creators. They work by stacking billions of probability calculations, shaped by pretraining, post-training, and prompts. And while they can seem magical, they're really just sophisticated completion machines with a lot of pattern memory.

Next, we'll explore two of the most important ingredients that make LLMs possible: tokenization and embeddings—how language gets converted into numbers, and how meaning is represented in a machine-readable way.

Tokens and Context

Imagine explaining a complex idea to someone who only understands a few pieces of it at a time. That's how language models work—they don't read entire pages or paragraphs at once. They process tokens, tiny units of text, usually just pieces of words.

Take the sentence: "The running dog barked loudly."

A tokenizer might break that down into tokens like:

["The", " run", "ning", " dog", " bark", "ed", " loud", "ly", "."]

These aren't whole words. They're subword units—efficient, compact, and designed to help the model recognize patterns across languages and topics. This technique is known as subword tokenization, and it helps models generalize better. That's why instead of learning "running" as a separate concept, the model learns "run" + "-ing," connecting it to "runner," "ran," or even "rerun."

If you want to see how this works under the hood, try the Tiktokenizer App, GPT Tokenizer, or the OpenAI's official one . Paste in any text and it'll show exactly how it gets split into tokens—helpful for understanding why even short prompts can quickly eat into your model's context window.

From Stemming to Semantics: How Language Preprocessing Has Evolved

In earlier natural language processing workflows—before the rise of deep learning—developers relied on tools like stemming and lemmatization to clean and reduce language to its base form.

  • Stemming is a quick-and-dirty way of chopping off word endings. "Running," "runner," and "runs" all get trimmed to something like "run." But stemmers can be crude—turning "better" into "bet," for example.
  • Lemmatization is more refined. It uses vocabulary and grammar rules to convert words into their dictionary form. "Running" becomes "run," but "better" becomes "good." It's slower, but smarter.

Modern LLMs often skip this step. Instead, they rely on subword tokenization and embeddings to understand relationships between words—even if those words aren't in their raw or base form. So while stemming and lemmatization are still useful in some pipelines (like search engines or classic ML), today's models do their own linguistic heavy lifting.

The model consumes these tokens one after another, tracking relationships, weights, and positions as it builds understanding. But it has limits. Each model has a context window—a maximum number of tokens it can process at once, including both the input and the output. If your window is 4,000 tokens, and your prompt is already 3,800, you've only got 200 left for the response.

Larger windows mean deeper reasoning, longer documents, better continuity. GPT-4 can go up to 128K tokens now in some cases, which opens the door to full-document comprehension, legal contract review, or long-form story generation. But those longer windows also cost more to compute—and every token counts toward your billing and latency.

What's a Token?

A token is a chunk of text—often a word, subword, or symbol—that the model processes. The phrase "ChatGPT is amazing!" could be tokenized into: ["Chat", "G", "PT", " is", " amazing", "!"] Most English words are 1-2 tokens. 1,000 tokens is roughly 750 words of English text.



To learn more, see Andrew Karpathy's video on building a tokenizer.

Understanding tokens helps you write better prompts, anticipate costs, and avoid context overflow. And it's the first step in understanding how models "see" the world.

Embeddings and Vectors

Once your text is tokenized and fed into a model, the real magic begins. Those tokens get transformed into something called embeddings—dense vectors of numbers that represent the meaning and relationships between concepts.

Think of an embedding like the GPS coordinates of a word in a high-dimensional space. Instead of "dog" just being a label, the model might represent it as something like:

[0.21, -0.68, 1.47, ..., 0.02]

Now imagine thousands of these, each representing a different word or sentence, positioned so that similar meanings live close together in this vector space. "Dog" might sit near "puppy" and "canine," but far from "moon" or "democracy."

These embeddings are how the model reasons about similarity, context, and relationships. It's how it knows "banana" is more like "apple" than "car," and how it can figure out that "king - man + woman" should equal something close to "queen."

And they're not just for internal reasoning. When you hear about vector databases, semantic search, or retrieval-augmented generation (RAG), embeddings are doing the heavy lifting. You embed your documents, store them as vectors, and later compare queries to those stored vectors to find relevant content—even if the words don't match exactly.

But embeddings matter outside of RAG too. They power recommendation engines, personalization systems, clustering algorithms, fraud detection, and even AI moderation tools. Any time you need a machine to understand similarity, concept relationships, or nuance, embeddings are your best friend.

Do Embeddings Matter Outside RAG?

Absolutely. Embeddings are used for search, similarity scoring, anomaly detection, personalization, recommendations, clustering, and more. RAG just happens to be a prominent use case—but vector representations are foundational to many modern ML systems.

The big idea? Tokens are the letters. Embeddings are the meanings. Together, they allow language models to convert raw text into geometry—turning language into numbers, patterns into predictions, and prompts into intelligent responses.

Cloud Vector Services at a Glance

Once you've created embeddings, you need a way to store, search, and retrieve them. Most major cloud providers now offer dedicated vector databases or built-in semantic search features:

  • AWS: Use OpenSearch with k-NN plugin for vector search or Amazon Aurora/RDS for PostgreSQL with pgvector. Amazon Kendra also supports semantic retrieval behind the scenes.
  • Azure: Offers Azure AI Search with native vector support, as well as Azure Cosmos DB and Azure SQL DB with vector capabilities.
  • Google Cloud: Provides Vertex AI Vector Search and BigQuery vector functions, integrated into the Gemini ecosystem and supporting RAG out of the box.

Each platform is evolving rapidly. If you're working on retrieval-augmented generation (RAG), semantic search, or recommendations, the choice of vector store can directly impact speed, scalability, and integration flexibility.

Tuning and Optimization

We've seen how LLMs tokenize, embed, and predict. But what happens when you want to steer the model more deliberately—or adapt it to your own domain?

That's where tuning and optimization come in.

In traditional ML, this often means adjusting hyperparameters—the knobs and dials that control how the model learns. Unlike model parameters (which the model learns on its own), hyperparameters are set by you before training starts.

HyperparameterWhat It AffectsWhy It Matters
Learning RateStep size for updating weightsToo high = overshooting, too low = slow/stuck
Batch SizeNumber of samples per training stepImpacts memory use, stability, and speed
EpochsFull passes over training dataToo many = overfitting; too few = underfitting
Layers / NeuronsModel depth and complexityMore layers = more power, more risk
Dropout RateRandomly disabled neurons during trainingHelps avoid overfitting
OptimizerMethod for adjusting weightsAdam, SGD, etc.—affects convergence

There's no universal best setting. That's why we turn to hyperparameter optimization. This is the search process—automated or manual—for the best combination of values. Strategies include:

  • Grid Search: Exhaustively trying combinations from a set grid
  • Random Search: Sampling combinations randomly (often surprisingly effective)
  • Bayesian Optimization: Using a probabilistic model to predict what combinations might work best next

Hyperparameter tuning typically happens after initial model setup but before full deployment, often using the validation set to measure results.

But what if we're dealing with a foundation model—an LLM or image generator that's already trained? Here, tuning looks different.

You're not starting from scratch. You're adapting a general-purpose model to suit your domain or dataset. The two most common strategies are fine-tuning and RAG (Retrieval-Augmented Generation).

Fine-tuning is a supervised training process, where you continue training a model using domain-specific examples. Think legal contracts, military doctrines, medical notes—whatever your niche is. It updates the internal weights of the model so it "thinks" more like your domain.

Steps typically include:

  1. Data Collection - Curate a high-quality, task-specific dataset
  2. Labeling - Add labels for supervised tasks (e.g., extract clause, answer question)
  3. Privacy & Guardrails - Secure and audit your sensitive input data
  4. Choose a Fine-Tuning Strategy:
    • Instruction Fine-Tuning - Train on example prompt/response pairs
    • RLHF (Reinforcement Learning from Human Feedback) - Start with supervised learning, then apply reward signals from human rankings
  5. Train, Evaluate, and Iterate - Until performance plateaus

This is also known as transfer learning—starting with a pretrained model, then transferring it to your specific domain. But it has tradeoffs: it's compute-heavy, data-sensitive, and risks overfitting if your dataset is too narrow.

That's where LoRA (Low-Rank Adaptation) and ReFT (Representation Fine-Tuning) come in. These newer techniques modify only small subsets of the model's weights—keeping compute and cost low, while retaining flexibility.

To make sense of all these terms—pretraining, fine-tuning, post-training, and more—here's a breakdown of how they relate:

TypeWho Typically Does ItWhen It HappensScopeFrequencyWhat It InvolvesExample Purpose
Training (umbrella)ML engineers, researchers, developersAny stage involving weight updatesGeneral or SpecificVariesAny method that modifies model weights to optimize performance based on data and objectivesPretraining, fine-tuning, post-training
PretrainingModel buildersFrom scratchGeneral-purposeOne-timeLearning broad, general patterns from massive, unlabeled datasetsTeaching a language model grammar, facts, common sense
Continuous PretrainingModel buildersAfter initial pretrainingGeneral-purposeOngoingUpdating the model with new, unlabeled data to improve freshness and adaptabilityKeeping a model current on recent news and language
Post-TrainingModel buildersAfter pretrainingAlignment/SafetyAs neededAligning the pretrained model to human preferences or ethical guidelines (e.g., RLHF, safety tuning)Making a chatbot polite and helpful
Fine-TuningYour team, organizationsAfter deployment or model releaseDomain-specificAs neededAdapting a pretrained model to a domain-specific or task-specific datasetTraining a model to extract clauses from contracts

⚠️ Clarifying the Confusion: Training vs Prompting

In ML and LLM contexts, training refers to anything that updates a model's internal weights using labeled data and an objective (like loss minimization). It includes pretraining, fine-tuning, and post-training—all of which involve gradient descent and compute.


Prompt engineering is not training. It doesn't change the model weights. Instead, you guide the model's behavior by crafting smart input text (system prompts, examples, formatting). It's powerful and flexible—but it's not learning under the hood. Think of it like writing a great search query, not rewriting the search engine.


Also, fine-tuning and post-training often use similar techniques (like supervised learning or reinforcement learning), but the key difference is intent and ownership:

  • Post-training is typically done by the original model creators to improve safety, helpfulness, and general alignment.
  • Fine-tuning is done by you or your team, often using smaller, specific datasets to teach the model about your business or use case.

But what if you don't want to fine-tune at all? That's where RAG shines.

Instead of modifying the model, RAG keeps it frozen—and just feeds it better context. It does this by retrieving relevant documents from a vector database, then stuffing them into the prompt. The model doesn't need to "know" the info ahead of time—it just needs access to it when it matters.

Here's how a typical RAG pipeline works:

  1. Collect and Index Your Data - PDFs, transcripts, reports, etc.
  2. Chunk and Embed - Break content into chunks and convert to vectors
  3. Store in Vector DB - Examples: OpenSearch, Pinecone, pgvector with Postgres
  4. User Prompt → Embedding - Convert the prompt into a query vector
  5. Retrieve Top-Matching Chunks
  6. Augment the Prompt - Add the chunks as extra context
  7. Generate the Answer - The LLM processes it all at once

🔍 Fine-Tuning vs. RAG

Fine-TuningRAG
Modifies the model? Yes, changes weights No, model stays frozen
Data needs?Labeled, domain-specificUnlabeled, semi-structured is fine
Cost/Compute?High (esp. GPUs, tuning cycles)Low to moderate (mostly indexing + inference)
Risk of overfitting?Moderate to highLow
Best for?Behavior change, tight controlInfo injection, faster deployment

💡 Exam Tip: Understanding the differences between fine-tuning and RAG is key for certification exams. When in doubt, the exams typically favor RAG as the more scalable, cost-effective, and low-effort approach to model customization.

Both approaches have their place. Many teams even combine them—fine-tune a domain-specific model, then use RAG to feed it fresh updates over time. Others start with RAG, then fine-tune only if performance plateaus.

Whether you're tuning hyperparameters on a decision tree or embedding documents into a knowledge base for your LLM, the goal is the same: close the gap between what your model does, and what your users need.

But sometimes, even without changing the model or retraining anything, you can still shape what it says—just by tweaking how it thinks during generation. This is where inference parameters come in.

Once you've selected a foundation model and crafted your prompts, you can still influence how the model responds—without changing its training or tuning. This is done through inference parameters. These are knobs you turn at generation time to shape the model's tone, randomness, and creativity.

Foundation models like GPT, Claude, Gemini, or Titan don't just spit out the "most likely next word"—they generate text by sampling from a probability distribution of next-token options. These parameters adjust how deterministic or exploratory that sampling is:

ParameterWhat It ControlsLower ValueHigher Value
TemperatureSharpness of the token probability distributionMore deterministic, factual, repeatableMore creative, varied, or even chaotic
Top KLimits choices to the top K probable tokensNarrower pool, higher-probability choices onlyMore diverse pool, includes less likely options
Top PIncludes tokens from the top P% of cumulative probsRestricts to only the most likely next tokensExpands choices to include more surprise or flair

Think of temperature like spice in a recipe. A temperature close to 0 makes the model "play it safe," choosing the most statistically likely responses. This is great for tasks like report generation, summarization, or FAQs. A higher temperature (like 0.9) flattens the probability curve, making the model more exploratory. It's great for brainstorming ideas, fictional dialogue, or writing poetry. But too much heat? You risk gibberish.

🧪 Temperature Example
Prompt: "The new robot was designed to..."
 
- At temp 0.2, the model replies: "...assist humans with household chores."
- At temp 0.9, it might say: "...juggle pineapples while quoting Shakespeare."

Same model, same prompt—but very different tone.

Top K works a bit differently. Instead of adjusting the shape of the entire probability curve, it simply narrows the options to the top K most likely next tokens. If set to K=1, the model always picks the single most likely token. Raise it to K=5 or K=100, and the model has a broader selection to work with.

🧪 Top K Example
Prompt: "The scientist placed the beaker under the..."
Model's internal probability list:
 
- "microscope": 42%
- "lamp": 25%
- "cabinet": 12%
- "telescope": 11%
- "desk": 6%
- "ceiling fan": 4%
- If Top K = 2, only microscope and lamp are in the pool.
- If Top K = 5, the model may surprise you with telescope or desk.

Top P, sometimes called nucleus sampling, uses a cumulative probability threshold instead. Instead of picking the top K tokens, it includes as many tokens as needed to reach the top P% of the total probability mass. This is often more adaptive than Top K, since it dynamically adjusts how many options are considered.

🧪 Top P Example
Prompt: "The dragon emerged from the cave and..."
Token probabilities:
 
- "roared": 40%
- "flew": 30%
- "slept": 15%
- "danced": 10%
- "sang": 5%
- With Top P = 0.5 (50%), only roared is eligible.
- With Top P = 0.9 (90%), roared, flew, and slept make the cut.
- With Top P = 1.0 (100%), even sang is fair game.

These parameters all influence creativity—but they can also interact in unexpected ways. That's why most developers stick to adjusting either Temperature or Top P, but not both at the same time. Top K can be layered in if you need stricter control over token choices. As a rule of thumb, use lower values for more factual and stable responses, and higher values for variety, surprise, or creative content.

📈 Pro Tip: When working with APIs like OpenAI, Claude, or Bedrock, start with temperature = 0.7 and adjust based on the use case. If outputs are too weird, lower it. If they're too boring, raise it—or experiment with Top P.

Diffusion Models

If transformers are the brains behind today's generative language systems, diffusion models are the brushes that paint the pictures. These models power some of the most visually stunning outputs in generative AI—whether it's surreal landscapes, photorealistic faces, or sci-fi scenes that never existed. They don't generate an image pixel by pixel or word by word. Instead, they work like sculptors in reverse: starting with pure visual noise, then carefully removing randomness until a coherent image emerges.

So how do they work? The core idea is deceptively simple: teach a model how to destroy something—and then teach it how to undo that destruction.

Diffusion models learn in two main phases:

  • Forward Diffusion
    In training, the model takes a real image and gradually adds noise to it over many steps, eventually turning it into near-random static. This teaches it how information deteriorates in a controlled way.
  • Reverse Diffusion (Generation)
    During inference, the model starts with random noise and reverses the process step-by-step, reconstructing a plausible image from the chaos. Your prompt guides this process, nudging the model toward "cat in a spacesuit" or "sunset over Mars."

Imagine it like watching a Polaroid photo develop—only in reverse. The image isn't revealed from blankness but from entropy. What starts as static becomes sharper, richer, and more specific with each denoising step.

Importantly, most diffusion models don't operate directly on raw pixels. Instead, they generate in a latent space—a compressed, abstract version of the image. This makes the process faster and more efficient, while preserving detail and flexibility.

And while diffusion models can run independently, they're often conditioned by prompts, style guides, or even image masks. This gives creators extraordinary control over what the model produces—not just what it draws, but how it draws it.

📘 Diffusion Terms, Explained

TermMeaning
Forward DiffusionAdds noise to an image during training
Reverse DiffusionRemoves noise to generate an image
Latent SpaceA compressed representation where generation occurs
ConditioningUsing a prompt or guide image to steer generation
StepsThe number of noise-removal iterations; more steps = more detail
SchedulerThe strategy used to decide how much noise is removed at each step

The impact of diffusion extends far beyond quirky art. These models are now used across industries—from creative tools to scientific research. Here's a look at some real-world domains where diffusion has made its mark:

DomainModel ExamplesWhat It Enables
Image GenerationDALL·E, Stable Diffusion, ImagenCreate realistic or artistic images from text prompts
Video CreationVeo, SoraGenerate animated or realistic motion sequences
Audio SynthesisMusicLM, Bark, TortoiseProduce music, sound effects, or human-like speech
Scientific FieldsDiffDock, RoseTTAFold, GNoMESimulate protein folding, molecule design, and materials

What makes diffusion especially powerful is its combination of controllability and fidelity. The outputs aren't just creative—they're high-resolution, style-aware, and surprisingly coherent. That's why diffusion has exploded in the open-source community, where creators and researchers alike can guide the generative process with increasing precision.

Diffusion vs. GANs: What's the Difference?

Before diffusion took over, Generative Adversarial Networks (GANs) were the dominant method for generating images. They work by training two networks:

  • A generator that tries to create realistic images
  • A discriminator that tries to tell fake from real

The generator improves by learning to fool the discriminator.

FeatureGANsDiffusion Models
Training StyleAdversarial (generator vs. discriminator)Self-supervised (noise prediction + denoising)
Output QualitySharp images, but may have artifactsHigh-fidelity, coherent, controllable
StabilityHard to train, prone to collapseMore stable and scalable with modern schedulers
InterpretabilityLimited—black-box competitionTransparent denoising steps
Popular ExamplesStyleGAN, BigGANStable Diffusion, DALL·E, Imagen

While GANs are still used in some domains, diffusion has largely overtaken them due to better training stability, flexibility, and creative control.

And while transformers still dominate the text world, diffusion models are leading the charge in vision. That said, the two are increasingly intertwined. Some multimodal systems use a transformer to understand your prompt, and then pass it to a diffusion model to "paint" the response. Others use diffusion as a post-processing layer, refining blurry outputs or applying a specific visual style.

So yes—transformers may understand the language. But it's diffusion that brings the vision to life.

Prompt Engineering

Prompting might seem like the easiest part of using AI. You just type something, hit enter, and voilà, magic happens. But if you've ever stared at a wildly off-base response and thought, "that's not what I meant," you already know—it's not about asking, it's about asking well.

The prompt is your interface. It's how you shape what the model does next. If the model is the engine, prompting is your steering wheel. Vague or sloppy instructions lead to vague or sloppy results. Clear and intentional ones give you focus, tone, structure—even creativity.

Prompt engineering is really just communicating with purpose. A weak prompt might be:

"Summarize this."

It'll try, sure, but it's guessing what kind of summary you want. A stronger version might be:

"Give me three bullet points explaining the key risks in this article, as if you're briefing a CEO who only has 30 seconds."

Same model, very different output.

Prompt TypeExample PromptWhy It Works (or Doesn't)
Weak / Vague"Tell me about climate change"Too open-ended; lacks scope, tone, and target audience
Strong / Clear"Write a 100-word summary of climate change causes for a 10th grade science class"Sets format, topic, and audience for a much more tailored response
Undirected"Explain this code"No indication of purpose, audience, or style
Purposeful"Explain this Python code step-by-step as if teaching a beginner programmer"Clear intent, target user, and tone
Overstuffed"What's the meaning of life and give me a recipe for pancakes and explain AI?"Multiple unrelated tasks in one; confuses the model
Focused"Write a friendly explanation of what AI is and how it's used in real life"One task, clear tone, practical context

It's not about using the fanciest prompt structure. It's about intent. Know what you want. Then express that as clearly as you can—who the response is for, what it should look like, how it should sound, and why you're asking.

Some prompts even work better when you give the model a role. Saying

Chat Window
"You are a helpful legal assistant..."
primes the model to speak in that tone and register.
 
 
You can follow that with a task like:
"Summarize this employment agreement into plain English for a new hire."
and get something much closer to what you actually need.
 

You can also improve results by working in iterations. Start with a base prompt, then refine. Add detail. Tighten the format. Keep adjusting until the output feels dialed in. The process is less like coding and more like sculpting—you're shaping something that responds to the pressure you apply.

Context is another critical piece. The model doesn't remember unless you remind it. If you're asking follow-up questions or referencing previous steps, include that info again. And if your use case involves user data, documents, or past interactions, feed that into the prompt dynamically. Retrieval systems help automate this in production, but even in simple use, more context = better results.

From Prompt Engineering to Context Engineering

AI thought leader Andrej Karpathy recently declared "+1 for "context engineering" over "prompt engineering".", and he's not alone. A growing number of practitioners are reframing this practice as context engineering—a more holistic approach that goes beyond writing prompts to designing the full information environment in which the model operates.


Instead of crafting clever phrases, context engineers orchestrate system prompts, conversation history, grounding documents, roles, tools, constraints, and memory to steer model behavior. As Build AI with AI puts it:


"Prompt Engineering is Dead. Long Live Context Engineering."


The idea is simple: Don't just ask better questions—give the model better context.

Prompting is a skill. And once you practice it enough, it becomes second nature. Many people find that the discipline of writing good prompts actually sharpens their thinking. It forces clarity. It rewards structure. And it teaches you to approach conversations—human or machine—with more purpose.

Cloud providers and their certification exams also introduce several prompt types that help structure interactions more effectively, especially for advanced tasks like reasoning, summarization, or generating consistent outputs.

Prompting TypeDescriptionExample Use Case
Zero-shotThe model is given a task with no examples—just instructions"Translate this sentence to French"
One-shotThe model is given one example to help guide its outputOne sample Q&A pair followed by a new question
Few-shotThe model is given multiple examples to establish a clear patternSeveral Q&A pairs followed by a new prompt
Chain-of-thoughtThe model is prompted to explain its reasoning step by stepMath word problems or logic puzzles
Role PromptingSets the model's persona or voice to guide tone and perspective"You are a customer support agent..."
Instruction PromptingGives explicit, structured commands with expected output style or format"Summarize in 3 bullet points" or "Respond in JSON"

You might start with a quick instruction and iterate from there. Over time, you'll learn which type of prompt—or context—works best for the task at hand. Prompt engineering may be evolving into something broader, but the core idea remains: shape the model's inputs with care, and you'll shape its outputs with power.

Want to Level Up Your Prompting Skills?

Here are some of the clearest, most practical guides out there for writing better prompts across major GenAI platforms:

Model Selection

So you know what kind of data you have, what type of problem you're solving, and maybe even what modality you're working with. Now comes the big question: What model should I use?

There's no perfect answer—but there are smart ways to narrow it down. Think of it like picking the right tool for the job, or the right vehicle for the terrain. A sleek sports car might look impressive, but it's not much use on a gravel road. Likewise, a massive LLM might impress on paper, but overkill for a simple classification task.

Here's a practical checklist to guide your model selection process:

ConsiderationWhat It MeansWhy It Matters
ModalityInput/output type: text, image, audio, etc.Not all models handle all modalities
Context WindowHow much the model can "remember" at onceImpacts reasoning, summarization, and long-form continuity
Model Size & PerformanceParameters and inference latencyBigger = better quality, but slower and more expensive
Accuracy & EvaluationBenchmark scores, internal testingNot all models excel at the same tasks
Fine-Tuning CapabilityCan you adapt it with domain-specific data?Necessary for tailoring to business or compliance needs
Prompting FlexibilityHow well it follows structured instructionsSome models require more coaxing or formatting
Retrieval Options (RAG)Can it incorporate external context during inference?Useful for private data, FAQs, or time-sensitive info
CostToken pricing, API fees, infrastructure costsCrucial for budget and scaling decisions
AvailabilityAPI-only, open-source, on-prem optionsInfluences deployment, security, and data control
Guardrails & SafetyToxicity filters, alignment tuning, moderationEssential for customer-facing or regulated environments

Of course, choosing a model also means navigating trade-offs:

  • A small model might be cheaper and faster—but less accurate or nuanced.
  • An open model offers flexibility—but may lack safety features or support.
  • High-context, high-accuracy models (like GPT-4 or Claude Opus) can be powerful—but pricey.

Another common distinction you'll run into is closed vs. open models—whether the model is accessible only via API or fully downloadable and customizable. This choice affects everything from privacy and cost to customization and deployment flexibility:

AspectClosed ModelsOpen Models
AccessAPI-only (e.g., GPT-4, Claude, Gemini)Downloadable, deployable (e.g., LLaMA, Mistral)
CustomizationLimited (prompting, RAG, fine-tuning via API)Full (fine-tuning, weights access, local inference)
Control & PrivacyData flows through third-party APIsFull control over data and deployment
PerformanceOften top-tier benchmarksCatching up rapidly; competitive in many tasks
CostPay-per-token/API usageCompute/storage costs, but no usage-based fees
Guardrails & SafetyBuilt-in safety layers, moderation, RLHFMust be added manually
CommunityProprietary updatesActive open-source innovation & support

Here's how some popular models map to real-world considerations:

ModelStrengthsTradeoffs
GPT-4Top-tier reasoning and summarizationHigh latency and cost
Claude 3 OpusLong context window, polite toneLimited fine-tuning options
Gemini ProMultimodal input, fast APIVariable quality depending on task
Mistral (Open)Open-source, fast, customizableRequires setup, no built-in guardrails
LLaMA 3Open, strong performance when fine-tunedLarge, resource-heavy, still maturing

When you're still exploring, you might try building a visual decision tree or using a simple scorecard based on these factors. Prototype with something powerful and forgiving (like GPT-4 or Claude), and once your requirements harden, explore cost-effective or private alternatives.

Benchmarks can help here, too. While not perfect, they provide a shared framework to compare model capabilities across tasks. Here are some of the most referenced:

Benchmark / MetricWhat It TestsOften Referenced In
MMLUGeneral knowledge, multitask QAAWS, Google GenAI Leader, Anthropic publications
HumanEvalCode generation and correctnessAWS, Azure developer certs, GitHub Copilot docs
BLEU / ROUGESummarization and translation qualityAzure AI-900, Google GenAI certs
PerplexityText fluency and next-word prediction qualityOpenAI, DeepMind, benchmark dashboards
AUC-ROC / F1 ScoreClassification accuracyAWS AI Practitioner, ML fundamentals courses
MAPE / RMSEForecasting, numeric predictionAWS/Azure ML optimization and data science tracks

Benchmarks give you the scoreboard. But they don't know your brand tone, internal jargon, or formatting quirks. That's why it's just as important to test models using your own prompts, real use cases, and actual documents. Check not just for accuracy—but for hallucination, latency, structure, and tone.

If it helps, think of model selection less like marriage, and more like speed dating. Try a few options. See what feels right. Prototype with the easy stuff, then evolve toward control and cost efficiency as you scale.

The model you choose is important. But what you build around it—from retrieval and post-processing to evaluation and guardrails—is where the real magic (and value) happens.

Conclusion: Prepped, Cooked, and Ready to Serve

We've spent this post in the heart of the machine learning kitchen—selecting models, feeding them data, shaping their behavior with tuning and prompts. But training isn't the finish line. It's the start of a much longer journey.

Because a model that performs well in the lab doesn't always hold up in the wild.

You've now seen how learning happens—how paradigms guide, architectures scale, and prompting steers. You've learned how to fine-tune or adapt a model to your world, and how to inject fresh context without retraining. But none of that guarantees success unless you measure, monitor, and manage what comes out the other end.

A model's output is only as useful as its accuracy, reliability, and trustworthiness. And those are earned not during training, but in what comes next: evaluation.

Up Next: Judgment Day

In the next post, we'll put models to the test. We'll explore:

  • How to evaluate model performance—beyond just accuracy
  • What metrics matter for different tasks (and which ones can mislead)
  • How to catch hallucinations, bias, and drift before users do
  • Why human-in-the-loop isn't just nice—it's necessary

Because building an AI system isn't just about teaching it to learn. It's about making sure it learns the right lessons—and keeps them when it matters most.

See the associated LinkedIn post.

main
git log
Comments

To leave feedback or questions, simply login using your preferred social network. I will read and answer your comments promptly, but please keep in mind that they will be public.

No comments yet.
main