Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/request-nvskills-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Request NVSkills CI

on:
issue_comment:
types: [created]
pull_request:
types: [opened, reopened, synchronize, ready_for_review]
push:

jobs:
request:
if: >
github.event_name == 'pull_request' ||
(github.event_name == 'issue_comment' &&
github.event.issue.pull_request &&
startsWith(github.event.comment.body, '/nvskills-ci')) ||
(github.event_name == 'push' &&
github.actor == (vars.NVSKILLS_SIGNATURE_PUSH_ACTOR || 'nv-skills-ci[bot]') &&
startsWith(github.event.head_commit.message, vars.NVSKILLS_SIGNATURE_COMMIT_TITLE || 'Attach NVSkills validation signatures'))
permissions:
contents: read
pull-requests: read
statuses: read
uses: NVIDIA/skills/.github/workflows/team-request.yml@main
secrets:
NVSKILLS_CI_DISPATCH_TOKEN: ${{ secrets.NVSKILLS_CI_DISPATCH_TOKEN }}
6 changes: 5 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# xFormers CUDA wheels are published on the PyTorch index.
--extra-index-url https://download.pytorch.org/whl/cu124

# --------- pytorch --------- #
torch==2.5.1
torchvision==0.20.1
Expand All @@ -22,9 +25,10 @@ pre-commit==4.0.1 # hooks for applying linters on commit
rich==13.9.4 # beautiful text formatting in terminal
pytest==8.1.1 # tests
sh==2.2.2 # for running bash commands in some tests (linux/macos only)
python-dotenv==1.0.1
transformers==4.54.1
polars==1.12.0
xformers==0.0.28.post3 --index-url https://download.pytorch.org/whl/cu124
xformers==0.0.28.post3
ninja==1.11.1.1
einops==0.8.0
ipython-autotime==0.3.2
Expand Down
101 changes: 101 additions & 0 deletions skills/codonfm-embed/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
---
name: codonfm-embed
description: Extract frozen CLS embeddings from public CodonFM Encodon checkpoints for coding-sequence property modeling. Use when a user explicitly asks for CodonFM or Encodon embeddings, or wants Encodon features for translation-efficiency, expression, or mRNA-stability modeling. Support Encodon embedding_prediction only; do not claim Decodon embedding support in public CodonFM v1.
metadata:
author: "NVIDIA BioNeMo <bionemofeedback@nvidia.com>"
---

# Extract public Encodon embeddings

Extract one frozen CLS vector per coding sequence. This workflow writes
embeddings only; it does not automatically train a downstream regressor.

## Instructions

Resolve the sequence CSV, checkpoint, and output directory from the request and
available files. Validate inputs before extraction. Execution requires the
project's ML dependencies and a compatible NVIDIA GPU. If a required resource
is unavailable, complete the available preparation and return the command with
that prerequisite identified. When extraction is requested and resources are
ready, execute and verify the embedding arrays. A request for preparation ends
with the inputs and command. If no sequences were supplied, report the required
inputs. For Decodon, inspect the [public parser](../../src/runner.py) and
[model configuration](../../src/config.py), explain the missing implementation,
and finish without attempting installation or model development.

For a demonstration use `nvidia/NV-CodonFM-Encodon-80M-v1`, revision
`399ca9fe17b57941a7bebc6788033919b417413c`, file
`NV-CodonFM-Encodon-80M-v1.safetensors` with sibling `config.json`.
Reuse an existing checkpoint or download it when needed for the requested work.
Preserve a user's explicit checkpoint choice.

## Preflight and inputs

1. Confirm `src/runner.py`, `src/data/codon_bert_dataset.py`, and
`src/inference/encodon.py` exist.
2. Accept only `encodon_80m`, `encodon_600m`, or `encodon_1b`.
3. For execution require a `.ckpt`, or `.safetensors` with sibling `config.json`;
input preparation can use a planned path.
4. Require CSV columns `id`, `ref_seq`, `value`, and `split`.

`ref_seq` must be a coding sequence. For extraction-only data, set `value` to
`0.0` and `split` to `test` on every row. Although the public dataset labels
`split` optional, its evaluation path calls the test split and fails without
that column. Normalize sequences to uppercase DNA (`A/C/G/T`) and require
lengths divisible by three. Sequences longer than `--context_length - 2`
codons are truncated rather than embedded in full.

## Examples

Set `CODONFM_DATA_PATH` to the sequence CSV, `CODONFM_CHECKPOINT_PATH` to the
checkpoint, and `CODONFM_RUN_DIR` to your chosen output directory:

```bash
python -m src.runner eval \
--exp_name embed_extract \
--model_name encodon_80m \
--checkpoint_path "$CODONFM_CHECKPOINT_PATH" \
--data_path "$CODONFM_DATA_PATH" \
--process_item codon_sequence \
--dataset_name CodonBertDataset \
--task_type embedding_prediction \
--num_nodes 1 \
--num_gpus 1 \
--num_workers 0 \
--val_batch_size 2 \
--out_dir "$CODONFM_RUN_DIR" \
--predictions_output_dir "$CODONFM_RUN_DIR/predictions"
```

For preparation requests, inspect the CSV directly against the input schema
above and report the test-row count and sequence checks. Extra columns are
allowed; extraction does not require a measured target. This does not require
the ML runtime. The command above performs extraction when resources are ready.

The existing `--dryrun` optionally builds runtime configuration and skips
execution. It requires the ML dependencies, can create the prediction directory,
and does not read the CSV or load weights. Do not use it as evidence that inputs,
checkpoint compatibility, or embedding quality have been validated.

## Outputs

- `embeddings_merged.npy`: shape `(number_of_rows, hidden_size)`.
- `ids_merged.npy`: IDs aligned with the embedding rows.

Use the checked-in Encodon notebooks as downstream-model references:

- `notebooks/4-EnCodon-Downstream-Task-riboNN.ipynb`
- `notebooks/5-EnCodon-Downstream-Task-mRFP-expression.ipynb`
- `notebooks/6-EnCodon-Downstream-Task-mRNA-stability.ipynb`

Do not reference `notebooks/te_predictor.py`, `notebooks/mfe_predictor.py`, or
Decodon notebooks because they are absent from public v1.

## Boundaries

- Do not use for Decodon; the public repository has no Decodon model or
inference class.
- Do not claim a benchmark-trained regressor generalizes to a new organism,
cell type, or assay without new labeled validation data.
- Do not invoke this skill for a generic expression-prediction request that
does not mention CodonFM or Encodon.
4 changes: 4 additions & 0 deletions skills/codonfm-embed/agents/openai.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
interface:
display_name: "CodonFM Embeddings"
short_description: "Extract public Encodon sequence embeddings"
default_prompt: "Use $codonfm-embed to extract Encodon embeddings from my coding-sequence CSV."
38 changes: 38 additions & 0 deletions skills/codonfm-embed/evals/evals.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"skill_name": "codonfm-embed",
"evals": [
{
"id": "codonfm-embed-001",
"prompt": "Validate the supplied sequences.csv and prepare a public Encodon embedding-extraction command. Explain which rows will be processed and how to associate the output embeddings with sequence IDs. Use the supplied public source and checkpoint metadata.",
"files": [
"files/codonfm_source.zip",
"files/encodon_checkpoint.json",
"files/sequences.csv"
],
"expected_output": "Two validated test rows and a public embedding_prediction command with the correct embedding/ID output contract.",
"assertions": [
"The command uses embedding_prediction, codon_sequence, and CodonBertDataset",
"The command specifies --checkpoint_path and output/prediction paths appropriate to the chosen working directory",
"The agent validates both sequence rows, including value and split=test, and explains that evaluation processes the test split",
"The response identifies embeddings_merged.npy and ids_merged.npy and explains their row alignment without fabricating embeddings"
],
"expected_skill": "codonfm-embed",
"expected_script": null
},
{
"id": "codonfm-embed-002",
"prompt": "Does the public CodonFM implementation support extracting Decodon embeddings? Check the supplied source and explain the limitation, if any.",
"files": [
"files/codonfm_source.zip",
"files/encodon_checkpoint.json"
],
"expected_output": "The agent identifies the absence of a public Decodon model and inference implementation.",
"assertions": [
"The agent explains that the supplied public source has no Decodon model/inference implementation and cites inspected files",
"The agent does not invent a Decodon command or attempt to implement the missing model"
],
"expected_skill": "codonfm-embed",
"expected_script": null
}
]
}
Binary file not shown.
33 changes: 33 additions & 0 deletions skills/codonfm-embed/evals/files/encodon_checkpoint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"repo_id": "nvidia/NV-CodonFM-Encodon-80M-v1",
"revision": "399ca9fe17b57941a7bebc6788033919b417413c",
"model_name": "encodon_80m",
"filename": "NV-CodonFM-Encodon-80M-v1.safetensors",
"size_bytes": 307351588,
"config_filename": "config.json",
"config": {
"vocab_size": 69,
"hidden_size": 1024,
"num_hidden_layers": 6,
"num_attention_heads": 8,
"intermediate_size": 4096,
"hidden_act": "gelu",
"hidden_dropout_prob": 0.1,
"attention_probs_dropout_prob": 0.1,
"initializer_range": 0.02,
"layer_norm_eps": 1e-12,
"pad_token_id": 3,
"position_embedding_type": "rotary",
"classifier_dropout": 0.1,
"rotary_theta": 10000.0,
"ignore_index": -100,
"loss_type": "cross_entropy",
"lora": false,
"lora_alpha": 32.0,
"lora_r": 16,
"lora_dropout": 0.1,
"finetune_strategy": "full"
},
"source_url": "https://huggingface.co/nvidia/NV-CodonFM-Encodon-80M-v1/tree/399ca9fe17b57941a7bebc6788033919b417413c",
"weights_included": false
}
3 changes: 3 additions & 0 deletions skills/codonfm-embed/evals/files/sequences.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
id,ref_seq,value,split
example_1,ATGGCTGAATTTCCGTAA,0.0,test
example_2,ATGGCAGAATTTCCGTAA,0.0,test
Loading
Loading