"There is no ghost in the machine. There is only linear algebra, wearing a very convincing costume."

Every time a product manager calls an AI system "smart" in a standup, somewhere an ML engineer flinches. Not because the word is entirely false, but because the actual mechanism is both less mystical and more interesting than "smart" implies. There's no brain running in a data center. There's no understanding in any sense you'd apply to a person. What's actually running is a massive volume of arithmetic, structured well enough that the output resembles cognition. Consider this the Anatomy of AI, opened up for inspection — vectors, pipelines, and the current controversies, no hand-waving included.

1. What AI Actually Is, Technically

1.1 Definition, No Marketing Layer

Artificial Intelligence is, formally, the field concerned with building systems that execute tasks normally requiring human cognition — pattern recognition, language generation, prediction, decision-making under incomplete information. Nearly everything shipped today under the "AI" label falls inside a narrower subfield called machine learning (ML), and inside that, a still-narrower one: deep learning.

The hierarchy, quickly:

  • Classical AI (1950s–1980s) — rule-based systems, hand-coded by engineers as explicit if-then logic trees. Referred to as "symbolic AI," or, in less flattering circles, "Good Old-Fashioned AI" (GOFAI).
  • Machine Learning — inverts the approach. Instead of hard-coding rules, you feed the system large volumes of labeled or unlabeled data and let it derive statistical patterns.
  • Deep Learning — machine learning implemented with multi-layered neural networks. "Deep" refers strictly to layer count, not conceptual sophistication, whatever the pitch deck implies.

1.2 Timeline, Compressed

The term "Artificial Intelligence" was coined in 1956 at the Dartmouth Summer Research Project, proposed by John McCarthy, Marvin Minsky, Nathaniel Rochester, and Claude Shannon. Their original proposal claimed "every aspect of learning... can in principle be so precisely described that a machine can be made to simulate it," and budgeted two months to solve it. Seventy years and counting.

Key milestones:

  1. 1943 — McCulloch and Pitts publish the first mathematical model of an artificial neuron.
  2. 1958 — Rosenblatt ships the Perceptron, the first trainable neural network.
  3. 1969–1980sAI Winter. Minsky and Papert's Perceptrons proves the limits of single-layer networks; research funding collapses.
  4. 1986 — Rumelhart, Hinton, Williams popularize backpropagation, making deep network training computationally viable.
  5. 2012AlexNet wins ImageNet by a wide margin, validating deep convolutional networks at scale with sufficient data and GPU compute. Generally cited as the start of the modern deep learning era.
  6. 2017 — Vaswani et al. publish "Attention Is All You Need" at Google, introducing the Transformer — the architecture underneath essentially every major LLM shipped since, GPT and Claude included.
  7. 2020s — LLMs scale to hundreds of billions of parameters; RAG and agentic tool-use ship in production; AI moves from research to core infrastructure.

The takeaway for engineers: progress didn't come from a conceptual breakthrough about cognition. It came from a better architecture (the transformer), more training data, and orders of magnitude more compute — three unglamorous variables that simply compounded.

2. Neural Networks: The Compute Layer

2.1 The Biology Analogy Doesn't Hold Up Under Load

Neural networks borrow their naming convention from biological neurons, but the analogy is superficial. A biological neuron is a self-repairing, chemically complex cell embedded in a living system. An artificial "neuron" is a single scalar — the result of a weighted sum passed through an activation function. Calling it a "brain" is roughly equivalent to calling for loops "decision-making." Useful shorthand for onboarding, technically inaccurate.

2.2 The Neuron, as Code Would Express It

Each artificial neuron performs one operation: n inputs in, one output. The math:

z = (w1*x1 + w2*x2 + ... + wn*xn) + b a = activation(z)

  • x1...xninputs: pixel values, token embeddings, any numeric feature vector
  • w1...wnweights: learned coefficients determining input importance
  • bbias: a learned offset
  • activation() — a non-linear function applied to z

Remove the non-linearity and any number of stacked layers collapses, algebraically, into a single linear transformation — no better than a one-layer model regardless of depth. Standard activation functions in production systems:

  • ReLU: f(z) = max(0, z) — cheap to compute, avoids vanishing gradients, default for most hidden layers.
  • Sigmoid: f(z) = 1 / (1 + e^-z) — bounds output to (0, 1), used where probability-like output is needed.
  • Softmax: normalizes a raw score vector into a probability distribution summing to 1 — this sits at the output head of a language model, converting logits into next-token probabilities.

