Large Language Models (LLMs) are machine learning models trained to understand and generate text. Most modern generative LLMs are trained to predict the next token based on the tokens that came before it.
Given the input:
Today the weather is
The model predicts possible next tokens and assigns probabilities to them. A decoding strategy selects the next token, which is then added to the input. This process repeats until the model finishes generating its response.
LLMs contain millions or billions of learned parameters that capture patterns in their training data.
Decoding determines how a model selects the next token.
Several parameters can influence sampling:
These techniques offer different trade-offs between predictability, diversity, and generation quality.
LLMs process numerical representations rather than raw text. A tokenizer converts text into tokens and maps them to numerical token IDs.
A token can represent a complete word, part of a word, punctuation, or another text unit.
Common tokenization approaches include:
Subword tokenization, including Byte Pair Encoding (BPE), is widely used because it balances vocabulary size and flexibility.
The context window defines how many tokens a model can process in a single context. It includes input content and, depending on the model and API, may also account for generated output.
There are two important categories of language models:
For example, a base model may continue a text sequence, while an instruction-tuned model is better suited to answering questions or following a task description.
Chat models also commonly use structured message formats with roles such as system, user, and assistant. Correct formatting helps the model interpret the conversation as intended.
When using a text generation API, several parameters control how the model behaves:
| Parameter | Purpose |
|---|---|
model | Specifies the model to use. |
messages | Provides conversation messages and their roles. |
max_tokens or an equivalent output limit | Limits generated output length, depending on the API. |
temperature | Controls sampling randomness. |
top_p | Controls nucleus sampling. |
n | Requests multiple output choices when supported. |
stream | Returns output incrementally instead of waiting for the complete response. |
Available parameters and their exact meanings depend on the provider and model.
A Local LLM runs on your own computer or infrastructure instead of relying entirely on a remotely hosted model.
Advantages
Disadvantages
Tools such as LM Studio make it easier to download and run compatible models locally. It can also expose a local API that supports integration with applications using compatible OpenAI-style API formats.
These are three different activities:
For most developers, starting with inference is the most practical approach. Fine-tuning can come later when a specific use case requires it.
Understanding LLMs starts with tokenization, next-token prediction, decoding strategies, and context windows. From there, developers can explore model inference, API integration, local deployment, fine-tuning, and retrieval-augmented generation (RAG).
You do not need to train a large model from scratch to build useful AI applications. Learning how to select, run, and integrate existing models is an excellent starting point.