1. Step One: How LLMs Slice Sentences Into Tokens (Not Whole Words)
Neural networks cannot multiply letters—they only process numbers. Before your prompt enters a Transformer model, a Tokenizer breaks the text into common character chunks called tokens and maps each chunk to an integer ID.
In English, 1 token averages roughly 4 characters (~0.75 words). Unusual names, code punctuation, and accented characters split into multiple smaller tokens—meaning longer prompts consume more of the model’s context window.
| Input Text | How the LLM Tokenizes It | Token Count | Key Takeaway |
|---|---|---|---|
| "algorithm" | ["algorithm"] | 1 token | Common English word -> single token ID |
| "algorithmic" | ["algorithm", "ic"] | 2 tokens | Prefixes/suffixes split cleanly |
| "for(int i=0;i<n;i++)" | ["for", "(", "int", " i", "=", "0", ";", "i", "<", "n", ";", "i", "++)"] | 13 tokens | Operators and brackets consume tokens individually |
| "9.11 > 9.9?" | ["9", ".", "11", " >", " ", "9", ".", "9", "?"] | 9 tokens | The model sees separate text tokens "9" and "11", not a decimal value! |
The model never sees individual letters s-t-r-a-w-b-e-r-r-y—it receives two or three integer token IDs like ["str", "aw", "berry"]. Unless it spells the word out step by step, it has to guess from patterns!
2. Next-Token Prediction: Softmax Probabilities & Temperature
After passing tokens through Transformer attention layers, the model scores every ~100,000 tokens in its vocabulary and applies the Softmax function to convert scores into percentages summing to 100%.
For „The capital of Romania is...”, „Bucharest” might get 98.5%. The Temperature dial adjusts how strictly or creatively the model picks from those percentages:
- Temperature = 0.0–0.2 (Deterministic): Almost always picks the #1 token. Best for C++ debugging, Excel formulas, translations, and factual summaries.
- Temperature = 0.7 (Balanced): Allows natural phrasing variety—the typical default for everyday chat.
- Temperature = 1.2+ (Creative / Risky): Flattens Softmax probabilities, boosting creative stories while raising hallucination risk.
3. Why AI Hallucinations Happen (Top 4 Homework Traps)
An AI hallucination occurs when a chatbot states fabricated information in a confident, polished tone. It happens because LLMs are trained to generate smooth, fluent completions even when they lack verified data:
- Invented page numbers & book quotes: Asking „Which exact page covers Topic X?” without uploading the textbook often produces a plausible-sounding fake number.
- Dead 404 URLs: LLMs guess web links that look grammatically realistic rather than checking live pages.
- Mental multi-digit arithmetic: Without an attached Python or calculator tool, large multiplication is only approximated.
- Leading false questions: Asking „Explain why Nikola Tesla invented Wi-Fi in 1995” can nudge weak models into playing along with the false premise.
4. The 60-Second Anti-Hallucination Check
Before trusting any AI output in an essay, lab report, or coding assignment, run these four quick checks:
1. Can I confirm proper names, dates, and definitions in a primary source (textbook / official site)?
2. For C++ code or Excel formulas, did I actually run them on 3 test inputs (including edge cases)?
3. Did I explicitly give the AI permission to reply "I cannot verify this"?
4. Can I explain every claim out loud in 30 seconds without reading off the screen?
5. Five High-Impact Educational Prompt Templates
Better prompts give clear Role, Context, Task, and Guardrails. Try these five study-safe templates:
- 1. Socratic Tutor (No Spoilers): „Act as a 7th-grade CS teacher. Do not write the full solution—give me only one hint for why my while loop never ends.”
- 2. Trace Table Debugger: „Walk through my C++ snippet on input n = 2040 using a step-by-step variable trace table.”
- 3. Kid-Friendly Analogy: „Explain RAM vs. SSD to an 11-year-old using the analogy of a desk and a filing cabinet.”
- 4. Teacher Quiz Builder: „Create 5 multiple-choice questions on Excel SUM, AVERAGE, and IF for Grade 8, including one trap involving absolute reference $A$1.”
- 5. Self-Critique Check: „List 3 assumptions or potential inaccuracies in your answer above.”