Clear, connected notes on how language models learn, find information, and respond to your prompts.
01
Start here
Basic Terms
AI is the broad field; Machine Learning is a subset of AI; LLMs are a type of machine-learning model designed to understand and generate language.
LLM
LLM = Large Language Model. It has learned patterns and relationships from huge amounts of training data.
Tokens
Tokens are the pieces of text an LLM processes. A token can be a whole word, part of a word, punctuation, etc.
Generating a response
At its core, an LLM generates responses by predicting the next token, then the next, repeatedly.
Training
Training is the process where the model learns from large datasets and its internal parameters are adjusted. The result is a trained model.
Inference
Inference happens when we give that trained model a new prompt and it generates a response.
Documents are context
Giving an LLM a document does not normally mean you're training it. You're giving the trained model additional context to use during inference.
Not a database
LLMs are not simply databases looking up stored answers. Their learned knowledge is encoded within their parameters.
Hallucination
Because they're generating likely responses rather than inherently retrieving verified facts, LLMs can hallucinate — produce convincing but incorrect information.
Therefore, one of the most important rules when working with LLMs is:
02
The essential distinction
Training & Inference
Training creates the model. Inference is what happens when you use the trained model.
Training
Learning patterns
Lots of data → learning → parameters → trained LLM
A prompt supplies the task and instructions. Context supplies the information the model can consider. The trained model uses both during inference to generate its response.
What inference does not do
Giving the model instructions, documents, examples, Jira tickets, or release information does not necessarily train it. These inputs supply context during inference.
How RAG connects
RAG retrieves relevant information and adds it to the context provided to the trained model during inference. It does not retrain the model.
03
Inside the model
How an LLM Learns
Neural networks
An LLM is built using a neural network—a large mathematical system containing layers that process information.
Input
Neural network
Output
Parameters
Definition
A parameter is an adjustable numerical value inside the model.
During training
During training, the model adjusts these parameters to improve its predictions.
Scale
LLMs can contain billions of parameters.
Where knowledge lives
Knowledge isn't simply stored like rows in a database; patterns and relationships are represented across these parameters.
How training works
The model learns by making predictions and measuring how wrong they are. This repeats across enormous amounts of training data.
Training data
Prediction
Measure error
Adjust parameters
Better predictions
Loss
A numerical measure of how wrong the model's prediction is. The goal of training is essentially to reduce loss by adjusting the model's parameters.
Backpropagation
Backpropagation calculates how changes to each parameter would affect the model's error. An optimiser then uses this information to update the parameters. You do not need to understand the mathematics yet.
Attention
Attention helps the model determine which pieces of information are related and relevant to each other in the context.
bankrelated towithdrawrelated tomoney
In “Paul went to the bank to withdraw money,” these relationships establish that bank means a financial institution. Attention is not simply keyword matching.
Transformer
A Transformer is the neural-network architecture underlying modern LLMs such as GPT. One of its key mechanisms is attention.
G Generativegenerates contentP Pre-trainedtrained before you use itT Transformerthe underlying architecture
The mental model to remember
Training data
Model makes predictions
Loss measures the errors
Backpropagation calculates gradients
Optimiser updates parameters
Model learns better patterns
Trained LLM
Then, when you give it a prompt:
Prompt + context
Transformer / attention
Token predictions
Response
04
Finding useful context
Embeddings, Vector Search & RAG
Embeddings
Definition
An embedding is a numerical representation of meaning.
Vector
Text is converted into a list of numbers called a vector.
Similarity
Text with similar meanings produces vectors that are mathematically closer together.
Why it matters
This allows AI systems to compare meaning, not just words.
Semantic / vector search
Traditional search relies heavily on matching keywords. Vector search finds information with similar meaning, even when different words are used.
Example
Search: “Software crashed during release”
Document: “Application failed after deployment”
Different words, similar meaning → vector search can recognise the similarity
Vector database
A vector database stores and searches embeddings so a system can efficiently retrieve information that is semantically similar to a user's question.
Documents
Embedding model
Vectors
Vector database
RAG — Retrieval-Augmented Generation
RAG allows an LLM to use external information when answering a question without needing to retrain the model on that information.
The basic RAG architecture
User question
Embedding model
Vector search
Retrieve relevant information
Question + retrieved information become context
LLM generates answer
Embedding model
Helps find relevant information.
Embedding → Find
LLM
Uses the retrieved information as context to understand the question and generate the answer.
LLM → Generate
Why RAG instead of training?
When company information changes regularly, retraining makes it difficult to stay current. With RAG, documents and the retrieval index can be updated while the existing LLM continues to be used. Answers can be grounded in company information and potentially reference their sources.
Embeddingrepresent meaningVector searchfind similar meaningRAGretrieve relevant contextLLMgenerate the answer
This is the core architecture behind a huge number of real-world enterprise AI applications.
05
Getting better results
Prompting & Context
A prompt is the input and instructions given to an LLM during inference.
Task+Context+Constraints+Output format+Examples
Task
What do I want the LLM to do?
Context
What information does it need?
Constraints
What rules or boundaries should it follow?
Output format
How should the answer be presented?
Examples
What does a good answer look like?
Main prompting types
01
Zero-shot
You give the LLM a task without examples. “Classify this Jira ticket as a Bug, Feature or Technical Task.” The LLM relies on its existing capabilities plus your instructions and context. Zero-shot = no examples.
02
One-shot
You provide one example first. “Example: Login button doesn't work → Bug. Now classify: Password reset page returns an error.”One-shot = one example.
03
Few-shot
You provide several examples: Login button doesn't work → Bug; Add biometric login → Feature; Upgrade Java runtime → Technical Task. Now classify: Improve database indexing → ? This helps the LLM understand the pattern and expected behaviour. Few-shot = several examples.
04
Role
You tell the LLM what perspective to adopt: “Act as a software release manager. Review the following release plan and identify delivery risks.” This can establish the expected perspective, terminology, and priorities. But a role does not replace good context—saying “You are the world's greatest software expert” does not magically make the model more knowledgeable.
05
Contextual
You provide the relevant background: Release date: 30 September; Development: 85% complete; Critical defects: 14; Security testing: Not started. Then ask: Assess the release risk. The model can make better assessments when it has relevant evidence.
06
Instruction / constraint
You explicitly define what the model should and should not do: “Identify only risks supported by the supplied data. Do not make assumptions. Identify a maximum of five risks.” Constraints reduce ambiguity and help control the response.
07
Structured output
You specify exactly how the response should be returned: Risk | Severity | Evidence | Recommended Action. You could instead request JSON when another application needs to consume the output.
Context matters
More information ≠ better context. Hundreds of irrelevant Jira tickets do not necessarily improve an answer. Relevant information plus clear instructions produces better results. This connects directly with RAG, which retrieves the most relevant information before generation.
Context window
The amount of information an LLM can consider during an interaction, measured in tokens. It can include system instructions, conversation, prompt, documents, RAG-retrieved information, and the generated response. Context is finite, so relevance matters.
Prompting does not change the model
If you give an LLM instructions, documents, examples, Jira tickets, or release information, you are not necessarily training it. You are supplying context during inference.
Hallucinations and insufficient context
If you ask whether a release delivers strong customer value without explaining what is being released, the model lacks enough evidence to answer reliably. If it confidently invents benefits anyway, that is the hallucination problem.
Things to remember
Good prompt: Task + Context + Constraints + Output Format + Examples.
Prompt types: Zero-shot → no examples; One-shot → one example; Few-shot → several examples; Role → define the perspective; Contextual → supply relevant information; Constraint → define boundaries or rules; Structured output → define the response format.
More information ≠ better context. Relevant information matters.
Prompting provides instructions and context during inference; it does not retrain the model.
Fluent ≠ factual. A well-written answer is not automatically correct.
06
Variation, evidence, and truth
Probability, Temperature & Hallucinations
LLMs are probabilistic
Next-token prediction
An LLM generates an answer by predicting the next token.
Probabilities
It calculates probabilities for possible next tokens and selects from those possibilities.
Variation
This means the same prompt can produce different responses.
Not always deterministic
Unlike traditional software, LLM output is not always deterministic.
How probabilistic generation works
Prompt + context
Calculate probabilities for possible next tokens
Select a token
Repeat the prediction process
Generated response
Temperature
Temperature controls the randomness or variation of generation.
Low temperatureMore predictable and consistentSuited to structured or consistency-focused tasks
High temperatureMore varied and creativeUseful for brainstorming and creative tasks
Not every modern LLM or product exposes temperature as a user-controlled setting.
Hallucinations
Definition
A hallucination occurs when an LLM generates information that appears plausible but is incorrect or unsupported.
Why it happens
This happens partly because an LLM is designed to generate likely continuations, not simply retrieve verified facts.
Reducing hallucinations
We can reduce the risk by:
Providing relevant, grounded context.
Using RAG to retrieve authoritative information.
Giving clear prompt constraints.
Instructing the model to say when information is insufficient.
Requiring sources or evidence.
Using tools or APIs for current authoritative information.
Evaluating and verifying important outputs.
Choosing the source of truth
Before designing an AI solution, ask:
“Where should the truth come from?”
General knowledge
“What is integration testing?”
Use the LLM
Company knowledge
“What does our testing SOP require?”
Use RAG
Current system data
“How many testing defects are open right now?”
Use a Jira API or tool
Information neededApproach
General knowledgeLLM / model knowledge
Company documents / knowledgeRAG
Current / live system informationTool / API
Key architecture principle
Do not expect the LLM itself to be the source of truth.
Source of truth
Provide evidence / data
LLM
Reasoning + useful response
The LLM can act as the reasoning and language layer around authoritative information.
Five things to remember
LLMs are probabilistic.
Temperature influences variation in generation.
Fluent does not mean factual.
RAG grounds answers in relevant knowledge; tools and APIs provide current authoritative data.