# AILT1001 Lecture 3: Instructor and TA Demo Setup

This guide covers the tokenization, top-eight next-token prediction, and
continuous-generation demos for **Lecture 3**, not Lecture 2.

## Find the Demo in the Lecture Release

From the extracted lecture release folder, open Terminal and run:

```bash
cd lecture.deckroom/demos/ailt_l3_demo
bash install_demo.command
bash start_demo.command
```

Run these commands as your normal user, without `sudo`.

Run the installer once. Before each class, run only `bash start_demo.command`
and leave its Terminal open, then start the lecture normally in another Terminal.
The demo is already extracted; no additional ZIP needs to be unpacked.
All five Demo tabs use this local service. Feedback needs no model loaded.

## This Computer: Main Classroom Setup

Use an Apple Silicon Mac. The two classroom models are **Qwen3.5-9B Base**
and **Qwen3.5-9B · Instruct**. Budget approximately 7–9 GB of runtime memory
for one model, plus macOS and Deckroom; this is an estimate, not a hard cap.
Both downloads total about 11.3 GB. Allow at least 13 GB free disk space.

**Deckroom already requires Node.js and Firefox.** If Deckroom works, do not
install Node.js again. The additional requirements for this demo are Python
3.11 or later, llama.cpp, and the downloaded model. The included webpage is
prebuilt; no npm commands are needed to run this instructor package.

### One-Time Setup

1. Open `lecture.deckroom/demos/ailt_l3_demo` in the extracted lecture release.
   If using the separate demo ZIP, extract its `ailt_l3_demo` folder instead.
2. Open Terminal in the extracted `ailt_l3_demo` folder.
3. Run `bash install_demo.command`. This installs missing Python and llama.cpp
   using Homebrew. If Homebrew is missing, follow https://brew.sh first.
4. Run `bash start_demo.command` and leave that Terminal window running.
5. Open http://127.0.0.1:7891/tokenization.
6. Download **Qwen3.5-9B Base** (5.63 GB), then **Qwen3.5-9B · Instruct**
   (5.68 GB), using **Download Model**. Progress and checksum verification
   are shown. Use **Resume Download** if interrupted.
7. Click **Reveal the Tokens**, then try **Next Token**. The first request loads
   the weights into memory and may take longer than later requests.

The installer does not download weights automatically. Download models from
inside the demo while you still have internet access. Closing the demo service
interrupts a download; completed partial data is retained for resuming.

### Before Each Class

1. Run `bash start_demo.command` from the demo folder.
2. Open the tokenization and prediction views and run an example to warm the
   model before students arrive.
3. Keep the Terminal running. Use the L3 local Demo tabs in Deckroom, or open
   the page in a regular browser. Deckroom does not start this model service.
4. Stop the service with Ctrl+C when finished. The weights remain on disk.

Downloads and logs are stored outside the lecture package in
`~/Library/Application Support/AILT1001/l3_demo/`, so newer lecture releases
reuse the same downloads.

Local addresses:

- L2 feedback: http://127.0.0.1:7891/l2_feedback_v2.html

- Tokenization: http://127.0.0.1:7891/tokenization
- Top eight predictions: http://127.0.0.1:7891/prediction
- Continuous generation: http://127.0.0.1:7891/continuous

### Models Used in Class

Demo 1 shows lecture feedback through the same local service. Start the service first; feedback needs no model download or loading. Demos 2–4 use Qwen3.5-9B Base. Demo 5 compares it with Qwen3.5-9B · Instruct:
http://127.0.0.1:7891/comparison.

Only one inference model runs at a time on this computer. An instruct request stops
the base process and waits for it to exit before loading instruct. Switching
back does the reverse. Weights stay on disk; previous responses remain visible.
Selecting a model alone does not load weights.

### Troubleshooting

- **Page unavailable:** start the demo service and leave its Terminal open.
- **Model not downloaded:** select Download Model or Resume Download. The page
  shows the reason if a download fails. Keep the demo Terminal open.
- **Download failed:** copy the error shown below the download button. Detailed
  logs are in `~/Library/Application Support/AILT1001/l3_demo/logs/`.
  A partial download is retained; a file that fails its checksum is discarded
  so the next attempt can download a fresh copy.
- **Model cannot load:** check available memory and
  `~/Library/Application Support/AILT1001/l3_demo/logs/`. The tested llama.cpp version is 0.4.0, build 10809. Update an
  older installation with `brew upgrade llama.cpp` if it lacks model support.
- **Port already in use:** use the already-running demo, or stop its Terminal
  with Ctrl+C before starting another copy.

No API key is needed for local inference.

## Instructor Package Contents

This ZIP contains the prebuilt demo webpage, local service, install/start
commands, model download metadata, and this guide. It excludes model weights,
API keys, hosted passwords, personal prompts, logs, and development dependencies.
Keep this guide and the demo ZIP with the future L3 instructor lecture package.
Existing numbered L1/L2 releases are not changed by this setup.
