Skip to content

Custom audiences notebook

A marimo notebook that writes six audiences for the local explanations of the Titanic EBM. An audience decides which facts the LLM gets and how the LLM is told to write. The notebook shows the short way (three subclasses of Layperson for a child, a chief executive and a reader of Simplified Technical English), a change of one rule (two subclasses of DataScientist for a loan officer and a machine learning engineer) and an audience with new rules (a subclass of Audience for a regulator). It prints the facts that each audience produces, side by side.

  • Everything up to "Put it in words" runs without an API key. This includes the errors that a wrong audience raises: an unknown name, and a missing method.
  • The last cells call the LLM (the global explanation, then the three local ones) and only run when you press their button. The default model needs OPENROUTER_API_KEY. Pass model= to use another model, see Choosing the model.

The page below is the notebook with the output of its cells, exported when the docs are built. To run it:

uv run marimo edit notebooks/audiences.py

The guide explains the ideas. The local explanations notebook shows the other parts of the feature.

Open the notebook in its own page