liveBook · Manning

Instrumentation

As explained in Natural Language Processing in Action, Second Edition

Model instrumentation is the addition of observations or logging that exposes a model's internal computations during execution.

Instrumentation adds observations or logging so a model’s computations become inspectable during execution. It turns loss, accuracy, probabilities, and internal states into evidence for evaluation and explanation. section 5.2.5 section 8.2.3

Practical instrumentation can:

  • Measure intuitive performance alongside loss, such as binary accuracy after each training epoch. section 5.2.5
  • Convert tensors into inspectable NumPy arrays, detaching them before recording values outside their device. section 8.2.3
  • Expose prediction probabilities, hidden-state vectors, and intermediate outputs through model convenience methods. section 8.2.3
  • Print selected values during execution when debugging or investigating how predictions arise. section 8.2.3

Tracing an RNN prediction

For “Khalid,” call predict_hidden and predict_category on each growing prefix. The resulting categories change from English to Chinese, Algerian, and Arabic, while the recorded 128-dimensional hidden states can be tabulated and compared with character position.

How Natural Language Processing in Action, Second Edition covers it

How deep it goes
Provides executable metrics, logging, tensor extraction, and hidden-state inspection, stopping short of a general interpretability theory.
Examples
Uses epoch metrics, ranked nationality probabilities, prefix predictions, and tabulated 128-dimensional hidden states.
What it assumes
Assumes familiarity with Python, PyTorch tensors, model execution, and basic loss and probability concepts.
What you can do after
Diagnose model behavior by recording metrics, probabilities, intermediate outputs, and hidden states during execution.
How it connects
Connects model evaluation with loss, accuracy, probability, hidden state, recurrent neural networks, and debugging.

Also explained in

Compare how 13 books explain instrumentation →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Natural Language Processing in Action, Second Edition. The section links point to the parts of the book it draws on.