Generative AI: how does it work and what is it made of?
Kacper Turczyński
AI writes text, creates images and music, and generates code. It learns patterns from examples, then uses those patterns to generate new content. Let’s focus on language models. Their answers can be useful and convincing. They can also be wrong.
What is it made of?
Data provides examples. The architecture determines how information is processed. Training adjusts the model’s parameters: numbers that influence how it works. This is no catalogue of ready-made answers, although a model can memorise fragments of its training data.
Tokens: the building blocks of text
Text is divided into tokens. A token can represent part of a word, a whole word or a punctuation mark. That is why the number of tokens is not the same as the number of words.
Embeddings: meaning represented in numbers
Tokens are given numerical representations that the model processes to capture learned relationships. Subsequent layers take context into account: “bank” in a financial context and “bank” by a river have different meanings.
Transformers: connecting the context
The attention mechanism helps the model weigh relationships between tokens. When generating text, it uses the available context, not future words. “Attention” is the name of a computation, not human concentration or a guarantee of understanding.
How does a model learn?
Many language models are trained to predict the next token. Prediction errors are used to adjust the model parameters. The process is repeated across many examples. Simply talking to a model does not mean its parameters are being updated in real time.
How is an answer generated?
The model calculates probabilities for the next token. The selected token is added to the context, and the process repeats. A likely continuation of text, however, is not the same as a true statement.
Images and sound
Not all generative AI works like a language model. In diffusion models, image generation can be described in simple terms as gradually transforming noise into an image. Audio and video are generated using different architectures, sometimes combining several methods.
Temperature, top-k and top-p
Temperature affects the randomness of token selection. A lower temperature favours more predictable answers, but does not guarantee accuracy or identical results. A higher temperature increases variety, though not necessarily the quality of ideas. Top-k restricts selection to the k most likely tokens. Top-p selects the smallest pool whose combined probability reaches a set threshold. The availability of these settings depends on the tool.
Context: what the model has to work with
The context window holds a limited number of tokens. If that limit is exceeded, the application may shorten or summarise the conversation history, or reject an input that is too long. Even information within the context window may be overlooked in the answer. State important points clearly and close to the task at hand.
Refining the model after training
A model is not neutral after its initial training. Its behaviour is shaped by the data and design choices. Further training using examples, human ratings or other signals helps align responses with instructions and expected rules. It does not automatically remove bias or errors.
RAG: answers supported by sources
The system first retrieves relevant materials and then passes them to the model as context. This can help it use current or company-specific information. The source and answer still need checking: a search may retrieve the wrong document, and the model may misinterpret it.
Personalisation without training from scratch
Instructions, examples and access to the right materials are often enough. If they are not, the model can be fine-tuned. Methods such as LoRA train a small set of additional parameters while leaving the base model’s parameters unchanged. Cost and effectiveness depend on the task and the quality of the data.
A practical example
A customer brief, previous proposals and style guidelines can be used to prepare a new proposal. The model creates a draft. A person checks the scope, prices, dates and commitments before it is sent to the customer.
Where do hallucinations come from?
A model can generate a plausible but untrue answer, even with access to sources. A clear task and good materials help, but do not eliminate errors. Figures, quotations and important claims need to be verified separately.
What to remember
A token is not necessarily a word. Context limits are usually measured in tokens.
A low temperature may produce a more repeatable error. It is no substitute for fact-checking.
A larger model will not always perform a specific task better. Data, training and tools also matter.
For exact calculations, use a calculator or code and check the assumptions.
A document or website may contain an attempt to change the instructions given to the model. This is called prompt injection. Limit access to data and permissions to act.
How to use it wisely
Specify the goal, necessary context, sources and expected format. Ask for missing information and assumptions to be identified. Instead of “analyse this company”, write: “Compare these two proposals by cost and scope. Identify gaps. Do not invent information.” Share only the data needed for the task.
A final thought
Generative AI can shorten the journey from source materials to a draft, a comparison or an idea. Quality depends on the model, the task, the data and how you work. Good instructions help. They cannot replace responsible verification.
Sources and further reading
Source materials on the mechanisms and limitations discussed above: Transformers · Data and bias · Temperature and top-p · Training with human feedback · RAG · Context · Diffusion · LoRA · Prompt injection
🌐 KT DEVELOPMENT
📲 instagram.com/cos.z.nicego
Content update: 24 November 2026.

