AI and Machine Learning reference

145 commands, numbers and terms from the 14 lessons, one line each. The right-hand column opens the page that teaches it.

1What AI and machine learning are

AI ⊃ ML ⊃ deep learningEach names a smaller field inside the one beforeAI, ML, deep learning
Rules vs learningProgramming writes the rules; ML learns them from dataAI, ML, deep learning
SupervisedLabelled examples: classification (a class) or regression (a number)Supervised learning
UnsupervisedNo labels: clustering, dimensionality reduction, anomaliesUnsupervised learning
PCANew columns ordered by variance; keep the first few. Standardise firstDimensionality reduction
ReinforcementAn agent learns from rewards its actions earnReinforcement learning
Self-supervisedThe data supplies its own labels (next word)Reinforcement learning
AI workloadsVision, speech, language, document extraction, prediction, generationAI workloads
Classification, detection, segmentationOne label per image / a box per object / a class per pixelTask vocabulary
When not to use MLRules can be written, no data, or every error must be explainedWhen not to use ML

2A first model: linear regression

Training data, feature, labelThe known examples / an input the model reads (size) / the answer it must predict (price)The task
ParametersThe knobs (weights) training setsModel parameters
LossOne number for how wrong: MSE for numbers, cross-entropy for classesLoss
MSE, MAE, HuberSquared: outlier-sensitive / absolute: robust / squared near zero, linear beyond δChoosing a loss
Gradient descentMeasure the slope, move the knobs downhillGradient descent
Gradient of MSE∂L/∂w = (2/n) Σ error × input; ∂L/∂b = (2/n) Σ errorThe gradient
Learning rateToo small crawls; too large overshootsLearning rate
Epoch, batchOne pass over all data / the slice used per stepEpochs and batches
Batch, mini-batch, SGDAll examples per step / a few (the default) / oneBatch size
Linear regressionWeighted sum of features predicts a numberLinear regression

3Classification

Logistic regressionWeighted sum through a sigmoid gives a probabilityLogistic regression
Log loss (cross-entropy)−ln(p of the true class), averaged; confident errors cost mostLog loss
TP, FP, FN, TNThe four cells of the confusion matrixConfusion matrix
Macro, weighted, micro averagePer class equally / by class size / pooled decisions (= accuracy)Multi-class metrics
Accuracy(TP + TN) ÷ all; misleading when one class is rareAccuracy
PrecisionTP ÷ (TP + FP): were the alarms real?Precision and recall
RecallTP ÷ (TP + FN): were the cases caught?Precision and recall
F1Harmonic mean of precision and recallPrecision and recall
ThresholdRaise it: precision up, recall downDecision threshold
ROC, AUCTrue vs false positive rate at every threshold; area 0.5 is chanceDecision threshold
Cost-based thresholdCompute misses × cost + false alarms × cost at each threshold; take the lowestChoosing the threshold

4Data and generalisation

CleaningMissing values, outliers, duplicates, wrong typesData cleaning
CSV vs ParquetRow text / columnar, typed, compressedData cleaning
One-hot encodingOne 0/1 column per categoryFeature engineering
Standardise, normalise, logz-score / 0 to 1 / tame long tailsFeature engineering
Train, validation, testFit / tune / judge once at the endData splits
k-fold cross-validationEvery example validates onceData splits
Data leakageTest or future information reaching training; fit preparation on training folds onlyData leakage
Overfitting vs underfittingMemorised the data / too simple to learn itOverfitting
Regularisation, dropout, early stoppingFixes for overfittingOverfitting
Learning curveTraining and validation error against training-set size; gap = variance, both high = biasLearning curves
Hyperparameter tuningGrid, random or Bayesian search over settingsHyperparameters
MAE, RMSE, R²Mean miss / punishes big misses / share of variance explainedRegression metrics
BaselineAlways compare with a simple rule or the majority classBaselines

5Trees, forests and clustering

