AI Model
Engineering AI Models
What is a Language Model?
Section titled “What is a Language Model?”A language model is an AI program trained on vast amounts of text to understand human language and predict the most likely next word in a sequence.
Real World Example
Think of it like supercharged autocomplete on your phone.
Input: “The cat sat on the…”
Language Model Prediction: It calculates probabilities based on patterns it learned from reading books and articles:
- Mat (85% probability)
- Rug (10% probability)
- Banana (0.01% probability)
By repeating this prediction process word by word (or token by token), the model generates full sentences, answers questions, translates languages, or writes code.
What is a token?
Section titled “What is a token?”A token is the basic unit of text that a language model reads and processes. It is not always a full word. It can be a single character, a word segment, or a whole word.
Think of tokens like Lego blocks for words.
If you input the sentence: “Unbelievable!”
A language model doesn’t process it as one big word. Instead, it breaks it into smaller chunks (tokens):
- Un (prefix)
- believ (root)
- able (suffix)
- ! (punctuation)
On average, for English text:
- 1 token ~ 4 characters or 0.75 words
- 100 tokens ~ 75 words
Different Kinds of AI Models
Section titled “Different Kinds of AI Models”AI models can be categorized in several ways. One useful classification is by the type of problem they solve.
Classification models
Section titled “Classification models”Classification models assign an input to one or more categories.
Examples:
Email -> Spam / Not SpamTransaction -> Fraud / LegitimateTicket -> Billing / Technical / AccountRegression models
Section titled “Regression models”Regression models predict continuous numerical values.
Examples:
House features -> Estimated priceHistorical traffic -> Expected trafficCustomer activity -> Expected revenueEmbedding models
Section titled “Embedding models”Embedding models convert data into numerical vectors that capture semantic relationships.
For example:
"How do I reset my password?" -> Embedding vectorSimilar concepts tend to produce vectors that are close together in vector space.
Embeddings are fundamental to systems such as:
- Semantic search
- Recommendation systems
- Document retrieval
- Retrieval-Augmented Generation (RAG)
- Duplicate detection
Generative models
Section titled “Generative models”Generative models create new content based on learned patterns.
They can generate:
- Text
- Code
- Images
- Audio
- Video
Large language models are one important category of generative models.
3.5 Multimodal models
Section titled “3.5 Multimodal models”Multimodal models can process more than one type of input or output.
For example:
Text + Image -> Reasoning -> TextA multimodal system may accept a screenshot and a question about that screenshot, rather than requiring the image to be converted into text first.
How LLMs Work
Section titled “How LLMs Work”A Large Language Model (LLM) is a language model trained on very large datasets using neural-network architectures, most commonly transformer-based architectures.
At a high level:
Tokenization
Section titled “Tokenization”The input text is converted into tokens.
"Design a scalable API" -> [tokens...]The model operates on these numerical representations rather than raw strings.
Embeddings
Section titled “Embeddings”Tokens are transformed into numerical representations called embeddings.
These representations allow the neural network to work with semantic and contextual information.
Transformer architecture
Section titled “Transformer architecture”Modern LLMs are primarily based on the Transformer architecture.
One of the most important components is self-attention.
Self-attention allows the model to determine which parts of the input are relevant to each other.
For example:
The service returned an error because it exceeded the timeout. <- relevant contextThe model can learn relationships between service, error, exceeded, and timeout rather than treating every word independently.
Training
Section titled “Training”During pretraining, the model is exposed to a large corpus of data and learns to predict tokens.
A simplified example:
Input:The API request returned a
Target:timeoutThe model produces a probability distribution over possible next tokens.
Training adjusts the model’s parameters to reduce prediction error over many examples.
This process requires substantial compute, data, and optimization infrastructure.
Inference
Section titled “Inference”After training, the model can be used to generate responses.
Generation happens token by token.
This is why concepts such as context window, latency, throughput, temperature, and token cost matter when designing LLM-powered applications.
What an LLM Does and Doesn’t Do
Section titled “What an LLM Does and Doesn’t Do”An LLM is fundamentally a model for generating outputs from input context.
It does not automatically have:
- Current information about your private systems
- Access to your database
- Access to your APIs
- Permission to execute arbitrary operations
- Reliable knowledge of events that occurred after its training data
- A guaranteed source of truth
This distinction is critical in production AI systems.
Instead of expecting the model to contain everything, production systems often provide the model with context, tools, retrieval systems, and controlled execution environments.
That leads to agentic AI.