Metadata-Version: 2.4
Name: waypoint-bio
Version: 1.0.0
Summary: Microbiome foundation models — pretraining, benchmarking, and embedding utilities for Waypoint.
Project-URL: Homepage, https://github.com/Outpost-Bio/waypoint
Project-URL: Repository, https://github.com/Outpost-Bio/waypoint
Project-URL: Bug Tracker, https://github.com/Outpost-Bio/waypoint/issues
Author-email: Outpost Bio <neythen@outpost.bio>
License: 
                                         Apache License
                                   Version 2.0, January 2004
                                http://www.apache.org/licenses/
        
           TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
        
           1. Definitions.
        
              "License" shall mean the terms and conditions for use, reproduction,
              and distribution as defined by Sections 1 through 9 of this document.
        
              "Licensor" shall mean the copyright owner or entity authorized by
              the copyright owner that is granting the License.
        
              "Legal Entity" shall mean the union of the acting entity and all
              other entities that control, are controlled by, or are under common
              control with that entity. For the purposes of this definition,
              "control" means (i) the power, direct or indirect, to cause the
              direction or management of such entity, whether by contract or
              otherwise, or (ii) ownership of fifty percent (50%) or more of the
              outstanding shares, or (iii) beneficial ownership of such entity.
        
              "You" (or "Your") shall mean an individual or Legal Entity
              exercising permissions granted by this License.
        
              "Source" form shall mean the preferred form for making modifications,
              including but not limited to software source code, documentation
              source, and configuration files.
        
              "Object" form shall mean any form resulting from mechanical
              transformation or translation of a Source form, including but
              not limited to compiled object code, generated documentation,
              and conversions to other media types.
        
              "Work" shall mean the work of authorship, whether in Source or
              Object form, made available under the License, as indicated by a
              copyright notice that is included in or attached to the work
              (an example is provided in the Appendix below).
        
              "Derivative Works" shall mean any work, whether in Source or Object
              form, that is based on (or derived from) the Work and for which the
              editorial revisions, annotations, elaborations, or other modifications
              represent, as a whole, an original work of authorship. For the purposes
              of this License, Derivative Works shall not include works that remain
              separable from, or merely link (or bind by name) to the interfaces of,
              the Work and Derivative Works thereof.
        
              "Contribution" shall mean any work of authorship, including
              the original version of the Work and any modifications or additions
              to that Work or Derivative Works thereof, that is intentionally
              submitted to Licensor for inclusion in the Work by the copyright owner
              or by an individual or Legal Entity authorized to submit on behalf of
              the copyright owner. For the purposes of this definition, "submitted"
              means any form of electronic, verbal, or written communication sent
              to the Licensor or its representatives, including but not limited to
              communication on electronic mailing lists, source code control systems,
              and issue tracking systems that are managed by, or on behalf of, the
              Licensor for the purpose of discussing and improving the Work, but
              excluding communication that is conspicuously marked or otherwise
              designated in writing by the copyright owner as "Not a Contribution."
        
              "Contributor" shall mean Licensor and any individual or Legal Entity
              on behalf of whom a Contribution has been received by Licensor and
              subsequently incorporated within the Work.
        
           2. Grant of Copyright License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              copyright license to reproduce, prepare Derivative Works of,
              publicly display, publicly perform, sublicense, and distribute the
              Work and such Derivative Works in Source or Object form.
        
           3. Grant of Patent License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              (except as stated in this section) patent license to make, have made,
              use, offer to sell, sell, import, and otherwise transfer the Work,
              where such license applies only to those patent claims licensable
              by such Contributor that are necessarily infringed by their
              Contribution(s) alone or by combination of their Contribution(s)
              with the Work to which such Contribution(s) was submitted. If You
              institute patent litigation against any entity (including a
              cross-claim or counterclaim in a lawsuit) alleging that the Work
              or a Contribution incorporated within the Work constitutes direct
              or contributory patent infringement, then any patent licenses
              granted to You under this License for that Work shall terminate
              as of the date such litigation is filed.
        
           4. Redistribution. You may reproduce and distribute copies of the
              Work or Derivative Works thereof in any medium, with or without
              modifications, and in Source or Object form, provided that You
              meet the following conditions:
        
              (a) You must give any other recipients of the Work or
                  Derivative Works a copy of this License; and
        
              (b) You must cause any modified files to carry prominent notices
                  stating that You changed the files; and
        
              (c) You must retain, in the Source form of any Derivative Works
                  that You distribute, all copyright, patent, trademark, and
                  attribution notices from the Source form of the Work,
                  excluding those notices that do not pertain to any part of
                  the Derivative Works; and
        
              (d) If the Work includes a "NOTICE" text file as part of its
                  distribution, then any Derivative Works that You distribute must
                  include a readable copy of the attribution notices contained
                  within such NOTICE file, excluding those notices that do not
                  pertain to any part of the Derivative Works, in at least one
                  of the following places: within a NOTICE text file distributed
                  as part of the Derivative Works; within the Source form or
                  documentation, if provided along with the Derivative Works; or,
                  within a display generated by the Derivative Works, if and
                  wherever such third-party notices normally appear. The contents
                  of the NOTICE file are for informational purposes only and
                  do not modify the License. You may add Your own attribution
                  notices within Derivative Works that You distribute, alongside
                  or as an addendum to the NOTICE text from the Work, provided
                  that such additional attribution notices cannot be construed
                  as modifying the License.
        
              You may add Your own copyright statement to Your modifications and
              may provide additional or different license terms and conditions
              for use, reproduction, or distribution of Your modifications, or
              for any such Derivative Works as a whole, provided Your use,
              reproduction, and distribution of the Work otherwise complies with
              the conditions stated in this License.
        
           5. Submission of Contributions. Unless You explicitly state otherwise,
              any Contribution intentionally submitted for inclusion in the Work
              by You to the Licensor shall be under the terms and conditions of
              this License, without any additional terms or conditions.
              Notwithstanding the above, nothing herein shall supersede or modify
              the terms of any separate license agreement you may have executed
              with Licensor regarding such Contributions.
        
           6. Trademarks. This License does not grant permission to use the trade
              names, trademarks, service marks, or product names of the Licensor,
              except as required for reasonable and customary use in describing the
              origin of the Work and reproducing the content of the NOTICE file.
        
           7. Disclaimer of Warranty. Unless required by applicable law or
              agreed to in writing, Licensor provides the Work (and each
              Contributor provides its Contributions) on an "AS IS" BASIS,
              WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
              implied, including, without limitation, any warranties or conditions
              of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
              PARTICULAR PURPOSE. You are solely responsible for determining the
              appropriateness of using or redistributing the Work and assume any
              risks associated with Your exercise of permissions under this License.
        
           8. Limitation of Liability. In no event and under no legal theory,
              whether in tort (including negligence), contract, or otherwise,
              unless required by applicable law (such as deliberate and grossly
              negligent acts) or agreed to in writing, shall any Contributor be
              liable to You for damages, including any direct, indirect, special,
              incidental, or consequential damages of any character arising as a
              result of this License or out of the use or inability to use the
              Work (including but not limited to damages for loss of goodwill,
              work stoppage, computer failure or malfunction, or any and all
              other commercial damages or losses), even if such Contributor
              has been advised of the possibility of such damages.
        
           9. Accepting Warranty or Additional Liability. While redistributing
              the Work or Derivative Works thereof, You may choose to offer,
              and charge a fee for, acceptance of support, warranty, indemnity,
              or other liability obligations and/or rights consistent with this
              License. However, in accepting such obligations, You may act only
              on Your own behalf and on Your sole responsibility, not on behalf
              of any other Contributor, and only if You agree to indemnify,
              defend, and hold each Contributor harmless for any liability
              incurred by, or claims asserted against, such Contributor by reason
              of your accepting any such warranty or additional liability.
        
           END OF TERMS AND CONDITIONS
        
           APPENDIX: How to apply the Apache License to your work.
        
              To apply the Apache License to your work, attach the following
              boilerplate notice, with the fields enclosed by brackets "[]"
              replaced with your own identifying information. (Don't include
              the brackets!)  The text should be enclosed in the appropriate
              comment syntax for the file format. We also recommend that a
              file or class name and description of purpose be included on the
              same "printed page" as the copyright notice for easier
              identification within third-party archives.
        
           Copyright 2026 Outpost Bio
        
           Licensed under the Apache License, Version 2.0 (the "License");
           you may not use this file except in compliance with the License.
           You may obtain a copy of the License at
        
               http://www.apache.org/licenses/LICENSE-2.0
        
           Unless required by applicable law or agreed to in writing, software
           distributed under the License is distributed on an "AS IS" BASIS,
           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
           See the License for the specific language governing permissions and
           limitations under the License.
