Given the joint distribution $P(X,Y)$:
| $X$ | $Y$ | $P$ |
|---|---|---|
| 0 | 0 | 0.1 |
| 0 | 1 | 0.2 |
| 1 | 0 | 0.6 |
| 1 | 1 | 0.1 |
Compute the conditional distribution $P(X \mid Y{=}1)$.
Given the marginal $P(W)$ and the conditional $P(D\mid W)$:
| $W$ | $P(W)$ |
|---|---|
| sun | 0.8 |
| rain | 0.2 |
| $P(D\mid W)$ | $D=$ wet | $D=$ dry |
|---|---|---|
| $W=$ sun | 0.1 | 0.9 |
| $W=$ rain | 0.7 | 0.3 |
Compute the joint table $P(W,D)=P(D\mid W)\,P(W)$.
Marginals $P(T)$: hot 0.5, cold 0.5; $P(W)$: sun 0.6, rain 0.4. Joint $P(T,W)$:
| $T$ | $W$ | $P(T,W)$ |
|---|---|---|
| hot | sun | 0.4 |
| hot | rain | 0.1 |
| cold | sun | 0.2 |
| cold | rain | 0.3 |
Are $T$ and $W$ statistically independent? Justify.
Explain what each ladder stage adds, and why only a tool-calling-tuned model can drive an agent loop.
(a) Classify each as chatbot or agent, and justify:
(b) In the three-layer architecture, which layer
Install (no root needed). Ollama runs without admin rights — install a user-local binary:
mkdir -p ~/.local
curl -L https://ollama.com/download/ollama-linux-amd64.tgz | tar -xz -C ~/.local
export PATH="$HOME/.local/bin:$PATH" # add this line to ~/.bashrc
Start the server — each session (lab machines have no auto-start service and no Docker/Podman):
ollama serve & # local server on 127.0.0.1:11434 — leave it running while you work
Pull a model and test it on the command line:
ollama pull qwen2.5:3b
ollama list # list installed models
ollama run qwen2.5:3b "Say hello in one word." # quick sanity check that Ollama works
Try different models — depending on the machine's free RAM. Smaller = lighter and faster on CPU, but tool calling gets less reliable below ~3B:
| free RAM | model | tool calling |
|---|---|---|
| ~4 GB | llama3.2:1b, qwen2.5:1.5b |
flaky |
| ~6–8 GB | qwen2.5:3b, llama3.2:3b |
reliable ✅ |
| 8+ GB | qwen2.5:7b |
best |
Pull a couple and compare speed and answer quality — set MODEL below to whichever you use.
On your own computer you may auto-start Ollama with
systemctl --useror Docker/Podman.
# Run me first — defines `client` and `MODEL` used by all lab exercises below.
from openai import OpenAI
client = OpenAI(base_url="http://localhost:11434/v1", api_key="ollama") # key is ignored
MODEL = "qwen2.5:3b" # try "llama3.2:3b", "qwen2.5:1.5b", or "qwen2.5:7b" (RAM permitting)
# MODEL = "qwen2.5:7b"
Send a single user message with the Chat Completions API to the model and print its reply.
Send the same user question with the Chat Completions API with two different system prompts and compare the answers. What does the system message control?
Tell the model your name in one request; in a new request ask for it without resending the history. Then repeat with the history. Use the Chat Completions API! Explain what you observe.
A first look at function calling — the mechanics are Week 2. Here you only advertise a tool and observe the structured request the model emits (you don't invent the schema or run the tool).
Using the tools schema below, ask "What's the weather in Berlin?" and inspect
response.choices[0].message.tool_calls — the structured JSON the model emits. Do not
execute the tool. Use the Chat Completions API.
tools = [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather for a city.",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"],
},
},
}]
Pass tools=tools to client.chat.completions.create(...). (The tool-schema format itself is
explained in Week 2 — you're just seeing the output here.)
Open question. Are language models capable of critical thinking — or do they mainly reproduce majority opinion, including its prejudices? Discuss this in terms of how they generate language: probabilistically, from $P(W_t \mid W_{1:t-1})$.
Work through (a)–(d) and write a ~1 page essay that takes a clear position and states the strongest objection to it.
(a) Start from the maths. The model is fitted by maximum likelihood on a corpus, so $\hat P(W_t \mid W_{1:t-1})$ approximates the distribution of that corpus. If the corpus records many conflicting voices on a contested question, what does the mode of that conditional correspond to — the best-argued position, or the most frequent one? What follows for a minority view that is well argued but rarely written down? (How a system then picks a token from the distribution — greedy vs. sampling, temperature — is Week 2, and W2's Exercise 13 measures it.)
(b) Where could disagreement with the majority come from at all? For each mechanism below, decide whether it produces a genuine evaluation of reasons or only a shift of the distribution:
(c) Alignment is not obviously a fix. Preference optimisation rewards answers that raters prefer, and Sharma et al. (2023) find that preference data systematically favours responses matching the user's stated view — sometimes over correct ones (sycophancy). Distinguish two different failures: a model echoing the corpus majority, and a model echoing the person in front of it. Which is more dangerous for an agent that acts (W12), and why?
(d) The counter-position. Bender et al. (2021) argue an LM is a "stochastic parrot" — form without communicative intent. Mahowald et al. (2024) instead separate formal linguistic competence (mastering the rules and statistical regularities of a language) from functional competence (using language rationally in the world: reasoning, world knowledge, situation tracking, social cognition). Sort the ingredients of "critical thinking" — internal consistency, spotting a fallacy, weighing evidence, changing one's mind when the evidence changes — onto that distinction. Then state what would count as evidence that a model did more than repeat patterns: design a concrete test, and say what result would falsify your own position.
References.