liveBook · Manning

Language model

As explained in Build an AI Agent (From Scratch)

A large language model is a neural language model trained on extensive text data that generates and interprets language.

A large language model (LLM) learns language patterns by training on vast amounts of text and predicting the next token from preceding tokens. Tokens are typically words or word fragments. Applying learned patterns to new examples is a form of generalization. The term LLM can also include multimodal variants that process images, audio, and video. section 1.2.1

Predicting a continuation

Given “Because it’s summer vacation, I didn’t go to _____,” a model might predict “school.” The prediction uses the preceding context rather than a fixed rule for that sentence. section 1.2.1

In an agent, the LLM is the decision-making core. Tools let it interact with the external world, while a loop lets it use tools iteratively until the task is complete. The model decides which tool to use and when to stop; a developer-defined workflow instead fixes the execution flow in advance. section 1.7 section 1.2

A model alone can answer some questions through reasoning or knowledge acquired during training. That knowledge is not a dependable source of current or precise information: a model may confabulate and may not accurately judge whether it needs external information. Search and file-reading tools can supply information that the model cannot reliably provide on its own. section 2.4.3 section 1.5.6

Table 2.1 Experiment results across models

Model

Accuracy

Judged solvable

GPT-5

10/20 (50%)

11/20 (55%)

GPT-5 mini

4/20 (20%)

8/20 (40%)

Claude Sonnet 4.5

3/20 (15%)

4/20 (20%)

Claude Haiku 4.5

3/20 (15%)

4/20 (20%)

Compare accuracy and self-assessed solvability across models on 20 GAIA problems; attempts and correct answers vary substantially. section 2.4.3

Use an LLM when inputs are varied or unstructured and require flexible interpretation. For predictable data processing or a small set of predefined tasks, traditional logic, rules, or a specialized model may be faster, cheaper, and more reliable. LLMs add computational cost and potential errors. section 1.4.1

Model choice also affects agent performance, cost, and development speed. Open models can be downloaded, run locally, and fine-tuned; closed models are accessed through APIs. Closed APIs allow rapid experimentation without deploying model infrastructure and may provide tool calling, structured output, prompt caching, and batch processing. section 2.1 section 2.1.1

How Build an AI Agent (From Scratch) covers it

How deep it goes
Explains next-token prediction and generalization, then compares model selection and tool-free performance without detailing training implementation.
Examples
Illustrates prediction with a vacation sentence and compares model accuracy and self-assessment on 20 GAIA problems.
What you can do after
Evaluate/understand when an LLM needs tools and when simpler logic may be preferable.
How it connects
Connects language models to agent loops, tool calling, prompt engineering, and context engineering.

Also explained in

Compare how 69 books explain language model →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build an AI Agent (From Scratch). The section links point to the parts of the book it draws on.