CRANE-LLM
Predict whether a ML notebook cell will crash — before you run it.
CRANE-LLM is a JupyterLab 4 / Notebook 7 extension. Select a cell, click a button, and it tells you whether executing that cell is likely to raise. What makes the prediction useful is that it does not read your code alone: it also inspects the live state of your kernel, so it knows the actual shape of the array, the dtype of the column and the length of the list the cell is about to use. The target cell is never executed.
This is the tool from the paper CRANE-LLM: Runtime-Augmented LLMs for Crash Prediction and Diagnosis in ML Notebooks.
Install
pip install crane-llm
jupyter lab
That is all — the package ships the compiled frontend, so there is nothing to build and no jupyter labextension command to run. Check it registered:
jupyter labextension list # expect: crane-llm-jlab <version> enabled ok
Set up a model
You need an API key for whichever model you want to use. One line in any notebook cell, remembered across sessions:
import crane_llm
crane_llm.set_api_key("sk-...")
That writes ~/.crane_llm/config.json. Settings are resolved in this order, and the first one found wins:
- an explicit argument, e.g.
%%crane_llm gpt-5-mini - the
CRANE_LLM_API_KEY,CRANE_LLM_MODELandCRANE_LLM_BASE_URLenvironment variables - the provider's own variables,
OPENAI_API_KEYandOPENAI_BASE_URL ~/.crane_llm/config.json
A .env file is not a step of its own. It is read first, from the directory you started Jupyter in or any directory above it, and fills in whichever of those variables the environment does not already define.
Using a provider other than OpenAI
Any OpenAI-compatible endpoint works by adding a base_url and a model name, which covers Claude and Gemini through a gateway, and local models with no account at all:
| Provider | base_url |
Example model |
|---|---|---|
| OpenAI | (none needed) | gpt-5 |
| OpenRouter (Claude, Gemini, Llama, …) | https://openrouter.ai/api/v1 |
anthropic/claude-sonnet-4.5 |
| Google Gemini | https://generativelanguage.googleapis.com/v1beta/openai/ |
gemini-2.5-flash |
| Groq | https://api.groq.com/openai/v1 |
qwen/qwen3-32b |
| Ollama, local, no key needed | http://localhost:11434/v1 |
qwen2.5-coder:32b |
import crane_llm
crane_llm.set_api_key(
"sk-or-...",
base_url="https://openrouter.ai/api/v1",
model="anthropic/claude-sonnet-4.5",
)
Or entirely locally:
crane_llm.set_api_key(base_url="http://localhost:11434/v1", model="qwen2.5-coder:32b")
With no base_url the OpenAI Responses API is used, which is what the paper's experiments used. Setting a base_url switches to Chat Completions, because almost no compatible server implements /responses.
Use it
- Run some cells as usual and let them finish.
- Select the cell you want to check.
- Click CRANE-LLM in the toolbar, or run Run CRANE-LLM from the command palette.
The verdict appears under the cell, and the right sidebar shows the full prompt and the raw response.
| Colour | Meaning |
|---|---|
| red | a crash is predicted |
| green | no crash is predicted |
| amber | the response could not be read as a verdict |
| grey | the prediction has gone stale |
The notebook must be idle. Reading the kernel namespace means running code in the kernel, and a kernel serves requests in order, so with cells still running the answer would describe the state afterwards rather than the one you asked about. A prediction goes stale when you edit the cell or run another one.
A checkbox on the toolbar button, in the sidebar and in the command palette turns the runtime information off, which asks the model to predict from the code alone. That is the comparison the approach is built against, and it is also worth trying when a prompt gets too large.
There is a cell magic as well, which needs the widgets extra (pip install crane-llm[widgets]):
%load_ext crane_llm
%%crane_llm
model.fit(x_train, y_train)
The cell body is analysed, not executed.
Requirements and what is not included
Python 3.9+, and JupyterLab 4 which is installed as a dependency. Two things are deliberately left out:
- Notebook 7. Add
pip install notebookif you want that interface rather than JupyterLab. - The ML stack. Runtime summarisation understands pandas, numpy, torch, scikit-learn and TensorFlow objects when those packages are present in your kernel, and quietly skips them when they are not. Your own notebooks will already have brought whichever ones they use.
Links
- Source, issues and full documentation: https://github.com/yarinamomo/crane_llm
- Releases, including installable wheels: https://github.com/yarinamomo/crane_llm/releases
- Paper artefacts, datasets and reproduction instructions: https://github.com/yarinamomo/crane_llm/blob/HEAD/PAPER.md
License
BSD 3-Clause.
Metadata
Release files for crane-llm 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| crane_llm-0.0.1.tar.gz | 116.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| crane_llm-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 240.9 kB
Release files / crane_llm-0.0.1.tar.gz
| Download URL | crane_llm-0.0.1.tar.gz |
|---|---|
| Size | 116.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f6f4a5cb41ffa3a9880161ce9759387bd491f310f6ad3cabeb446026df6c760f
|
|
BLAKE2b-256 checksum How to use checksums |
21a80d194c273f2c4ca88f82c331aef4b6259dfe97824523cc9237668f770fd3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 22, 2026.
Transparency logRelease files / crane_llm-0.0.1-py3-none-any.whl
| Download URL | crane_llm-0.0.1-py3-none-any.whl |
|---|---|
| Size | 124.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6b71e99123bb045aae6d45513df3d88d5e8c0104baf47b3d37546c4b3bc3c167
|
|
BLAKE2b-256 checksum How to use checksums |
198363b036b062f5fbcd90cb1cda0f32e7b936d6210a0d84c3c88f6d22356895
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 22, 2026.
Transparency log