Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Lispyn

A new way to write and run machine-learning experiments.

Lisp for expressive experiments · Python for the ecosystem · Jupyter for sharing results.

PyPI Tests Python Apache-2.0

Go from experiment idea to reproducible results in one Hy/Lisp file. Write expressive experiments using Lispyn macros, run your existing PyTorch models, and publish the result as an ordinary, executable Jupyter notebook—complete with parameters, explanations, training curves and metrics. Keep the Python ecosystem you already know.

Lispyn adds a new way to author experiments, not a new training framework. Your data, models and optimizers stay native PyTorch.

Explore all 43 supported macros · Hy source · Executed notebook · Example gallery

Install

Requires Python 3.10+. Use a virtual environment if possible.

python -m pip install --upgrade "lispyn[notebook,plots]"
python -m pip install torch
lispyn doctor

For a CUDA/ROCm or platform-specific PyTorch build, follow the official installation guide. Lispyn supports optional extras for pandas, vision, audio and PEFT; the example below needs only PyTorch, Jupyter and Matplotlib.

From a Lisp experiment to the finished notebook

This is actual PyTorch training, not a fabricated plot or an estimated metric. The model trains on deliberately small synthetic classification data (CPU only, no downloads) and reserves a held-out test subset. The numbers are illustrative, not scientific performance claims.

Below is a complete, runnable notebook example in Hy, followed immediately by its actual recorded metrics and training graph. You can also open the generated .ipynb to inspect all the executed Python/Jupyter cells.

A complete notebook written in Hy/Lispyn

This is the complete, runnable source of examples/quickstart.hy. The md macros become notebook Markdown cells; the remaining forms become ordinary Python code cells.

; Real CPU PyTorch training on deliberately small SYNTHETIC data.
; Every notebook cell and the final figure are recorded, not fabricated.
(require lispyn.macros [md])
(md "# Quickstart · from Lisp to an executed research notebook"
    "A native PyTorch classifier on synthetic data. We reserve an unseen"
    "test partition for a final, illustrative evaluation.")

(require lispyn.macros [experiment-params])
(experiment-params
  (setv seed 42)
  (setv epochs 10))

(require lispyn.macros [md])
(md "## 1. Prepare data and isolate the test set"
    "Create two-dimensional toy samples; split them before training.")

(require lispyn.macros [train-val-test])
(import torch)
(torch.manual_seed seed)
(setv features
  (torch.tensor
    [[0.0 0.0] [0.0 1.0] [1.0 0.0] [1.0 1.0]
     [0.2 0.3] [0.3 0.9] [0.9 0.3] [0.8 0.9]
     [0.1 0.2] [0.1 0.8] [0.9 0.2] [0.9 0.8]
     [0.4 0.1] [0.4 0.9] [0.7 0.1] [0.7 0.9]]))
(setv labels (torch.tensor [0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1]))
(setv dataset (torch.utils.data.TensorDataset features labels))
(setv [training validation held-out]
  (train-val-test dataset :validation-fraction 0.25
    :test-fraction 0.25 :seed seed))
(print "Samples:" (len training) "train," (len validation)
  "validation," (len held-out) "held-out test")

(require lispyn.macros [md])
(md "## 2. Train a native PyTorch model"
    "Lispyn handles the training loop and early stopping; model, optimizer"
    "and tensors remain ordinary PyTorch objects.")

(require lispyn.macros [train-until])
(setv model (torch.nn.Linear 2 2))
(setv run
  (train-until model training 3
    :validation validation :loss-fn (torch.nn.CrossEntropyLoss)
    :epochs epochs :batch-size 4 :lr 0.05 :seed seed :device "cpu"))
(print "Completed epochs:" (len (get run.history "train_loss")))

(require lispyn.macros [md])
(md "## 3. Report and evaluate"
    "Summarize recorded metrics, then evaluate the untouched test subset once."
    "This tiny synthetic dataset is a workflow demo, not research evidence.")

(require lispyn.macros [report-run narrate metric-table])
(import lispyn.training [evaluate-metrics])
(report-run run :title "PyTorch baseline · recorded metrics")
(setv held-out-loader (torch.utils.data.DataLoader held-out :batch_size 4))
(setv test-scores
  (evaluate-metrics run.model held-out-loader
    :loss-fn (torch.nn.CrossEntropyLoss) :metrics "accuracy" :device "cpu"))
(narrate "Held-out test accuracy: **{accuracy:.1%}**"
  :accuracy (get test-scores "accuracy"))
(metric-table
  {"best_val_loss" (min (get run.history "val_loss"))
   "test_loss" (get test-scores "loss")
   "test_accuracy" (get test-scores "accuracy")}
  :title "Recorded experiment scores" :precision 4)

(require lispyn.macros [md])
(md "## 4. Plot the real training history"
    "Generated from the run.history actually recorded above, never fake curves.")

(require lispyn.macros [curve])
(curve run :metric "loss" :theme "paper"
  :title "Quickstart · real PyTorch training"
  :subtitle "Train versus validation loss · synthetic dataset"
  :figsize [8 4.5]
  :save "../example_generated_notebooks/assets/quickstart_training_curves.png")

