Learn how to make better pics and vids!

Courses / AI Fundamentals / Lesson 2 of 6

How AI Models Actually Work

20 min5-question check

A plain-English look at how these systems generate answers, and why that one idea explains both their strengths and their mistakes.

Start with an example

Finish this sentence in your head: “Thanks for your order! It will ship…”

You probably thought “tomorrow” or “today.” Maybe “soon.” You almost certainly did not think “purple” or “elephant.” Why not? Because you’ve seen thousands of sentences like this one, and your brain has learned what usually comes next.

AI language models do the same thing, at an enormous scale and at incredible speed. Once you understand that single idea, most of AI’s strengths and weaknesses stop being mysterious.

Diagram: the AI’s likely next words with percentages.

The plain-English version

There are three stages to keep in mind.

1. Training: learning patterns

Before you ever use it, the model is trained on a massive amount of text: books, articles, websites, code, and more. During training, it plays a guessing game billions of times: hide the next word, predict it, check the answer, and adjust.

Over time, it gets very good at the game. It doesn’t memorize the text like a library storing books on shelves. Instead, it learns patterns: which words go together, how arguments are structured, what a polite email sounds like, how a recipe is laid out, and how Python code is written.

Here is a useful comparison. A person who has read hundreds of mystery novels can write a convincing mystery opening without copying any single book. They’ve absorbed the patterns of the genre. That’s roughly what a model has done, across almost every kind of writing.

2. Your prompt: setting the starting point

When you type a prompt, the model reads all of it: your instructions, any examples, any text you paste in. Your prompt becomes the beginning of a document, and the model’s job is to continue it in the most fitting way.

3. Prediction: one piece at a time

The model predicts a likely next piece of text (often a word or part of a word, called a token), adds it, then predicts the next piece, and the next, until the answer is complete. A long answer is built from thousands of these tiny predictions.

That’s it. There’s no little person inside reading your question, and no lookup in a giant answer book. It’s very good pattern prediction.

Why this one idea explains so much

What you notice Why it happens
The writing is smooth and confident It has seen how good writing flows, so it predicts fluent sentences
It sometimes states false facts confidently It predicts what sounds right, not what is right
Vague prompts get generic answers With little to go on, it predicts the most average, common response
Specific prompts get specific answers Your details steer the prediction toward your situation
The same question gets different answers It adds a little variety when choosing words, so no two runs are identical
It doesn’t know about very recent events Its training stopped at a certain date, called its knowledge cutoff

Hallucinations: the big one

When a model invents information that sounds believable, it’s called a hallucination. Ask about your store’s hours when it has no way to know them, and it may produce realistic-looking hours rather than saying “I don’t know.” It isn’t lying on purpose. Predicting a likely-sounding answer is simply what it was built to do.

Common hallucinations include:

  • Made-up statistics (“73% of customers prefer…”)
  • Fake quotes attributed to real people
  • Citations to articles or court cases that don’t exist
  • Wrong details about real people, like the wrong job title or hometown

You’ll learn how to catch these in Lesson 4. For now, remember this: a confident tone is not evidence.

What about AI that searches the web or reads files?

Many tools can now search the internet, read a PDF you upload, or connect to your company’s documents. This is a real improvement. The model can base its answer on actual sources instead of only its training patterns.

But the writing step still works by prediction. The model can still misread a source, mix up two numbers, or summarize something incorrectly. When an answer includes links or sources, click them and confirm they say what the AI claims.

A worked example: steering the prediction

Watch how the output changes as the input gets more specific.

Prompt 1: “Write a message about our sale.” Likely result: A generic announcement about “amazing savings” on “selected items.” The model had nothing specific, so it predicted the average sale message.

Prompt 2: “Write a text message to our salon’s regular clients about a 20% off sale on hair treatments this Friday and Saturday only.” Likely result: A short, relevant text with the right discount, dates, and service.