Decision treeOne question at a time; easy to read, overfits aloneDecision trees
Gini impurityHow mixed a node is; the split that lowers it most winsDecision trees
Random forestMany trees on random samples voteRandom forests
Out-of-bag (OOB) scoreEach tree is scored on the ~37% of rows its bootstrap sample left outWhy forests work
Gradient boostingEach tree fixes earlier errors (XGBoost, LightGBM)Gradient boosting
eta, max_depth, subsampleXGBoost defaults 0.3, 6, 1; lower eta needs more roundsBoosting settings
k-meansk centres move to the middle of their groupsk-means clustering
Elbow, silhouetteBend in inertia against k / cohesion against separation, from −1 to 1Choosing k
ChoosingTables: boosted trees first; images and text: neural networksChoosing an algorithm

6Neural networks

NeuronWeighted sum of inputs plus bias, then an activationArtificial neuron
ReLU, sigmoid, softmaxBends that let layers learn curves; softmax gives class probabilitiesActivation functions
Softmax, logitse^z ÷ Σ e^z turns raw scores (logits) into probabilities that sum to 1Softmax and cross-entropy
LayersInput, hidden, output: raw input to features to answerLayers
Forward passInput to prediction, layer by layerForward pass
BackpropagationThe error flows back; each weight gets its shareBackpropagation
Vanishing gradientSlopes below 1 multiplied per layer; fixed by ReLU, normalisation, residual connectionsVanishing gradients
CNNA small filter slides across the imageConvolutional networks
CNN, RNN, transformerImages / sequences (older) / text and most else nowConvolutional networks
Conv output size⌊(W − K + 2P) ÷ S⌋ + 1; parameters = (K × K × channels in + 1) × filtersStride and padding
GPUMatrix maths in parallelGPUs and accelerators

7From model to production

LifecycleFrame, data, features, train, evaluate, deploy, monitor, repeatML lifecycle
Problem framingA business goal becomes one prediction you can measureProblem framing
Real-time, batch, async inferencePick by who waits and how often requests comeInference options
p95, p99 latencyThe time 95% / 99% of requests finish within; targets use these, not the meanSizing an endpoint
MLOpsVersioned data and models, pipelines, registry, monitoringMLOps
Feature storeOffline store for point-in-time training sets, online store for serving; one definitionFeature stores
Shadow, canary, A/B, blue-greenShift traffic to a new model in stepsDeployment strategies
Real-time, serverless, async, batch endpointsSageMaker inference optionsDeployment strategies
A/B testSplit live traffic, compare a business metric, test the difference for significanceA/B testing
Data drift, concept driftInputs change / the right answer changesModel drift
Model monitorCompare live inputs and outputs to trainingModel drift

8How large language models work

TokenPiece of a word; roughly ¾ of an English wordTokens
Byte-pair encoding (BPE)Repeatedly merge the most frequent adjacent pair into a new tokenByte-pair encoding
Next-token predictionThe only thing an LLM does, again and againNext-token prediction
EmbeddingMeaning as a point; close when similarEmbeddings
Cosine similaritya·b ÷ (|a| |b|); equals the dot product for unit-length vectorsCosine similarity
AttentionEach token draws on every other tokenAttention
Long context costAttention grows with the square of the lengthAttention
Context windowEverything the model can see: prompt, history, answerContext window
Pretraining, fine-tuning, RLHFLanguage / instructions / preferencesTraining stages
Foundation modelOne pretrained model adapted to many tasksTraining stages
TemperatureLow: focused and repeatable; high: variedTemperature and sampling
Top-p, top-k, max tokens, stopOther sampling controlsTemperature and sampling
BLEU, ROUGE, BERTScore, LLM judgeGenerated text by overlap, meaning or a judgeTemperature and sampling
DiffusionStart from noise, remove it step by stepDiffusion models

9Prompting

Prompt partsTask, context, example, formatPrompt anatomy
Zero-shot, few-shot, chain of thoughtTechniques and when to use eachPrompt anatomy
System promptSets rules for the whole chat; messages carry turnsSystem prompt and messages
system / system_instructionWhere each API takes the system prompt; Gemini calls the assistant role "model"API differences
Few-shotTwo or three examples teach the formatFew-shot prompting
Step by stepAsk for the reasoning first on multi-step problemsStep-by-step reasoning
Structured outputJSON against a schema when code reads the answerStructured output
Validate and retryjson.loads, schema validation, one retry with the error text, then hand offValidate and retry
Prompt failuresVague task, missing context, conflicting rulesPrompt failures
Prompt testsVersion prompts and run a test set on each changeTesting prompts
Confidence interval on a score45/50 is 79% to 96% at 95% confidence; small sets only show large changesTest set size

