Skip to main content

How LLMs Understands Your Questions: A Beginner-Friendly Guide to LLMs, Tokens, and Transformers

Updated 9 min readMarkdown
How LLMs Understands Your Questions: A Beginner-Friendly Guide to LLMs, Tokens, and Transformers

Have you ever wondered how ChatGPT, Gemini , Claude etc LLMs can answer your questions in seconds, write code, explain difficult concepts in simple words, or even help you draft an email ? It almost feels like talking to another person without having any tantrums. But here's the surprising truth: ChatGPT like LLMs doesn't actually understand language the way humans like us do.

Instead, it converts your words into numbers, processes them using advanced mathematical formulas, and predicts the most likely next words to generate a meaningful response.

In this article, you'll learn what happens behind the scenes every time you send a message to Large Language Models. By the end, you'll understand the building blocks of modern AI without needing a computer science degree or Hammering your head against the wall to understand differential calculus like advanced mathematical formulas.

What Is an LLM?

LLM stands for Large Language Model.

It is an artificial intelligence model trained on massive amounts of text from books, websites, research papers, articles, and publicly available information. During training, the model learns language patterns, grammar, reasoning styles, and relationships between words.

Rather than memorizing every sentence, an LLM learns how language works.

See It in Action: Calling an LLM with TypeScript

This shows readers that everything starts with sending a prompt to an LLM.

import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.OPENAI_API_KEY,
});

async function main() {
  const response = await client.responses.create({
    model: "gpt-4.1",
    input: "Explain what an LLM is in one sentence."
  });

  console.log(response.output_text);
}

main();

Example Output

An LLM (Large Language Model) is an AI system trained on massive amounts of text to understand and generate human

What Problems Do LLMs Solve?

Large Language Models help computers perform tasks that previously required human language skills.

Some common examples include:

  • Answering questions

  • Writing articles and emails

  • Summarizing long documents

  • Translating languages

  • Explaining technical topics

  • Generating code

  • Brainstorming ideas

  • Assisting with customer support

Instead of building separate AI systems for every task, one well-trained language model can perform many of them simply by changing the prompt.

Several organizations have developed powerful language models, including:

  • ChatGPT

  • Gemini

  • Claude

  • Llama

  • DeepSeek

  • Mistral

Although they have different architectures and training methods, they all rely on similar core concepts, especially the Transformer architecture.

How We Use LLMs Every Day

You may already be using LLMs without realizing it.

For example:

  • Students ask AI to explain difficult subjects.

  • Developers generate and debug code.

  • Businesses create marketing content.

  • Writers overcome writer's block.

  • Travelers translate conversations instantly.

  • Professionals summarize lengthy reports.

AI assistants have quietly become part of everyday productivity.

What Happens When You Send a Message to LLM?

Let's follow the complete journey of a single prompt.

Imagine you type:

"Explain black holes like I'm 10 years old."

Although it seems simple, several complex steps happen in milliseconds.

Step 1: You Type a Prompt

Everything starts with your prompt.

A prompt is simply the instruction or question you give the AI.

Examples include:

  • "Write a Python function."

  • "Summarize this article."

  • "Explain quantum physics."

  • "Generate interview questions."

The quality of your prompt often influences the quality of the response.

See It in Action: Sending a Prompt

import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.OPENAI_API_KEY,
});

async function ask() {
  const response = await client.responses.create({
    model: "gpt-4.1",
    input: "Why is the sky blue?"
  });

  console.log(response.output_text);
}

ask();

Example Output

The sky appears blue because molecules in Earth's atmosphere scatter shorter wavelengths of sunlight more than lo

Step 2: Your Message Is Processed

LLMs cannot directly understand letters or words.

Before doing anything, your message is converted into smaller pieces called tokens.

We'll discuss tokens in detail later.

These tokens are then converted into numerical representations that the model can process mathematically.

Step 3: The Transformer Analyzes the Context

The Transformer model studies relationships between all the tokens in your message.

Instead of reading from left to right like humans, it looks at the entire context simultaneously.

This helps the model understand:

  • What you're asking

  • Which words are important

  • How different words relate to one another

  • What information is likely expected next

Step 4: LLMs Predicts the Next Token

This is one of the biggest misconceptions about AI.

LLMs does not search Google every time you ask a question.

Instead, it predicts the most probable next token based on everything it has learned during training and the current conversation.

It repeats this prediction process thousands of times until the entire answer is generated.

Think of it like an extremely advanced autocomplete system.

Why Responses Are Not Copied from the Internet

Many people assume LLM copies answers from websites.

That's not how modern LLMs work.

During training, the model learns language patterns instead of storing complete webpages.

When you ask a question, it generates a fresh response based on learned patterns rather than retrieving and pasting existing articles.

This is why two users asking similar questions may receive different wording while still getting accurate information.

Why Computers Don't Understand Human Language

Humans naturally understand words.

Computers don't.

For a computer, everything ultimately becomes numbers.

Consider the sentence:

"I love programming."

To you, it has meaning.

To a computer, it first needs to become numerical data before any calculations can happen.

That's why AI systems convert text into numbers.

Without this conversion, computers cannot perform mathematical operations required for machine learning.

Text vs Numbers

Imagine trying to solve a math equation using only letters.

It wouldn't work.

Similarly, computers perform calculations using numerical vectors rather than raw text.

Every word, punctuation mark, and even spaces may eventually become numerical representations inside the model.

Introducing Tokens

Before words become numbers, they are broken into tokens.