2.3 Forward Pass, Vectorized

"Forward propagation" is pushing an input tensor through the network layer by layer until an output tensor emerges. For a single dense layer, in matrix notation:

Z = W·X + B A = activation(Z)

W is the weight matrix for that layer, X the input vector, B the bias vector. This is why AI workloads are, fundamentally, linear algebra at industrial scale — a single inference call to a large language model triggers trillions of matrix multiplications, which is precisely why GPUs and TPUs exist instead of relying on general-purpose CPUs for this workload.

2.4 Backprop and Gradient Descent

Training is the iterative process of updating every weight and bias to minimize prediction error. The loop:

Loss computation — comparing predicted output against ground truth via a loss function, commonly cross-entropy loss for classification tasks: L = -Σ y_true * log(y_predicted)

  1. Backpropagation — applying the chain rule to compute the gradient of the loss with respect to every weight in the network: ∂L/∂w.
  2. Gradient descent — updating each weight in the direction that minimizes loss:

w_new = w_old - learning_rate * (∂L/∂w)

Run this loop over billions of training examples across millions of iterations, and the network converges on a weight configuration that produces useful output. Nobody hand-tunes any individual weight — it's discovered through optimization, not engineered directly. This is exactly why these models are described as black boxes: there's no single weight you can point to and say "this is the Paris-is-the-capital-of-France weight." The representation is distributed statistically across billions of parameters.

2.5 The Six-Layer Anatomy of an ANN

A moderately complex Artificial Neural Network (ANN) decomposes into roughly six functional stages:

  1. Input Layer — ingests raw numeric data (pixel values, token IDs, audio samples). Zero computation happens here; it's the entry point.
  2. Embedding / Encoding Layer — maps discrete tokens into dense vectors that encode semantic meaning, where "king" and "queen" end up close together in vector space.
  3. Hidden Layer 1 (Feature Detection) — extracts low-level patterns: edges and gradients in vision models, basic syntactic structure in text.
  4. Hidden Layer 2 (Feature Combination) — aggregates low-level features into higher-order concepts: shapes from edges, phrases from tokens.
  5. Hidden Layer 3+ (Abstraction / Attention) — in transformer architectures, self-attention lives here, computing weighted relevance between every token pair in the input. This layer group carries most of the model's representational capacity.
  6. Output Layer — projects the final hidden representation into the target output space: next-token probability distribution, classification logits, or pixel values.

Caveat for anyone benchmarking this against real architectures: production LLMs like Claude or GPT don't stop at six layers — they stack dozens to hundreds of transformer blocks, each with multiple internal sub-layers (multi-head attention, layer normalization, feed-forward networks). The six-stage breakdown above is a conceptual model, not a literal layer count you'd find in a config file.

3. How AI "Thinks": Vectors, Embeddings, Latent Space

This is where the "brain" framing collapses entirely for anyone who's actually inspected model internals. AI doesn't "think" — it converts every input into vectors (fixed-length arrays of floats) and operates on them geometrically.

  • A token becomes a vector — commonly 4,096 dimensions or more in modern LLMs.
  • A sequence becomes a set of such vectors, fused through attention into a single contextual representation.
  • An image becomes a grid of patch vectors.
  • Semantic meaning becomes distance and direction in this high-dimensional space, called latent space.

The textbook demonstration: in a properly trained embedding space, the vector operation

vector("king") - vector("man") + vector("woman") ≈ vector("queen")

approximately holds. That's literal vector arithmetic, not metaphor, and it happens to align with human semantic intuition. "Thinking," at the implementation level, is a trajectory through this space, with the final token or output read off wherever that trajectory lands.

4. Reasoning in AI: Chain-of-Thought and Its Descendants

Early LLMs generated a response in one forward pass — glorified autocomplete. Modern "reasoning" models improve output quality with Chain-of-Thought (CoT) prompting, formalized in Wei et al.'s 2022 Google paper. The core finding: models produce measurably better answers when forced to emit intermediate reasoning tokens instead of jumping straight to a final answer.