10Retrieval-augmented generation

RAGRetrieve relevant passages, put them in the promptWhy RAG
RAG vs long prompt vs fine-tuneChanging facts / small fixed set / behaviour and styleWhy RAG
Index and query pipelinesChunk, embed, store once; embed, search, answer each timeThe two pipelines
Vector storeBedrock Knowledge Bases, Azure AI Search, pgvectorThe two pipelines
ChunkingSize and overlap decide what can be foundChunking
Cosine similarityNearest chunks in meaningVector search
ANN index (HNSW)Approximate search over millions of vectors fastVector search
Hybrid search, rerankerKeyword plus vector, then a model reordersHybrid search and reranking
BM25Keyword ranking: IDF × saturating term frequency, length-normalised; k1 1.2, b 0.75BM25
GroundingAnswer only from the sources, and cite themGrounding and citations
Evaluating RAGRetrieval (recall@k) and answer (faithfulness) separatelyEvaluating RAG
Recall@k, MRR, nDCGFound ÷ existing in top k / mean of 1 ÷ first relevant rank / rank-discounted gainRetrieval metrics

11Agents and tools

Tool callingThe model asks; your code runs the tool and returns the resultTool calling
Tool definitionName, description, JSON schema of inputsTool calling
Agent loopReason, act, observe, until the goal is metThe agent loop
Managed agentsBedrock Agents, Azure AI Agent Service, Vertex AI Agent BuilderThe agent loop
MCPOne standard for apps to use tools and dataModel Context Protocol
Host, client, server, transportThe parts of MCPModel Context Protocol
Agent memorySummarise the context; store facts outside itMemory
Workflow vs agentFixed steps when you can; an agent when you mustWorkflows and agents
Compounding errorA 95%-reliable step gives a 36% chance of 20 clean stepsWhy long chains fail
Verification stepA check after each agent step; with one retry, 95% a step becomes about 99%Checks and retries
Agent safetyLeast privilege; a person approves risky actionsKeeping agents safe

12Customising and running models

Customisation ladderPrompt, RAG, fine-tune, train from scratchWays to customise a model
LoRATrain a tiny add-on instead of every weightFine-tuning and LoRA
SFT, instruction tuning, preference tuningKinds of fine-tuningFine-tuning and LoRA
Inference costInput and output tokens × price per tokenCost of inference
Prompt cachingA repeated, identical prompt prefix billed at a reduced rateResent history
TTFT, tokens per secondWait before the first token / writing speed; latency = TTFT + output ÷ speedLatency
QuantisationFewer bits per weight: smaller, faster, a little less accurateQuantisation
On-demand, batch, provisionedPay per token / cheaper, slower / reserved capacityQuantisation
Quantisation scaleLargest |weight| ÷ top integer level; weight is stored as round(weight ÷ scale)Quantisation by hand

13Responsible AI and security

PrinciplesFairness, reliability and safety, privacy, inclusiveness, transparency, accountabilityResponsible AI principles
BiasCompare groups in the data and in the outcomesMeasuring bias
DPPL, RD, DARClarify post-training metrics: gap in predicted approvals / in recall / in precisionBias after training
SHAPHow much each feature pushed this one predictionExplainability
Interpretable modelsLinear models and small trees explain themselvesExplainability
Shapley valueA feature's contribution averaged over all orderings; values sum to prediction − baseShapley values
HallucinationFluent and false: ground, cite, checkHallucination
Prompt injectionInstructions hidden in text the model should only readPrompt injection
OWASP LLM Top 10Injection, data leaks, excessive agency and the restPrompt injection
GuardrailsFilters on what goes in and comes outGuardrails
EU AI ActUnacceptable, high, limited, minimal riskGovernance and regulation
ISO/IEC 42001, NIST AI RMFAI management and risk frameworksGovernance and regulation
When the AI Act appliesPlacing on, or use in, the EU marketGovernance and regulation

NeuroqAI · AI and Machine Learning · neuroqai.com/courses/ai-and-machine-learning/reference/