License-File: LICENSE.txt
License-File: NOTICE.txt
Keywords: bioinformatics,foundation-models,metagenomics,microbiome,transformers
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
Requires-Python: >=3.10
Requires-Dist: accelerate
Requires-Dist: datasets
Requires-Dist: ipykernel
Requires-Dist: nbformat>=5.10.4
Requires-Dist: numpy
Requires-Dist: pandas
Requires-Dist: peft
Requires-Dist: plotly
Requires-Dist: pyarrow
Requires-Dist: pyyaml
Requires-Dist: scikit-learn
Requires-Dist: torch
Requires-Dist: tqdm
Requires-Dist: transformers
Description-Content-Type: text/markdown

# Pretraining and benchmarking Waypoint models

Minimal, self-contained examples for **pretraining** a transformer language model on microbiome taxonomic abundance data and **benchmarking** it on the [Compass](https://huggingface.co/datasets/outpost-bio/Compass) suite of 8 downstream tasks.

All data and models are loaded from the Hugging Face Hub. **Atlas**, **Compass**, and the published **Waypoint** checkpoints are **gated**: you must **request access** on each [dataset](https://huggingface.co/datasets/outpost-bio/Atlas) and [model](https://huggingface.co/outpost-bio/Waypoint-6m). Requests will be auto accepted instantly. After access is granted, **authenticate** locally so downloads succeed (see [Hugging Face access](#hugging-face-access-gated-resources) below).

See [our preprint](https://www.biorxiv.org/content/10.64898/2026.05.02.722381v1) for details.

Join [our slack community](https://join.slack.com/t/outpostbio-waypoint/shared_invite/zt-3w6ivgtba-WJOCkdxiISxQpwVq9ZZxTA) for support and discussion about microbiome foundation models.

## Setup

Install from PyPI:

```bash
pip install waypoint-bio
```

This gives you the `waypoint` command with four subcommands: `pretrain`, `benchmark`, `embed`, and `prepare-dataset`. Configs and example data live inside the package, so no clone is required.

### For contributors

If you want to work on the code itself, clone the repo and use `uv`:

```bash
git clone https://github.com/Outpost-Bio/waypoint.git
cd waypoint
uv sync
```

If `uv sync` fails (for example lockfile resolution errors or a broken cache state), remove the lockfile and sync again so `uv` regenerates it from `pyproject.toml`:

```bash
rm uv.lock
uv sync
```

Then use `uv run waypoint <subcommand> ...` instead of `waypoint <subcommand> ...`.

## Hugging Face access (gated resources)

1. **Request access** on the Hub for every resource you need: the [Atlas](https://huggingface.co/datasets/outpost-bio/Atlas) and [Compass](https://huggingface.co/datasets/outpost-bio/Compass) dataset repos, and each [model](https://huggingface.co/outpost-bio/Waypoint-6m) repo you plan to load. Requests will be auto accepted instantly. 
2. **Log in** on the machine where you run this repo:

   ```bash
   huggingface-cli login
   ```

   Or set **`HF_TOKEN`** to a [read token](https://huggingface.co/docs/hub/security-tokens) with access to those repos.

`waypoint pretrain`, `waypoint benchmark`, and the manual download snippets below all use the same Hub authentication.

## Pretraining

Train a GPT2 causal language model on the Atlas pretraining dataset:

```bash
# Full pretraining (6M parameter model, matches Waypoint-6m)
waypoint pretrain \
    --model_config configs/models/gpt2-6m.yaml \
    --pretrain_config configs/pretraining.yaml \
    --output_dir outputs/pretrain

# Train a larger model
waypoint pretrain \
    --model_config configs/models/gpt2-45m.yaml \
    --pretrain_config configs/pretraining.yaml \
    --output_dir outputs/pretrain_45m

```

The `--model_config` and `--pretrain_config` flags accept either a bundled config name (e.g. `configs/models/gpt2-6m.yaml`, resolved inside the package) or a path to your own YAML.

Available model configs (in `configs/models/`):

| Config | Layers | Embedding | Heads | ~Params |
|---|---|---|---|---|
| `gpt2-6m.yaml` | 8 | 256 | 4 | 6M |
| `gpt2-6m-mgm.yaml` | 8 | 256 | 8 | 6M |
| `gpt2-10m.yaml` | 8 | 320 | 5 | 10M |
| `gpt2-18m.yaml` | 10 | 384 | 6 | 18M |
| `gpt2-29m.yaml` | 12 | 448 | 7 | 29M |
| `gpt2-45m.yaml` | 14 | 512 | 8 | 45M |
| `gpt2-79m.yaml` | 16 | 640 | 10 | 79M |
| `gpt2-85m-gpt-small.yaml` | 12 | 768 | 12 | 85M |
| `gpt2-170m.yaml` | 24 | 768 | 12 | 170M |

The script will:
1. Download the pretraining dataset from `outpost-bio/Atlas`
2. Build a taxonomic tokenizer from the data
3. Compute per-token abundance statistics for z-score ordering
4. Train a GPT2 model with next-token prediction and early stopping
5. Save the best model to `outputs/pretrain/best_model/`

### Pretraining on your own data

Pass `--data PATH` to pretrain on a local file instead of downloading Atlas. The file must be in waypoint format — a `.parquet`/`.csv`/`.tsv` with two list-columns, `Taxa` and `Relative Abundances`:

```bash
waypoint pretrain \
    --data path/to/my_samples.parquet \
    --model_config configs/models/gpt2-6m.yaml \
    --pretrain_config configs/pretraining.yaml \
    --output_dir outputs/pretrain
```

If your data is a sample × taxa abundance matrix instead, serialize it first with `waypoint prepare-dataset` — see [Preparing a dataset from an abundance matrix](#preparing-a-dataset-from-an-abundance-matrix).

## Benchmarking

Evaluate a pretrained model on all 8 Compass tasks:

```bash
# Benchmark the published model from HuggingFace Hub
waypoint benchmark --model outpost-bio/Waypoint-6m --output_dir outputs/benchmark

# Benchmark a locally pretrained model
waypoint benchmark --model outputs/pretrain/best_model --output_dir outputs/benchmark

```

The script will:
1. Load the pretrained model and tokenizer
2. For each task: download data, fine-tune with a classification/regression head, evaluate on the test set
3. Report per-task scores and the final benchmark score (mean across tasks)
4. Save results to `outputs/benchmark/benchmark_results.json`

## Fine-tuning on Your Own Labels

Use `waypoint finetune` to fine-tune a published Waypoint checkpoint from the Hugging Face Hub, or a local checkpoint such as `outputs/pretrain/best_model`, on your own labelled data. The task-specific inputs are command-line arguments; the config file contains the remaining fine-tuning settings.

The input must be a waypoint-format `.parquet`/`.csv`/`.tsv` with `Taxa`, `Relative Abundances`, and a target column. If your labels live in a separate metadata table, merge them when preparing the dataset:

```bash
waypoint prepare-dataset \
    --input my_matrix.csv \
    --metadata sample_labels.csv \
    --output my_dataset.parquet
```

Classification example (Compass `mgnify-biomes`, target `Biome 1`):

```bash
waypoint finetune \
    --model outpost-bio/Waypoint-6m \
    --data data/compass_biome1_smoke.parquet \
    --output_dir outputs/finetune_biome1 \
    --task_type classification \
    --target "Biome 1" \
    --config configs/finetune_classification.yaml
```

Regression example (Compass `mastrorilli`, target `Degradation Rate`; includes `Drug` as a categorical covariate, matching `waypoint benchmark`):

```bash
waypoint finetune \
    --model outpost-bio/Waypoint-6m \
    --data data/compass_degradation_smoke.parquet \
    --output_dir outputs/finetune_degradation \
    --task_type regression \
    --target "Degradation Rate" \
    --covariate_column Drug \
    --config configs/finetune_regression.yaml
```

The config is flat and contains settings such as `max_length`, split fractions, batch size, learning rate, and early stopping patience. To add a categorical covariate, pass `--covariate_column COLUMN`. To use LoRA, set `use_lora: true`; the default target modules are GPT-2 style attention/projection layers (`c_attn`, `c_proj`). By default, `waypoint finetune` makes a random 80/10/10 train/validation/test split. To use predefined splits, set `split_column` to a column with values such as `train`, `validation`, and `test`. Outputs include `finetune_results.json`, per-split metric JSON files, checkpoints, and `best_model/` with the tokenizer, base model, fine-tuned head/adaptor state, and fine-tuning metadata.

### `benchmark_results.json` structure

The file is one JSON object. `results` has one object per benchmark task (eight by default, or fewer if you pass `--tasks`).

**Layout (nesting):**

```
benchmark_results.json
├── model                 string — same value as `waypoint benchmark --model`
├── final_score           number — arithmetic mean of every results[].score
└── results               array of objects, one per task
    └── [each element]
        ├── task          string — internal task id (e.g. "1_biome", "6_drug_degradation")
        ├── task_type     string — "classification" or "regression"
        ├── score         number — task primary metric (macro F1 or R² clamped to [0,1])
        └── metrics       object — extra metrics; keys depend on task_type (see below)
```

**Example** (abbreviated; real files list all tasks and more keys inside `metrics`):

```json
{
  "model": "outpost-bio/Waypoint-6m",
  "final_score": 0.71,
  "results": [
    {
      "task": "1_biome",
      "task_type": "classification",
      "score": 0.65,
      "metrics": {
        "accuracy_Biome 1": 0.72,
        "f1_macro_Biome 1": 0.68,
        "f1_macro_mean": 0.65,
        "roc_auc_mean": 0.81,
        "pr_auc_mean": 0.74
      }
    },
    {
      "task": "6_drug_degradation",
      "task_type": "regression",
      "score": 0.42,
      "metrics": {
        "mse_Degradation Rate": 0.019,
        "r2_Degradation Rate": 0.44,
        "pearson_Degradation Rate": 0.67,
        "r2_mean": 0.44
      }
    }
  ]
}
```

**`metrics` keys** (each target column from the task produces a set of suffixed keys; `<target>` is the column name, e.g. `Biome 1`, `Degradation Rate`):

| `task_type` | Typical keys |
|---|---|
| `classification` | `accuracy_<target>`, `balanced_accuracy_<target>`, `f1_macro_<target>`; if probabilities exist: binary `roc_auc_<target>`, `pr_auc_<target>`, or multiclass `roc_auc_macro_ovo_<target>`, `pr_auc_macro_ovo_<target>`. Means: `f1_macro_mean`, optionally `roc_auc_mean`, `pr_auc_mean`. |
| `regression` | `mse_<target>`, `r2_<target>`; often `pearson_<target>`, `spearman_<target>`. Mean: `r2_mean`. |

## Generating embeddings

Use `waypoint embed` to produce one fixed-size embedding vector per sample with a pretrained Waypoint model (no fine-tuning required). Input is a waypoint-format file — if you only have an abundance matrix, run `waypoint prepare-dataset` first to serialize it.

```bash
waypoint embed \
    --model outpost-bio/Waypoint-6m \
    --data path/to/samples.parquet \
    --output embeddings.parquet
```

Output is a parquet (or CSV, if `--output` ends in `.csv`) indexed by sample ID with columns `dim_0 … dim_{H-1}`, where `H` is the model's hidden size.

Useful flags:

| Flag | Default | Notes |
|---|---|---|
| `--pooling` | `last_token` | How to collapse the token sequence: `last_token`, `mean`, `first_token`, `cls_token`. |
| `--batch_size` | `32` | |
| `--max_length` | `512` | Truncates samples with more taxa than this (after sorting by abundance / z-score). |
| `--device` | auto | `cuda`, `mps`, or `cpu`. |

## Preparing a dataset from an abundance matrix

`waypoint prepare-dataset` converts a sample × taxa abundance matrix into a serialized waypoint-format file. Run it once; the output can then be passed to `waypoint pretrain --data` or `waypoint embed --data` (or loaded directly in Python).

```bash
# MGnify-style TSV (taxa as rows, samples as columns; auto-detected)
waypoint prepare-dataset \
    --input examples/abundance_matrix.tsv \
    --output examples/abundance_matrix.parquet

# Then use it anywhere:
waypoint embed    --model outpost-bio/Waypoint-6m --data examples/abundance_matrix.parquet --output emb.parquet
waypoint pretrain --data examples/abundance_matrix.parquet --model_config configs/models/gpt2-6m.yaml --pretrain_config configs/pretraining.yaml --output_dir outputs/pretrain
```

### Supported matrix layouts

| `--orientation` | Layout | Example |
|---|---|---|
| `samples_as_rows` | Rows = samples, columns = taxa, first column = sample ID. | A CSV exported from a phyloseq OTU table. |
| `taxa_as_rows` | Rows = taxa, columns = samples, first column = taxonomy lineage. | MGnify amplicon abundance TSVs. |
| `auto` (default) | Detected from the first column header (treated as `taxa_as_rows` if the header is `taxonomy`, `lineage`, `taxon`, `otu`, or `#otu id`). | |

Taxa identifiers should be **full lineage strings** (`k__Bacteria; p__Firmicutes; … ; g__Lactobacillus`) so the tokenizer can extract whichever rank the model was trained at (genus by default) and fall back to a higher rank when a lineage is shorter. If your column / row headers are bare names instead (e.g. just `Lactobacillus`), pass `--taxonomy_format genus` (or `species`, `family`, …) to prefix them with the rank tag — but be aware this disables higher-rank fallback.

### Other flags

| Flag | Default | Notes |
|---|---|---|
| `--no_normalize` | off | Skip row-normalization (use if the matrix already holds relative abundances). |
| `--keep_zeros` | off | Keep zero-abundance entries in each sample's lists. |
| `--metadata PATH` | none | CSV/TSV/parquet of per-sample metadata (indexed by sample ID); columns are merged into the output for use as labels/targets. |

A tiny MGnify-style example lives at `examples/abundance_matrix.tsv` (6 samples, 11 lineages at varying depths).

### Using the converter from Python

```python
from waypoint_bio import load_abundance_matrix, matrix_to_waypoint_df

matrix = load_abundance_matrix("examples/abundance_matrix.tsv")  # samples x taxa
df = matrix_to_waypoint_df(matrix)
df.to_parquet("my_dataset.parquet")
# df has columns: 'Taxa' (list[str]) and 'Relative Abundances' (list[float]),
# indexed by sample ID. Feed it to MicrobiomePretrainingDataset /
# MicrobiomeBenchmarkDataset directly, or save it for the CLI scripts.
```

## Benchmark Tasks

| # | Task | Type | Dataset | Targets |
|---|---|---|---|---|
| 1 | Biome classification | Classification | mgnify-biomes | Biome 1–5 |
| 2 | Gut biome classification | Classification | mgnify-biomes | Biome 4, 5 |
| 3 | SIC classification | Classification | handuo | SIC Name |
| 4 | Drug vs. control | Classification | handuo | Control |
| 5 | Drug class | Classification | handuo | ATC Class |
| 6 | Drug degradation | Regression | mastrorilli | Degradation Rate |
| 7 | Infant age | Classification | roswall | Timepoint |
| 8 | Birth mode | Classification | roswall | Delivery Mode |

**Scoring**: Classification tasks use macro-averaged F1; regression uses R² (clamped to [0,1]). The final benchmark score is the mean of all task scores.

## Repository Structure

```
├── examples/
│   └── abundance_matrix.tsv       # MGnify-style example input for `waypoint prepare-dataset`
├── src/
│   └── waypoint_bio/
│       ├── cli.py                 # `waypoint` command dispatcher
│       ├── pretrain.py            # Pretraining command
│       ├── benchmark.py           # Compass benchmark command
│       ├── finetune.py            # User-provided labelled-data fine-tuning command
│       ├── embed.py               # Generate per-sample embeddings
│       ├── prepare_dataset.py     # Convert abundance matrices into waypoint format
│       ├── tokenizer.py           # TaxonomicTokenizer
│       ├── dataset.py             # Torch datasets + waypoint-format I/O helpers
│       ├── abundance_matrix.py    # Matrix conversion helpers
│       ├── models.py              # Classification/regression heads
│       ├── scoring.py             # Metric computation and task scoring
│       └── configs/               # Bundled model/training/fine-tuning configs
├── pyproject.toml
└── README.md
```


## Pretraining dataset

The pretraining corpus is **[outpost-bio/Atlas](https://huggingface.co/datasets/outpost-bio/Atlas)** on the Hugging Face Hub (**gated**; requires access and [authentication](#hugging-face-access-gated-resources)). `waypoint pretrain` loads the **`pretrain`** split with the [`datasets`](https://huggingface.co/docs/datasets) library. Rows provide microbiome samples as paired **`Taxa`** and **`Relative Abundances`** lists, which the training code turns into token sequences.

**Manual download.** After you are approved and logged in, download the dataset in your own code with:

```python
from datasets import load_dataset
ds = load_dataset("outpost-bio/Atlas", split="pretrain")
```

Or use the [Hugging Face CLI](https://huggingface.co/docs/huggingface_hub/guides/cli) to save a local copy (optional):

```bash
hf download outpost-bio/Atlas --repo-type dataset --local-dir ./data/atlas
```

## Benchmark datasets

Downstream evaluation uses **[outpost-bio/Compass](https://huggingface.co/datasets/outpost-bio/Compass)** (**gated**; requires access and [authentication](#hugging-face-access-gated-resources)). This is a multi-configuration dataset: each **configuration** matches one source study and exposes **`train`**, **`validation`**, and **`test`** splits. `waypoint benchmark` calls `load_dataset("outpost-bio/Compass", "<config>")` per task.

| Task # | Hub configuration | Notes |
|--------|-------------------|--------|
| 1–2 | `mgnify-biomes` | Biome classification |
| 3–5 | `handuo` | SIC / drug-related classification |
| 6 | `mastrorilli` | Drug degradation (regression); includes a **`Drug`** column |
| 7–8 | `roswall` | Infant cohort classification |

**Manual download.** Example for one configuration:

```python
from datasets import load_dataset
ds = load_dataset("outpost-bio/Compass", "mgnify-biomes")
# ds["train"], ds["validation"], ds["test"]
```

## Models

**Published checkpoints** are Hugging Face **model** repositories (for example **`outpost-bio/Waypoint-6m`**, which matches the default `gpt2-6m` setup). They are **gated**; request access on each model page and [authenticate](#hugging-face-access-gated-resources) before loading from the Hub. Each repo contains the pretrained weights, tokenizer files, and (when available) **`token_std_means.parquet`** for z-score ordering of tokens during fine-tuning.

**Using models in this repo**

- **Benchmark:** pass the Hub id or a local directory to `waypoint benchmark --model`:

  ```bash
  waypoint benchmark --model outpost-bio/Waypoint-6m --output_dir outputs/benchmark
  waypoint benchmark --model outputs/pretrain/best_model --output_dir outputs/benchmark
  ```

- **From Python:** load with `transformers` (the benchmark uses `AutoTokenizer` and `AutoModel` with `trust_remote_code=True` because the tokenizer is custom):

  ```python
  from transformers import AutoTokenizer, AutoModel
  tok = AutoTokenizer.from_pretrained("outpost-bio/Waypoint-6m", trust_remote_code=True)
  model = AutoModel.from_pretrained("outpost-bio/Waypoint-6m")
  ```

**Local checkpoints.** After `waypoint pretrain` finishes, use **`outputs/pretrain/best_model/`** (or your `--output_dir/best_model`): it holds the saved GPT-2 LM head, tokenizer, and `token_std_means.parquet`, and can be passed to `--model` the same way as a Hub id.

## License
apache-2.0

Maintainer / contact: neythen@outpost.bio
