Skip to main content

friendly parrot

Cotorra: a configurable trainer

PyPI Version DOI SWH tests codecov

🦜 the wild parakeet of Chicago's south side

About

This repo provides a configurable trainer for generative event models on tokenized timelines. It also supports three types of downstream inference on held-out data: (i) representation-based, (ii) generative, and (iii) inference via supervised finetuning. Cotorra is a Spanish term for a small-to-medium sized parrot, particularly the Monk parakeet. Monk parakeets were introduced to the south side of Chicago, where they have flourished. 1 The library benefits from previous experience training foundation models on tokenized electronic health records. 2 3 4 5 6

Installation

Install the latest release from PyPI:

pip install "cotorra" \
  --index-url https://download.pytorch.org/whl/cu128 \
  --extra-index-url https://pypi.org/simple

This installs the cotorra command. To see it run end to end on public data, follow the MIMIC-IV demo.

cotorra generative-score also needs SGLang, which the gen extra installs (pip install "cotorra[gen]>=26.11.1") on Linux with an NVIDIA GPU and Python 3.11 or 3.12, or 3.13 once a Rust compiler and a few build tools are in place; see the MIMIC-IV demo's generative step.

On a Mac, LightGBM and XGBoost look for Homebrew's OpenMP runtime, while PyTorch brings its own: without Homebrew's, importing cotorra fails, and with it, a process holding both runtimes can crash. The cotorra command sees to this itself, starting again with PyTorch's runtime first on DYLD_LIBRARY_PATH. To import cotorra in Python of your own, such as a notebook, set that before Python starts:

export DYLD_LIBRARY_PATH="$(python -c 'import os, torch; print(os.path.dirname(torch.__file__))')/lib"

Usage

Each stage of the pipeline is a cotorra command, driven by a YAML config:

train / tune  →  extract  →  rep-based-score
               ↘  generative-score

baseline-score (transformer-free)

The documentation covers:

  • Inputs: the tokenized timelines and tables the commands read, as cocoa writes them.
  • Training: fitting a model with cotorra train or cotorra tune, including how records are packed into rows and the secondary heads it can train alongside next-token prediction.
  • Extraction: hidden-state representations and head predictions from a trained model, with cotorra extract.
  • Scoring: outcome scores for held-out data, from an estimator fit on extracted features (cotorra rep-based-score), from sampled trajectories (cotorra generative-score), or from a supervised head; and baselines that need no model (cotorra baseline-score).
  • Configuration: the YAML config each command reads, and how to change its keys on the command line.
  • The CLI reference, with every command's options, and the recipes, worked examples from a run on public data to transfer learning.

Contributing

Bug reports, fixes, recipes, and new features are all welcome. The contributing guide explains how to report an issue, set up a development install, and open a pull request.

  1. L. Gersony, "The Quiet Victory of Chicago’s Monk Parakeets," The Chicago Maroon, 23 January 2022, https://chicagomaroon.com/28830/grey-city/quiet-protest-chicagos-monk-parakeets/ ↩

  2. M. Burkhart, B. Ramadan, Z. Liao, K. Chhikara, J. Rojas, W. Parker, & B. Beaulieu-Jones, Foundation models for electronic health records: representation dynamics and transferability, arXiv:2504.10422 ↩

  3. M. Burkhart, B. Ramadan, L. Solo, W. Parker, & B. Beaulieu-Jones, Quantifying surprise in clinical care: Detecting highly informative events in electronic health records with foundation models, Pacific Symposium on Biocomputing 31 (2026), 173–188 ↩

  4. L. Solo, M. McDermott, W. Parker, B. Ramadan, M. Burkhart, & B. Beaulieu-Jones, Efficient generative prediction for EHR foundation models: the SCOPE and REACH estimators, arXiv:2602.03730 ↩

  5. I. Lee, L. Solo, M. Burkhart, B. Ramadan, W. Parker, & B. Beaulieu-Jones, Representation before training: a fixed-budget benchmark for generative medical event models, arXiv:2604.16775, to appear in ML4H 2026 ↩

  6. M. Burkhart, L. Solo, I. Lee, S. Charles, Z. Liao, K. Chhikara, D. Therese, W.-T. Liao, C. Gao, W. Parker, & B. Beaulieu-Jones, Federated generative event models for tokenized electronic health records, arXiv:2608.02939 ↩

Metadata

Release files for cotorra 26.11.1

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

Source distribution (sdist)

Source distribution for cotorra 26.11.1
File Size Uploaded Provenance Actions
cotorra-26.11.1.tar.gz 199.3 kB With provenance Details for cotorra-26.11.1.tar.gz

Built distribution (wheel)

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

Total release size: 275.7 kB

Release files / cotorra-26.11.1.tar.gz

Download URL cotorra-26.11.1.tar.gz
Size 199.3 kB
Tags Source
SHA-256 checksum
How to use checksums
d1f3fe40dfacd6fbe10eaab8efef7058c95b21a57ed78d1f757759de85c8845b
BLAKE2b-256 checksum
How to use checksums
f2a0ab2c04c0bb304d810318ee1588ac2c6b33d2ff3a5c6927f91f7d060f5106
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 11, 2026.

Transparency log

Release files / cotorra-26.11.1-py3-none-any.whl

Download URL cotorra-26.11.1-py3-none-any.whl
Size 76.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f11d0ec9f7732f1f74e15f46fb05a33ca8358696dad669e6bc4ebfcb15a45aaf
BLAKE2b-256 checksum
How to use checksums
06e71c9ff7b748e1f9a68f58cbd9ae5442f435181078f159b3cc36dbdc40b314
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 11, 2026.

Transparency log

Security for cotorra 26.11.1

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 cotorra-26.11.1.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 11, 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.

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