Whitepaper

Introduction to Large Language Models

December 15, 2025
Introduction to Large Language Models

In 2017, Google Published a paper titled “Attention Is All You Need” introduced the Transformer architecture, a novel approach to deep learning that would eventually power systems like ChatGPT, Claude, and Gemini.

An LLM(Large Language Model) is not a conscious entity; it is a sophisticated, probabilistic engine designed for next-token prediction. To completely understand its capability, we must look beyond the outputs and analyse the underlying mechanics, data structures, and training methodologies.

1.The Core Concept: The Language of Mathematics

 An LLM operated entirely in the domain of numerical computation. Language must first be translated into a mathematical representation before processing can begin. The translation happens through two key concepts, Tokenization and Embeddings.

Tokenization

LLMs do not process words or characters directly; they operate on tokens. A token is a variable-length chunk of text, often a word, a common sub-word, or punctuation. For example,

  • Input: "The quick brown fox"
  • Tokens: ["The", " quick", " brown", " fox"]

 Tokenization is crucial for efficiency and managing the vocabulary size.

Embeddings

Once text is tokenized, it is converted into a vector—a long list of numbers (e.g., [0.12, -0.98, 0.55, ...]). This is the embedding. These vectors capture the semantic meaning of the token.

Imagine a 3D graph where every word has a coordinate. Words with similar meanings are placed physically closer together.  In modern LLMs, these aren't just 3D coordinates; they are thousands of dimensions (dmodel = 4096 or more), capturing nuanced relationships like syntax, tone, and context.

2. The Engine: The Transformer Architecture

The Transformer’s architecture is built upon stacked encoder and decoder layers, with the Attention Mechanism serving as the key innovation that enables parallel processing of sequence data.

Attention Mechanism

Attention allows the model to selectively weigh the importance of every other token in the input sequence when processing the current token. This mechanism provides essential contextual understanding, solving the problem of long range dependencies in text. 

Consider this below sentence;

"The animal didn't cross the street because it was too tired."

To a human, "it" clearly refers to the animal. To a standard computer program, "it" is ambiguous. Self-attention allows the model to assign a "relevance score" between every token and every other token in the sequence.

When the model processes the word "it," the attention mechanism highlights "animal" with a high weight (e.g., 0.8) and "street" with a low weight (e.g., 0.1).

Inside the Black Box 

Technically, this is done using three vectors for every token: Query (Q), Key (K), and Value (V).

  • Query: What information is this token looking for?
  • Key: What information does this token contain?
  • Value: What is the actual content to pass along?

The Query vector of the current token is compared against the Key vectors of all other tokens, and the resulting weights are applied to the Value vectors to form a new, context-aware representation for the token.

3. The Lifecycle: How an LLM Learns

An LLM goes through a rigorous three-stage pipeline.

Stage 1: Pre-training

The model is fed massive datasets (Common Crawl, GitHub, Wikipedia) and given a simple objective, i.e., predict the next token.

  • Input: "The capital of France is _____"
  • Target: "Paris"

This is unsupervised learning. The model effectively compresses the internet's knowledge into its parameters (weights). At the end of this stage, the model is smart but unruly—it can complete sentences but won't necessarily follow instructions.

Stage 2: Supervised Fine-Tuning (SFT)

To make the model helpful, developers feed it curated datasets of (Instruction, Response) pairs.

  • Instruction: "Summarize this article."
  • Response: [A high-quality summary written by a human].

This teaches the model the format of a helpful assistant.

Stage 3: RLHF (Polishing)

Reinforcement Learning from Human Feedback (RLHF) aligns the model with human values.

  1. The model generates three possible answers.
  2. A human ranker picks the best one (ranking helpfulness/safety).
  3. A "Reward Model" learns these preferences and mathematically penalizes the LLM for toxic or nonsensical outputs during further training.

Limitations: The "Hallucination" Problem

Despite their power, LLMs have critical flaws rooted in their architecture.

  • Hallucinations: The model is not a database; it is a probabilistic engine. If it doesn't "know" a fact, it will predict the next statistically likely word, resulting in confident but false statements.
  • Context Window: Models have a limited memory (e.g., 128k tokens). Once a conversation exceeds this, the model "forgets" the beginning of the chat.
  • Stochasticity: Unless you set the "Temperature" parameter to 0, the model can give different answers to the exact same question.

Conclusion

We are witnessing a shift comparable to the invention of the internet. By converting language into vector math and training on the scale of the entire web, we have created systems that can mimic reasoning. However, treating them as magic boxes is dangerous. Understanding the mechanical reality i.e., tokens, attention, and probability are the first step to building reliable software on top of them.