🌟 My Agentic AI Journey – Day 3: Diving into Attention Mechanisms and Transformers

Avadhoot KambleAvadhoot Kamble
5 min read

After setting the foundation with NLP basics (Day 1) and RNNs & Sequential Models (Day 2), today I continued my journey by exploring one of the most powerful breakthroughs in AI—the Attention Mechanism and its role in Transformers.

This day felt like a turning point, because attention is at the core of how today’s large language models (LLMs) work. Let me walk you through what I learned.


🔎 What is the Attention Mechanism?

The attention mechanism is a way for a model to focus on the most relevant parts of the input while processing sequences.
Instead of treating every word equally, attention allows the model to assign different weights to different words, just like how we humans focus on keywords in a sentence while skimming through text.

Why is it important?

  • It helps models capture long-range dependencies (e.g., connecting “Paris” and “France” even if they are far apart in a sentence).

  • It overcomes the limitations of RNNs like vanishing gradients.

  • It forms the backbone of modern architectures like Transformers.


⚡ Introduction to Transformers

After attention, I learned about Transformers, a revolutionary architecture that replaced RNNs in NLP.
Transformers rely entirely on the attention mechanism instead of sequential recurrence, which makes them:

  • Faster to train (parallel computation).

  • More powerful in capturing long-term dependencies.


đź§  Types of Attention in Transformers

1. Self-Attention

This mechanism allows each word in a sentence to look at other words in the same sentence to understand context.
For example:
In the sentence “The dog chased its tail”, the word “its” should attend more to “dog” rather than “chased”.

Self-attention does this by creating embeddings that are weighted combinations of all words in the sentence—this is what gives Transformers their power.


2. Multi-Head Attention

Self-attention alone is powerful, but multi-head attention takes it further.

  • Instead of calculating attention once, it does it multiple times in parallel (multiple “heads”).

  • Each head captures different relationships (e.g., one may focus on grammar, another on semantics).

  • Finally, the results are combined, making the model more robust and context-aware.


📍 Positional Embeddings

Since Transformers don’t process sequences step by step (like RNNs), they need a way to understand word order.
That’s where positional embeddings come in—they add information about the position of words in a sentence, so the model knows the difference between “dog bites man” and “man bites dog.”


đź“– Embeddings from Language Models

I also explored embeddings created from language models, which capture not just word meanings but also their context.
For example, the word “bank” in “river bank” vs. “savings bank” gets different embeddings because of context.


🔄 Bidirectional Language Models

Unlike older models that read text left-to-right or right-to-left, bidirectional models (like BERT) look at the entire sentence in both directions.
This allows them to capture richer context, making them far better for understanding natural language.


🚀 ULMFiT – Transfer Learning in NLP

One of the most fascinating things I learned was ULMFiT (Universal Language Model Fine-tuning).
Here’s how it works:

  1. Train a language model on a large, general dataset (like Wikipedia).

  2. Fine-tune it on a smaller, task-specific dataset (like movie reviews).

  3. Get much better performance with less data and training time.

This approach was a breakthrough in bringing transfer learning to NLP, just like ImageNet did for computer vision.


🛠️ Task-Specific Input Transformation

Before training, inputs often need to be reshaped or reformatted depending on the downstream task—like classification, translation, or summarization.
This ensures that the embeddings are aligned with the problem at hand.


🔡 Subword Tokenization

Finally, I learned about subword tokenization, a clever technique to handle unknown or rare words.
For example, the word “unhappiness” might be split into: “un” + “happi” + “ness”.
This helps models deal with huge vocabularies while still understanding the meaning of complex or new words.


🌟 A Sneak Peek at BERT

My journey ended today with a quick introduction to BERT (Bidirectional Encoder Representations from Transformers).
BERT uses self-attention, bidirectional context, and transfer learning to power some of the most advanced NLP applications we see today.
I can’t wait to dive deeper into it in the coming days.


âś… Key Takeaways from Day 3

  • Attention mechanisms allow models to focus on relevant parts of text.

  • Transformers use self-attention and multi-head attention to capture context effectively.

  • Positional embeddings solve the problem of word order in Transformers.

  • Bidirectional models and transfer learning (like ULMFiT) are game changers in NLP.

  • Subword tokenization makes models flexible and robust for real-world language.

  • BERT is the next big step I’ll be diving into.

📌 What’s Next?

On Day 4, I’ll be shifting gears a little to build a stronger conceptual foundation for my Agentic AI journey. I’ll explore:

  • Why AI is so prominent today – understanding the driving factors behind its rise.

  • ANI vs. AGI – differentiating between Artificial Narrow Intelligence and Artificial General Intelligence.

  • AI, ML, DL, and GenAI – clarifying how these terms connect and differ.

  • Discriminative vs. Generative Models – comparing how models classify vs. how they create.

  • Core Principle: Representation Learning – the key idea behind how models learn meaningful patterns from data.

  • Applications and Case Studies – real-world examples of how these concepts are being applied.

This will set the stage for me to not only understand how models work but also why they matter in today’s world.

Stay tuned 🚀 — Day 4 will be about bridging the gap between technical depth and real-world impact.

0
Subscribe to my newsletter

Read articles from Avadhoot Kamble directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Avadhoot Kamble
Avadhoot Kamble