📧 chinmayeepavi@gmail.com Support

Artificial Intelligence (AI) & Machine Learning (ML)

Overview of AI, ML, Deep Learning, Gen AI

Artificial Intelligence (AI) is an expansive field creating intelligent systems that perform tasks associated with human intelligence—perception, reasoning, learning, problem-solving, and decision-making. AI encompasses a hierarchy: AI → Machine Learning (ML) → Deep Learning → Generative AI.

Four Fundamental Layers of AI Systems: 1. Data Layer – Collection of vast amounts of information 2. Algorithm Layer – Frameworks are defined 3. Model Layer – Dedicated to training 4. Application Layer – Delivers the model to users

Machine Learning enables machines to identify patterns from data rather than being explicitly programmed. Techniques include regression (trend prediction) and classification (data categorization).

Deep Learning employs neural networks inspired by the human brain. It is termed "deep" due to multiple hidden layers between input and output, enabling processing of intricate patterns. Requires large datasets and powerful GPUs.

Generative AI utilizes foundation models based on the transformer architecture, processing entire sentences efficiently. Powers models like BERT and ChatGPT, and includes diffusion models for image generation and multi-modal models for various input/output types.

Key Machine Learning Terms

Term Purpose Use Case
GPT (Generative Pre-trained Transformer) Generates human-like text or code Text generation, coding
BERT (Bidirectional Encoder Representations) Processes text bidirectionally Translation tasks
RNN (Recurrent Neural Network) Handles sequential data Speech recognition, time series
ResNet (Residual Network) Deep CNN for visual tasks Image recognition, facial recognition
SVM (Support Vector Machine) Classification and regression Data categorization
WaveNet Generates audio waveforms Speech synthesis
GAN (Generative Adversarial Network) Produces synthetic data Data augmentation
XGBoost (Extreme Gradient Boosting) Regression tasks Predictions

Exam Recall: GPT & BERT → language, ResNet → images, WaveNet → audio, GAN → data augmentation.

Training Data

In machine learning, data quality is paramount—if you input poor-quality data, the output will similarly be poor.

Labeled vs. Unlabeled Data: - Labeled data contains input features and corresponding output labels (e.g., images tagged as "dog" or "cat"). Used for supervised learning. - Unlabeled data consists solely of input features without labels. The algorithm identifies patterns independently through unsupervised learning.

Structured vs. Unstructured Data: - Structured data is organized in rows and columns (spreadsheets, databases, time series). - Unstructured data lacks specific structure (text, social media posts, images, audio).

Both data types are valid for ML but require different algorithms for effective processing.

Supervised Learning

Supervised learning uses labeled data to establish a mapping function that predicts outcomes for new, unseen inputs.

Regression vs. Classification: - Regression predicts continuous numeric values (house prices, stock values, weather) - Classification predicts discrete categorical labels—can be binary (spam/not spam), multi-class (mammal/bird/reptile), or multi-label (action + comedy movie)

Data Splitting: - Training set (60-80%) – for model training - Validation set (10-20%) – for tuning parameters - Test set (10-20%) – for evaluating final accuracy

Feature Engineering: Transforming raw data into meaningful features: - Feature extraction (deriving age from birth date) - Feature selection (choosing relevant features) - Feature transformation (normalizing values for faster convergence)

Unsupervised Learning

Unsupervised Learning utilizes unlabeled data to uncover inherent patterns, structures, or relationships.

Key Techniques: - Clustering – Organizes similar data points into groups (e.g., customer segmentation: students, new parents, vegetarians) - Association Rule Learning – Discovers items frequently purchased together (bread and butter) - Anomaly Detection – Identifies outliers deviating from normal patterns (fraud detection)

Semi-Supervised Learning: Bridges supervised and unsupervised approaches. Starts with small labeled data + larger unlabeled pool. Trains initial model → assigns pseudo-labels to unlabeled data → retrains on expanded dataset.

Self-Supervised Learning

Self-supervised learning is a methodology where a model creates its own pseudo-labels from unlabeled data, eliminating the need for human annotation.

How it works: Uses pretext tasks—simple challenges the model solves to uncover patterns: - Predicting the next word ("Amazon Web ___" → "Services") - Completing sentences - Reconstructing hidden elements from visible ones

By engaging in numerous pretext tasks, the model develops an internal representation of data—understanding grammar, word meanings, and relationships. This approach powers groundbreaking models like GPT and sophisticated image recognition systems.

Reinforcement Learning

Reinforcement learning is a subset of ML where an agent learns to make decisions by taking actions within an environment to maximize cumulative rewards.

Key Concepts: - State – Current situation within the environment - Policy – Strategy for selecting actions based on state - Reward – Feedback from the environment - Agent – The learner/decision maker

Learning Cycle: Observe state → Choose action → Environment transitions → Receive reward → Update policy → Repeat

Use Cases: Gaming (chess, Go), robotics (navigation), finance (trading strategies), healthcare (treatment optimization), autonomous vehicles (path planning).

Reinforcement Learning from Human Feedback (RLHF)

RLHF is a technique used to fine-tune large language models by incorporating human preferences into the training process. It bridges the gap between what a model can generate and what humans actually find helpful, harmless, and honest.

How RLHF Works:

  1. Initial Training – A base LLM is pre-trained on large text corpora using self-supervised learning
  2. Human Ranking – Human evaluators rank multiple model outputs for the same prompt based on quality, helpfulness, and safety
  3. Reward Model Training – A separate reward model is trained on these human preferences to predict which outputs humans would prefer
  4. Policy Optimization – The original LLM is fine-tuned using reinforcement learning (typically PPO – Proximal Policy Optimization) with the reward model providing the reward signal

