More

AI Engineering in 76 Minutes (Complete Course/Speedrun!)

Marina Wyss - AI & Machine Learningautoenpublicupdated

Read in about 5 minutes instead of watching 76 minutes.

AI Engineering and Foundation Models

  1. AI engineering focuses on building applications with existing foundation models, emphasizing adaptation rather than training models from scratch.
  2. Foundation models learn through self-supervision and increasingly support multimodal inputs such as text, images, and video.
  3. Transformers use attention to reference relevant tokens and process inputs in parallel, although long contexts increase computation and memory costs.
  4. Scaling improves capabilities but faces diminishing returns, limited high-quality training data, and growing electricity requirements.

Post-Training and Generation

  1. Supervised fine-tuning teaches conversational behavior, while preference fine-tuning aligns responses with human preferences through methods such as RLHF and DPO.
  2. Temperature, top-k, and top-p sampling control the balance between deterministic accuracy and creative diversity.
  3. Probabilistic generation explains output inconsistency and confident hallucinations.

Evaluation and Model Selection

  1. Evaluation is difficult because AI tasks are often open-ended, subjective, expertise-intensive, and poorly represented by saturated public benchmarks.
  2. Useful evaluation methods include functional correctness, exact match, lexical or semantic similarity, human review, and AI judges.
  3. AI judges are scalable but can be inconsistent and exhibit self, position, and verbosity biases.
  4. Select models by filtering hard constraints such as licensing and privacy, then comparing domain capability, instruction following, cost, and latency on application-specific tests.
  5. Evaluation metrics should connect directly to business outcomes, cover important user and data segments, and be tested for reliability.

Prompt Engineering and Security

  1. Prompt engineering adapts model behavior without changing weights and should be treated as a systematic experimental process.
  2. Effective prompts combine a clear task description, representative examples, the concrete request, and an explicit output format.
  3. Complex tasks can be decomposed into subtasks, paired with reasoning or self-critique, and optimized through versioned experiments.
  4. Production systems must defend against prompt extraction, jailbreaking, prompt injection, and sensitive-information extraction.
  5. Security measures include adversarial testing, isolated execution, human approval for impactful actions, anomaly detection, and input and output guardrails.

Retrieval-Augmented Generation

  1. RAG supplies query-specific external information through a retriever and a foundation-model generator.
  2. Retrieval may use fast lexical search, semantic embedding search, or hybrid pipelines that retrieve candidates and rerank them.
  3. Chunk size, overlap, query rewriting, metadata augmentation, and reranking must be tuned for the application and data.
  4. RAG also supports images and structured data, including systems that translate natural-language questions into SQL.

Agents and Tools

  1. Agents observe an environment, plan decisions, and use tools such as search, databases, calculators, code interpreters, APIs, and write actions.
  2. Multi-step agents face compounding errors and higher risk because their tools can affect external systems.
  3. Planning should be separated from execution, validated before tool calls, and reviewed by humans for sensitive tasks.
  4. Agent evaluation should measure plan validity, tool and parameter correctness, completion rate, step count, latency, and cost.
  5. Agent memory combines model knowledge, the short-term context window, and external long-term stores such as RAG.

Fine-Tuning and Data Engineering

  1. Fine-tuning is most useful after prompting has been exhausted, especially for domain specialization, structured outputs, or stronger task-specific behavior.
  2. Use RAG for information failures and fine-tuning for behavioral failures; combining both can produce the strongest results.
  3. Quantization, gradient checkpointing, and parameter-efficient methods reduce the substantial memory required for fine-tuning.
  4. LoRA trains small low-rank matrices while freezing original weights, enabling efficient adaptation with relatively little data.
  5. High-quality, relevant, consistent, diverse, compliant, and correctly formatted data often matters more than sheer volume.
  6. Start with roughly 50 to 100 carefully designed examples, measure improvement, and expand the dataset only when results justify it.

Inference Optimization

  1. Inference optimization balances cost, latency, throughput, utilization, and the application's responsiveness requirements.
  2. Identify whether workloads are compute-bound or memory-bandwidth-bound before choosing hardware and optimizations.
  3. Key latency measures include time to first token and time per output token; percentile measurements are more informative than averages.
  4. Common model optimizations include quantization, pruning, distillation, speculative decoding, and more efficient attention.
  5. Service-level techniques include dynamic or continuous batching, prompt caching, decoupled prefill and decode, and multiple forms of parallelism.

Production Architecture and Feedback

  1. AI applications commonly evolve from a direct model call toward context construction, guardrails, model routing, gateways, caching, and controlled write actions.
  2. A model gateway provides a unified interface, access control, fallbacks, load balancing, cost management, logging, and analytics.
  3. Monitoring detects failures, while observability records enough internal state to diagnose their causes.
  4. Explicit and implicit user feedback creates proprietary data that can drive continuous product and model improvement.
  5. Architecture complexity should solve real problems; simpler systems are often more reliable and maintainable.

Actiepunten

  1. Define application-specific evaluation criteria, usefulness thresholds, and business-linked metrics before adapting a model.
  2. Filter model candidates by hard constraints, use public benchmarks only for shortlisting, and run your own representative experiments.
  3. Design a standard internal model interface so providers and models can be swapped without rewriting the application.
  4. Version prompts, track experiments with standardized datasets and metrics, and store prompts separately from application code.
  5. Validate agent plans before execution and require human approval for sensitive or impactful actions.
  6. Start adaptation with prompting, add RAG for missing information, and use fine-tuning when behavioral problems remain.
  7. Pilot fine-tuning with 50 to 100 high-quality examples before investing in a large dataset.
  8. Preserve original data, inspect distributions and disagreements, deduplicate examples, remove noncompliant content, and use the correct model template.
  9. Profile inference bottlenecks and optimize against latency, throughput, cost, and utilization requirements.
  10. Collect detailed logs and connect component-level operational metrics to business outcomes.