File size: 3,637 Bytes
5686f5b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | ---
language:
- en
license: apache-2.0
library_name: generative-pk
datasets:
- simulated
metrics:
- rmse
- npde
tags:
- generative
- predictive
---
# Hierarchical Neural Process for Pharmacokinetic Data
## Overview
An Amortized Context Neural Process Generative model for Pharmacokinetic Modelling
**Model details:**
- **Authors:** César Ojeda (@cesarali)
- **License:** Apache 2.0
## Intended use
Sample Drug Concentration Behavior and Sample and Prediction of New Points or new Individual
## Runtime Bundle
This repository is the consumer-facing runtime bundle for this PK model.
- Runtime repo: `cesarali/AICME-runtime`
- Native training/artifact repo: `cesarali/AICMEPK_cluster`
- Supported tasks: `generate`, `predict`
- Default task: `generate`
- Load path: `AutoModel.from_pretrained(..., trust_remote_code=True)`
### Installation
You do **not** need to install `sim_priors_pk` to use this runtime bundle.
`transformers` is the public loading entrypoint, but `transformers` alone is
not sufficient because this is a PyTorch model with custom runtime code. A
reliable consumer environment is:
```bash
pip install torch transformers huggingface_hub lightning datasets pandas torchtyping gpytorch pot torchdiffeq torchsde ruamel.yaml pyyaml
```
### Python Usage
```python
from transformers import AutoModel
model = AutoModel.from_pretrained("cesarali/AICME-runtime", trust_remote_code=True)
studies = [
{
"context": [
{
"name_id": "ctx_0",
"observations": [0.2, 0.5, 0.3],
"observation_times": [0.5, 1.0, 2.0],
"dosing": [1.0],
"dosing_type": ["oral"],
"dosing_times": [0.0],
"dosing_name": ["oral"],
}
],
"target": [],
"meta_data": {"study_name": "demo", "substance_name": "drug_x"},
}
]
outputs = model.run_task(
task="generate",
studies=studies,
num_samples=4,
)
print(outputs["results"][0]["samples"])
```
### Predictive Sampling
```python
from transformers import AutoModel
model = AutoModel.from_pretrained("cesarali/AICME-runtime", trust_remote_code=True)
predict_studies = [
{
"context": [
{
"name_id": "ctx_0",
"observations": [0.2, 0.5, 0.3],
"observation_times": [0.5, 1.0, 2.0],
"dosing": [1.0],
"dosing_type": ["oral"],
"dosing_times": [0.0],
"dosing_name": ["oral"],
}
],
"target": [
{
"name_id": "tgt_0",
"observations": [0.25, 0.31],
"observation_times": [0.5, 1.0],
"remaining": [0.0, 0.0, 0.0],
"remaining_times": [2.0, 4.0, 8.0],
"dosing": [1.0],
"dosing_type": ["oral"],
"dosing_times": [0.0],
"dosing_name": ["oral"],
}
],
"meta_data": {"study_name": "demo", "substance_name": "drug_x"},
}
]
outputs = model.run_task(
task="predict",
studies=predict_studies,
num_samples=4,
)
print(outputs["results"][0]["samples"][0]["target"][0]["prediction_samples"])
```
### Notes
- `trust_remote_code=True` is required because this model uses custom Hugging Face Hub runtime code.
- The consumer API is `transformers` + `run_task(...)`; the consumer does not need a local clone of this repository.
- This runtime bundle is intentionally separate from the native training export so you can evaluate both distribution paths in parallel.
|