← Home · Tutorial 03 · Working with LLMs

What LLMs can do

The short list of text operations behind most language-model applications, and how they chain into an agent.

Last reviewed 5 October 2026 · Written with AI assistance and reviewed by me

Where I learned this: my notes from the Inferring, Transforming and Expanding lessons of DeepLearning.AI's ChatGPT Prompt Engineering for Developers (Isa Fulford and Andrew Ng). The examples here are my own, written in my own words. Go to the course for the original material and notebooks.
Who this is for: anyone building with language models. You will learn the short list of text operations behind most applications, and how they chain into an agent.

1Purpose first

Why learn the list of operations at all.

A language model can feel like magic until you notice what it is actually doing. Most of its everyday work is a short list of operations on text: read it, label it, pull something out, rewrite it, expand it.

Knowing the list demystifies AI. It also makes the word "agent" much less mysterious, because an agent is mostly several of these operations chained together instead of called one at a time.

Why it matters in practice: each operation replaces a task that used to need a person, or a separate piece of software. Ticket triage, review analysis, document clean-up and first-draft replies are all on the list.

2The operations at a glance

Seven things a model does with text, and one dial.

OperationWhat goes inWhat comes outTypical use
InferenceTextSentiment, emotion or a labelTicket triage, review analysis
Extracting entitiesTextSpecific fields such as product or companyTurning free text into data
Inferring topicsTextA list of topicsGrouping feedback with no preset tags
Translation and toneTextSame meaning, another language or registerSupport in many languages, formal to casual
Format conversionData in one formatSame data in another formatJSON to an HTML table
Spell and grammar checkDraft textCorrected text, plus a diffClean-up with a visible audit trail
ExpandingA short instruction or summaryA full draftReply emails, descriptions

One setting sits across all of them: temperature, which controls how varied the output is.

3Inference

Reading sentiment, emotion and labels.

Inference means the model reads the text and tells you something it implies: a sentiment, an emotion, a category. Often the answer is a single word or short phrase.

Two habits make this reliable. Mark off the text you want analysed, and say exactly what shape the answer should take.

Python
review = "The lamp is lovely and arrived early, but the switch feels cheap."

prompt = f"""
What is the sentiment of the review below, delimited by triple backticks?
Answer with one word: positive, negative or mixed.

Review: ```{review}```
"""
Illustrative output
mixed

The same pattern can ask for a list of emotions, or whether the writer sounds angry (yes or no). The model reads the tone so a person does not have to.

Good fit when: you need a quick read on tone before deciding what happens next, for example whether a ticket jumps the queue.

4Extraction and topics

From free text to fields.

Extracting entities pulls specific things out of free text: an item, a brand, a name, a date. Inferring topics asks the model to name what a text is about, then you split the answer into a list.

Ask for JSON and you can load the reply straight into a dictionary, which is what lets other code use it.

Python
review = "I bought the Lumina desk lamp last week and the switch broke already."

prompt = f"""
From the review below, delimited by triple backticks, return JSON with the keys
"item" and "brand". If a value is missing, use "unknown".

Review: ```{review}```
"""
Illustrative output
{"item": "desk lamp", "brand": "Lumina"}
Python
import json
d = json.loads(reply)        # reply is the text the model returned
print(d["item"], d["brand"])

For topics, ask for a short list ("name up to five topics, as a comma-separated list") and split it with reply.split(","). No predefined tag list is needed, so you can sort large volumes of feedback without deciding the categories first.

Check the shape: a model can return malformed JSON or an unexpected key now and then. Parse inside a try block and fall back safely instead of assuming.

5Translation and tone

Same meaning, different language or voice.

Translation covers three jobs: detect the language, detect several languages in a batch, and translate. It also covers tone, which is often the more valuable part: the same message rewritten from casual to formal, or the reverse.

Python
prompt = f"""
Translate the text below, delimited by triple backticks, into formal Hindi
and into casual English. Return two lines labelled Hindi and English.

Text: ```{text}```
"""

For a support team the useful version is not just language but register: same content, different voice for a different reader.

Know the limit: for anything legal, medical or contractual, treat machine translation as a draft and have a person who reads the language check it.

