> ## Documentation Index
> Fetch the complete documentation index at: https://docs.auremi.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Notebooks

> Prototype with your model in the browser. Load its trained weights, run diagnostics and inference, and draw the results.

A notebook is a page of cells for one model. Your agent writes the cells in `src/notebook.tsx` in your repo and pushes them to Auremi. You open the page in the console and run the cells in your browser.

Use a notebook to prototype an idea before you train on it, to look inside a trained model's weights, to run inference on a few examples, or to chart a diagnostic. A new repo from `auremi init` starts with an example notebook.

<Note>
  Notebooks are TypeScript and TensorFlow\.js only for now. PyTorch model repos can't push a notebook yet.
</Note>

## Cells

A notebook is a list of cells. Each cell has a title and its own run button. There is no run-all button. There are two kinds of cell:

* **Browser cells** run TypeScript in your browser tab. They can load a trained run's weights, run the model with TensorFlow\.js, and show the result as text, a table, JSON, an image, or any HTML you draw, such as a chart or an audio player. A browser cell can also pass data to the cells below it. Browser cells run again each time the page loads, unless a cell is set to run only when you click it.
* **Job cells** queue work on a [training worker](/training-workers). A training cell starts a training run. An inference cell runs a finished run on an input you give it. Each job cell lists its runs.

Here is a notebook with one of each:

```tsx src/notebook.tsx theme={null}
export const cells = [
  {
    id: "train",
    kind: "training",
    title: "Train",
    run: { kind: "training", runScope: "training-only", executionTarget: "browser" },
  },
  {
    id: "notes",
    kind: "browser",
    title: "Notes",
    runLabel: "Regenerate",
    runCell({ cellData }) {
      const summary = { cellsAbove: Object.keys(cellData) };
      return {
        summary: "Generated notes.",
        data: summary,
        display: [{ kind: "json", value: summary }],
      };
    },
  },
];
```

A browser cell returns a short `summary`, optional `data` for later cells, and a `display` list. A display item's `kind` is `text`, `json`, `table`, `html`, `canvas` for raw pixels, or `custom` to draw into the page yourself.

To use TensorFlow\.js in a browser cell, import it from a URL when the cell runs. `auremi check` rejects a plain `import ... from "@tensorflow/tfjs"` in notebook code, because the browser can't resolve package names. A type-only import is fine.

```ts theme={null}
import type * as tf from "@tensorflow/tfjs";

const tfjs = (await import("https://esm.sh/@tensorflow/tfjs@4.22.0")) as typeof tf;
```

## Open a notebook

In the [Auremi console](https://auremi.ai), open your model and click the **Notebook** tab.

The menu at the top picks which revision of the notebook you are looking at: **Latest notebook**, an older revision under **Notebook revisions**, or a commit under **Git commits**. **Runs** lists the runs started from that revision. Each cell's results appear under **Cell Output**.

## Add or change cells

Ask your agent for the cell you want. It edits `src/notebook.tsx`, checks it, and pushes a new revision. Changes in your repo don't appear in the console until they are pushed. The open page updates by itself when a push lands.

<Prompt description="Add a diagnostic cell">
  Add a notebook cell that loads the newest trained run and shows a histogram of each layer's weights.
</Prompt>

<Accordion title="What the agent runs">
  ```bash theme={null}
  auremi check
  auremi notebook push --message "Weight histograms"
  auremi notebook open
  ```
</Accordion>

Every push makes a new revision, even when nothing changed. `auremi notebook status` shows the latest one, and `auremi notebook open` prints the link to the page.

## Train from a notebook

A training cell trains the model code in the revision you are viewing, so push your changes first. Choose a **Train dataset**, a **Mode** (**Quick** or **Full**), where it runs under **Compute**, and the **Epochs**, **Batch size**, and **Learning rate**. Then click **Run cell**. To add a dataset first, see [Datasets](/datasets).

## Run inference

There are two ways to run a trained model from a notebook:

* **In a browser cell.** The cell loads a run's weights and runs the model in your tab. The result is immediate, which suits a few examples, a sweep of settings, or a diagnostic you want to rerun as you change the code.
* **In an inference cell.** Choose a finished run under **Trained cell run**, give it an input, and click **Run cell**. The job runs on a training worker, like any other job.

<Prompt description="Try the model in the browser">
  Add a notebook cell that runs the newest trained run on three validation examples and shows the outputs next to the expected ones.
</Prompt>
