Deep learning is a subset of machine learning based on artificial neural networks that learn to recognize patterns in data. In the context of modern AI, it is the mathematical engine used to train Large Language Models (LLMs) to understand and generate human-like text.
What is Deep Learning?
At its core, deep learning is the process of training neural networks to recognize complex patterns in data. While traditional programming requires explicit rules, deep learning allows a system to "learn" by processing massive amounts of information and adjusting its internal settings to reduce errors.
In the context of LLMs, deep learning involves training a transformer architecture on enormous amounts of text. The goal is to learn adjustable numbers called parameters. These parameters are the internal "knobs" that the model turns during training to improve its ability to predict the next piece of text in a sequence.
Think of it like a student practicing math problems. Initially, the student makes many mistakes. But by checking the answers and adjusting their logic, they eventually learn the underlying patterns. A deep learning model does this with billions of parameters, allowing it to grasp grammar, facts, and even reasoning styles.
The Transformer and Attention
Most modern LLMs are built using a specific type of neural network called the transformer architecture. The breakthrough that made current AI possible is a mechanism known as attention.
Before transformers, models often "forgot" the beginning of a long sentence by the time they reached the end. Attention solves this by allowing a model to look at every single word in a sentence simultaneously to decide which ones are most relevant to the current word being processed.
For example, consider the sentence: "The clinic called the patient because she was late."
Through the attention mechanism, the model can mathematically link the word "she" back to "the patient." It understands that "she" refers to the person being called, not the clinic. This ability to understand context and long-range relationships is what makes AI feel conversational rather than robotic.
How Attention Works Under the Hood
For every token (word or piece of a word) the model processes, a layer computes three specific vectors:
- Query: What am I looking for?
- Key: What information do I offer to others?
- Value: What information do I actually carry?
The model compares the "Query" of one word against the "Keys" of all previous words. The resulting scores act as weights, telling the model how much of each "Value" to include in its current understanding. This allows the model to build a rich, multi-dimensional representation of meaning.
The Training Process
Building a powerful LLM happens in stages, moving from general knowledge to specific utility. You can think of this as the difference between a student finishing school and a professional undergoing specialized job training.
1. Pretraining: The Foundation
In the pretraining phase, the model is shown trillions of tokens of text and code. The only task is next-token prediction: given a sequence of words, what comes next? Each time the model makes a wrong guess, it nudges its billions of parameters slightly to correct itself. The result is a base model. This model is incredibly knowledgeable but lacks "manners"—it might continue a question with more questions rather than answering them.
2. Instruction Tuning: Learning to Help
To turn a base model into a useful assistant, developers use instruction tuning. The model is trained on curated examples of instructions and high-quality responses. This teaches the model the format of a conversation: "If a user asks a question, provide a direct answer."
3. Preference Tuning: Shaping Behavior
The final layer of polish often involves Reinforcement Learning from Human Feedback (RLHF). Human testers rank different model responses from best to worst. A "reward model" learns these human preferences, and the LLM is optimized to favor the types of answers humans find most helpful, safe, and polite.
| Training Stage | Goal | Outcome |
|---|---|---|
| Pretraining | Predict the next word | A knowledgeable "Base Model" |
| Instruction Tuning | Follow directions | A helpful "Assistant Model" |
| Preference Tuning | Align with human values | A safe and conversational AI |
How Models Read: Tokens and Embeddings
Computers cannot understand letters or words directly; they only understand numbers. To bridge this gap, models use a two-step process of tokenization and embedding.
Tokens: The Building Blocks
A tokenizer splits text into tokens. A token isn't always a whole word; it might be a single character, a syllable, or a common chunk of a word. For example, a common word like "apple" might be one token, while a rare word or a complex name might be split into three or four tokens.
This has real-world business implications. Languages that are under-represented in training data—such as many Indian languages written in their own scripts—often require more tokens to represent the same sentence. This means processing text in these languages can be slower and more expensive on some models.
Embeddings: The Geometry of Meaning
Once a word is turned into a token, it is converted into an embedding. An embedding is a long list of numbers (a vector) that represents the meaning of that token in a high-dimensional mathematical space.
In this "space," words with similar meanings are placed close together. The concept of "king" will be mathematically near "queen," and "doctor" will be near "hospital." This mathematical representation of meaning is what enables advanced AI features like semantic search and RAG (Retrieval-Augmented Generation).
Reasoning and Test-Time Compute
Standard LLMs are designed for speed and fluency, making them excellent at tasks like drafting emails or summarizing text. However, for complex logic, math, or programming, a different approach is emerging: reasoning models.
Newer models are trained using reinforcement learning to "think" before they speak. Instead of immediately predicting the next word, they generate an internal "chain of thought." They try different approaches, catch their own mistakes, and verify their logic before providing a final answer.
This introduces a concept called test-time compute. While traditional models use a fixed amount of "brainpower" to generate any response, reasoning models spend more computational effort (and thus more time/cost) on harder problems. For a business, this means you should use these high-reasoning models for complex multi-step problems, but stick to faster, cheaper models for simple text rewriting.
From Models to Agents
A standalone LLM is essentially a very smart text generator. It can talk about your business, but it cannot actually *do* anything. To move from a model to an AI agent, the model must be given access to tools through a process called function calling.
By describing specific functions to the model—such as check_inventory(item_id) or send_invoice(customer_id)—the model can recognize when a user's request requires an action. Instead of just talking about an invoice, the model can output a structured request to your software to actually create one.
When a model can follow a loop of Plan → Call Tool → Read Result → Decide Next Step, it becomes an agent. This allows for automated workflows, such as a system that can reconcile payments, follow up on unpaid invoices via WhatsApp, and only alert a human if a discrepancy is found.
Frequently Asked Questions
- What is the difference between a parameter and a token?
- A parameter is an adjustable number learned during training that determines how the model processes information. A token is a unit of text, such as a word or part of a word, that the model reads and writes.
- Why do LLMs hallucinate?
- Hallucinations happen because models are trained to produce the most plausible next text rather than to verify facts. If training data is thin on a topic, the model generates its best-sounding guess.
- What is the purpose of the context window?
- The context window is the maximum number of tokens a model can consider at once, including your instructions, documents, and previous conversation history.
- What is RAG and why is it used?
- Retrieval-Augmented Generation (RAG) involves adding your own documents to the context at question time. It is the best way to give a model access to your specific, changing data.
- What is the benefit of quantization?
- Quantization stores model weights in fewer bits (like 4-bit or 8-bit), which reduces memory requirements and allows models to run faster on cheaper or mobile hardware.

Questions people ask
What is the difference between a parameter and a token?
A parameter is an adjustable number learned during training that determines how the model processes information. A token is a unit of text, such as a word or part of a word, that the model reads and writes.
Why do LLMs hallucinate?
Hallucinations happen because models are trained to produce the most plausible next text rather than to verify facts. If training data is thin on a topic, the model generates its best-sounding guess.
What is the purpose of the context window?
The context window is the maximum number of tokens a model can consider at once, including your instructions, documents, and previous conversation history.
What is RAG and why is it used?
Retrieval-Augmented Generation (RAG) involves adding your own documents to the context at question time. It is the best way to give a model access to your specific, changing data.
What is the benefit of quantization?
Quantization stores model weights in fewer bits (like 4-bit or 8-bit), which reduces memory requirements and allows models to run faster on cheaper or mobile hardware.
