COMP5046 — Natural Language Processing

Lecture 12: Models — LLM Agents

Reasoning + Acting · ReAct · RAG · tool use · multi-agent systems · evaluation.

How to use: picture the Reason → Act → Observe loop · close the page and answer Recall lines.

Definition

What is an agent?

Agent (LLM) reason + act Memory short / long term Tools / APIs search · code · calc External Data documents · KB World user · web · robot
Agent architecture: LLM core surrounded by memory, tools, external data, and a world it acts on. Arrows = information flow.

RecallWhat two ingredients turn an LLM into an agent?

Context

Historical language-based agents

RecallWhat was missing from ELIZA / Siri that LLM agents now add?

Think first

Reasoning: Chain-of-Thought and variants

RecallWhat is the difference between CoT and self-consistency CoT?

Reason + Act

ReAct: reasoning interleaved with acting

Thought internal reasoning Action call tool / API Observation tool / env response repeat …until done → Answer
ReAct loop: the agent emits a Thought (free-form reasoning), then an Action (tool call), reads the Observation, and repeats until it can produce a final answer.

RecallDoes ReAct require fine-tuning? How is it implemented?

Retrieve then generate

RAG: Retrieval-Augmented Generation

Query Embed Vector Store Retriever (top-k) LM → Output cosine sim → ranks docs → prepended to prompt
RAG: encode the query, retrieve top-k passages from a vector store by cosine similarity, prepend them to the prompt, then generate.

RecallWhat two factors determine whether a RAG system is useful?

Acting

Tool use

RecallHow does an LLM "call" a tool at the token level?

Many LLMs

Multi-agent systems

RecallName two ways multiple LLMs can be composed into a single agent.

How do we measure progress?

Evaluation and risks

RecallName a sandboxed benchmark for agents, and one safety risk it does not directly test.

Lab

Workshop & materials

Quick practice

What is the core idea of ReAct?
Fine-tune the LM with reinforcement learning on tool-use traces
Retrieve documents before every generation step
Interleave free-form reasoning steps with tool actions via prompting, looping until the answer
Use multiple LMs to vote on a single answer
In a typical dense RAG pipeline, how are documents ranked?
Random sampling from the knowledge base
Cosine similarity between query and document embeddings
Edit distance between query and document text
The LM scores each document with a chain-of-thought rationale
Which agent risk is specific to RAG and tool use (vs plain LM generation)?
Hallucination of facts
High training cost
Token limit exhaustion
Prompt injection via untrusted retrieved or tool content

Chapter quizzes

Retrieval practice for this lecture.

Open Quiz Hub Chapter flashcards