liveBook · Manning

Overfitting

As explained in Generative AI in Action

Overfitting is a modeling condition in which learned patterns fit training data too closely and fail to generalize well to new examples.

Overfitting occurs when a model learns the patterns of its training data so closely that it performs well on those examples but struggles with new, unseen inputs. For an enterprise fine-tuning an LLM, this can limit the benefit of adapting a model to a specific task or domain. section 2.8.6 section 2.5

A related prompt-engineering problem is overspecification. An overly directive prompt can cause a model to echo the prompt or produce less novel output. This is an analogy to training-data overfitting, not the same training process: prompt instructions do not fundamentally change the model’s capabilities. section 6.7 section 2.5

To manage overfitting during fine-tuning:

  • Separate training, validation, and test data. Training data updates model parameters; validation data monitors progress; test data measures final accuracy. section 9.3.1
  • Use validation performance to guide adjustments to the learning rate, number of epochs, or other hyperparameters. Compare the fine-tuned model with other models or established baselines. section 9.3.1 section 9.1.2
  • Prioritize high-quality examples and adjust dataset size based on performance, task complexity, and available resources. section 9.1.2

Emoji chatbot dataset

A JSONL dataset can contain conversations that train a chatbot to respond with emojis. A separate validation set can help assess its progress on the target task; the training examples alone do not establish that it generalizes. section 9.3.1

Context-window size is another trade-off: longer windows can improve handling of broader context, but increase computational requirements and may raise overfitting risk when training data is limited. section 2.8.6

How Generative AI in Action covers it

How deep it goes
Explains validation and hyperparameter adjustment, while deferring detailed benchmarks and evaluation tools.
Examples
Uses an emoji chatbot JSONL dataset to illustrate examples for fine-tuning.
What you can do after
Evaluate generalization by monitoring validation performance, adjusting hyperparameters, and comparing fine-tuned models against baselines.
How it connects
Connects overfitting to generalization, fine-tuning, validation datasets, context windows, and prompt engineering.

Also explained in

Compare how 25 books explain overfitting →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Generative AI in Action. The section links point to the parts of the book it draws on.