Prompt 3: Same as Prompt 2, plus “Our clients are mostly busy moms. Keep it under 160 characters, warm but not pushy, and end with ‘Reply BOOK to grab a spot.’” Likely result: A message you could almost send as-is.

The model didn’t get smarter between prompts. You gave it a better starting point, so its predictions landed closer to what you needed.

The practical takeaway

If the AI… Then you…
States a fact, number, date, or quote Verify it with a trusted source
Writes in a generic voice Give it an example of your voice
Misses the point Add context: who it’s for, what you want, and why
Gives a different answer each time Pick the best one, or ask it to combine the strongest parts
Says something about recent events Check the date and confirm with a current source

Think deeper: tokens, memory, and a little randomness

Three small ideas explain a lot of AI’s odd behavior.

Tokens. AI doesn’t read words; it reads tokens, which are chunks of letters. “Cat” is one token. “Unbelievable” might be three: “un,” “believ,” “able.” A token is about three-quarters of a word. AI companies charge by the token, and rare names or other languages often use more of them.

The context window. An AI can only “see” so much at once. That limit is its context window. Your instructions, pasted documents, and its own replies all have to fit. In very long chats, early instructions can fade, which is why the AI sometimes “forgets” what you said at the start.

Temperature. When the AI predicts the next token, it has a ranked list of options. A setting called temperature controls how adventurous it is. Low temperature: it nearly always picks the safest word, so it’s consistent but bland. High temperature: more surprising choices, and more mistakes. That’s why the same prompt can give different answers.

After learning from raw text, chat assistants get extra training where people rate their answers. That shapes the friendly, helpful personality, but underneath, every answer is still built one predicted token at a time.

Questions to sit with:

  • If an AI’s “personality” comes from people rating its answers, whose preferences do you think shaped it, and what might they have missed?
  • When would you want a creative, unpredictable answer, and when would that be a problem?

Practice: run your own test

  1. Ask an AI tool a well-known public fact, such as the capital of Illinois. Note whether it’s correct.
  2. Ask something about your own business or school that it couldn’t possibly know. Does it admit it doesn’t know, or invent an answer?
  3. Ask the same open question twice, such as “Give me a slogan for a neighborhood bakery.” Compare the two answers.
  4. Rewrite your question with three specific details and run it again. Compare the quality.
  5. Write down one sentence describing what you learned about how the model behaves.

Next, you’ll learn exactly what a prompt is and what separates a weak one from a strong one.

Try it

Ask an AI tool three questions: one about a famous public fact, one about your own business that it could not know (your hours or prices), and one about something very recent. Write down which answers were right, which admitted 'I don't know', and which were confidently made up. You just ran your own hallucination test.

Key takeaways

  • Language models write by predicting the next most likely piece of text, over and over.
  • They learned patterns from huge amounts of text during training. They do not look things up by default.
  • Confident wording is not proof. Models can 'hallucinate', meaning they invent believable facts.
  • Everything in your prompt shapes the prediction, so clear instructions and good context get better results.
  • Tools that search the web or read your files help with facts, but you still verify before you rely on them.

Knowledge check

Answer all 5 questions correctly to complete this lesson. You can try as many times as you need.

1. At its core, how does a text AI model write an answer?

Language models generate text one piece at a time by predicting what most likely comes next, based on patterns from training.

2. What happened during the model's 'training'?

Training teaches the model patterns from enormous amounts of text. It isn't a stored copy of the internet, which is why it can be fluent and still get facts wrong.

3. What is an AI 'hallucination'?

A hallucination is invented content presented as fact. It happens because the model predicts likely-sounding words, not checked facts.

4. You ask the same question twice and get two different answers. Why?

Models don't always choose the single most likely word. A little randomness makes writing more natural, so answers can vary between tries.

5. Why do clear instructions improve AI answers?

The model predicts from what you give it. Better input narrows the likely output toward what you actually need.

Pass the knowledge check to complete this lesson.