Why RLHF Matters: - Aligns model outputs with human values and expectations - Reduces harmful, biased, or misleading responses - Improves helpfulness and instruction-following ability - Used by OpenAI (ChatGPT), Anthropic (Claude), and others to make models safer and more useful

Key Exam Points: RLHF combines supervised learning (human rankings) with reinforcement learning (policy optimization) to align AI behavior with human preferences.

Model Fit, Bias, and Variance

Understanding model fit is crucial for building effective ML models:

Underfitting (High Bias): - Model is too simple to capture patterns in the data - Performs poorly on both training and test data - Example: Using a straight line to fit curved data - Fix: Use more complex models, add features, reduce regularization

Overfitting (High Variance): - Model memorizes training data including noise - Performs well on training data but poorly on new/test data - Example: A model that perfectly fits every training point but fails on unseen data - Fix: Add more training data, use regularization, simplify model, use dropout

Good Fit: - Model generalizes well to unseen data - Balanced performance on both training and test sets

Bias-Variance Tradeoff: - Bias – Error from oversimplifying assumptions. High bias = underfitting - Variance – Error from sensitivity to training data fluctuations. High variance = overfitting - Goal: Find the sweet spot that minimizes total error (bias² + variance)

Model Evaluation Metrics

Classification Metrics:

Metric Formula Use Case
Accuracy (TP + TN) / Total Overall correctness (use when classes are balanced)
Precision TP / (TP + FP) When false positives are costly (spam detection)
Recall (Sensitivity) TP / (TP + FN) When false negatives are costly (disease detection)
F1 Score 2 × (Precision × Recall) / (Precision + Recall) Balance between precision and recall
AUC-ROC Area under ROC curve Model's ability to distinguish between classes

Regression Metrics: - MAE (Mean Absolute Error) – Average absolute difference between predicted and actual values - MSE (Mean Squared Error) – Average squared difference (penalizes large errors more) - RMSE (Root Mean Squared Error) – Square root of MSE (same units as target variable) - R² Score – Proportion of variance explained by the model (1.0 = perfect fit)

Confusion Matrix: A table showing True Positives, True Negatives, False Positives, and False Negatives—the foundation for classification metrics.

Machine Learning – Inferencing

Inferencing (or inference) is the process of using a trained ML model to make predictions on new, unseen data in production.

Key Concepts:

  • Batch Inference – Processing large volumes of data at once (e.g., scoring all customers overnight for churn risk). Cost-effective but not real-time.
  • Real-Time Inference – Processing individual requests as they arrive with low latency (e.g., fraud detection on each credit card transaction). Requires always-on endpoints.
  • Edge Inference – Running models on edge devices (IoT, mobile) for ultra-low latency without internet connectivity.

Inference Optimization: - Model compression (quantization, pruning, distillation) - Hardware acceleration (GPUs, AWS Inferentia chips) - Caching frequent predictions - Model serving frameworks (TensorFlow Serving, TorchServe)

AWS Inference Services: Amazon SageMaker endpoints, AWS Inferentia/Trainium chips, Amazon Elastic Inference.

Phases of a Machine Learning Project

  1. Business Problem Definition – Identify the problem, define success metrics, determine if ML is the right approach
  2. Data Collection & Integration – Gather data from various sources (databases, APIs, logs, third-party datasets)
  3. Data Preprocessing & Cleaning – Handle missing values, remove duplicates, fix inconsistencies, transform features
  4. Exploratory Data Analysis (EDA) – Visualize data, identify patterns, understand distributions, detect outliers
  5. Feature Engineering – Create new features, select relevant ones, transform variables for better model performance
  6. Model Selection – Choose appropriate algorithms based on problem type, data characteristics, and requirements
  7. Model Training – Train the model on prepared data, tune hyperparameters using validation set
  8. Model Evaluation – Assess performance using appropriate metrics, compare against baselines
  9. Model Deployment – Deploy to production (endpoint, batch, edge), set up monitoring
  10. Monitoring & Maintenance – Track model performance over time, detect data drift, retrain as needed

Hyperparameters

Hyperparameters are configuration settings that control the training process itself—they are set BEFORE training begins and are not learned from data.

Key Hyperparameters:

Hyperparameter Purpose Effect
Learning Rate Controls step size during optimization Too high = overshooting; too low = slow convergence
Batch Size Number of samples processed before updating weights Larger = stable but slower; smaller = noisy but faster
Number of Epochs How many times the model sees the entire dataset Too few = underfitting; too many = overfitting
Regularization (L1/L2) Prevents overfitting by penalizing large weights Higher = simpler model; lower = more complex
Number of Layers/Neurons Network architecture depth and width More = greater capacity but risk of overfitting
Dropout Rate Fraction of neurons randomly disabled during training Prevents overfitting in neural networks

Hyperparameter Tuning Methods: - Grid Search – Exhaustively tries all combinations (thorough but expensive) - Random Search – Randomly samples combinations (faster, often sufficient) - Bayesian Optimization – Intelligently explores promising regions (efficient) - AWS SageMaker Automatic Model Tuning – Managed hyperparameter optimization service

Parameters vs. Hyperparameters: - Parameters are learned during training (weights, biases) - Hyperparameters are set before training (learning rate, epochs)