AI

Vector Semantics and Embedding

NLP - Vector Semantics and Embedding #

  • Lexical semantics and word meaning.
  • Lemmas, senses, and semantic relationships.
  • Distributional hypothesis.
  • Vector semantics and word embeddings.
  • Document and word vectors.
  • Dot product and cosine similarity.
  • Term Frequency–Inverse Document Frequency (TF-IDF).
  • Prediction-based word embeddings and self-supervision.
  • Word2Vec using Skip-gram with Negative Sampling and CBOW.
  • Embedding matrices, context-window choices, analogies, visualisation, and bias.
  • GloVe and global word–word co-occurrence statistics.

Learning Objectives #

  • Explain lexical semantics and distinguish a lemma from a word sense.
  • Compare synonymy, similarity, relatedness, antonymy, and connotation.
  • Explain the distributional hypothesis and its role in modelling meaning.
  • Describe how words and documents can be represented as vectors.
  • Construct and interpret word–document and word–context matrices.
  • Calculate dot product and cosine similarity between vectors.
  • Explain why raw word frequency can be misleading.
  • Calculate TF, IDF, and TF-IDF weights.
  • Explain how Word2Vec learns embeddings from a prediction task.
  • Construct positive and negative Skip-gram training pairs.
  • Explain how sigmoid, negative sampling, and gradient descent train SGNS.
  • Compare Skip-gram with CBOW.
  • Explain how context-window size affects the relationships captured.
  • Interpret word analogies and two-dimensional embedding visualisations.
  • Explain how GloVe combines global counts with learned dense vectors.
  • Recognise how social biases can be encoded in word embeddings.

Big Picture #

flowchart TD
    A[Words and Documents] --> B[Observe Their Context]
    B --> C[Represent Them as Vectors]
    C --> D[Compare Vector Directions]
    D --> E[Estimate Semantic Similarity]
    E --> F[Search, Classify, Retrieve or Generate]

    style A fill:#E1F5FE
    style B fill:#C8E6C9
    style C fill:#FFF9C4
    style D fill:#EDE7F6
    style E fill:#E1F5FE
    style F fill:#C8E6C9

1. Lexical Semantics ☆ #

Lexical semantics is the linguistic study of word meaning and the relationships between word meanings.

Conditional Probability

Conditional Probability #

Conditional probability updates the probability of an event when new information is available.

It shows up whenever a question says:

  • “given that…”
  • “among those who…”
  • “out of the items that…”
  • “if it does not fail immediately…”

Key takeaway: Conditional probability is always:

joint probability ÷ probability of the condition.

The condition must not be an impossible event.


Prior vs posterior #

  • Prior probability: probability with no condition (before new information)

Bayes’ Theorem

Bayes’ Theorem #

2.1 Total probability (needed for Bayes) #

Often we split the world into cases \( E_1,E_2,\dots,E_k \) that:

  • are mutually exclusive
  • cover the whole sample space

Then for any event \( A \) :

\[ P(A)=\sum_{i=1}^{k} P(A\mid E_i)\,P(E_i) \]

Tree intuition:

Naïve Bayes

Naïve Bayes #

Naïve Bayes is a probabilistic classifier.

  • Supervised Learning Problem
  • Binary Classification - final target variable is considered in two classes
  • Hypothesis is target which you want to classify
  • Total Probability (Prior) of Yes and No is already calculated
  • Post / Posterior is when you start studying data
  • Based on max probability of hypotheses classify given instance into a class

It predicts a class label by computing:

Probability Distributions

Probability Distributions #

Probability distributions are the bridge between: real-world randomness and mathematical modelling.

A random experiment produces outcomes. A random variable turns those outcomes into numbers. A probability distribution tells you how likely each number (or range of numbers) is.

Key takeaway: A distribution is a complete “story” about uncertainty: what values are possible, how likely they are, and how we summarise them (mean, variance).


flowchart TD
	PD["Probability<br/>distributions"] --> RV["Random<br/>variables"]
	PD["Probability<br/>distributions"] --> DS["Common<br/>distributions"]

	style PD fill:#90CAF9,stroke:#1E88E5,color:#000
	style RV fill:#90CAF9,stroke:#1E88E5,color:#000
	style DS fill:#90CAF9,stroke:#1E88E5,color:#000

AI/ML Connection #

  • Many ML models are probabilistic: they assume data (or errors) follow a distribution.
  • Loss functions often come from distribution assumptions: squared loss aligns with Gaussian noise.
  • Naïve Bayes (from the previous module) becomes practical once you can model: \( P(X\mid Y) \) using suitable distributions.