That's evolved into more structured techniques:

  • Chain-of-Thought: the model emits step-by-step natural-language reasoning before the final answer token.
  • Tree-of-Thought: the model explores multiple reasoning branches in parallel, scoring each for viability — analogous to a search tree in classical game-playing algorithms.
  • Self-consistency decoding: the model samples several independent reasoning chains for one prompt and takes a majority vote on the final answer, on the assumption errors are inconsistent while correct reasoning converges.
  • Extended "thinking" tokens: modern reasoning models (OpenAI's o-series, Claude's extended thinking mode) are trained via reinforcement learning to emit long internal reasoning traces before the final answer — effectively a scratchpad buffer.

Worth stating plainly for anyone building on top of these systems: this is not reasoning in the cognitive sense. It's a learned statistical correlation — emitting reasoning-shaped tokens increases the probability of subsequent correct tokens, because reasoning-like sequences correlated with correct answers in the training corpus. The model isn't verifying its own logic the way a person would; it's exploiting a distributional pattern that happens to resemble verification.

5. Retrieval-Augmented Generation (RAG): Full Technical Breakdown

5.1 The Problem RAG Solves

An LLM's parametric knowledge freezes at training completion — the knowledge cutoff. Query it about anything past that point and it either flags uncertainty or, worse, hallucinates — generates a fluent, confident, factually wrong answer. RAG addresses this directly, introduced in Lewis et al.'s 2020 paper at Facebook AI Research, "Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks."

The architecture: decouple knowledge storage from the model's weights by attaching an external, queryable retrieval system at inference time.

5.2 The RAG Pipeline, Component by Component

A production RAG stack typically runs:

  1. Document Ingestion
  2. Source documents (PDFs, web pages, internal wikis, ticket systems) are collected and normalized.
  3. Chunking
  4. Documents get split into passages, typically 200–1,000 tokens each — embedding an entire document as one vector destroys granularity. Chunking strategy (fixed-size, sentence-boundary, or semantic chunking) directly impacts retrieval precision.
  5. Embedding
  6. Each chunk is passed through an embedding model (text-embedding-3, Voyage embeddings, etc.), producing a dense vector, typically 384–3,072 dimensions.
  7. Vector Database Storage
  8. Vectors are indexed in a database optimized for similarity search (detailed in 5.3).
  9. Query Embedding
  10. The user's query gets embedded using the identical embedding model, ensuring vector-space compatibility.
  11. Similarity Search / Retrieval
  12. The query vector is compared against indexed vectors, typically via cosine similarity:

cosine_similarity(A, B) = (A · B) / (||A|| * ||B||)

  1. Top-k (commonly 3–10) most similar chunks are returned.
  2. Re-ranking (common in production)
  3. A secondary, computationally heavier cross-encoder re-scores retrieved chunks, since vector similarity alone is fast but imprecise.
  4. Prompt Augmentation
  5. Retrieved chunks are injected into the model's context window alongside the query: "Using the following context, answer the question: [chunks] [query]".
  6. Generation
  7. The LLM produces its final output, now grounded in retrieved, current, verifiable source material instead of relying solely on parametric memory.

5.3 Vector Databases

A vector database exists to solve one problem efficiently: Approximate Nearest Neighbor (ANN) search in high-dimensional space at scale. Standard relational databases index for exact-match or range queries and perform poorly on "find the k most similar vectors" workloads. Vector databases typically implement HNSW (Hierarchical Navigable Small World) graph indexes, trading marginal recall for major throughput gains.

Production vector database options: Pinecone, Weaviate, Milvus, Qdrant, Chroma, and vector-native extensions on existing systems, such as pgvector for PostgreSQL.

5.4 Tradeoffs and Deployment Patterns

Advantages:

  • Avoids full model retraining to incorporate new information — retraining large models is a multi-million-dollar operation.
  • Reduces hallucination rate by grounding generation in retrievable source documents.
  • Supports citation — traceability back to the specific document backing a claim.
  • Enables querying private, proprietary corpora without ever encoding that data into the model's weights.

