Let's talk

The Engine of AI

Machine Learning in the Age of LLMs

At its core, modern AI is driven by machine learning techniques that allow models to predict the next piece of text in a sequence.

By Divyaprakash JhaUpdated 6 min readTopic: Large language models

Photo for Machine Learning in the Age of LLMs

How Machine Learning Powers LLMs

Machine learning is the process of training models to recognize patterns in data so they can make predictions. In Large Language Models (LLMs), this means predicting the most likely next piece of text in a sequence.

At its core, an LLM is a neural network trained on massive text datasets. Instead of being programmed with rigid rules of grammar, the model learns through experience. It adjusts billions of internal numbers, called parameters, to minimize errors in its predictions.

Through this training, the model develops the ability to perform complex tasks like coding, translating languages, or reasoning through a logic puzzle. It does this by generating the most likely next "token" based on everything it has seen before.

  • Neural Networks: The mathematical structure that mimics how information flows through a model.
  • Parameters: The adjustable numbers the model learns to improve its accuracy.
  • Next-Token Prediction: The fundamental skill that allows a model to "write" by guessing what comes next.

The Transformer Architecture

Most modern LLMs are built using the transformer architecture. This specific type of neural network relies on a breakthrough mechanism called attention.

Attention allows a model to look at every other word in a sentence to understand context. Without attention, a model might struggle with words that have multiple meanings. For example, in the sentence, "The clinic called the patient because she was late," attention is what allows the model to work out that "she" most likely refers to the patient.

Each layer in the transformer refines how the model understands these relationships. As these layers stack, the model builds a sophisticated grasp of grammar, facts, and even subtle styles of writing.

From Pretraining to Instruction Tuning

Building a useful AI model happens in distinct stages, moving from general knowledge to specific behavior.

1. Pretraining

In the pretraining phase, the model is shown trillions of tokens of text and code. The goal is simple: predict the next token. Each time the model makes a wrong guess, it nudges its parameters to do better next time. The result is a "base model" that is incredibly knowledgeable but isn't very good at following directions; it might just try to complete a sentence rather than answering a question.

2. Instruction Tuning

To make the model useful for humans, we use instruction tuning. The model is trained on examples of specific instructions and the ideal responses. This teaches the model the format of being an assistant—knowing when to stop talking and how to follow a requested format.

3. Preference Tuning (RLHF)

Finally, models undergo preference tuning, such as Reinforcement Learning from Human Feedback (RLHF). Humans rank different answers from the model, and the model is optimized to favor the types of responses humans prefer. This stage is critical for shaping the model's tone and ensuring it remains safe and helpful.

Tokens and Semantic Embeddings

It is a common misconception that models read words like humans do. Instead, they use a tokenizer to split text into smaller units called tokens. A common word might be a single token, while a rare word or a complex technical term might be split into several pieces.

Once text is tokenized, each token is mapped to an embedding. An embedding is a list of numbers, also known as a vector, that represents the meaning of that token. In this mathematical space, tokens with related meanings end up with similar vectors.

This concept is the foundation of semantic search. When you ask a question, the system converts your query into an embedding and then finds documents whose embeddings are mathematically closest to yours.

Concept What it is Why it matters
Token The unit of text (word or part of a word) Determines pricing, speed, and context limits.
Embedding A list of numbers (vector) Allows the model to understand meaning and similarity.

Note for builders: Languages that were under-represented in a tokenizer's training data—such as many Indian languages written in their own scripts—often require more tokens to represent the same sentence. This makes them slower and more expensive to process on some models.

The Rise of Reasoning Models

A new family of models has emerged that focuses on "thinking" before they speak. Unlike standard models that generate text instantly, reasoning models use reinforcement learning to create an internal chain of reasoning.

These models use more test-time compute. This means they spend more computational power at the moment you ask the question to work through complex, multi-step problems. This makes them highly effective for difficult tasks like advanced mathematics or complex coding.

However, this comes with a trade-off. Because they spend more time "thinking," they have higher latency. They are best suited for hard problems rather than simple tasks like rewriting a polite email.

Making Models Useful for Business

For a business owner, a general model is a starting point, but you likely need it to do something specific for your operations. There are three primary ways to bridge that gap.

Method What it changes Best use case
Prompting The instructions you send Changing format or tone (e.g., "Reply in polite Hindi").
RAG The documents you add to the context Answering questions using your current, specific data.
Fine-tuning The model's actual weights Giving a model a consistent style or specialized skills.

For most businesses, Retrieval-Augmented Generation (RAG) is the right answer to the question: "How do I make it know our data?" It allows the model to look up your specific documents (like a price list or a manual) and answer based on them, without the high cost of retraining the model.

Open-Weight vs. Closed Models

When choosing how to deploy your AI, you must decide between closed and open-weight models. This is a critical decision for data privacy and cost management.

Closed models are accessed via an API provided by a company. They are the easiest to start with and usually the most capable, but you must send your data to the provider, and you are subject to their pricing changes. This is a common choice for rapid prototyping in AI applications.

Open-weight models allow you to host the model on your own servers. This is often the better fit for businesses with strict data residency requirements or those who need to operate offline. Because you own the deployment, you have more control over your costs at high volumes.

To make these models run more efficiently, developers often use quantization. This process reduces the precision of the model's numbers (for example, from 16-bit to 4-bit). This significantly reduces the memory needed, allowing large models to run on much cheaper or smaller hardware without a massive loss in quality.

Frequently Asked Questions

Do LLMs look up facts like a database?
No, they generate likely text one token at a time. This is why they can hallucinate—they are producing plausible-sounding text rather than retrieving stored facts.
What is a token in machine learning?
A token is the unit of text a model reads and writes. It can be a common word or a piece of a rare word.
Why do some languages cost more to process?
If a language was under-represented in a tokenizer's training data, it may require more tokens to represent the same sentence, making it slower and costlier.
What is the difference between RAG and fine-tuning?
RAG provides the model with new documents to read at question time, whereas fine-tuning actually updates the model's internal weights.
What are hallucinations?
A hallucination is a fluent but false answer. It happens because the model is trained to produce plausible text, not necessarily factual truth.
Close-up of a computer screen displaying lines of CSS code with color swatches.
Photo: Free computer code screen image by unknown, CC0

Questions people ask

Do LLMs look up facts like a database?

No, they generate likely text one token at a time. This is why they can hallucinate—they are producing plausible-sounding text rather than retrieving stored facts.

What is a token in machine learning?

A token is the unit of text a model reads and writes. It can be a common word or a piece of a rare word.

Why do some languages cost more to process?

If a language was under-represented in a tokenizer's training data, it may require more tokens to represent the same sentence, making it slower and costlier.

What is the difference between RAG and fine-tuning?

RAG provides the model with new documents to read at question time, whereas fine-tuning actually updates the model's internal weights.

What are hallucinations?

A hallucination is a fluent but false answer. It happens because the model is trained to produce plausible text, not necessarily factual truth.