The Glorified Autocomplete
If you listen to tech marketing, Generative AI is either going to solve climate change tomorrow or build a robot army to take your job by next Tuesday. The reality is much more mundane, though incredibly clever. At its core, a Large Language Model (LLM) like GPT-4 is essentially a super-powered version of the autocomplete on your smartphone.
When you type "I am going to the..." on your phone, it suggests "store," "gym," or "beach." It does not know where you are going. It does not care. It just knows that in the history of millions of text messages, those words frequently follow that phrase. Generative AI works on the exact same principle, just on a massive scale.
Tokens: The Alphabet of AI
Computers do not understand words, emotions, or your existential dread. They understand numbers. Before an LLM can process your prompt, it breaks the text down into chunks called tokens. A token can be a whole word, a syllable, or even a single character.
For example, the word "unbelievable" might be split into three tokens: "un", "believ", and "able". The model converts these tokens into mathematical vectors (lists of numbers) and processes them through neural network layers to calculate what token should logically come next.
The "Drunk Slider": What is Temperature?
If AI only picked the absolute most likely next word, every response would be completely identical and incredibly boring. To fix this, developers use a parameter called temperature. Think of temperature as a slider that controls how creative, or how "drunk," the AI is:
- Temperature 0.0: Super deterministic. The model always picks the highest probability word. Great for code generation or factual lookups.
- Temperature 0.7: The sweet spot. Balanced, creative, yet coherent.
- Temperature 1.5+: Pure chaos. The model starts picking highly unlikely words, resulting in gibberish or digital poetry.
Predicting the Next Word in Python
To see this in action, we can look at a simplified, conceptual representation of how an LLM decides on the next word using probabilities. Here is a basic Python mockup:
import random
# A naive database of word probabilities based on context
context_database = {
"i love eating": [
{"word": "pizza", "probability": 0.6},
{"word": "sushi", "probability": 0.3},
{"word": "screws", "probability": 0.1} # High temperature might pick this
]
}
def generate_next_word(phrase, temperature=0.7):
options = context_database.get(phrase.lower())
if not options:
return "unknown"
if temperature < 0.2:
# Strict mode: pick the highest probability
return max(options, key=lambda x: x["probability"])["word"]
else:
# Random choice weighted by probability
words = [o["word"] for o in options]
weights = [o["probability"] for o in options]
return random.choices(words, weights=weights, k=1)[0]
# Example run
print(generate_next_word("I love eating", temperature=0.1)) # Output: pizza
The Takeaway
Generative AI does not "think" or "know" things. It calculates probabilities based on its training data. When it hallucinates (makes things up), it is not lying to you; it is simply predicting a highly probable sequence of words that happens to be factually incorrect. Treat it like an incredibly fast, slightly eccentric assistant who has read the entire internet but sometimes forgets to check the facts.


