Unit 2 / 12

How Does Generative AI Work?

Gains:

  • Token can intuitively explain the concepts of probability and prediction
  • Understands why a language model produces text 'piecemeal'
  • Can interpret why the model sometimes behaves decisively and sometimes creatively

When you write "the best thing about Istanbul" into a language model, it produces a fluent paragraph in a few seconds. How does this happen? Does the model really "think" or is there a much simpler but powerful mechanism behind it? In this unit we will explain how generative AI works, without going into technical equations but by establishing the right intuition. This intuition is the basis for everything that follows—especially the topics of hallucination, verification, and good prompt writing. Generative AI, that is, "generative artificial intelligence", is the common name for tools that create text from scratch instead of finding and fetching an existing answer.

Basic Idea: Predicting the Next Piece

The surprising thing is that the only basic task a language model learns is “which part of a text is most likely to follow?” is to answer the question. The model does not prepare a complete sentence and present it in front of you. Instead, it produces the sentence piece by piece, from left to right.

Here's how it works step by step:

  1. It reads the text (prompt) you write.
  2. Predicts the most likely part to follow this text.
  3. Adds that piece.
  4. It looks again at the newly formed text and guesses the next most likely piece.
  5. Repeats until the answer is complete.
Example: If you gave the model the text "Have a hot cup when you wake up in the morning...", the most likely continuation would be "tea" or "coffee"; Not "asphalt". The model has learned such probabilities from millions of texts. Then he adds "tea", then looks at the new sentence and guesses the next most likely part, and so on.

In other words, at each step, the model takes the next step by looking at what it has written. That's why it's sometimes called a "very advanced version of autocomplete." But this analogy should not belittle talent; At the right scale, this prediction can produce results that look like reasoning.

Token: Small Pieces of a Word

The model actually works not with full "words" but with smaller pieces called tokens. A token; Sometimes it is a whole word, sometimes it is part of a word, sometimes it is a punctuation mark.

  • "book" can be a single token.
  • "from our books" can be divided into several tokens such as "book", "s", "our", "from".
  • Spaces and punctuation marks also count as tokens.
Attention: Token is not just a technical detail. Most AI tools charge by number of tokens, and the length of text (context window) models can process at a time is also limited in tokens. So "how long you write" is a direct cost and limit.

Probability and “Warmth”: Determination or Creativity?

At each step, the model produces not a single definitive answer but a probability list of possible continuations. For example, after the word "hot": tea 55%, coffee 35%, milk 7%, other 3%. So which one does he choose?

Here, a setting called temperature comes into play. Temperature is a kind of creativity knob that determines how much the model will "risk".

Setting

behavior

Conclusion

Where is it useful?

low temperature

Always takes the most likely option

Stable, repeatable

Legal summary, technical description, data extraction

medium temperature

Balanced choice

Natural but consistent

General email, report draft

high temperature

Tries less likely options

Creative, diverse, unpredictable

Brainstorming, slogan, name production

This also explains the frequently asked question: "Why do I get different answers when I ask the same question twice?" Because there is some randomness in the selection process; The model does not draw a fixed answer from a database, it reproduces it every time.

Weak Prompt / Strong Prompt

Knowing that the model works with "probability" also changes how you instruct it. The more context you give, the more likely the correct continuation becomes.

Weak prompt: Write an introductory text.

Result: The model produces the most "average" and generic text because it doesn't know which product, which audience, which tone.

Strong prompt: Write an Instagram promotional text for a small cafe's new filter coffee. Audience: 25-35 years old, coffee enthusiast. Tone: friendly, short. Maximum 3 sentences, 2 hashtags at the end.

Result: A usable text that is relevant because context narrows down the possibilities.

Three Mini Cases

Case 1 — Marketing, high variety. A team wanted 30 slogans for a new product. With its high temperature setting, the model produced different, creative options; The team selected and developed 4 out of 30. Total time: 10 minutes. If it was done by hand it would take half a day.

Case 2 — Law, high determination. The same company's legal team was simplifying a contract clause. They wanted consistency, not creativity; With low temperature the model gave almost the same, conservative summary each time. Thus, there was no inconsistency between different trials.

Case 3 — “Why did it change?” question. An employee requested the same email draft twice and received two different results; He thought it was a "mistake". In fact, this is a natural consequence of the randomness of the model. Once the employee learned to save the version he liked and say "make it like the previous one" if necessary, there was no problem.

Does the model "get it"?

This is the most curious question. The model has learned the statistical relationships between words so thoroughly that it pretends to understand many tasks. But it has no conscious understanding, intention or reality-controlling mechanism. It produces "the most probable sequel"; It does not guarantee producing the "most accurate information". This distinction is the basis of the subject of hallucination, which we will discuss in the next units.

Common Mistakes

Common mistakes

  • Mistaking the model for a search engine. The model does not search the internet and retrieve resources (unless there is a special search feature); Generates possible text from memory. So he can make up the source/figure.
  • Mistaking fluency for accuracy. Just because the text is beautiful and confident does not mean that its content is correct.
  • Expecting the same answer every time. Randomness is natural; Save the output you like for critical tasks.
  • Pasting very long, unnecessary text and pushing the token limit. Length both increases cost and can distract the focus of the model; just give the necessary context.
Attention: Just because the model speaks fluently and confidently does not mean that she speaks correctly. Fluency is the natural consequence of probability estimation; Accuracy is something that must be checked separately and independently.

In summary

  • Generative AI generates text step by step by predicting the next most likely fragment (token); constructs the sentence piece by piece.
  • Tokens are smaller parts of words and set both cost and length limits.
  • At each step, the model produces a list of possibilities; The temperature setting determines how stable or creative the output will be.
  • The reason for different answers to the same question is due to the randomness inherent in this process.
  • The model speaks fluently, but this does not guarantee that she is telling the truth; Fluency and accuracy are different things.

Application Task

Give your AI tool the same creative task (e.g. “write a quick thank you note”) twice in a row and observe how the outputs differ. Then repeat the same task with the “Powerful prompt” template, adding context, and note the difference in quality between the two results.

Checklist

  • [ ] I can explain that the model produces the text by "predicting the next possible chunk".
  • I know what [ ] Token is and why it stands for cost/limit.
  • [ ] I can distinguish between jobs that require determination and those that require creativity.
  • [ ] I know it is normal to get different answers to the same question.
  • [ ] I have internalized that fluency is no guarantee of accuracy.