Skip to content
Service status

Type to search

How AI works, and where it goes wrong · 3 min read

What AI is and how a language model works

What AI and generative AI are, how a language model writes text, what it knows, and why it sounds confident even when it is wrong.

Once you know how an AI answer is made, you can judge when to trust it.

Artificial intelligence (AI) is a name for computer systems that do tasks which used to need a person. Examples are recognizing speech, sorting cases, translating a text and writing a summary. The important word is imitate: an AI system computes its way to behavior that looks intelligent, without thinking, understanding or having intentions. A calculator solves sums faster than you can without understanding mathematics. AI does the same kind of thing for much more complicated tasks.

Most software follows rules a programmer wrote: if the invoice is overdue, send a reminder. Many tasks cannot be described that way. There is no simple rule for whether a sentence is sarcastic, or whether a photo contains a cat. Machine learning shows the system a very large number of examples and lets it find the patterns itself. Nobody has to write the rules. Three things made this practical in the last fifteen years: far more digital data, much faster computers, and better training methods.

This is also the source of one of AI’s weak points: a model learns whatever patterns are in its data, including the unfair ones. The section on bias later in this module returns to it.

Kind What it does Examples
Analytical AI Sorts, predicts and recommends from existing data Spam filters, recommendations, fraud detection
Generative AI Creates new content: text, images, audio, code Chat assistants, image generators, transcription
AI in physical systems Acts in the physical world Self-driving vehicles, industrial robots

This course is about generative AI, and mostly about the kind that works with text: language models. When you ask an AI assistant to draft an email, summarize a report or explain a regulation, a language model writes the answer.

All AI in use today is narrow: each system is very good at a particular kind of task and has no understanding outside it. A system that is impressive at writing text is not, by that fact, good at judging what is fair, true or appropriate. AI that can learn any task and reason like a person, often called artificial general intelligence, does not exist.

A language model is trained on an enormous collection of text: books, articles, websites, reference works and more. It learns patterns in language, such as which words tend to follow which and how people build an argument. It also learns what a letter, a summary or a legal text usually looks like. After that, people rate its answers so it becomes more helpful and follows instructions better.

The model reads text as tokens: short pieces that can be a whole word, part of a word or a punctuation mark. When you ask a question, it predicts which token is most likely to come next, given everything before it. It adds that token and predicts again, until the answer is complete. The model does not always pick the single most likely token, so the same question can give slightly different answers. Small differences in how you phrase a question change the result too.

Everything the model works with in one go has to fit in its context window. That includes your question, the earlier messages in the conversation, any documents you attach and its own replies. In a very long conversation, the earliest parts may no longer fit, and the model loses track of them. A fresh conversation that restates what matters often works better.

Training stops at a certain date: the model’s knowledge cutoff. The model knows nothing that happened after that date, such as a law passed last month or your organization’s new procedure. Newer information has to reach it another way: your message, an attached document, or a tool that searches the web or your organization’s sources. It also has no memory of your organization unless someone has connected it to your documents. What it writes about “how things work” comes from general patterns, not from your rules.

The model has learned how experts write, so it writes like one: complete sentences, clear structure, no hesitation. It does this whether the content is right or not, because it is predicting plausible language, not checking facts. When it lacks the information, it fills the gap with something that sounds right, such as a plausible date or a reference that looks real. The tone stays exactly as confident as before.

Test your knowledge

Question 1 of 4

Question 1 of 4

What is the main difference between traditional software and machine learning?

What is the main difference between traditional software and machine learning?