Generative AI flashcards
How AI writes, draws and talks, from tokens to RAG.
Beginner friendly, starts from zero
0
Generative AI at a glance
Generative AI is software that creates new text, pictures or sound from a plain-language request.
Like a super-powered autocomplete that has read a huge library and keeps adding what usually comes next.
Words you will meet
- Model
- The AI's learned skill, saved as a big file of numbers
- Training data
- The huge pile of examples the model learned from
- Token
- A small piece of text that the model reads and writes
- Prompt
- Everything you send the model, including your question
- Context window
- The most text the model can read at one time
- Hallucination
- A confident answer that is made up
- Temperature
- A setting for how safe or adventurous the answers are
The steps
- 1. Start from zero (12 cards): What generative AI is, where you meet it, and the words you need before Core basics.
- 2. Core basics (16 cards): Tokens, prompts, context, sampling and where models go wrong.
- 3. Next steps (16 cards): Attention, embeddings, RAG, structured output, tools and cost.
- 4. Go deeper (17 cards): Post-training, reasoning, inference maths, security and evals.
All 12 cards in Start from zero
- What is generative AI, in one plain sentence?
- It is computer programs that create new text, pictures or sound when you ask in plain words, such as a birthday message, a poster idea or a summary of a long letter.
- Before generative AI, what could a computer do with a request like 'write me a thank-you note'?
- Almost nothing. Computers followed fixed rules or picked from ready-made options, so writing, drawing and summarising needed a person. Now a tool drafts it in seconds and you check it.
- Where do you already meet generative AI in daily life?
- Chat assistants, word suggestions on your phone keyboard, suggested email replies, auto captions on videos, and photo editors that fill in a missing background.
- What is a simple picture of how a text AI writes?
- Think of a super-powered autocomplete that has read a huge library. It keeps adding the piece of text that most often comes next, one small step at a time.
- What do model, training, training data and weights mean?
- A model is the AI's learned skill, saved as a huge file of numbers called weights. Training is how it learns: it reads masses of examples (training data) and adjusts those numbers.
- What is an LLM?
- A large language model: a model trained on a vast amount of text to predict what comes next. Chat assistants are built on top of one.
- What is a token?
- A token is a small piece of text, often a whole short word or part of a longer one. Models read and write in tokens, and AI services count your bill in tokens.
- What do prompt and context window mean?
- The prompt is everything you send the model: your question plus any instructions or documents. The context window is the most it can read at once, like the size of a desk.
- Why can an AI say something false with full confidence?
- It writes what sounds likely, not what it looked up. A confident made-up answer is called a hallucination, so names, numbers and quotes always need checking.
- What do probability, sampling and temperature mean here?
- The model gives each possible next token a chance (a probability) and picks one by those chances, which is sampling. Temperature is a dial: low plays it safe, high takes more risks.
- What do you need before you start?
- A web browser and a free account on any chat assistant, so you can try ideas as you read. No coding is needed; the few code samples are short and explained.
- After this topic, what will you be able to do?
- Explain how AI writes text and makes pictures, predict where it will go wrong, pick the right settings for a job, and use it safely with private data.
Generative AI cheatsheet
Sampling settings
temperature: 0 to 0.3Extraction, code, factual answerstemperature: 0.7 to 1.0Drafting, brainstormingtop_p: 0.9Sample only from the top 90% probability massmax_output_tokensHard cap on reply length and coststopStrings that end generation earlyseedBest-effort repeatable sampling where supported
Back-of-envelope maths
1 English wordabout 1.3 tokensWeights memoryparams x bits / 8 (70B at 4-bit is about 35 GB)KV cache per token2 x layers x kv_heads x head_dim x bytesDaily tokenscalls x (input + output) tokensChinchilla ratioabout 20 training tokens per parameter
RAG pipeline
1. ChunkSplit on headings, a few hundred tokens, small overlap2. EmbedOne embedding model for docs and queries3. IndexHNSW in pgvector or a vector store, with metadata4. RetrieveHybrid: BM25 plus vectors, fused by rank5. RerankCross-encoder keeps the best 3 to 86. GenerateAnswer only from sources, cite chunk ids7. EvaluateRetrieval hit rate and answer faithfulness
Model families
Decoder-only LLMText, code, tool callsReasoning modelMaths, planning, hard code; slower and pricierEmbedding modelVectors for search and clusteringCross-encoderReranking query and passage pairsLatent diffusionImages and video from textSpeech to text / text to speechTranscripts and voices
Cut cost and latency
Model routingSmall model first, escalate hard casesPrompt cachingStable prefix first, changing input lastBatch APIOffline jobs at a discount, results within hoursStreamingLower time to first tokenQuantisation8 or 4-bit weights for self-hostingSpeculative decodingDraft model plus verify, same output