Skip to main content

neopatient: language-controlled generation of artificial patient records

neopatient generation pipeline


neopatient generates useful, realistic (but artificial), longitudinal patient records. Just write out (in natural language) what you do and do not want the patients to be like. neopatient handles steps like sampling, chunking, batching, structuring, and verification. It cost-effectively generates lots (tens of thousands) of records, each up to 100K+ tokens, in the MEDS format.

Unlike rule-based generators like Synthea, patient trajectories are language-controlled -- producing a new kind of cohort doesn't require writing simulation code or state machines, just a description.

Pipeline

Given a positive description (what the patients should be like) and a negative description (what they should not be like), neopatient runs a multi-stage pipeline:

  1. Sampling -- An LLM generates individualized "patient recipes" (demographics, temporal segments, event densities) that match your descriptions, guided by reference statistics from real record distributions.
  2. Generation -- For each recipe, an LLM generates longitudinal medical events across temporal segments, with appropriate code systems (SNOMED, ICD-10, LOINC, RxNorm, CPT, etc.).
  3. Matching -- Free-text event descriptions are matched to real medical codes via a precomputed vector database (ChromaDB + embeddings over standard terminologies).
  4. Verification -- An LLM checks each completed record against the original positive/negative descriptions, filtering out records that don't meet the specification.

The output is a Parquet file in MEDS format. For large cohorts, neopatient uses LLM batch APIs with a state file for resumability.

Usage

Generate a single patient:

# make sure OPENAI_API_KEY is set
uvx neopatient single \
  --positive "Adult patient with type 2 diabetes managed with metformin, with at least 5 years of follow-up" \
  --negative "Patient with type 1 diabetes or gestational diabetes" \
  --out patient.parquet

Generate a cohort of patients:

uvx neopatient cohort \
  --positive "Adult patient with type 2 diabetes managed with metformin, with at least 5 years of follow-up" \
  --negative "Patient with type 1 diabetes or gestational diabetes" \
  --size 1000 \
  --state-file state.json \
  --out cohort.parquet

The --state-file tracks pipeline progress, so if a long-running job is interrupted, rerunning the same command resumes where it left off.

Use --record-type to choose between ehr-inpatient, ehr-outpatient (default), and claims, which determines the available code systems and timestamp precision. Use --generator, --sampler, and --verifier to pick models for each pipeline stage.

Vector database

The matching stage relies on a precomputed vector database of medical codes. A default database (embedded with Qwen3-Embedding-8B) is downloaded automatically from Hugging Face on first use. To build your own from a parquet file of codes and descriptions:

uvx --from neopatient neopatient-db --parquet_path codes.parquet --db_dir ./my_db

Then pass --db_dir ./my_db to neopatient.

Metadata

Release files for neopatient 0.1.0

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

Source distribution (sdist)

Source distribution for neopatient 0.1.0
File Size Uploaded Provenance Actions
neopatient-0.1.0.tar.gz 480.1 kB Without provenance Details for neopatient-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 969.6 kB

Release files / neopatient-0.1.0.tar.gz

Download URL neopatient-0.1.0.tar.gz
Size 480.1 kB
Tags Source
SHA-256 checksum
How to use checksums
474fec24a1753f910222ccc857587d36250bb421d0da1964f7bc3130cba38bd4
BLAKE2b-256 checksum
How to use checksums
1825566a53614b88e1bc17835970e367600e89e2c73e6d1ece890a41de08e973
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / neopatient-0.1.0-py3-none-any.whl

Download URL neopatient-0.1.0-py3-none-any.whl
Size 489.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e6c602b9898d386b99c5403af2e37cae80ae90900d38bd155128d644c4631290
BLAKE2b-256 checksum
How to use checksums
2ef31b6492ba59cda811d14b228d3585cad0702696a259b3fbf7e18f35389fca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for neopatient 0.1.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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

0.1.0 This release

2 release files No provenance

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