Limitations:

  • Retrieval quality is bottlenecked by chunking and embedding choices — poor chunking degrades context relevance and, downstream, answer quality.
  • Adds inference latency from the extra retrieval round-trip.
  • Weak at multi-document synthesis tasks requiring reasoning across several sources rather than one relevant passage.
  • Semantic similarity is not truth — a retrieved chunk can be topically close to the query while being factually incorrect or stale, and the pipeline has no built-in fact-verification step.

Typical deployments: documentation-grounded customer support bots, legal and medical research assistants, enterprise document Q\&A systems, and coding assistants retrieving relevant code snippets from a large repository before generating a response.

6. Benchmarks: Quantifying Model Capability

There's no standardized IQ test for software, so the field relies on benchmarks — curated evaluation sets targeting specific capabilities:

  • MMLU (Massive Multitask Language Understanding): \~16,000 multiple-choice questions across 57 subjects, used as a general knowledge/reasoning benchmark.
  • HumanEval: evaluates functional correctness of code generated from natural-language problem statements.
  • GPQA (Graduate-Level Google-Proof Q\&A): extremely difficult science questions designed to resist quick lookup even by domain experts with internet access, targeting genuine reasoning capability.
  • SWE-bench: evaluates whether a model can resolve real, historical GitHub issues on real repositories — a stronger proxy for production software engineering competence than synthetic coding puzzles.
  • ARC-AGI: specifically engineered to resist memorization, testing abstract pattern reasoning against novel puzzle formats.

A relevant caveat for anyone citing benchmark scores in production decisions: data contamination — benchmark questions leaking into training corpora — is a documented, ongoing issue, inflating reported scores without corresponding real-world capability gains. This is driving the field toward held-out, continuously refreshed, or dynamically generated evaluation sets, an arms race between evaluators trying to measure genuine capability and models that are, deliberately or incidentally, very good at memorizing the answer key.

7. How AI Generates Images

Modern image generation (Midjourney, DALL·E, Stable Diffusion, Imagen) runs on diffusion models. Pipeline:

  1. Text Encoding — the prompt is embedded via a text encoder (typically CLIP-style), mapping words to a shared text-image embedding space.
  2. Noise Initialization — generation starts from Gaussian random noise — a tensor of statistical static.
  3. Iterative Denoising — a network trained to predict added noise at each timestep progressively subtracts predicted noise from the tensor, conditioned on the text embedding at every step, across dozens to hundreds of steps.
  4. Classifier-Free Guidance — at each step, the model computes predictions both with and without prompt conditioning and amplifies the difference, tightening prompt adherence.
  5. Decoding — many systems (Stable Diffusion included) operate in a compressed latent space for compute efficiency; a final VAE decoder upsamples the latent representation into full-resolution pixel space.

Training runs this process in reverse: the model is shown millions of real images with synthetic noise added at controlled intensities and trained to predict and remove that noise. At sufficient scale, the network internalizes the statistical structure of "plausible image" and applies that learned prior to pure random noise, conditioned entirely on the text prompt.

8. How AI Generates Video

Video generation (Sora, Veo, Runway) extends the diffusion approach across an added temporal dimension. Pipeline:

  1. Prompt and Reference Encoding — text (and optionally a reference image or clip) is embedded identically to the image case.
  2. Spatiotemporal Latent Representation — instead of a 2D latent grid, the model operates on a 3D tensor of patches spanning height, width, and time.
  3. Joint Denoising Across Frames — denoising runs across the full clip simultaneously rather than frame-independently, which is the mechanism that prevents flickering and object-identity drift between frames.
  4. Temporal Attention Layers — dedicated attention mechanisms track object continuity and motion consistency across the frame sequence, effectively learning approximate physics from training video.
  5. Decoding and Upscaling — the final latent tensor is decoded into full-resolution frames, typically followed by a separate upscaling/interpolation pass for resolution and frame-rate targets.

The compute cost gap between video and image generation is straightforward: a still image is one correlated tensor; a five-second, 24fps clip is 120 mutually-constrained frames requiring temporal consistency — an exponential increase in optimization complexity relative to a single image.

9. How AI Searches the Web

