What is an LLM?

A Large Language Model is a next-word predictor trained on enormous amounts of text.

A Large Language Model is a deep neural network trained to do one deceptively simple thing: predict the next piece of text given everything before it.

Why that is powerful

To predict the next word well across billions of examples, the model must absorb grammar, facts, reasoning patterns, code, and style. That single objective — predict what comes next — produces a system that can summarise, translate, answer questions, and write code.

Key traits

  • General-purpose — one model handles many tasks.
  • Prompt-driven — you steer it with instructions, not by re-programming it.
  • Probabilistic — it produces likely text, not guaranteed-correct answers.

Example

Example · json
{
  "prompt": "The capital of France is",
  "model_predicts_next": " Paris",
  "why": "In its training data, ' Paris' is by far the most likely continuation."
}

When to use it

  • A legal-tech company uses an LLM to draft first-pass contract clauses from a lawyer's bullet-point notes.
  • A developer uses an LLM as a coding assistant that auto-completes functions based on a docstring.
  • A media platform uses an LLM to generate article summaries in multiple languages from a single source text.

More examples

Next-token prediction concept

Illustrates that an LLM picks the next token by assigning a probability to every possible word.

Example · python
# Conceptual: what an LLM does internally
sentence = ['The', 'cat', 'sat', 'on', 'the']
probs = {'mat': 0.42, 'floor': 0.31, 'sofa': 0.14, 'roof': 0.07}
next_token = max(probs, key=probs.get)
print(' '.join(sentence), next_token)

Text completion via chat API

Demonstrates text completion — the LLM predicts the most likely continuation of the prompt.

Example · python
from openai import OpenAI

client = OpenAI()
response = client.chat.completions.create(
    model='gpt-4o-mini',
    messages=[{'role': 'user', 'content': 'Complete: The capital of France is'}],
    max_tokens=10
)
print(response.choices[0].message.content)

List available LLM model IDs

Lists available LLM model IDs from the API so you can see what is available to call.

Example · shell
curl https://api.openai.com/v1/models \
  -H 'Authorization: Bearer $OPENAI_API_KEY' \
| python3 -c "
import json, sys
models = json.load(sys.stdin)['data']
for m in sorted(models, key=lambda m: m['id'])[:8]:
    print(m['id'])
"

Discussion

  • Be the first to comment on this lesson.