**LLM as coding partner**
- Turn a scientific question into working Python
- Explain unfamiliar code and libraries
- Generate tests and fixtures
- Diagnose failures from evidence
- Improve the project files over time
**LLM inside an application**
- Start with a tiny browser chat in Week 1
- Return typed scientific information
- Call controlled tools
- Retrieve supporting evidence
- Analyze data with explicit boundaries
- Pause for human review
The same model may fill both roles. The responsibilities are different.
---
# Three course strands
## Independent cases prepare students for three project blocks
01 · Build with an LLM
Vibe coding, short briefs, context, and inspection of generated changes.
02 · Build an LLM application
A tiny chat in Week 1; plotting agents in Week 4, Connect Four with MCP in Week 5, then verification loops, RAG, and code actions.
03 · Make it scientifically reliable
Provenance, evaluation, audit trails, security boundaries, and human approval.
---
# Learning outcomes
## At the end of the course, students can…
- Use LLM coding assistants to design, build, test, and package complete, working Python desktop applications
- Inspect generated code and verify that the application meets its requirements
- Decide when an LLM is appropriate—and when deterministic code is better
- Build a typed PydanticAI agent with structured outputs and function tools
- Compare PydanticAI Code Mode with controlled tool calling
- Build a small agentic RAG assistant with keyword search and traceable evidence
---
# Learning outcomes: scientific reliability
## Evidence students must be able to produce
- Expose and consume a reusable capability through MCP
- Design evaluation cases for scientific correctness and failure behavior
- Add a human approval gate before consequential output leaves the application
- Produce a reproducible, human-reviewed analysis report with Python, visualizations, and Typst
---
# Twenty-eight hours
## Contact time plus guided independent work
14 × 90 minutes
21 hours in class: concepts, demonstrations, guided coding, and review.
14 × 30 minutes
7 guided hours: one small artifact or project checkpoint each week.
Total · 28 hours
Independent cases through Week 11, then one project built over three weeks.
Week numbers count teaching sessions and skip the holiday week.
---
# A repeatable 90-minute class
## Concept → demonstration → lab → scientific review
Data integrity
Schema, historical missing values, repeated identifiers, dates, and provenance.
Analysis
Turnout, yes-vote shares, proposal kinds, distributions, and comparisons.
Reliable applications
Typed outputs, controlled tools, citations, evaluations, and human review.
Week 1 uses `agent.to_web()` for everyday questions such as Martigny's population,
then asks for the year and source. The chat has no dataset, tools, or structured
output; generated source claims still need checking.
Independent data cases through Week 11 reuse one licensed dataset and a
reliability pattern. Week 4 combines plotting tools and a bounded agent team.
Week 5 uses generated Connect Four positions to challenge naive models with
structured output and decision APIs, then a coding assistant connected through
MCP that may create its own helpers. Week 6 uses tool evidence in a bounded correction loop. Week 7 combines
keyword retrieval with an agent that searches, reads, and cites official voting
explanations. Semantic search is optional for RAG.
Weeks 12–14 build one bounded evaluation project in three blocks, carrying the
same implementation forward each week.
---
# Swiss Popular Voting · source and scope
## Public national voting records for transferable engineering practice
- `dataset/voting.csv`: 692 records, 22 columns; recorded dates 1848–2024
- National proposal records with Italian, French, and German titles
- Vote totals, turnout, yes/no shares, recorded outcomes, and cantonal vote totals
- `participation`, `ratio_yes`, and `ratio_no` are fractions in [0, 1]
- Aggregate observations support descriptive comparisons, not individual-voter claims
**Attribution:** Vasco (vascos), *Swiss Popular Voting*,
[Kaggle](https://www.kaggle.com/datasets/vascos/swiss-popular-voting),
version 1, 24 November 2024, MIT license.
[Upstream project](https://github.com/VascoSch92/swiss_popular_voting) draws on
Swiss Federal Chancellery records. Preserve attribution in reports and derived data.
---
# Read the data card before analyzing
## A licensed dataset still needs verification
- Missing values occur in historical and recent records; never replace them silently with zero
- `ballots_returned` is entirely empty; `no` repeats and is not a unique row key
- `kind` is inferred from title text by the upstream extractor
- `domestic_voters` has a documented extraction defect; exclude it from electorate comparisons
- Some counts and ratios disagree; retain source values and report consistency warnings
- Report each statistic's own nonmissing denominator and the selected date range
The [data card and dictionary](https://gitlab.idiap.ch/devel/biss/workshops/aiforlifescience/-/blob/main/dataset/README.md) record the source, units,
snapshot, limitations, and license. Repeated dates represent multiple proposals;
row order is not a time variable, and cantonal vote totals are not canton microdata.
---
# Assessment principles
## Reward evidence—not apparent autonomy
Correctness + provenance
Are calculations reproducible? Can every claim be traced to data or a source?
Verification + evaluation
Do tests cover normal cases, edge cases, and known failure modes?
Design + judgment
Are tool boundaries, human decisions, limitations, and risks explicit?
---
# Evaluation project
## Build a human-reviewed scientific report assistant
Question +
validated data
→
Python analysis +
X candidates
→
Student choice
compare · select · order
→
Structured
report draft
→
Human review
review · revise · approve
→
Typst source +
final PDF
The model may propose analysis queries, prose and layout; submitted numbers and
figures must come from reproducible Python computation. Confirm selected evidence
before drafting; explicitly approve the final version before final export.
Editing alone is not approval.
---
# Evaluation project · three weekly blocks
## The same application grows at each checkpoint
| Week | Block | Checkpoint |
| --- | --- | --- |
| **12** | **1 · Reproducible evidence** | Validated data, deterministic results, **X ≥ 5** purposeful figures, initial tests and provenance |
| **13** | **2 · Selection and draft** | Confirmed selection, order and notes, structured LLM draft from selected evidence, Typst preview marked as a draft |
| **14** | **3 · Review and export** | Human review, explicit approval tied to the exported version and enforced in Python, final Typst/PDF and reproducible package |
The checkpoints replace the weekly lab deliverables within the existing hours.
Earlier cases provide preparation and reusable artifacts. Week 7 RAG, Week 9
MCP queries and plots, and Weeks 10–11 evaluation and review remain independent
cases before the evaluation project.
---
# Evaluation project · scope
## One analysis and one story are sufficient
- **Python required** for application logic and analysis; **NiceGUI recommended**
- Other UI frameworks are allowed, including a separate frontend with a Python backend
- Shared voting CSV, one question, result table, configurable **X ≥ 5** purposeful figures
- Confirm one or more figures, their order when multiple, and notes on observations and a caveat
- Structured LLM draft from selected evidence, human review, audit and reproducible Typst/PDF export
Read-only agent queries and plots from their computed results, general CSV
exploration, AI judging, multiple stories and advanced review are bonuses.
They are not needed for full marks. The
project brief (not yet released) defines the complete scope and rubric;
the Rust/Dioxus teacher app is a behavior reference.
---
# Engineering compass for the course
## Each block adds one kind of control
| Weeks | Engineering focus | Control added |
| --- | --- | --- |
| **1–4** | First chat app + model limits · levels 2–4 | Intent, context, reversibility, verification |
| **5–7** | Agent anatomy + harness · levels 5–6 | Raw-CSV limits, structured output, and typed tools |
| **8** | Code Mode and a ready-made controlled-tool comparison | Explicit trade-off between flexibility and execution risk |
| **9–11** | Two-stage RAG + MCP | Evidence-grounded answers and reusable capability boundaries |
| **12–14** | Three incremental project blocks | Reproducible evidence, confirmed draft, reviewed export |
The weekly cases develop the controls that students integrate during the final
three project blocks.