Results from the executed notebook

These values come directly from the executed Jupyter notebook, not from manually written or simulated results.

Dataset and execution

Samples: 8 train, 4 validation, 4 held-out test
Completed epochs: 10

Training report

PyTorch baseline · recorded metrics

Epochs recorded: 10 Early stopping: no

Metrics

Metric Optimize Best epoch Best value Final value
train_loss min 10 0.440579 0.440579
val_loss min 10 0.429638 0.429638

Best epochs are 1-based. This report contains only metric summaries, not raw dataset rows, predictions, or model weights.

Held-out evaluation

Held-out test accuracy: 50.0%

Recorded experiment scores

Metric Value
best_val_loss 0.4296
test_loss 0.7664
test_accuracy 0.5

Final graph — training vs. validation loss

Loss curves generated by Lispyn from real quickstart training

Open the full executed notebook · View original Hy source

Verified Hy source SHA-256: 1712e572ac12fde0249c8fc45efcd222cc586b40b8b580bbea1680e1cb6384ea.

The data are deliberately synthetic and small: this demonstrates the workflow, not model performance on a real research task.

Reproduce the result

Run the exact Hy file shown above:

# Build only: Hy becomes an inspectable Python notebook; no training.
lispyn build examples/quickstart.hy

# Actually train on CPU and capture *every* notebook cell and figure.
lispyn execute examples/quickstart.hy \
  -o example_generated_notebooks/quickstart_executed.ipynb

# Verify the source fingerprint and that code cells executed without errors.
lispyn audit example_generated_notebooks/quickstart_executed.ipynb \
  --source examples/quickstart.hy

# Export the notebook as a portable Markdown report.
lispyn export example_generated_notebooks/quickstart_executed.ipynb \
  -o quickstart_report.md

The plot is written to example_generated_notebooks/assets/quickstart_training_curves.png by the curve Hy macro, from the actual training history. To change an experiment parameter without editing the source, use lispyn build examples/quickstart.hy --set epochs=20.

Discover your best experiments automatically

Save runs with :experiment-dir "runs/baseline" from the native train-until macro, then compare all saved histories without manually listing each run:

lispyn leaderboard runs/ --metric loss --rank-by best -o leaderboard.md

Or write the comparison directly inside your Hy notebook:

(require lispyn.macros [experiment-leaderboard])
(experiment-leaderboard "runs" :metric "accuracy" :mode "max"
  :save "runs/leaderboard.md")

Lispyn discovers completed run histories, ranks their best or final scores and shows a shareable Markdown table. It skips incomplete or incompatible runs by default (--strict turns that into an error), and supports CSV/JSON export. It reads only saved aggregate metrics, not checkpoints or training data. Rankings are descriptive, not proof of statistical significance.

Explore the synthetic Hy leaderboard example or see the macro catalog.

Keep experimenting in Hy

You can use the same approach with early stopping, grouped and temporal cross-validation, parameter sweeps, model-head fine-tuning, confusion matrices, evidence checks and reusable chart styles. The complete macro reference documents all 43 public macros with Hy examples.

Explore additional examples in examples/ and their compiled Jupyter notebooks. Lispyn is an alpha project; interfaces may change as it evolves.

For contributors: add a defmacro in src/lispyn/macros.hy, update supported_macros/README.md and include a runnable example. CI checks the catalog against the public macros.


Created by Eduardo J. Barrios · Apache-2.0 · GitHub issues

Metadata

Release files for lispyn 0.28.0a1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lispyn 0.28.0a1
File Size Uploaded Provenance Actions
lispyn-0.28.0a1.tar.gz 124.9 kB With provenance Details for lispyn-0.28.0a1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lispyn 0.28.0a1
File Interpreter ABI Platform Actions
lispyn-0.28.0a1-py3-none-any.whl Python 3 none any Details for lispyn-0.28.0a1-py3-none-any.whl

Total release size: 206.4 kB

Release files / lispyn-0.28.0a1.tar.gz

Download URL lispyn-0.28.0a1.tar.gz
Size 124.9 kB
Tags Source
SHA-256 checksum
How to use checksums
c151bb60624a7a1823d3b20d265c63baa48b14356ab59650e0992639d927a51b
BLAKE2b-256 checksum
How to use checksums
428bfb8c733ba4bc8041762ced99bbae9670195f0eaa4c987995e25b29e791b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 16, 2026.

Transparency log

Release files / lispyn-0.28.0a1-py3-none-any.whl

Download URL lispyn-0.28.0a1-py3-none-any.whl
Size 81.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cda5efa3bee280a07ae64032706dcf0eb5aefde412f40cf54a7856f0e553f419
BLAKE2b-256 checksum
How to use checksums
73a7e640d7b5678d2d22335f23c891f99f72a2a842f0389249f5068cc11394ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 16, 2026.

Transparency log

Security for lispyn 0.28.0a1

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for lispyn-0.28.0a1.tar.gz

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 Nov 16, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page