When an AI system "searches the internet," it isn't crawling the web itself in real time. The pipeline:

  1. Query Formulation — the model reformulates a natural-language question into concise, search-engine-appropriate query strings.
  2. Search API Call — those queries hit an actual search index (Google, Bing, or a specialized provider), returning ranked URLs and snippets.
  3. Result Filtering — the model evaluates result relevance and filters low-quality or spam sources.
  4. Fetching and Extraction — for sufficiently relevant pages, the system fetches raw HTML and extracts readable content, stripping navigation, ads, and boilerplate.
  5. Synthesis — extracted content is loaded into the model's context window alongside the original query — functionally identical to the RAG pipeline in Section 5, except the retrieval corpus is the live, indexed web rather than a fixed private document set.
  6. Citation — claims in the output are attributed to specific source URLs for verifiability.

This is RAG applied to an open, web-scale corpus instead of a curated one — which is why the RAG section earlier in this piece wasn't tangential; it's the same architecture running against a different retrieval target.

10. How AI Writes Code

Code-generation models use the same transformer architecture as general-purpose LLMs, trained on a corpus heavily weighted toward source repositories, technical documentation, and — critically — signal correlating code with outcomes (compilation success, test pass rate). A modern coding agent's execution loop:

  1. Context Gathering — the model reads relevant files, directory structure, and documentation before making changes, rather than operating on the prompt alone.
  2. Planning — for non-trivial tasks, the model typically generates an explicit plan or task decomposition before emitting code — a domain-specific application of Chain-of-Thought.
  3. Code Generation — token-by-token prediction, identical mechanism to prose generation, trained on syntax-dense data.
  4. Tool Use / Execution — production coding agents execute the code, read stdout/stderr, and iterate — a closed feedback loop resembling actual developer debugging workflows, not open-loop generation.
  5. Testing and Verification — the model may write and run tests to validate behavior rather than relying on a single unverified generation pass.

A minimal illustration of next-token prediction applied to source code:

```

The model isn't reasoning about mathematical induction as a formal concept.

It has seen this exact pattern millions of times in training data

and learned the statistical shape of a correct implementation.

def factorial(n):
if n <= 1:
return 1
return n * factorial(n - 1)
```

The model isn't evaluating recursion conceptually. It has encountered this function shape thousands of times during training and learned, statistically, the most probable next token given everything preceding it — and that mechanism, at sufficient parameter and data scale, produces functionally correct code.

11. Training Data, and the Economics Nobody Explains Clearly

This section shifts from architecture to business model, and it's the part every paying user should actually understand. LLM training requires an enormous data volume — books, web text, code repositories, and, increasingly, conversational data generated by users interacting with the models themselves.

That creates a real tension for paying subscribers. Multiple independent reports document a policy change Anthropic implemented around late September 2025: conversations from Free, Pro, and Max subscribers became training-eligible by default, requiring users to manually opt out via privacy settings if they want exclusion. Training-eligible data retention extends to five years, up from a prior 30-day deletion window. Business, Enterprise, and API accounts remain contractually excluded from training use. Consumer-tier users must locate and disable the "Help improve Claude" toggle to opt out.

The structural irony: a paid subscription typically implies you're the customer, not the product. Under this policy, unless a paying consumer explicitly opts out, their usage data becomes training input for the next model release — meaning the same user is simultaneously the customer and an unpaid data contributor. This is disclosed in the terms of service, and disclosure is not the same as informed understanding at the point of signup. For anyone who wants a definitive answer about their own account, the practical step is: check your Privacy Settings directly, since defaults and policies have changed before and can change again.

This isn't specific to one vendor — it reflects an industry-wide dependency. Models require continuous, high-quality conversational data to keep improving, and real user interactions carry signal that scraped web corpora don't, precisely because they represent authentic, task-relevant human-model exchanges. The actionable takeaway isn't outrage; it's checking the setting.

12. The Claude Code Leak of March 31, 2026

On March 31, 2026, between approximately 00:21 and 03:29 UTC, Anthropic accidentally exposed the full internal source code of Claude Code, its terminal-based agentic coding tool, on the public internet. Root cause and timeline:

  • Anthropic's Claude Code build pipeline uses Bun as its bundler. Bun generates JavaScript source map (.map) files by default during builds — debugging artifacts mapping minified production code back to fully readable original source.
  • Version 2.1.88 of the @anthropic-ai/claude-code npm package shipped with a 59.8 MB source map file accidentally included in the public package, missing from .npmignore.
  • The source map referenced an archive hosted on Anthropic's cloud storage, effectively exposing the complete, human-readable original codebase.
  • Within hours, an intern at Solayer Labs discovered the exposure and posted publicly. The codebase — approximately 512,000 lines of TypeScript across roughly 1,900 files — was mirrored to GitHub and analyzed extensively before Anthropic could fully remediate it.

