PySvelte

An unsupported Python library that Anthropic published on GitHub in December 2021, already archived, which lets researchers call web-based interactive visualizations written in Svelte from Python notebooks and publish them as shareable pages; its example component is the attention-pattern viewer behind the interactive figures of A Mathematical Framework for Transformer Circuits.

Chris Olah, with Nelson Elhage and Catherine Olsson (Anthropic) · 2021-12-23 · original

Interpretability research produces large amounts of data about a model's internals, and much of it is read through interactive visualizations. The research itself runs in Python, while the richest tools for interactive graphics are web standards (HTML, JavaScript, CSS). PySvelte, a small library that Anthropic published on GitHub in December 2021, is one attempt to join the two: a researcher writes a visualization once as a web component and then calls it from Python like a function. The Transformer Circuits index lists it under December 2021, dated 23 December, with the description "One approach to bridging Python and web-based interactive diagrams for interpretability research." The release is a code repository with a README of about 800 words. It makes no research claims and reports no measurements.

What the repository contains

The README states four design goals (section "PySvelte"):

  • make it easy to create bespoke visualizations with web standards and the Svelte framework, and use them from Python;
  • keep visualizations modular and reusable;
  • publish persistent visualizations as standalone pages that can be shared;
  • let researchers who know nothing about web technologies use visualizations their colleagues write.

The workflow it describes (section "Basic use") is as follows. A component file placed in the src/ folder, such as src/Hello.svelte, becomes available in Python as pysvelte.Hello(), with tab completion for its arguments. The library runs the JavaScript build itself (npm install and webpack) when components are missing or out of date, so the Python user never runs a web build. Arguments must be passed by name, which the README explains guards against breakage when a component is edited. NumPy arrays passed in arrive on the JavaScript side as n-dimensional arrays. In a Jupyter or Colab notebook the visualization displays in the cell.

Three further features are described:

  • Publishing. A .publish() call writes a visualization to a standalone page. Results can be added together into a page of several components. At Anthropic, the config.py file says, publishing went to an S3 bucket served through an authenticating frontend, and each publication was announced on Slack.
  • Companion Python files. A component can have a Python file beside it that supplies docstrings, type signatures and checks on the data before it reaches JavaScript.
  • An example component. src/AttentionMulti.svelte displays attention patterns for several heads of a transformer, with optional "info-weighted" patterns and head labels. Its documentation says a version of it generated the attention explorer linked from A Mathematical Framework for Transformer Circuits; the README says the rendered page shows "(a variant of)" the component.

In all, the repository holds about 1,900 lines of Python, Svelte and JavaScript (this note's count over its source files, including the webpack configuration), under the Apache License 2.0.

Support status and history

The README opens with a warning in capitals: "THIS LIBRARY IS TOTALLY UNSUPPORTED. IT IS PROVIDED AS IS, AS AN EXAMPLE OF ONE WAY TO SOLVE A PROBLEM." It adds that many features, publishing among them, will not work until users write their own config.py.

The history is short. The repository has five commits. The first, "Initial import", is dated 17 December 2021; the last four, all on 21 December 2021 (Pacific time), update the README, remove "some Anthropic-internal dependencies", add the license and add the AttentionMulti component. The commits are by Nelson Elhage and Christopher Olah. The earliest Internet Archive capture of the repository page (23 December 2021, 03:59 UTC) already shows it as archived and read-only, so it appears never to have been open for outside changes; this is our inference from that capture. On 13 November 2026 the GitHub API reported the repository as archived, with 228 stars and 52 forks.

This note takes its date from the Transformer Circuits index (the entry's data-date), as for the other undated resources on that index. That date, 23 December, is one day after the framework paper, published 22 December 2021, said "We've released one of the libraries we made for our research, PySvelte" (section "Additional Resources"). The last commit was pushed on 22 December 2021 (UTC), according to the GitHub API.

Who built it and where it was used

The framework paper's author-contributions statement says Chris Olah created PySvelte and many of the paper's visualizations, with contributions from Nelson Elhage and Catherine Olsson, and that Ben Mann set up infrastructure for sharing visualizations securely (Author Contributions, "Visualizations"). In-context Learning and Induction Heads (March 2022) says Elhage set up its interactive visualizations with visualization tools built by Olah, "using PySvelte" (Author Contributions, "Figures and visualizations").

This note found no mention of PySvelte in five later Transformer Circuits papers it searched (Softmax Linear Units, Toy Models of Superposition, Privileged Bases in the Transformer Residual Stream, Towards Monosemanticity and Scaling Monosemanticity) or in HeadVis (May 2026), whose own viewer is open source. The search was not exhaustive, and it does not show whether later interactive figures were built with PySvelte.

Limitations

  • The library is a snapshot of an internal tool with internal pieces removed. Publishing and Slack sharing depend on functions each user must write.
  • Its dependencies are pinned to versions current in 2021 (for example Svelte 3 and webpack 5 ranges in package.json), and nothing has been updated since. Whether it still builds today was not tested for this note.
  • The repository has no tests (the package.json test script only prints an error) and no documentation beyond the README and docstrings.

Research questions

  1. Which later tools adopted the "write once in web code, call from Python" pattern? Public interpretability visualization libraries appeared after 2021. Reading their documentation for credits to PySvelte, or for the same design, would show whether this release influenced them.
  2. Does PySvelte still build with current Node and Svelte releases? Installing the archived commit in a clean environment would show how long an unsupported research tool stays usable, which bears on the reproducibility of the interactive figures it produced.
  3. How were the framework paper's interactive figures made, beyond the attention explorer? The paper credits PySvelte for visualizations in general. Inspecting the published figure pages for the component's code would show how many depend on it.

How it connects

  • A Mathematical Framework for Transformer Circuits announces the release in its "Additional Resources" section, and its attention explorer used a version of the example component.
  • Garcon, published the same week, describes the other internal tool named in that section: the server for reaching model internals at scale. Garcon was described but not released.
  • In-context Learning and Induction Heads credits PySvelte for its interactive visualizations.
  • HeadVis (2026) is a later open-source visualization release from the interpretability team, for attention heads. It does not mention PySvelte; the comparison is this note's.

References