In practice: choosing a distribution is a modelling decision. It affects: prediction, uncertainty estimates, and what “rare” or “typical” means in your data.

AI Pipeline

AI Pipeline #

The AI pipeline is a continuous process where data is collected, prepared, used to train models, evaluated for performance, and continuously improved after deployment.

  1. Collect Data #

  2. Prepare data #

  3. Train Model #

    • Iterate until model is good enough
  4. Deploy Model #

    • Get data back
    • Maintain & update model
timeline
    title AI Pipeline
    Collect Data : Data Ingestion
                 : Data Understanding
    Prepare Data : Cleaning
                 : Feature Engineering
                 : Sampling
    Train Model  : Model Training
                 : Validation & Metrics
    Deploy Model : Deployment
                 : Monitoring & Retraining

Home | AI Foundation

M3: Scale-Out Systems

M3: Scale-Out Systems #

This module examines the platforms, communication patterns, and hardware organisation used to train across larger systems. It extends distributed algorithms into coordinated training services and federated settings.

Module coverage:

  • ML Platforms and Frameworks: the Parameter Server model, Spark MLlib, and TensorFlow/PyTorch distributed training.
  • Distributed Deep Learning: decentralised SGD, all-reduce, asynchronous parallelism, and large-scale neural networks.
  • Federated Learning: training that preserves data privacy, communication efficiency, and hardware utilisation.

Learning Objectives #

  • Explain how training platforms organise model state, workers, and updates.
  • Compare centralised parameter services with collective communication.
  • Assess the effects of bandwidth, latency, locality, and stale updates.
  • Relate federated training to data distribution, privacy goals, and communication limits.

Pages and Planned Topics #

ChapterTopicAvailability
8ML Platforms and FrameworksPage available; currently focuses on the Parameter Server model
9Distributed Deep Learning: Synchronisation and CommunicationPage available; parameter-server synchronisation, compression, overlap, and placement
10Locality and Large-Scale ParallelismPlanned
11GPU Architecture and Federated LearningPlanned

The outline below describes the full module scope. Planned topics have no chapter page yet. Chapter 9 currently covers parameter-server execution policies and communication optimisation; collective communication, matrix multiplication, and Local SGD remain to be added from their source material.

Markov Decision Processes

Markov Decision Processes #

A Markov Decision Process (MDP) is the mathematical framework used to describe sequential decision-making in reinforcement learning. It brings together the agent, environment, states, actions, transition dynamics, rewards, returns, policies, and value functions in one model.

A basic bandit asks which action is best in a recurring situation. An MDP goes further: the action taken now can change the next state, which changes the decisions and rewards that become possible later.

Parallel Programming Models

Parallel Programming Models #

Parallel algorithms need hardware that can execute independent work efficiently. Modern systems therefore combine multiple CPU cores, memory hierarchies, threads, instruction pipelines, GPUs, clusters, and specialised matrix processors.

Course coverage:

  1. Parallel programming models for expressing independent work
  2. MapReduce, task-parallel, and request-parallel patterns
  3. Multi-core CPUs and GPGPUs: SIMD, MIMD, SIMT, memory hierarchy, and bandwidth
  4. Distributed clusters: CPU-only and GPU-accelerated systems, data sharding, parameter servers, and all-reduce

The hardware sections also cover specialised matrix processors and the performance limits introduced by memory and communication.

Problem Solving and Uninformed Search

Problem Solving and Uninformed Search #

A problem-solving agent converts a goal into a precisely defined search problem. An uninformed search algorithm then explores the state space using only the information in that problem definition.

  • Problem Solving Agent
  • Problem Formulation - Examples
  • From Uninformed to Informed Search Algorithms

Learning Objectives #

  • formulate a search problem using five components
  • distinguish a state-space graph from a search tree
  • explain nodes, frontiers and node expansion
  • compare tree search with graph search when states repeat
  • compare BFS, DFS, UCS, DLS and IDS
  • select an appropriate uninformed strategy for a problem
  • distinguish offline and online search

Big Picture #

flowchart TD
    G["Goal"] --> F["Formulate problem"]
    F --> S["Search for actions"]
    S --> X["Execute solution"]

    style G fill:#E1F5FE
    style F fill:#C8E6C9
    style S fill:#FFF9C4
    style X fill:#EDE7F6

1. Problem-Solving Agents ☆ #

A problem-solving agent normally follows three stages: