ai-engineer-notebooks

calmrocksMIT活跃维护

一套不依赖框架的 Colab 实战笔记本,覆盖模型 API、结构化输出、工具调用、RAG、评测、Agent 循环、LoRA 微调与提示注入防护,帮 AI 工程师和 FDE 快速上手真实技能。

Hands-on, framework-free Colab notebooks for the AI Engineer / Forward Deployed Engineer (FDE) skill set — model APIs, structured output, tool calling, RAG, evals-as-the-spine, agents (loop from scratch, tool design, guardrails, MCP, Skills), fine-tuning vs LoRA, prompt-injection/security, LLMOps, and customer craft. Runs on the free Groq API.

v0.1.0发布于 2026-08-27 20:20 UTC743star +3 / 7 天73fork同步于 2026-11-10 17:56 UTC

怎么上手

由 README 提炼,执行前请确认
pip install -r requirements.txt && pip install -e .
export GROQ_API_KEY=...
硬件要求按 README 说明

README 未说明本地显存要求;主体内容跑在免费 Groq API 上,无需 GPU。仅 LoRA 微调(06)和自托管服务(09)提供可选的 Colab GPU 附录,已在真实 Colab T4 上验证。

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

一套不依赖框架的 Colab 实战笔记本,帮你从提示词一路练到 RAG、Agent、微调和红队评测

一套不依赖框架的 Colab 实战笔记本,覆盖模型 API、结构化输出、工具调用、RAG、评测、Agent 循环、LoRA 微调与提示注入防护,帮 AI 工程师和 FDE 快速上手真实技能。

核心能力

  • 用原始 API 手写 Agent 循环、RAG 和评测,不依赖 LangChain 等框架
  • 把 Evals 作为贯穿主线,每个章节都回到「先测量再调优」
  • 覆盖模型 API、结构化输出、工具调用、流式、上下文与缓存
  • 包含四个端到端案例:生产排障、成本对比、红队基准、深伪合规
  • 全程兼容 OpenAI 接口,换 base URL 即可迁移到 OpenAI/Anthropic

容易踩的坑

需要先在 console.groq.com 申请免费 API key,Colab 中要存为 GROQ_API_KEY 密钥并开启笔记本访问权限;本地运行时第二条 pip install -e . 用于安装 aien 辅助工具,别漏掉;LoRA 微调与自托管服务章节需额外用 Colab GPU 附录,不是默认就能跑。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

1 个版本v0.1.0
  1. v0.1.0v0.1.0 — the full applied-LLM track最新正式版2026-08-27 · 2026-08-27 20:20 UTC

    First tagged release. The repo now covers the applied-LLM stack end to end, framework-free, on the free Groq API.

    What's inside

    Teaching notebooks (00–11) — one skill at a time, raw APIs, evals as the spine:

    • 00–01 Setup, prompting fundamentals, structured output, tool calling, streaming, context & caching
    • 02 / 04 Evals I & II — golden sets, LLM-as-judge, regression-as-CI (the spine)
    • 03 RAG — retrieve → hybrid/rerank → chunking → why-RAG-fails
    • 05 Agents — loop from scratch, tool design, guardrails, MCP, Skills, harness engineering
    • 06 Adaptation — fine-tune vs RAG vs prompt; LoRA (with a Colab-T4-verified appendix)
    • 07 Security — prompt injection & the trust boundary
    • 08 Operations — observability/LLMOps, reliability, MLflow experiment tracking & registry
    • 09 / 10 Serving & inference performance (vLLM/TGI/Triton/TensorRT-LLM) and ML system design
    • 11 Customer craft — scoping & discovery

    Case studies & capstone (12) — three runnable, end-to-end case studies:

    • A Customer-support assistant: scoping → deployed → debugged in production
    • B Contract extraction: pipeline vs agent, settled with eval + cost
    • C Red-team robustness benchmark: an attacker→target→judge PAIR loop reporting ASR

    Plus the capstone brief for the deployed project that goes on your resume.

    Verified

    GPU appendices (06 LoRA, 09 vLLM) run end to end on a free Colab T4; 08/03 MLflow runs locally. Everything else is verified statically and runs on the free Groq API.

    Feedback and run-reports welcome in Discussions.

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    AI Engineer Notebooks

    License: MIT Open In Colab GitHub stars

    Learn the applied-LLM stack the way you'll actually be interviewed on it: framework-free, on a free API, from prompting all the way to serving, fine-tuning, and a red-team benchmark.

    Runnable Colab notebooks for the AI Engineer / Forward Deployed Engineer (FDE) skill set. You build working systems on top of foundation models (model APIs, RAG, evals, agents, adaptation, serving) using raw APIs, not frameworks.

    What makes this different

    • Framework-free, on purpose. You write the agent loop, RAG, and evals from raw API calls first, so you understand what LangChain/LlamaIndex actually do before you reach for them (and can judge when not to). Patterns are durable; wrappers churn.
    • Evals are the spine. "Measure before you tune" is installed early and returns in every section. It's the habit that separates an engineer who shipped a system from one who built a demo.
    • Free to run, end to end. Everything runs on the free Groq API (no credit card). The two topics Groq can't host, LoRA fine-tuning (06) and self-hosted serving (09), are concept-first with optional, fenced Colab-GPU appendices that were verified on a real Colab T4.
    • Real case studies, not toy demos. Four end-to-end case studies show the skills combined under real constraints: a support assistant debugged in production, a pipeline-vs-agent cost showdown, a red-team robustness benchmark, and a deepfake-compliance test system comparing a detector, a VLM, and a hybrid.
    • OpenAI-compatible throughout, so every pattern transfers directly to OpenAI and (with small changes) Anthropic. Swap the base URL and the skills carry over.

    Built as the hands-on companion to Plan: Transitioning to Forward Deployed Engineer / AI Engineer. The plan explains what to learn and why; these notebooks are where you run it.

    Who this is for

    Backend or full-stack engineers moving into AI Engineer, FDE, Applied AI, or Solutions Engineer (AI) roles. Different titles, largely the same job. You can ship production code; you want the applied-model layer on top.

    Learning order

    Work top to bottom. Each notebook is self-contained (installs its own dependencies, reads API keys from Colab secrets) and ends with exercises.

    00 — Setup

    NotebookWhat you'll learn
    Environment & cost hygieneOpen In ColabAPI keys via Colab secrets, spend guards, model picking

    01 — Model APIs

    NotebookWhat you'll learn
    Prompting fundamentalsOpen In ColabClear instructions, few-shot, output-format specs, step-by-step reasoning: the cheapest lever, each shown moving a number
    Structured outputOpen In ColabGetting reliable JSON out of a model, and where it breaks
    Tool callingOpen In ColabFunction/tool calling end to end, error paths included
    StreamingOpen In ColabStreaming responses and what UIs need from them
    Context & cachingOpen In ColabContext-window budgeting, prompt caching, batch vs real-time pricing

    02 — Evals I: measuring outputs

    NotebookWhat you'll learn
    Measuring outputsOpen In ColabGolden sets and metrics on the section-01 task; install the "measure before you tune" habit before building anything you'd need to tune. Evals is the spine; it returns in every section after this

    03 — RAG

    NotebookWhat you'll learn
    What is RAG?Open In ColabThe retrieve → augment → generate loop, why RAG beats a plain LLM, and why RAG isn't the same as embeddings, with a 15-line working demo
    Embeddings & retrievalOpen In ColabEmbedding choice, vector search, similarity pitfalls. Get retrieval working first
    Hybrid & rerankingOpen In ColabKeyword + vector hybrid retrieval, rerankers, when each earns its cost
    ChunkingOpen In ColabChunking strategies on a real messy corpus, revisited last once you can judge them against retrieval
    Why RAG failsOpen In ColabDiagnosing bad answers: retrieval quality, not generation, is usually the bottleneck

    04 — Evals II: the differentiator

    NotebookWhat you'll learn
    Golden setsOpen In ColabBuilding a golden set for the RAG system from section 03
    LLM as judgeOpen In ColabJudge prompts, agreement with humans, and the judge's own failure modes
    Regression evalsOpen In ColabEvals as CI: catching quality regressions when you change a prompt or model

    05 — Agents

    NotebookWhat you'll learn
    Agent loop from scratchOpen In ColabA working agent loop in raw API calls, no framework
    Tool designOpen In ColabDesigning tools the model can actually use well
    Guardrails & budgetsOpen In ColabStopping conditions, cost/latency budgets, when a pipeline beats an agent
    MCP & the tool ecosystemOpen In ColabConcept: what the Model Context Protocol standardizes, how it maps to the raw tool loop, and when to reach for it
    Skills & progressive disclosureOpen In ColabConcept: packaging reusable know-how an agent loads on demand. The SKILL.md pattern, the context-budget payoff, and Tools/MCP/Skills as one story
    Harness engineeringOpen In ColabSynthesis: the scaffold around the call: context assembly & compaction, tool-result shaping, and verification loops. Names the discipline the section has been teaching piece by piece

    06 — Adapting the model

    NotebookWhat you'll learn
    Fine-tune vs RAG vs promptOpen In ColabWhen to change the model's weights vs its inputs; what LoRA/QLoRA are and cost; the argument you'll have in the room, plus an optional real LoRA fine-tune on a free GPU

    07 — Security

    NotebookWhat you'll learn
    Prompt injection & the trust boundaryOpen In ColabDirect & indirect prompt injection, output handling, PII, excessive agency. The OWASP LLM Top 10 risks, failing live then defended

    08 — Operations

    NotebookWhat you'll learn
    Observability & LLMOpsOpen In ColabTracing every call, safe prompt logging, cost/latency/error metrics, drift detection, and the observe→eval feedback loop
    Reliability & fallbacksOpen In ColabRetries with backoff, timeouts, fallback models, output validation, circuit breakers, graceful degradation
    Experiment tracking & registryOpen In ColabMLflow end to end: log runs/params/metrics from the section-04 eval harness, register and version a model, and promote by stage: the tooling that turns "I ran an eval" into a tracked, reproducible workflow

    09 — Serving & inference performance

    Where the free Groq API can't run the topic (these frameworks need a GPU), the notebook teaches it concept-first and fences an optional Colab-GPU appendix, the same pattern as the section-06 LoRA appendix.

    NotebookWhat you'll learn
    Serving frameworksOpen In ColabThe serving stack an AI engineer actually picks between (vLLM, TGI, Triton, TensorRT-LLM): what each optimizes, how they map onto the raw API you've been calling, and when to reach for which
    Inference performanceOpen In ColabThe levers behind throughput and latency: continuous batching, the KV cache, quantization, and the throughput-vs-latency trade, with the napkin math to size a deployment
    GPU capacity mathOpen In ColabDoes a model fit on an H100, H20, H200, or a domestic part, how many tokens/s it produces, and how many cards a load needs: a spec-sheet calculator, then measuring bandwidth and FLOP/s on a real GPU
    Monitoring inferenceOpen In ColabRead vLLM's /metrics like on-call: percentiles and goodput from histogram buckets, why GPU utilization misleads, diagnosing three incidents, then watching a live server and a prefix-cache regression

    10 — ML system design & performance

    NotebookWhat you'll learn
    Designing an inference serviceOpen In ColabConcept: the ML system design interview, worked end to end: QPS/VRAM/latency/cost estimation, replica scaling, queueing, caching, and the SLA trade-offs, on a realistic LLM-serving prompt

    11 — Customer craft (the FDE differentiator)

    NotebookWhat you'll learn
    Scoping & discoveryOpen In ColabTurn a vague customer ask into a scoped, evaluable system: discovery questions, a one-page scoping doc, the demo discipline: the customer-scenario interview round most engineers can't evidence

    12 — Case Studies & Capstone

    Where the skills come together into projects. First a case study (one realistic scenario worked end to end, runnable), then the capstone: the deployed repo you build yourself. (Section overview.)

    NotebookWhat you'll learn
    Case study A — Customer-support assistantOpen In ColabOne scenario scoped → built → served → debugged in production: a vague ask becomes a deployed, evaluated RAG+agent assistant, then a live quality regression (a stale index after a corpus migration) that you diagnose and fix. A build-to-debug arc threading sections 02–11
    Case study B — Contract extraction: pipeline vs agentOpen In ColabThe judgment call interviewers love: build the same extraction task as both an agent and a pipeline, then prove with accuracy + token cost that the pipeline wins when the steps are known
    Case study C — Red-team robustness benchmarkOpen In ColabA different kind of system, a harness that evaluates a model instead of serving one: an attacker→target→judge (PAIR) loop that measures attack success rate, composing the agent loop, LLM-judge, security, and evals
    Case study D — Deepfake detection for EU AI Act Art. 50(4)Open In ColabCompares three designs for flagging undisclosed deepfakes: an off-the-shelf detector (SwinV2 and CLIP trained on recent generators vs the classic 2020 CNNDetection ResNet-50), a VLM end to end, and a hybrid that adds a provenance check, on hand-picked cases and then on any image URL you give it. Shows why "is it AI-generated" and "does it break Art. 50(4)" need different tools

    Capstone: the brief for the deployed project that goes on your resume, a real repo with a serving component and an eval report. Case studies are for learning; the capstone is for hiring.

    Conventions

    • Raw model APIs, no frameworks. Patterns are durable; wrappers churn.
    • One shared corpus (data/) across RAG and eval sections, so evals measure the retrieval you actually built.
    • Self-contained notebooks. First cell installs, second cell calls from aien import setup; client, MODEL = setup() to load your key from Colab secrets (or a local env var). No hidden state between notebooks. aien is the tiny shared-setup package in this repo (one place to change credential loading), installed automatically by the first cell.
    • Every notebook ends with exercises. Do them before moving on.

    Setup

    1. Get a free API key at console.groq.com, no credit card required.
    2. In Colab: the key icon in the left sidebar → add GROQ_API_KEY as a secret, and toggle notebook access on.
    3. Open any notebook via its badge and run top to bottom.

    Running locally instead: pip install -r requirements.txt && pip install -e . (the second installs the aien setup helper), export GROQ_API_KEY=..., open with Jupyter.

    Related reading