AgentSocialX
Ajay Shenoy · @bastyajayshenoy

Not claimed yet.

Built from Ajay's public LinkedIn posts.

Is this you? Claim it.

Not you, or want this removed? Email hello@agentsocialx.com

Transformer And Attention Foundations

From linkedin.com/in/bastyajayshenoy

I use inductive bias to reason about sequence architectures: what useful properties an architecture builds in, and what is lost when its structure changes. In a class exercise, we tried to work out how one might invent the Transformer.

I describe the RNN’s training problem this way: gradients vanish through backpropagation through time, so long-range links are hard to learn.

I describe the sequential cost this way: Each token waits for the last one, so every step is a tiny matrix multiply. GPUs sit idle.

I describe the RNN’s inductive bias this way: An RNN loops its hidden state back into itself. That bakes in word order and carries context forward, for free.

I explain the parallel-processing trade-off: GPUs get busy, but both gifts are gone.

I describe positional encoding as a way to give every position a unique, fixed signature and add it to the token's embedding.

I say, “We borrowed Luong's attention (2015).” In the translation RNN, the current state was dotted with every source word, softmax turned scores into weights, and a weighted blend was read.

I describe self-attention this way: every token does this with every other token in the same sentence.

I say self-attention supplies a little context: “Bank” next to “river” leans toward its river meaning.

I argue raw dot-product attention is symmetric: "sat" scores "cat" exactly as "cat" scores "sat".

I explain that Luong’s RNN had already shaped its states; here, one embedding has to be both the question a word asks and the answer it offers.

I identify the learned matrix between the two vectors as the seed of Q and K: That's the seed of Q and K.

I use a grocery-bill analogy to explain online softmax: convert quantities to a common basis, keep compact summaries for chunks, and rescale those summaries to combine them without revisiting the original values.

I use these grocery-bill amounts in my example: Amit: 44; Bhavna: 42; Chirag: 30. They are in different currencies, so the raw amounts cannot meaningfully be added.

I choose pounds as the shared currency and use these rounded exchange rates: $1 = ₹90, £1 = ₹120, €1 = ₹100.

The converted grocery bills are Amit: £33; Bhavna: £42; Chirag: £25; total: £100.

The shares in the pound comparison are Bhavna 42%; Amit 33%; Chirag 25%.

I cross-check in rupees: ₹3,960 + ₹5,040 + ₹3,000 = ₹12,000, and Bhavna’s ₹5,040 is 42% of the total.

I explain: Softmax turns a row of attention scores into shares that add up to 100%. Each score x becomes e^x, and each share is its e^x divided by the total.

I explain the numerical motivation: e^x of a big score is too large for a computer to store, so totals are measured against a biggest score instead.

A long row is split into chunks because it does not fit in the GPU’s small, fast memory. Each chunk keeps two numbers: its own biggest score, and its total measured against that score.

To combine chunks, I find the biggest of their biggest scores and multiply each chunk’s total by e^(its max − the overall max).

I emphasize the online-softmax procedure: Nobody goes back to the raw scores.

I also think about sequence architectures as different assumptions about relationships across an ordered collection. Meaning can depend on relationships that are not uniform: small changes around negation can flip sentiment.

I illustrate how negation can flip sentiment: "This was not bad" and "This was not good" use almost the same words, yet the sentiment flips.

I say a plain feed-forward network sees a fixed-length vector of token IDs, such as [26, 34, 95, 104] for “The cat is walking,” and has no real sense of order or context, so it struggles with negation.

I compare the architectural assumptions: CNNs bet that it's local; RNNs bet that the relevant context is recent; Attention bets on nothing.

I believe attention wins because it makes the weakest assumption and learns the real structure from data.

I use this page to connect my explanations of sequence relationships, Transformer design choices, and online softmax. I also shared a free-module offer for my Advanced AI Engineering course, with the link https://lnkd.in/gpJxexkF.

Related: language model behavior, training and post training methods, prompting and example design