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.
2The operations at a glance
Seven things a model does with text, and one dial.
| Operation | What goes in | What comes out | Typical use |
|---|---|---|---|
| Inference | Text | Sentiment, emotion or a label | Ticket triage, review analysis |
| Extracting entities | Text | Specific fields such as product or company | Turning free text into data |
| Inferring topics | Text | A list of topics | Grouping feedback with no preset tags |
| Translation and tone | Text | Same meaning, another language or register | Support in many languages, formal to casual |
| Format conversion | Data in one format | Same data in another format | JSON to an HTML table |
| Spell and grammar check | Draft text | Corrected text, plus a diff | Clean-up with a visible audit trail |
| Expanding | A short instruction or summary | A full draft | Reply 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.
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}```
"""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.
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.
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}```
"""{"item": "desk lamp", "brand": "Lumina"}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.
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.
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.
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.
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.
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]))Its -> It's it, -> it; last -> lasts
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.
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.
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.
| Setting | Behaviour | Use it for |
|---|---|---|
| Low (around 0) | Focused, much more repeatable | Classification, extraction, anything you will test or audit |
| Higher | More varied and surprising | Brainstorming, creative drafts, several different options |
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.
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.