6Format conversion

Dropping output into reports and screens.

Models convert between formats well: JSON to an HTML table, a list to a bulleted summary, one data shape to another. That is what lets a model's output drop into a report, an email or a screen without anyone reformatting it by hand.

Python
prompt = f"""
Convert the following JSON to an HTML table with column headers and a title.

{data_json}
"""

Always say the target format explicitly, and say what to do with missing values. If your code will parse the result, prefer a format with strict rules, such as JSON, over free text.

7Spell and grammar check

Correct, then compare.

You can ask a model to proofread and correct a piece of text. The better habit is to compare its output with the original, so you see exactly what changed instead of trusting a black box.

Python's standard library can do the comparison. This example compares an original with a corrected version, and I ran it to check the output.

Python
import difflib

orig  = "Got this for my daughter's birthday and she loves it. Its a bit pricey but worth it, the battery last all day."
fixed = "Got this for my daughter's birthday and she loves it. It's a bit pricey but worth it; the battery lasts all day."

sm = difflib.SequenceMatcher(None, orig.split(), fixed.split())
for tag, i1, i2, j1, j2 in sm.get_opcodes():
    if tag != "equal":
        print(" ".join(orig.split()[i1:i2]), "->", " ".join(fixed.split()[j1:j2]))
Output
Its -> It's
it, -> it;
last -> lasts
Why the diff matters: a correction you can inspect is a correction you can defend. It is the difference between trusting the tool and being able to show what it changed.

8Expanding

Short instruction to full draft.

Expanding turns a short instruction or a summary into a full draft: a reply email from a customer review, a product description from a few facts. It is where a one-line instruction becomes a ready-to-edit draft.

Python
prompt = f"""
You are a customer service assistant. Write a short, polite reply to the review
below, delimited by triple backticks. The sentiment is {sentiment}.
If the sentiment is negative, apologise and suggest contacting support.
Use specific details from the review. Sign off as "AI customer agent".

Review: ```{review}```
"""

Notice the prompt feeds in the result of an earlier step ({sentiment}). That is the first hint of how these operations chain.

Keep a person in the loop: drafts that go out under your organisation's name should be reviewed, and it is good practice to be open that a reply was machine-assisted.

9Temperature

How much variety you allow.

Temperature controls how random the model's choices are. At 0 the model leans heavily on its most likely next word. Higher values allow more variety.

SettingBehaviourUse it for
Low (around 0)Focused, much more repeatableClassification, extraction, anything you will test or audit
HigherMore varied and surprisingBrainstorming, creative drafts, several different options
Two cautions: low temperature makes output more repeatable, but it does not guarantee identical text every time. And some newer models limit or ignore sampling settings such as temperature, so check the documentation for the model you use.

10Chaining into an agent

The same operations, in sequence.

An agent is not one giant model doing everything. It is several of the operations above, in sequence, with ordinary code deciding what happens between them.

One customer review, five steps
Infersentiment: negative
→
Extractitem, brand
→
Expanddraft a reply
→
Formatinto the ticket tool
→
Reviewa person approves

Each box is one of the operations you just met, and a plain if statement decides whether a negative review jumps the queue. Seen this way, "agent" is a pipeline you can trace one step at a time.

11Check yourself

Short questions and one line to remember.

Why show a diff after an AI correction?

So you can see exactly what changed and defend it, instead of trusting an opaque rewrite.

When would you set temperature low?

For work that must be repeatable and testable, such as classification or extraction.

What is an agent, in these terms?

Several of these operations chained together, with code deciding what happens between them.

Why parse a model's JSON inside a try block?

Because the reply can be malformed or missing a key, and your program should fail safely instead of crashing.

One line to remember: "An agent is a handful of text operations in a row, and knowing the operations makes it something you can trace."
Try it yourself: take five real reviews or messages, run infer, extract and expand on them with any chat model, and write down where a person still needs to step in.
Notes based on lessons from DeepLearning.AI’s ChatGPT Prompt Engineering for Developers by Isa Fulford and Andrew Ng. Examples and wording are my own. Independent notes, not affiliated with or endorsed by DeepLearning.AI or any company named here.