Contents of the leak:

  • The full agent harness architecture: the orchestration layer wrapping the underlying Claude model, providing tool use, shell command execution, file management, and multi-agent coordination.
  • A three-layer memory architecture and context-compaction logic used to manage long-running coding sessions within context-window limits.
  • Approximately 44 hidden, unreleased feature flags, exposing unshipped product capabilities — including an autonomous background-operation mode internally codenamed KAIROS, designed for persistent operation without an active user session, plus related unreleased offline/"away" operation modes.
  • Internal permission-sandbox logic governing the exact scope of autonomous actions the coding agent is authorized to take.
  • Internal codenames, developer comments, and a hidden novelty feature (an embedded virtual pet, described by several outlets as a "Tamagotchi" easter egg) that generated nearly as much online discussion as the architectural findings.

Strategic implications: competing teams building AI coding agents (Cursor, GitHub Copilot, Windsurf, OpenAI's Codex, among others) gained a detailed, real-world reference implementation of a production-grade agentic harness, previously only inferable from external behavior. Multiple industry analyses concluded this reinforces an existing argument in the field: the harness layer wrapping a model is not a durable competitive moat, since it's reverse-engineerable once exposed. Differentiation increasingly has to come from underlying model capability rather than orchestration tooling.

Concurrent, unrelated incident: during the same window, a separate supply-chain attack compromised the axios npm package, publishing malicious versions containing a Remote Access Trojan (RAT). Anyone running npm install or updating Claude Code during the specific 00:21–03:29 UTC window was advised to audit lockfiles for the compromised versions and treat affected machines as potentially compromised. This was coincidental timing with a genuinely independent incident, not caused by the Claude Code leak, but it substantially complicated incident response during the initial hours.

Anthropic subsequently pursued DMCA takedowns against repositories hosting the leaked source and shifted its recommended installation path to a standalone native installer, reducing dependency on the npm chain responsible for the exposure. Claude Code remains closed-source, proprietary software; the leak didn't alter its licensing or distribution model — it simply meant that, for a few hours, the full implementation was publicly readable.

Conclusion: There Is No Ghost, Just Very Good Bookkeeping

Strip away the branding, the anthropomorphic language, and the increasingly cinematic marketing videos, and what remains is this: matrices multiplying matrices, gradients updating weights, vectors clustering by semantic proximity, and large pipelines of retrieval, denoising, and prediction, engineered with genuine rigor. None of this requires assuming machine consciousness to be useful, and none of it requires dismissing its usefulness to stay precise about the mechanics — or about who actually benefits from your data in the process.

The Anatomy of AI was never a brain. It was always vectors and math, engineered at scale.

References

  • McCulloch, W. \& Pitts, W. (1943). A Logical Calculus of the Ideas Immanent in Nervous Activity.
  • Rumelhart, D., Hinton, G., \& Williams, R. (1986). Learning Representations by Back-Propagating Errors. Nature.
  • Krizhevsky, A., Sutskever, I., \& Hinton, G. (2012). ImageNet Classification with Deep Convolutional Neural Networks (AlexNet).
  • Vaswani, A. et al. (2017). Attention Is All You Need. Google Research / NeurIPS.
  • Lewis, P. et al. (2020). Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks. Facebook AI Research.
  • Wei, J. et al. (2022). Chain-of-Thought Prompting Elicits Reasoning in Large Language Models. Google Research.
  • VentureBeat (March 31, 2026). Claude Code's source code appears to have leaked: here's what we know.
  • Zscaler Security Research (2026). Anthropic Claude Code Leak — Critical AI Security Threat 2026.
  • DEV Community (April 1, 2026). The Great Claude Code Leak of 2026.
  • Tom's Guide (2026). Your Claude chats are being used to train AI — here's how to opt out.
  • MPG ONE (2026). Does Anthropic Train Claude on Your Data? Full Answer.
  • Website: ahmershah.dev