Definition
Could you now explain what happens between typing a prompt and reading the answer, design prompts and tests, call an API safely, add memory and grounding, and judge the risks and costs of a generative AI product?
This review brings together Generative AI and Large Language Models in Practice: what LLMs are, tokens and context windows, embeddings, how LLMs are trained, sampling and temperature, prompting techniques, structured outputs, testing prompts, using an LLM API, chatbots with memory, retrieval-augmented generation, AI agents, image generation, hallucinations and grounding, and safety, privacy and cost, followed by a scored quiz.
In simple words
Read the recap table, try the activities, then take the quiz. Each answer comes with an explanation. If you miss one, go back to that topic.
Why it matters
Generative AI is the fastest-moving area of AI. These foundations stay useful as models change, because they describe how every LLM product is built and where it can fail.
How it works
| Topic | Key idea |
|---|---|
| Tokens and context | Models see a limited window of tokens; cost scales with tokens |
| Embeddings | Meaning vectors for semantic search and RAG |
| Training | Pre-training, instruction tuning, preference tuning; knowledge cutoff |
| Sampling | Low temperature for consistency, higher for creativity; top-p |
| Prompting | Clear task, context, examples, format, delimiters, reasoning |
| Structured output and tests | Schemas, validation, evaluation sets and one change at a time |
| APIs and memory | Stateless calls, retries, keys on servers; memory built in your app |
| Grounding | RAG, citations, tools and abstention reduce hallucinations |
| Images | Diffusion removes noise step by step; label AI images |
| Safety, privacy, cost | Injection defences, least privilege, redaction, DPDP Act, right-sized models |
Try it yourself
Match the problem to the fix
Which technique addresses each problem?
- The bot invents scheme details
- Extraction gives different answers each run
- The bot forgets the user's name in long chats
- A web page tricks the bot into leaking data
- Costs are far above budget
True or false?
Decide for each statement.
LLM APIs remember earlier requests automatically
Temperature 0 guarantees correct answers
Output tokens count towards the context window
Diffusion models start generation from random noise
Common mistakes
- Trusting fluent output without grounding or checking.
- Shipping prompts without an evaluation set.
- Ignoring privacy, injection and cost until after launch.
Check yourself
Summary
- LLMs predict tokens within a context window; training stages shape knowledge and behaviour.
- Prompts, sampling settings, schemas and tests turn models into reliable components.
- Ground answers, protect keys and data, defend against injection and control cost.
Finished reading?
Sources: Jurafsky and Martin, Speech and Language Processing (3rd ed. draft) · OWASP Top 10 for Large Language Model Applications