Introduction to generative AI and agents
-
Introduction to generative AI and agents
-
Large language models (LLMs)
-
Prompts
-
AI agents
You’ve probably typed a question into ChatGPT, Claude or Gemini and watched the answer appear word by word. This first lesson shows you what’s going on behind that chat box, and why an AI agent is a different animal from a chatbot.
After that you’ll do something most tutorials skip and run your own AI model on your own laptop. It costs nothing, works offline and doesn’t need an account.
| Time | You need | By the end you can |
|---|---|---|
| About 45 minutes | A laptop with 8 GB RAM, 3 GB free disk space, and internet once (for the download) | Explain generative AI and agents in plain words, and run a local AI model from the command line and over its API |
What it is, in one line
Generative AI is software that creates new text, code or images from patterns it learned, and an AI agent is generative AI that can also use tools to get a job done for you.
In Simple Words
The bedtime-story child
Think of a child who has heard thousands of bedtime stories. One night you say, “Tell me a story about a cat who flies a plane.” They’ve never heard that one, but they know how stories go, with a “once upon a time”, a problem and a happy ending, so they make up a brand-new one on the spot.
That is generative AI. It doesn’t look the answer up anywhere; it makes one from the patterns it picked up.
A few years later you tell the same child, “We’re out of milk. Sort it out.” They check the fridge, take money from the jar, walk to the shop, buy the milk, come back and say, “Done!”
That is an AI agent. Besides talking, it plans, uses what’s around it, checks the result and finishes the job.
Engineer's View
What is really going on
- Large Language Models (LLMs). Most text-based generative AI today is an LLM built on the transformer architecture, and Llama, GPT, Claude, Gemini and Qwen are all examples.
- One job: predict the next token. A token is a small piece of text, often part of a word. The model looks at the text so far, predicts the most likely next token, adds it and goes again, thousands of times over, and that’s how paragraphs appear. Lessons 2 to 7 open this up piece by piece.
- Parameters (weights). Training tunes billions of numbers inside the model, and “1B” means about 1 billion of them. Once training ends those numbers are frozen, so the model does not learn from your chat.
- Inference. This is the word for running a trained model to get an answer. The model file has to fit in RAM (or VRAM on a GPU) with some room left over, which is why model size matters so much on a laptop.
- Hallucination. The model predicts likely text rather than true text, so it can give you a confident answer that’s completely wrong.
- Knowledge cutoff. The model knows nothing that happened after its training data ends unless you hand it fresh information yourself, and that’s the job of RAG (Lesson 11).
- AI agent = LLM + tools + a loop. The LLM decides which tool to call (this is called tool calling or function calling), your program runs the tool and passes the result back, and that repeats until the goal is reached. Real agents add memory and guardrails on top (Lesson 14).
| Chatbot | AI agent | |
|---|---|---|
| Can it run a command or call an API? | No. It only replies with text | Yes, through tools you give it |
| Who decides the next step? | You | The model, inside limits you set |
| Worst case when it’s wrong | A wrong answer | A wrong action, like a deleted file or a restarted service |
| Example at work | “Summarise this incident ticket” | “Find why server-01 is out of disk and open a change request” |
How it works, step by step
Before going further, see where generative AI and agents sit next to the ordinary software you already know:
What happens when you ask an LLM a question:
- You type a prompt. For example: “Write a short email telling users about tonight’s 10 PM downtime.”
- The text is cut into tokens. “downtime” might turn into “down” + “time”. (Lesson 3)
- Each token becomes a list of numbers called a vector, so the computer can do maths on meaning.
- Transformer layers read all the tokens together and work out which words matter to which, so “10 PM” gets tied to “downtime” and not to “email”. This is called attention.
- The model scores every possible next token and picks one. Sometimes it goes with the top choice and sometimes it adds a little randomness (Lesson 7).
- It adds that token and goes again until it decides the answer is finished.
- The tokens are turned back into text, which is why the answer streams in word by word.
An agent wraps that same model in a loop:
Here’s one real loop, step by step. You tell an agent: “server-01 is low on disk. Find out why.”
| Round | Think (LLM) | Act (tool) | Observe (result) |
|---|---|---|---|
| 1 | I need to see disk usage. | df -h | /var is 96% full |
| 2 | Which folder inside /var is big? | du -sh /var/* | /var/log is 18 GB |
| 3 | I know enough. Report back. | (none) | Answer: “Old logs in /var/log are filling the disk. Suggest setting up log rotation.” |
One thing it didn’t do
A well-built agent stops and asks before deleting anything. Reading is safe, but changing things needs a human “yes”, and you’ll build exactly this guardrail in Lesson 14.
Hands-on Lab: run your own AI model on your laptop
Before you run any command, double-check it
Read every command twice before you press Enter. Check the target: the system or account, the IDs, the names and the sizes. These commands are for learning and were tested in our lab, not on your system. At work, run the read-only list commands first, follow your change process, make sure a backup exists, and ask a second person to check anything that changes or deletes data. You run them at your own risk.
You’ll use Ollama, a free, open-source tool that downloads AI models and runs them on your own machine, so your questions never leave your laptop.
Prefer a separate test machine?
If you’d like, do the Linux steps inside an Ubuntu VM in VirtualBox, giving the VM at least 6 GB RAM and 2 CPUs.
Running Ollama directly on Windows or Mac works just as well. Pick whichever you’re comfortable with.
1Install Ollama
- Windows: go to ollama.com/download, download OllamaSetup.exe and run it, and a small llama icon will appear in your system tray.
- Mac: download the app from the same page and drag it into Applications, or if you use Homebrew, run
brew install ollama. - Linux / Ubuntu VM: run this one line:
Run this (Linux):
curl -fsSL https://ollama.com/install.sh | sh2Check it is installed
Open a new terminal (PowerShell on Windows, Terminal on Mac/Linux) and run:
Run this:
ollama --versionYou should see something like this:
ollama version is 0.x.x✅ Checkpoint: you see a version number (any number is fine). If you get command not found, close the terminal and open a new one.

3Download a small model
We’ll use Meta’s Llama 3.2 with 1 billion parameters. It’s about 1.3 GB and runs comfortably on 8 GB RAM.
Run this:
ollama pull llama3.2:1bYou should see something like this:
pulling manifest
pulling ... 100% ▕████████████████▏ 1.3 GB
pulling ... 100% ▕████████████████▏ ...
verifying sha256 digest
writing manifest
success✅ Checkpoint: the last line says success. On a normal connection this takes a few minutes.
4See what you have
Run this:
ollama listYou should see something like this:
NAME ID SIZE MODIFIED
llama3.2:1b xxxxxxxxxxxx 1.3 GB About a minute agoYour ID will be different, and that’s fine.
✅ Checkpoint: llama3.2:1b is in the list.
5Chat with your own AI
Run this:
ollama run llama3.2:1bYou should see something like this:
>>> Send a message (/? for help)Now type this and press Enter:
Type this at the >>> prompt:
Explain what a DNS server does in two lines, like I am 8 years old.An answer will stream in, something like “A DNS server is like a phone book for the internet…”. Your wording will be different, because the model writes a fresh answer every time.
Now try a trick question:
Type this at the >>> prompt:
Who won yesterday's cricket match?Watch carefully. A small model may admit it doesn’t know, or it may make up a confident answer, but either way it can’t know, because it has no internet and its training ended long ago. You’ve just seen the knowledge cutoff (and maybe a hallucination) with your own eyes.
✅ Checkpoint: you got answers to both questions. Type /bye to leave the chat.

6See the model sitting in RAM
Start the chat again with ollama run llama3.2:1b. Keep it open, open a second terminal, and run:
Run this:
ollama psYou should see something like this:
NAME ID SIZE PROCESSOR UNTIL
llama3.2:1b xxxxxxxxxxxx 2.x GB 100% CPU 4 minutes from nowThe SIZE here is the memory the model is using right now. It’s bigger than the 1.3 GB file because the model needs working space as well. 100% CPU means there’s no GPU, which is normal on most laptops, and the exact numbers will vary by machine.
✅ Checkpoint: you can see the model loaded. This is the first command to run when an AI app feels slow.
7Talk to it the way programs (and agents) do
The chat window is only one way in. Ollama also runs a small web server on port 11434, and every app and agent you build later in this course will talk to the model through that port.
Run this (Linux or Mac):
curl http://localhost:11434/api/generate -d '{"model": "llama3.2:1b", "prompt": "Give one tip to keep a Linux server secure.", "stream": false}'Run this (Windows PowerShell):
Invoke-RestMethod -Uri http://localhost:11434/api/generate -Method Post -ContentType "application/json" -Body '{"model": "llama3.2:1b", "prompt": "Give one tip to keep a Linux server secure.", "stream": false}'You should see something like this:
{
"model": "llama3.2:1b",
"created_at": "...",
"response": "Disable root login over SSH and use key-based authentication...",
"done": true,
...
}On Windows, PowerShell shows the same fields as a tidy list instead of raw JSON.
✅ Checkpoint: you see a response field with text, and done is true. You’ve just called an AI model over an API, the same way a production app does.
Break It, Then Fix It
A working lab only teaches you the happy path, and it’s the broken ones that teach you the job, so here are two things to break on purpose.
ABreak #1: a typo in the model name
Run this:
ollama run lama3.2:1bYou’ll get this error:
pulling manifest
Error: pull model manifest: file does not existWhy it happened: Ollama couldn’t find lama3.2:1b on your laptop, so it tried to download it, and since no model by that name exists, the download failed.
Fix: run ollama list, copy the exact name and run it again:
Run this:
ollama run llama3.2:1b✅ Checkpoint: the >>> prompt is back.
Watch out for this one
ollama run llama3.2 (no tag) does not fail. It quietly downloads the 3B model, which is 2.0 GB, because models are named name:tag and leaving out the tag means “:latest”, which may not be what you wanted. Always type the tag.
BBreak #2: stop the engine
The ollama command you type is only a client, and the real work happens in a background server. Stop that server now.
Run this (Linux):
sudo systemctl stop ollamaWindows: right-click the llama icon in the system tray and choose Quit Ollama. Mac: click the llama in the menu bar and choose Quit Ollama.
Now try to use it:
Run this:
ollama listYou’ll get this error:
Error: could not connect to ollama app, is it running?Run this (Linux or Mac):
curl http://localhost:11434You’ll get this error:
curl: (7) Failed to connect to localhost port 11434 after 0 ms: Couldn't connect to server(Older curl versions say Connection refused. It means the same thing.)
Why it happened: nothing is listening on port 11434 any more. The model file is still on disk, but there’s no engine left to run it.
Fix: start the server again.
Run this (Linux):
sudo systemctl start ollamaWindows / Mac: open the Ollama app from the Start menu or Applications, then check:
Run this (Linux or Mac):
curl http://localhost:11434You should see something like this:
Ollama is runningOn Windows, open http://localhost:11434 in your browser and you should see the same message.
✅ Checkpoint: you see Ollama is running, and ollama list works again.
Why this matters on the job
When someone says “the AI is down”, the model itself is hardly ever the problem. Usually the service has stopped, the port is blocked or the machine has run out of memory, so check those first. On Linux, journalctl -u ollama --since "10 min ago" shows you the server’s own log.
This happened at work
The chatbot that invented a VPN server
A mid-size company’s IT helpdesk put an AI assistant on its intranet to handle common questions like password resets, printer setup and VPN. The first week went fine, but in the second week VPN tickets suddenly shot up, and lots of users wrote almost the same thing: “I connected to vpn-blr-02 like the assistant said, but it doesn’t work.”
There was no vpn-blr-02. The real servers were vpn-hyd-01 and vpn-blr-01, and because the assistant had seen plenty of names in that pattern, it generated one that looked right. It wasn’t lying; it was doing what an LLM does, which is predict likely text.
How the team fixed it:
- They connected the assistant to the real IT knowledge base so it answers from actual documents. This is RAG.
- They added an instruction: if the answer isn’t in the documents, say “I don’t know” and offer to raise a ticket.
- For server names, IPs and steps, the assistant now shows a link to the source document so users can check for themselves.
The lesson: treat generative AI like a bright new joiner. It’s quick and helpful, but you check its work before trusting it with facts.
Common mistakes and troubleshooting
| Mistake | What happens | How to avoid it |
|---|---|---|
| Thinking the model “looks up” answers | You trust a wrong answer, like the VPN story above | Check the facts, and for company data give the model real sources (RAG). |
| Pasting passwords, customer data or internal IPs into public AI tools | Sensitive data leaves your company | Stick to company-approved tools or a local model like Ollama, and mask sensitive values. |
| Downloading the biggest model on an 8 GB laptop | Very slow answers, or a “requires more system memory” error | Begin with 1B–3B models and check RAM with ollama ps. |
| Leaving out the tag | ollama run llama3.2 downloads 2 GB, not 1.3 GB | Always type name:tag. |
| Calling every chatbot an “agent” | Wrong design choices, and a red flag in interviews | Agent = model + tools + loop. |
| Giving an agent delete or restart powers with no approval step | One wrong guess becomes an outage | Give it read-only tools first, and make changes wait for a human “yes”. |
Quick troubleshooting
| You see… | Do this |
|---|---|
ollama: command not found / “not recognized” | Close and reopen the terminal. On Windows, sign out and back in so PATH gets refreshed. |
could not connect to ollama app | The server isn’t running, so start it (see Break #2 above). |
| Answers are very slow | That’s normal on CPU. Use a smaller model and close heavy apps such as browsers with lots of tabs. |
| “model requires more system memory” | The model is too big for the RAM you have free. Use llama3.2:1b or give your VM more RAM. |
| Port 11434 already in use | Ollama is already running, maybe the tray app plus a manual ollama serve, so stop one of them. |
Interview questions
Click a question to open it. Each one is phrased the way an interviewer would ask it, and underneath you’ll find why they ask it and one way you could answer in your own words.
Fresher level
1. Can you explain in simple words what generative AI is, and give me one example of how you’d use it in IT work?
Why they ask this: They want a clear, plain explanation without buzzwords, and a real IT example shows you’ve thought about how it fits into daily work.
How you might answer: It’s software that creates new content, like text or code, from patterns it learned during training. In IT I’d use it to draft a change-request summary from a long incident ticket, or to write a first version of a PowerShell script that I’d then review and test myself.
2. A friend asks you, “Isn’t an AI agent just a chatbot?” How would you explain the difference?
Why they ask this: They want to know whether you get what makes an agent different, and they’re listening for the model, the tools and the loop.
How you might answer: I’d say a chatbot only replies with text and stops there, while an agent uses an LLM plus tools in a loop. It decides on an action, runs a tool, reads the result and keeps going until the goal is done.
3. Say the AI gives you a confident answer that turns out to be wrong. What is that called, and how would you protect yourself from it?
Why they ask this: They’re checking that you know where these models fall short and that you’d check the output before acting on it.
How you might answer: That’s a hallucination, and it happens because the model predicts likely text rather than true text. To guard against it I check facts before I use them, ground the answers in real documents with RAG, and let the model say “I don’t know” instead of guessing.
2–5 years experience
4. Your team wants an AI assistant for internal runbooks. Would you pick a public chatbot, a cloud API, or a self-hosted model, and why?
Why they ask this: They want to see you weigh privacy, cost, speed and quality like an engineer, and think about the data before the features.
How you might answer: It comes down to how sensitive the data is, the cost and the quality we need. Runbooks usually have hostnames and IP addresses in them, so a public chatbot is normally ruled out. A cloud API under an enterprise agreement gives the best quality and comes with data-protection terms, while a self-hosted model like Ollama on a GPU server keeps everything in-house but needs hardware and gives weaker answers. I’d start with an approved API plus RAG and keep self-hosted for highly restricted data.
5. You ask the model the same question twice and get two different answers. A teammate says it’s broken. What would you tell them?
Why they ask this: They want to know you understand that LLMs aren’t deterministic by default, and that you know how to make the output repeatable when it matters.
How you might answer: I’d tell them nothing’s broken. The model samples from the likely next tokens, and settings like temperature add randomness on purpose, so when I need repeatable output, like a script or JSON, I lower the temperature and give the model a fixed format to follow.
6. Walk me through how you would check that a local model server, like Ollama, is healthy.
Why they ask this: They’re looking for practical ops habits. A model server is still a server, so they expect the same checks you’d run on any service: process, port, memory and logs.
How you might answer: I’d check the service with systemctl status ollama and the port with curl localhost:11434, then run ollama ps to see which models are loaded and how much memory they’re using. After that I’d send a small test prompt over the API to make sure it answers, and if anything looks off I’d read the logs with journalctl -u ollama.
Senior level
7. We want an agent that can restart services in production. What guardrails would you put around it before you let it run?
Why they ask this: They want to see you think about blast radius, accountability and failure, because a senior engineer protects production before adding features.
How you might answer: Least privilege first, so by default the agent only has read-only tools. It gets an allow-list of exact commands and target hosts, and any change waits for a human to approve it. I’d also want a dry-run mode, a cap on loop steps, rate limits and full audit logging of every prompt, tool call and result, plus a rollback plan. And I’d start it in non-prod and roll it out slowly.
8. Tell me about a case where you would NOT use generative AI, even if someone asked for it.
Why they ask this: It’s a test of judgement. Senior engineers can tell when a tool is the wrong one and explain why without sounding against new tech.
How you might answer: If a simple script or rule does the job reliably and cheaply, I’d use that instead. I’d also keep it away from anything that has to be exactly right every time with no human check, like compliance values or billing, and from places where a wrong action is costly and we can’t verify it first.
9. Six months after launch, your manager asks if the AI helpdesk assistant is actually helping. How would you prove it?
Why they ask this: They want you to tie AI to business results. “Users like it” won’t do; they want real measures of quality and cost.
How you might answer: I’d compare the numbers before and after: tickets resolved without a human agent, time to resolve, escalations, user ratings and cost per conversation. On top of that I’d have people sample answers every week to track the wrong-answer rate, and I’d keep hallucination reports as a separate measure.
Quick quiz
Q1. How does generative AI answer a question?
- It searches Google and copies the top result
- It generates new text from patterns it learned in training
- It reads the answer from a fixed database
Show answer
B — It creates a fresh answer by predicting likely text. That’s also why it can be wrong.
Q2. What makes an AI agent different from a plain chatbot?
- It has a bigger model
- It can use tools and loop until a goal is done
- It never makes mistakes
Show answer
B — Agent = model + tools + loop. The model can be the same size.
Q3. You run ollama run llama3.2 without a tag. What gets downloaded?
- Nothing, it shows an error
- The 1B model (1.3 GB)
- The “latest” tag, which is the 3B model (2.0 GB)
Show answer
C — No tag means :latest. Always type the tag you want.
Q4. You see could not connect to ollama app, is it running? What do you check first?
- Re-download the model
- Whether the Ollama server/service is running
- Buy more RAM
Show answer
B — The CLI is only a client. Start the service, then test with curl localhost:11434.
Q5. Which port does the Ollama API listen on by default?
- 8080
- 11434
- 443
Show answer
B — http://localhost:11434. Your apps and agents will use it in later lessons.
Quick recap
- Generative AI creates. It predicts the next token over and over, and doesn’t look answers up.
- LLMs are the engine, with a fixed knowledge cutoff and a habit of hallucinating sometimes.
- AI agent = LLM + tools + loop. It thinks, acts, looks at the result and goes again until it’s done.
- Because agents take real actions, they need guardrails and human approval for changes.
- You ran a model locally with Ollama, checked its memory with
ollama ps, and called it over its API on port 11434. - When “the AI is down”, look at service, port and memory first.
Next lesson
Large language models (LLMs) → What’s inside that 1.3 GB file, and why some models are smarter, faster or bigger than others.
New to servers and cloud as well? The Cloud Computing course goes well alongside this one.
