The Beginner’s Guide to Generative AI - Token to Thought

🌟 What is Generative AI?
Generative AI is a type of artificial intelligence that can create brand-new content — text, images, music, code, and more — by learning patterns from vast amounts of data.
💡 Unlike traditional AI that only analyzes or sorts data, Generative AI actually creates.
Think of it like a chef who doesn’t just follow recipes but understands flavors well enough to invent dishes on the spot.
🧀 Example:
You upload a photo to an app, and it suggests a clever caption like:
“Serving pizza and looks tonight 🍕💁”
That’s not just a random guess — that’s Generative AI at work.
🤖 What is GPT?
GPT stands for Generative Pre-trained Transformer — a type of large language model (LLM).
- Generative: It creates new content.
- Pre-trained: It has already learned from tons of information before you start using it.
- Transformer: The smart engine that processes your input and understands context. It was introduced in the paper _“Attention is All You Need”_ by Google researchers in 2017.
📚 Example:
Prompt:
“Once upon a time”
GPT Completion:
“…a little girl lived in a cottage near the woods.”
It predicts the next token (piece of text) repeatedly until it finishes your request.
🛠️ How Does GPT Actually Work?
Let’s say you ask ChatGPT:
“Write a funny birthday wish for my friend who loves pizza.”
Here’s what happens behind the scenes — simplified:
1. 💻 Tokenization – Breaking Words Into Tokens
Your sentence is broken into parts called tokens — these can be full words, parts of words, or even letters depending on the model.
💡 Example:
“I love pizza” → [ "I", "love", "pizza" ]
(tokens)
→ [ 40, 3047, 27941 ]
(token IDs)
Code snippet:
import tiktoken
enc = tiktoken.encoding_for_model("gpt-4o")
text = "Hello, I am Yash"
tokens = enc.encode(text)
print("Tokens:", tokens)
tokens = [13225, 11, 357, 939, 865, 1229]
decoded = enc.decode(tokens)
print("Decoded Text:", decoded)
2. 🧠 Vector Embeddings: Giving Meaning to Words
Once we have tokens, we need to understand what they mean. That’s where embeddings come in — they position words in a high-dimensional space based on relationships.
“Cat” and “Kitten” are different tokens — but live close in this vector space because they’re related.
🔗 Vector embeddings visualizer
Code snippet:
from dotenv import load_dotenv
from openai import OpenAI
load_dotenv()
client = OpenAI()
text = "dog chases cat"
response = client.embeddings.create(
model="text-embedding-3-small",
input=text
)
print("Vector Embeddings", response)
print(len(response.data[0].embedding))
3. 📍 Positional Encoding – Why Word Order Matters
GPT doesn’t just look at which words you used — it also cares where each word appears in the sentence. This is called positional encoding, and it's what helps the model understand the sequence of words.
Why Is This Important? — Words in different orders can mean totally different things, even if they’re the exact same words.
“She gave the book to her friend.”
vs
“Her friend gave the book to her.”
Same words — very different action. Without understanding the order, the model wouldn’t know who is giving and who is receiving.
4. 🔁 Self-Attention – Understanding the Full Sentence
Every token can “look” at every other token to judge relevance — called self-attention.
💡 Example:
“He sat by the bank.”
Here, “bank” could mean riverbank or money bank. Context matters.
🚀 Analogy:
Like remembering key parts of a story, GPT focuses on important words based on the full sentence.
5. 👀 Multi-Head Attention – Seeing from Many Angles
GPT uses multiple attention heads — like viewing a scene from different angles:
It’s like trying to understand a scene in a movie using:
- 🎵 The background music
- 😶 The facial expressions
- 💬 The dialogue
- 💡 The lighting
Each head looks at one detail and contributes to understanding the whole sentence.
🚀 Phases of GenAI Model
Phase | Analogy | What Happens |
Training | Studying for exams | Model sees billions of text/image pairs and learns patterns |
Fine-tuning / RLHF | Practice quizzes | Aligned with human preferences or specific tasks |
Inference | Taking the exam | You give a prompt; it generates a response |
⚠️ Limitations of Generative AI
Like any tool, it has its flaws:
- Hallucinations – It can generate confident but wrong answers.
- Bias – Training data biases.
- Freshness – Knowledge is frozen at the last training update.
✅ But with clearer prompts and more usage, your results improve.
📅 Final Thought: AI is Your Learning Partner, Not Your Competitor
Think of AI as a helpful friend:
- 🤝 Someone who supports your practice
- 💡 A guide who offers tips
- 🚀 A partner cheering you on
All you need is:
- A clear goal or question
- Patience and curiosity to keep exploring and improving
No matter who you are or what you do, Generative AI is here to help you grow and create. So hop on, enjoy the ride, and let AI be your trusted companion!
✨ Why It Matters
Generative AI is like a creativity booster — helping you:
- ✍️ Write essays, captions, or emails
- 💻 Build code or brainstorm ideas
- 📚 Learn faster with instant explanations
Whether you're a student, writer, marketer, or just curious — AI is here to help you think bigger, work smarter, and create more.
🧠 So the next time you write a poem, plan a project, or need a pizza joke — try prompting AI.
You’ll be surprised by how far a little spark can go.
Subscribe to my newsletter
Read articles from Yash Mantri directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Yash Mantri
Yash Mantri
An engineer by profession and a JavaScript Lover by heart. First and foremost, I love writing code. Ever since writing my first program in C and manipulating it to produce the desired output. I believe in the power of programming to transform and improve the lives of people around the world. My curiosity levels are as fresh as when I was a child. I believe in eternal learning and deliberate effort as they are the only way to become the smartest in the room. I am a good timekeeper, always willing to learn new skills and use them in real-life problems. An ambitious individual with a desire to succeed. A Cricket fanatic. A student who likes to take risks and does not shy away from experimenting with various combinations in life. Striving to do a lot. Wish me good luck 🙏🏼 My primary interest is in Web Development and Mobile Application Development. Tech Stack:- ReactJS, NextJS, NodeJS, MongoDB, GraphQL, Javascript Version Control:- Git, Gitlab