Skip to Content

ML / AI Deep Dive

The core concepts behind modern LLMs, RAG pipelines, and production AI systems. Read in order if you’re new; jump to whichever concept your interview questions target.

Concepts at a Glance

#ConceptOne-liner
1Transformer ArchitectureEncoder + Decoder blocks; replaces RNNs through parallelisation.
2Self-AttentionQ.K.V matrices decide which tokens attend to which.
3Multi-Head AttentionMultiple attention heads in parallel; each learns a different relationship.
4Positional EncodingInject order into a parallel-only architecture (sinusoidal, learned, RoPE).
5TokenizationBPE / WordPiece / SentencePiece substrate that converts text to integer IDs.
6EmbeddingsDense vectors where semantic similarity = geometric proximity.
7Cosine vs L2Pick the angle metric for text similarity, the distance metric for magnitudes.
8RAGRetrieve -> Augment -> Generate; beats stale or proprietary knowledge alone.
9Fine-Tuning vs RAGUpdate weights vs inject data vs prompt. Pick by data stability and cost.
10RLHFPost-pretraining alignment with human preference signals.
11Gradient Descent & BackpropThe chain-rule loop that trains every neural net.
12LSTM vs TransformerRNNs scale linearly; self-attention scales in parallel and gets long context.
13Hallucinations & DefensesProbabilistic next-token prediction requires layered defences.
14Embedding DriftNew embedding model = new vector space = re-index required.
15HNSWApproximate nearest-neighbors graph that makes 10M-vector search ms-latency.

How These Layers Compose

       tokens (ints)
           |
           v
+--------------------+    +--------------------+    +--------------------+
|  Token + Positional|    |  Multi-Head        |    |  LayerNorm +       |
|  Embedding         | -> |  Self-Attention    | -> |  FeedForward       |
+--------------------+    +--------------------+    +--------------------+
                                                          |
                                                          v
                                                  (stack N times)
                                                          |
                                                          v
                                                  Next-token logits
                                                          |
                                                          v
                                                Human feedback (RLHF)

The same backbone powers GPT-4, Llama, Claude, Mistral, Gemini — only the data and scale differ.

Tip: If asked “what changed in the last 5 years of AI?”, 80% of the answer is scale + attention + RLHF.

Advertisement