liveBook · Manning

Degradation

As explained in LLMs in Production

Performance decay is a decline in a model's output quality over time despite the model continuing to operate.

Degradation is performance decay: a model keeps operating but produces poorer outputs and no longer meets quality expectations. Unlike an outage, it can remain silent until quality monitoring detects it. Language models are especially exposed because language, vocabulary, and word meanings continually change. section 6.2.5

Treat degradation as an ML monitoring problem alongside ordinary system monitoring. Track incoming prompts and generated text, then evaluate signals such as readability, complexity, toxicity, and similarity to known prompt-injection attacks. Data-drift detection is harder for unstructured text than for numerical data, so production evaluation practices remain necessary. section 6.2.5

Monitoring text with whylogs and LangKit

A rolling whylogs logger can collect text profiles every five minutes and use LangKit metrics to monitor prompts or generated responses. The resulting profiles help reveal when an LLM service begins failing quietly. section 6.2.5

Listing 6.11 Using whylogs and LangKit to monitor text data
import os
import pandas as pd

import whylogs as why
from langkit import llm_metrics
from datasets import load_dataset

OUTPUT_DIR = "logs"


class LoggingApp:
    def __init__(self):
        """
        Sets up a logger that collects profiles and writes them
        locally every 5 minutes. By setting the schema with langkit
        we get useful metrics for LLMs.
        """
        self.logger = why.logger(
            mode="rolling",
            interval=5,
            when="M",
            base_name="profile_",
            schema=llm_metrics.init(),
        )
        self.logger.append_writer("local", base_dir=OUTPUT_DIR)

    def close(self):
        self.logger.close()

    def consume(self, text):
        self.logger.log(text)


def driver(app):
    """Driver function to run the app manually"""
    data = load_dataset(
        "shahules786/OA-cornell-movies-dialog",
        split="train",
        streaming=True,
    )
    data = iter(data)
    for text in data:
        app.consume(text)


if __name__ == "__main__":
    app = LoggingApp()       #1
    driver(app)
    app.close()

    pd.set_option("display.max_columns", None)      #2

    all_files = [                #3
        f for f in os.listdir(OUTPUT_DIR) if f.startswith("profile_")
    ]
    path = os.path.join(OUTPUT_DIR, all_files[0])
    result_view = why.read(path).view()
    print(result_view.to_pandas().head())

Inspect the Python listing for a rolling logger that records LLM-oriented text metrics and writes profiles locally. section 6.2.5

How LLMs in Production covers it

How deep it goes
Defines performance decay and gives monitoring procedures, but does not explain model-internal causes or remediation algorithms.
Examples
Demonstrates rolling whylogs profiles with LangKit metrics for readability, complexity, toxicity, and prompt-injection similarity.
What it assumes
Assumes familiarity with ordinary software monitoring and introduces the additional need for ML-specific quality monitoring.
What you can do after
Diagnose silent LLM quality decline by monitoring text profiles and evaluating production outputs.
How it connects
Connects degradation with data drift, ML monitoring, production evaluation, and unstructured text monitoring.

Also explained in

Compare how 5 books explain degradation →

Related concepts

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