Tokens are the basic building blocks processed by language models.

Interestingly, tokens are not always complete words.

A token could be:

  • A complete word

  • Part of a word

  • A punctuation mark

  • A number

  • A symbol

What Is Tokenization?

Tokenization is the process of breaking text into tokens before the AI begins processing it.

Without tokenization, language models couldn't efficiently analyze text.

Example 1

Sentence:

I love AI.

Possible tokens:

  • I

  • love

  • AI

  • .

Example 2

Word:

unbelievable

Possible token split:

  • un

  • believable

import OpenAI from "openai";

const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY, });

async function ask() { const response = await client.responses.create({ model: "gpt-4.1", input: "Why is the sky blue?" });

console.log(response.output_text); }

ask();

Example Output

Words

[
  "unbelievable"
]

Tokens

[
  359,
  13472
]

Why Not Just Use Words?

Using words alone creates several problems.

Languages contain:

  • Millions of unique words

  • Misspellings

  • Slang

  • Emojis

  • New vocabulary every day

Tokenization helps AI efficiently handle all these variations while keeping vocabulary manageable.

What Are Transformers?

Transformers are the technology that revolutionized modern artificial intelligence.

Introduced in 2017 through the research paper "Attention Is All You Need," Transformers dramatically improved how machines process language.

Almost every major language model today is built using this architecture.

Why Did Transformers Change AI?

Earlier language models struggled with long sentences.

They often forgot information from the beginning of a paragraph.

Transformers solved this problem using a mechanism called self-attention.

Instead of processing words one at a time, they analyze relationships across the entire sentence simultaneously.

This allows the model to understand context much more effectively.

How Transformers Understand Language

Suppose you ask:

"Rajarshi gave Rahul his laptop because he had finished coding."

Who finished coding?

Humans use context to infer the answer.

Transformers use self-attention to identify relationships between words and determine which earlier tokens are most relevant.

This ability significantly improves reasoning, summarization, translation, and conversation quality.

Why Almost Every Modern LLM Uses Transformers

Transformers offer several advantages:

  • Better understanding of long documents

  • Faster training using parallel processing

  • Strong contextual understanding

  • Excellent scalability

  • Superior text generation

This is why ChatGPT, Gemini, Claude, Llama, and most modern LLMs are based on Transformer architectures.

Real-World Example

Imagine you're asking a LLM

"Plan a three-day trip to Goa under ₹15,000."

Behind the scenes:

  1. Your prompt is tokenized.

  2. Tokens become numbers.

  3. The Transformer analyzes relationships.

  4. The model predicts one token at a time.

  5. A complete travel itinerary is generated.

All of this happens in just a few seconds.

Every Great Conversation with AI Starts with Mathematics

The next time you ask a LLM to write code, explain a scientific concept, summarize a document, or plan a vacation, remember that an incredible sequence of computations is happening behind the scenes.

Your words aren't understood the way humans understand language. Instead, they're transformed into tokens, converted into numerical vectors, processed through billions of parameters inside Transformer layers, and used to predict the most likely next token - one token at a time. This entire process, from the moment you press Enter to the moment a polished response appears on your screen, typically takes only a few seconds.

What feels like a natural conversation is actually the result of decades of research in machine learning, natural language processing, probability, linear algebra, and computer science. Modern Large Language Models combine these disciplines to create systems capable of generating human-like text, solving complex problems, writing software, translating languages, and assisting millions of people every day.

As AI continues to evolve, understanding these core concepts becomes increasingly valuable - not just for researchers, but for developers, students, creators, and anyone who wants to use AI more effectively. Knowing how LLMs process information helps you write better prompts, interpret responses more critically, and appreciate both the remarkable capabilities and the current limitations of these models.

The journey doesn't stop here. Concepts like embeddings, self-attention, context windows, Retrieval-Augmented Generation (RAG), fine-tuning, AI agents, and multimodal models build upon the same foundations you've learned in this guide. Once you understand tokens and Transformers, you're already well on your way to understanding the technology powering today's AI revolution.

The next time GPTs answers one of your questions, you'll know that behind that seemingly simple response lies one of the most sophisticated engineering achievements ever built—a system that transforms language into mathematics and mathematics back into language, all in the blink of an eye.

And perhaps the most exciting part is this: we're only at the beginning of what Large Language Models can achieve.

About the author

  • Hello :) I’m Rajarshi Chakraborty, a proactive, result-oriented STEM undergraduate majoring in Computer Science & Engineering at Techno Main Salt Lake, belonging to the class of 2027. As an aspiring Software Development Engineer (SDE/SWE/SRE), I am passionate about driving technological innovation, streamlining processes, and delivering high-impact solutions. I excel in problem-solving, critical thinking, and strategic decision-making, with a focus on agile methodologies and cross-functional collaboration. With a strong foundation in data structures, algorithms, and full-stack development, I am committed to continuous learning, performance optimization, and scalable architecture design. My technical expertise includes end-to-end development, code optimization, and software lifecycle management, ensuring robust, secure, and efficient applications. My interests lie in Gen-Agentic AI and Machine Learning , where I aim to apply predictive analytics, automation, and data-driven decision-making to enhance business intelligence and improve operational efficiency. I am actively seeking challenging roles in dynamic, growth-oriented environments where I can contribute to mission-critical projects, engage in transformational initiatives, and work alongside industry leaders. My goal is to drive measurable business outcomes, foster innovation, and advance my technical and leadership capabilities.

No comments yet. Be the first to comment.