GenAI engineering

Learn to build with large language models, from prompts and APIs to tools, RAG, agents, evals and safety, and to explain it all clearly in GenAI interview rounds. Examples use Claude; the ideas work with any vendor.

14 chapters111 practice questions4 week study plan
Open the courseChapters, a study plan and timed practice exams.

Chapters

  1. 1. What generative AI is 25 min

    What a large language model is, how it is trained, what it is good and bad at, and why it sometimes makes things up.

    • Explain the difference between training and inference in one minute.
    • Describe the stages pretraining, instruction tuning and preference training (RLHF, Constitutional AI) at a high level.
    • List tasks LLMs do well and tasks where they need tools, retrieval or plain code.
    • Explain hallucination and name three practical ways to reduce it.
  2. 2. Transformers, intuitively 30 min

    A correct, low-maths picture of how a transformer turns tokens into next-token probabilities, and why long context costs more.

    • Trace a prompt through tokenisation, embeddings, transformer layers and the output distribution.
    • Explain self-attention with queries, keys and values in plain words.
    • Explain why cost and latency grow with context length, and what the KV cache does.
    • Explain why text is generated one token at a time.
  3. 3. Tokens and context windows 25 min

    Tokens are the unit of cost, speed and limits. Learn to count them, budget a context window and manage conversation state.

    • Estimate token counts for English, code and Indian languages, and know why estimates are approximate.
    • Explain what counts toward the context window and what happens when you go over it.
    • Calculate the cost of a request from input and output tokens.
    • Design conversation state for a stateless API: history, trimming and summarising.
  4. 4. Sampling and decoding 20 min

    How a model picks each token: temperature, top-p, top-k, determinism, stop sequences and max_tokens.

    • Explain temperature, top-p and top-k and how each reshapes the distribution.
    • Choose settings for extraction versus brainstorming.
    • Explain why the same prompt can give different outputs and what "deterministic" really means.
    • Use stop sequences and max_tokens, and handle every stop reason.
  5. 5. Prompt engineering 35 min

    Write prompts that work the first time and keep working: clear tasks, context, roles, XML structure, examples, thinking and chaining.

    • Write a clear prompt with task, context, constraints and output format.
    • Use a system prompt for role and rules, and XML tags to separate instructions from data.
    • Choose good few-shot examples and know their limits.
    • Use thinking and prompt chaining for complex tasks.
    • Improve prompts with a test set instead of gut feeling.
  6. 6. Structured output 25 min

    Get machine-readable output you can trust: JSON, schemas, tool-based extraction, validation and safe retries.

    • Choose between prompt-only JSON, schema-constrained output and tool-based extraction.
    • Design a JSON schema that a model can fill correctly.
    • Validate output and retry with the error message.
    • Parse defensively and handle refusals and truncation.
  7. 7. Working with LLM APIs 40 min

    Call an LLM API like a production engineer: messages and roles, streaming, errors and retries, prompt caching, batches and key safety.

    • Build a Messages API request and read the response: content blocks, stop_reason and usage.
    • Stream responses and know the order of events.
    • Handle 429, 5xx and 529 errors with backoff and respect retry-after.
    • Use prompt caching and batch processing to cut cost.
    • Keep API keys on the server and out of client code.
  8. 8. Tool use (function calling) 35 min

    Let the model call your functions safely: tool schemas, the tool loop, parallel calls, server tools, permissions and good descriptions.

    • Define a tool with a name, description and input_schema.
    • Implement the loop: tool_use, run the tool, return tool_result, repeat until the model finishes.
    • Handle parallel tool calls and tool errors correctly.
    • Explain client tools versus server tools.
    • Add permission checks and write descriptions that models use well.
  9. 9. Embeddings and vector search 30 min

    Turn text into vectors, measure similarity and search millions of chunks quickly: chunking, ANN indexes, hybrid search and reranking.

    • Explain embeddings and cosine similarity with an example.
    • Choose a chunking approach and a starting chunk size.
    • Explain approximate nearest neighbour (ANN) indexes such as HNSW and their trade-offs.
    • Combine keyword (BM25) and vector search, and add a reranker.
  10. 10. RAG end to end 40 min

    Build retrieval-augmented generation end to end: ingest, chunk, retrieve, ground answers with citations, debug failures and evaluate each stage.

    • Draw the RAG pipeline from ingestion to a cited answer.
    • Choose chunking and retrieval settings, and explain contextual retrieval.
    • Write a grounded prompt that cites sources and admits missing information.
    • Separate retrieval failures from generation failures and evaluate both.
    • Recognise when you do not need RAG at all.
  11. 11. Agents and MCP 40 min

    Know when to build a workflow and when an agent, how the agent loop works, and how MCP connects models to tools and data.

    • Tell workflows from agents and pick the simplest design that works.
    • Describe the agent loop with planning, memory, subagents and stopping rules.
    • Name the common workflow patterns: chaining, routing, parallelisation, orchestrator-workers and evaluator-optimiser.
    • Explain MCP hosts, clients and servers, and tools versus resources versus prompts.
  12. 12. Evaluation 30 min

    Measure LLM features like any other software: test sets, code and model graders, regression checks, RAG and agent metrics, and monitoring.

    • Write measurable success criteria and build a representative test set.
    • Choose between code-based, model-based and human grading.
    • Run regression evals on every prompt, model or retrieval change.
    • Pick metrics for RAG and agents, and monitor production.
  13. 13. Safety and security 35 min

    Defend LLM apps against prompt injection, jailbreaks and data leaks with least privilege, layered guardrails and human approval.

    • Explain direct and indirect prompt injection with examples.
    • Explain why prompt instructions alone are not a security boundary.
    • Protect secrets and personal data (PII) in prompts, logs and outputs.
    • Design layered defences: least privilege, input and output screening, and human-in-the-loop.
  14. 14. Production and choosing an approach 45 min

    Pick the right approach and model, control cost and latency, observe everything, and design a grounded study assistant end to end.

    • Choose between prompting, RAG, tools, agents and fine-tuning for a requirement.
    • Select a model by quality, latency and cost using evals.
    • Estimate monthly cost and cut it with caching, batching and routing.
    • Set up observability for LLM features.
    • Present a complete design for a grounded study assistant in an interview.