Introduction to artificial intelligence. This tutorial explains the vocabulary around artificial intelligence, how machine learning and large language models work, and how developers use them in practice.
1. What is artificial intelligence
1.1. Definition
Artificial intelligence (AI) is the field of computer science that builds systems which perform tasks that usually require human intelligence. Typical tasks are recognizing objects in an image, translating text, answering questions, or planning a sequence of actions.
The important difference to classical software is how the behavior is created. In classical software a developer writes explicit rules. In an AI system the behavior is derived from data, and the rules stay implicit in the parameters of a model.
1.2. Artificial intelligence, machine learning and deep learning
The three terms are often used as synonyms, but they describe nested areas.
- Artificial intelligence
-
The whole field, including rule based expert systems and search algorithms that contain no learning at all.
- Machine learning
-
The subset of AI in which a program improves at a task by processing data instead of being programmed with explicit rules.
- Deep learning
-
The subset of machine learning that uses neural networks with many layers. Nearly all current systems that generate text, images, or audio are deep learning systems.
1.3. Narrow AI and general AI
All systems in production today are narrow AI. They are trained for a bounded set of tasks, for example text generation or speech recognition, and they have no understanding of the world beyond the patterns in their training data.
Artificial general intelligence (AGI) describes a hypothetical system that matches human ability across arbitrary tasks. AGI does not exist, and predictions about it are speculation, so treat product claims about it with skepticism.
1.4. Generative AI
Generative AI describes models that produce new content, for example text, images, audio, video, or source code. The current generation of these models is built on the transformer architecture, described in Neural networks and transformers.
A generative model does not look up answers in a database. It predicts plausible output for the given input. This is the reason why the output is fluent and creative, and also why it can be confidently wrong.
2. Machine learning basics
2.1. Training and inference
Machine learning has two distinct phases.
- Training
-
The model processes a large dataset and adjusts its internal parameters, called weights, so that its predictions match the data better. Training is expensive, needs specialized hardware, and happens once per model version.
- Inference
-
The finished model is applied to new input and produces a prediction. Inference is what happens every time you send a request to a model. It is much cheaper than training, but it is the cost that scales with the number of users.
A trained model is therefore a static artifact. It does not learn from your conversation, and it does not remember your previous requests unless the application sends the earlier messages along with the new one.
2.2. Types of machine learning
- Supervised learning
-
The training data contains the expected answer, for example images labeled with the object they show. The model learns the mapping from input to label. Classification and regression are the classic examples.
- Unsupervised learning
-
The training data has no labels and the model finds structure on its own, for example clusters of similar customers.
- Self-supervised learning
-
The labels are generated from the data itself. Large language models are trained this way, by hiding the next word of a text and asking the model to predict it. This is why the internet can serve as training data without anyone labeling it.
- Reinforcement learning
-
An agent interacts with an environment and receives a reward signal. It learns a strategy that maximizes the reward over time. Game playing systems and robot control use this approach.
2.3. Data quality decides the result
The quality of a model is bounded by the quality of its training data. Missing groups in the data become blind spots in the model, and biases in the data are reproduced and often amplified by the model.
Two failure modes are important to know.
- Overfitting
-
The model memorizes the training data, including its noise, and performs badly on new data.
- Underfitting
-
The model is too simple to capture the structure of the data and performs badly everywhere.
To detect these effects, the data is split into a training set, a validation set used while tuning, and a test set that is only used for the final measurement.
3. Neural networks and transformers
3.1. Neural networks
A neural network consists of layers of simple units, called neurons. Each neuron multiplies its inputs with learned weights, adds them up, and applies a non-linear function. Stacking many such layers allows the network to represent complex relationships.
Training uses backpropagation. The network makes a prediction, the error against the expected result is calculated, and the weights are adjusted in the direction that reduces the error. Repeating this over a large dataset is what turns random weights into a useful model.
The number of weights is called the parameter count and is used as a rough size indicator, for example 7B for seven billion parameters. A larger model is usually more capable, but it also needs more memory and produces answers more slowly.
3.2. The transformer architecture
The transformer architecture, published in 2017, is the basis of nearly all current language and image models. Its central idea is the attention mechanism.
Attention lets every position in the input look at every other position and decide how relevant it is.
In the sentence The server rejected the request because it was overloaded attention is what relates it to server instead of to request.
Unlike the older recurrent networks, a transformer processes the whole input in parallel, which is what made training on internet scale data practical.
3.3. Embeddings
A neural network cannot process text directly. Text is converted into vectors of numbers, called embeddings.
Embeddings place semantically similar content close to each other in a high dimensional space.
The vectors for car and automobile end up close together, while car and banana are far apart.
This property is what makes semantic search and the retrieval described in Giving a model access to your own data possible.
4. Large language models
4.1. What a large language model does
A large language model (LLM) is a transformer trained on large amounts of text. Its only operation is to predict the next token for a given sequence of tokens. The model produces one token, appends it to the input, and repeats until it emits a stop token.
Everything else, for example answering a question, writing code, or summarizing a document, is a consequence of this prediction task. Understanding this helps to explain the behavior of these models. The model always produces a plausible continuation, even when it has no reliable knowledge about the topic.
4.2. Tokens
Models do not work on characters or words but on tokens. A token is a frequent character sequence, and one token corresponds to roughly four characters of English text. Common words are a single token, while rare words, identifiers, and non-English text are split into several tokens.
Tokens matter for two practical reasons. Providers bill per token, for input and output separately, and every model has a limit on how many tokens it can process at once.
4.3. The context window
The context window is the maximum number of tokens a model can consider in one request. It contains the system instructions, the conversation history, any attached documents, and the answer that is being generated.
Because the model is stateless, an application creates the impression of memory by resending the previous messages with every request. This is why long conversations become slower and more expensive, and why content drops out of the model’s view once the window is full.
4.4. Common request parameters
- Temperature
-
Controls the randomness of the selection between likely tokens. A low value produces focused and repeatable output and suits extraction or classification. A higher value produces more varied output and suits brainstorming or creative writing.
- Maximum output tokens
-
An upper bound on the length of the answer. If an answer stops in the middle of a sentence, this limit is the usual cause.
- System prompt
-
An instruction that describes the role and the rules for the model and applies to the whole conversation.
4.5. From base model to assistant
Training an assistant happens in stages.
- Pre-training
-
The model learns language and world knowledge from a large text corpus. The result is a base model that continues text but does not follow instructions well.
- Fine-tuning
-
Additional training on curated examples teaches the model to follow instructions and to answer in a specific format or style.
- Alignment
-
Human or model generated feedback is used to prefer helpful and harmless answers. Reinforcement learning from human feedback (RLHF) is the best known technique.
The training data has a cutoff date. Events after that date are unknown to the model unless the information is supplied in the request or retrieved with a tool.
5. Working with prompts
5.1. What makes a good prompt
The prompt is the only control you have over a model at runtime, so its precision decides the quality of the answer. A useful prompt states the task, the context, and the expected output format.
Instead of a vague request such as Write about testing, describe the situation.
You are a Java developer.
Write three JUnit 5 test methods for the class below.
Cover the empty list, a single element, and a null argument.
Return only the code, without explanation.
The following guidelines have the largest effect in practice.
-
Be specific about the goal, the audience, and the length of the answer.
-
Provide the relevant material instead of assuming that the model knows your project.
-
Describe the output format, for example JSON, a table, or a patch.
-
Say what to do rather than only what to avoid.
-
Split a complex task into several requests instead of asking for everything at once.
5.2. Zero-shot, few-shot and chain of thought
- Zero-shot
-
The task is described without examples. This is sufficient for common tasks.
- Few-shot
-
The prompt contains a handful of input and output examples. This is the most reliable way to pin down a format or a style that is hard to describe in words.
- Chain of thought
-
The model is asked to work through the problem step by step before it answers. This improves results for tasks with several reasoning steps. Current reasoning models do this internally, so an explicit instruction is often no longer needed.
5.3. Iterate on the prompt
Treat a prompt like code. Change one aspect at a time, keep a set of representative inputs, and check whether the change improves the results across all of them, not only on the case that failed.
For anything that runs in production, store the prompts in your version control system and review changes to them like any other change.
6. Giving a model access to your own data
6.1. The available options
A model knows nothing about your internal documents or your code base. Three approaches exist to change this, and they differ in cost and effort.
- Context
-
The relevant content is placed into the request. This is the simplest option and works as long as the material fits into the context window.
- Retrieval augmented generation
-
The relevant parts are searched at request time and only those are placed into the request. This is the standard approach for larger document collections.
- Fine-tuning
-
The model itself is trained further on your data. This is useful to teach a style, a format, or a domain vocabulary, and it is a poor tool for facts that change, because every update requires a new training run.
Start with context, move to retrieval when the data no longer fits, and consider fine-tuning only when behavior rather than knowledge is the problem.
6.2. Retrieval augmented generation
Retrieval augmented generation (RAG) combines a search step with a generation step.
-
The documents are split into chunks of a few hundred tokens.
-
An embedding model converts every chunk into a vector, and the vectors are stored in a vector database.
-
A user question is converted into a vector with the same model.
-
The database returns the chunks whose vectors are closest to the question.
-
These chunks and the question are sent to the language model, with the instruction to answer from the provided material.
The result is an answer that is grounded in your own content and can cite its sources. Because the retrieved chunks are visible, a wrong answer can be traced back to either a retrieval problem or a generation problem.
6.3. Practical advice for retrieval
Retrieval quality, not the model, is usually the limiting factor.
-
Choose a chunk size that keeps a complete thought together, and let chunks overlap slightly so that a sentence at a boundary is not lost.
-
Keep metadata such as the title, the section, and the source URL with each chunk, so the answer can reference them.
-
Combine vector search with a classic keyword search, because exact identifiers and error codes are matched better by keyword search.
-
Instruct the model to state that the answer is not contained in the provided material instead of filling the gap with its own knowledge.
7. Tools and agents
7.1. Tool use
A language model can only produce text. Tool use is the mechanism that turns this text into actions.
The application describes the available functions, with their names, their purpose, and their parameters. When the model decides that a function helps, it does not answer the user but returns a structured call with the arguments. The application executes the function, for example a database query or an HTTP request, and sends the result back to the model, which then continues.
This is how a model reads current data, searches the web, or changes files, none of which it can do on its own.
7.2. Model Context Protocol
The Model Context Protocol (MCP) is an open protocol that standardizes how applications provide tools, data, and prompts to a model. Instead of implementing an integration for every combination of client and system, a system is exposed once as an MCP server and can then be used by any MCP capable client.
7.3. Agents
An agent is an application that runs a model in a loop with tools. The model receives a goal, chooses a tool, sees the result, and decides on the next step, until it considers the goal reached.
The difference to a single request is autonomy. Nobody approves the individual steps, which is what makes agents productive and what makes their failures harder to notice.
The following rules keep agents manageable.
-
Give an agent the smallest set of tools that the task needs.
-
Make destructive operations require an explicit confirmation.
-
Limit the number of iterations, so that a loop terminates.
-
Log every tool call with its arguments, because this log is the only way to reconstruct what happened.
-
Run the agent with the permissions of the task, not with the permissions of an administrator.
7.4. Prompt injection
A model cannot reliably distinguish instructions from data. Any content that enters the context, for example a web page, an issue description, or a source file, can contain text that the model treats as an instruction. This attack is called prompt injection.
Treat all model output as untrusted input. Validate arguments before a tool executes them, and never combine untrusted content with tools that have destructive or outbound effects without a confirmation step.
8. Limitations and risks
8.1. Hallucinations
A model produces the most plausible continuation, not the true one. When it lacks knowledge, it fills the gap with something that looks right, for example a method that does not exist, a library version that was never released, or a citation with a plausible title and a wrong author.
The wording of such an answer is as confident as the wording of a correct one, so fluency is no indicator of correctness. Verify every fact that matters, and prefer setups in which the model works from provided material, as described in Giving a model access to your own data.
8.2. Knowledge cutoff and missing context
The training data ends at a fixed date, so recent releases and current events are unknown to the model. The model also has no access to your systems unless a tool provides it. If an answer must reflect the current state, the current state has to be part of the request.
8.3. Bias and fairness
Models reproduce the patterns of their training data, including stereotypes. Where a decision affects people, for example in hiring, lending, or moderation, a model must not be the only decision maker, and its output has to be reviewed.
8.4. Data protection
Data that you send to a hosted model leaves your infrastructure. Clarify before you use a service whether the provider trains on your data, how long requests are stored, and in which jurisdiction the processing happens.
For personal data or confidential source code the relevant questions are the same as for any other cloud service, including a data processing agreement under the GDPR. A locally hosted model, for example through Ollama, avoids the transfer entirely at the cost of quality and operational effort.
8.5. Reproducibility and evaluation
The same prompt can produce different answers, and a new model version changes behavior that used to work. Anything that runs in production therefore needs an evaluation set.
Collect representative inputs with their expected results, and run them after every prompt or model change. Without such a set, quality changes are only noticed by your users.
9. Using AI as a developer
9.1. Coding assistants
AI support for developers exists on several levels.
- Completion in the editor
-
The assistant suggests the next lines based on the surrounding code. This is fast and useful for repetitive code.
- Chat in the IDE
-
You discuss a selected piece of code with a model, for example to explain an error message or to propose a refactoring. For the Eclipse IDE, the AI assistant plug-in for Eclipse adds such a chat view.
- Command line agents
-
An agent reads and changes files in your project, runs the build, and reacts to the results. Claude Code is an example, see Claude Code basics.
The productive tasks are the ones where checking the result is cheaper than writing it. Tests, boilerplate, migrations, log analysis, and first drafts of documentation fit well. Review every generated change like a change from a colleague who does not know the project, because that is exactly what it is.
9.2. Connecting your tools with MCP
An MCP server exposes the capabilities of an existing system to any MCP capable client. The Eclipse MCP server does this for the Eclipse IDE and lets an external agent use the running IDE, for example its build and its refactorings, instead of reimplementing them.
9.3. Running models locally
Local models keep your data on your machine and cost nothing per request. The price is lower quality compared to the large hosted models, plus the hardware and the operational effort.
Ollama is the simplest way to run a model locally. It downloads the model and serves it through a REST API on port 11434.
ollama run llama3.2
See Docker for running such a model in a container with GPU access.
9.4. Keeping cost and latency under control
Cost and response time both scale with the number of tokens, so the same measures help for both.
-
Send only the material that the request needs instead of whole files or long histories.
-
Choose the model per task, and use a small fast model for classification, extraction, and routing.
-
Use prompt caching if your provider offers it, so that a stable prefix such as a system prompt is not billed at full price on every request.
-
Stream the answer, so that the user sees the first tokens instead of waiting for the complete result.
-
Measure token usage per feature from the start, because a request that is cheap in a demo is not cheap at production volume.
10. Links and literature
10.1. vogella resources
If you need more assistance we offer Online Training and Onsite training as well as consulting