CAFA5 with UniProt metadata
CAFA5 protein function prediction data joined with UniProt metadata and GO term metadata, prepared for the BioReason-Pro project.
Source
Raw sequences and GO labels are pulled from AmelieSchreiber/cafa_5 (public mirror of the CAFA5 challenge files: train_sequences.fasta, train_terms.tsv, testsuperset.fasta, testsuperset-taxon-list.tsv, IA.txt, go-basic.obo). Per-protein metadata (protein_names, protein_function, organism, subcellular_location) is fetched from the UniProt REST API via the /accessions batch endpoint. The test split's protein_function field is rewound to the 2023-01 SwissProt snapshot (parsed from uniprot_sprot.xml) to remove any post-CAFA5 leakage, and PubMed citations are stripped.
Configs
cafa5_reasoning
train: 132,791 rowstest: 141,798 rows- Columns:
protein_id,protein_names,protein_function,organism,length,subcellular_location,sequence,go_ids,go_bp,go_mf,go_cc
go_metadata
- 43,248 rows
- Columns:
go_id,go_name,go_def,go_aspect,go_depth,go_weight go_weightis the CAFA5 information-accretion (IA) score;go_depthis the shortest-path depth ingo-basic.obo.
Usage
from datasets import load_dataset
ds = load_dataset("emngarcia/cafa5", "cafa5_reasoning")
go = load_dataset("emngarcia/cafa5", "go_metadata", split="train")
Methodology and design choices
This section documents the decisions that produced this dataset and the
modality-ablation experiments shipped alongside it under ablations/.
Why this dataset exists
BioReason-Pro's training and evaluation pipelines default to
wanglab/cafa5. That repo is a gated dataset on Hugging Face β
downloads require manual approval from the wanglab maintainers, and our
access request returned the "awaiting review" status for an extended
period. To unblock the project, we rebuilt the pieces of wanglab/cafa5
we actually need from public inputs and published them here.
Dataset build: choices and trade-offs
- Raw source. Pulled from public
AmelieSchreiber/cafa_5because it contains the exact CAFA5 challenge files (train_sequences.fasta,train_terms.tsv,testsuperset.fasta,testsuperset-taxon-list.tsv,IA.txt,go-basic.obo) with no gating. - UniProt metadata fetch. The first implementation used 500-accession
OR-joined queries against the UniProt search endpoint and hit HTTP 400.
Replaced with the
/accessionsbatch endpoint (comma-separated, batch size 200) with skip-if-exists guards so the long fetch is resumable. This covers all ~140k train + ~141k test accessions. - Temporal leakage fix for the test split. UniProt's current entries
may have
protein_functiontext written after the CAFA5 challenge closed, so a model trained on UniProt-derived prompts could see future knowledge at eval time. We re-parseduniprot_sprot.xml(the 2023-01 SwissProt snapshot, 7.1 GB extracted, ~569k entries) and rewoundprotein_functionfor the test split to its 2023-01 form. The pure-Python parser replaces an earlierseqkitshell-out so the pipeline doesn't depend on shelling out. - PubMed citation cleanup. Function descriptions in UniProt carry
(PubMed:N)and(PMID:N)markers that bias the model toward citation patterns. Stripped in cells 96β108. - GO term metadata.
go_depthis computed by shortest-path traversal ingo-basic.obo;go_weightis the official CAFA5 IA (information accretion) score taken straight fromIA.txt. - Storage. We initially tried
push_to_hub("wanglab/cafa5", ...)(writes were 403; that token has no write access there anyway). We pivoted to local parquet files at_local_dataset/and then pushed here from a write-scoped token.
Configs we did not publish (yet)
wanglab/cafa5 ships dozens of derived configs
(interlabel_test_dataset_with_gogpt_memorized_copy, interpro_metadata,
ppi_metadata, structures_*, temporal_holdout_*, β¦). This release
only contains the two raw-ish configs that the project depends on for
ablations:
cafa5_reasoningβ the joined CAFA5 + UniProt-metadata tablego_metadataβ per-term GO definitions, aspects, depth, IA weight
Downstream notebooks 002 β¦ 021 in BioReason-Pro/data/ build the
remaining configs (PPI, InterPro features, the InterLabel test set,
GoGPT-augmented prompts, temporal holdouts). Those still reference
wanglab/cafa5 for inputs and have not been retargeted.
Ablation pipeline adaptations
The eval entry point β ablations/eval_cafa5.py β was originally written
to consume wanglab/cafa5's curated
interlabel_test_dataset_with_gogpt_memorized_copy config (chat-template
prompts pre-assembled, plus GoGPT predictions in go_pred and InterPro
features). That config is not in this repo. We adapted instead of
reproducing it.
- Bypass
load_cafa5_datasetfor this dataset. Addedablations/dataset_adapter.py::load_emngarcia_cafa5_eval. When--cafa5_dataset emngarcia/cafa5is passed, eval_cafa5 calls the adapter directly and the heavy multi-config loader is skipped. - Prompt template choice. Selected
CAFA5_REASONING_TEMPLATE(the simplest of the available templates: no InterPro, no PPI, no GoGPT hint, no UniProt summary). The richer templates require fields this dataset does not carry. - Sample shape per row. One sample per protein, asking about all
three GO aspects at once (
go_aspect="all",split_go_aspects=False). Each row carries the protein/go_graph special-token slots that the model'sprocess_protein_embeddingsandprocess_go_aspectswill scatter encoder outputs into. - Ground-truth caveat. The CAFA5 challenge test split has no public
ground-truth GO terms β that is the whole point of CAFA. The
go_bp,go_mf,go_cccolumns on the test rows of this dataset are placeholder["None"]lists, mirroring the original. The adapter builds an assistant message containing"MF: None\nBP: None\nCC: None"so downstream code that reads fromsample["prompt"]doesn't crash, but F-max scoring against ground truth is not meaningful for these rows.
Modality-ablation method
Four ablation modes are implemented in ablations/ablation.py. Each one
wraps the model's encoder-output methods (process_protein_embeddings,
process_go_aspects) with a hook that transforms the projected
per-batch-item tensors after the encoder runs but before the LLM
scatters them into input embeddings at modality-pad-token positions.
| mode | what the hook does |
|---|---|
full |
passthrough (sanity baseline) |
protein_zero |
replace projected protein embeddings with zeros of identical shape/dtype/device |
protein_noise |
replace with Gaussian noise matched to the real embeddings' per-tensor mean/std |
go_zero |
replace projected GO embeddings with zeros |
Bugs fixed during the run:
- The noise generator was created with
device="cpu"but the projected encoder outputs live on CUDA, soprotein_noisefailed every sample with"Expected a 'cuda' device type for generator but found 'cpu'". Fixed inablations/ablation.pyby lazily re-creating the generator on the tensor's device the first time the hook fires.
Scoring choice
Because the test split has no public ground truth, F-max is not
computable for this evaluation. Instead ablations/analyze_results.py
treats each ablation as a perturbation of the baseline (full) and
reports, per protein:
jaccard(full_preds, ablated_preds)β overlap of predicted GO setsrecall_of_fullβ fraction of the baseline's predicted terms that survive the ablationsize_ratioβ|ablated_preds| / |full_preds|
Means across proteins are reported in
ablations/cross_config_summary.json.
Results (N=30, max_new_tokens=512, A100 80GB)
| config | jaccard vs full | recall of full | preds / protein |
|---|---|---|---|
full (baseline) |
1.000 | β | 1.70 |
protein_zero |
0.208 | 0.251 | 1.30 |
protein_noise |
0.220 | 0.311 | 2.73 |
go_zero |
0.209 | 0.293 | 2.27 |
Both modalities are load-bearing: any single-modality ablation drops the
predicted-set overlap with the baseline to ~21%. The direction of the
distortion differs β protein_zero makes the model under-predict, while
protein_noise and go_zero make it over-predict. Sample size is small
(N=30), so these numbers are best read as a sanity check that the
ablation hooks fire correctly and modality-removal has the expected
qualitative effect, not as a precise quantification.
ablations/ directory layout (round 1, N=30, no GT)
ablations/
βββ full/<protein_id>_all_k00.json # 30 records per config
βββ protein_zero/<...>.json
βββ protein_noise/<...>.json
βββ go_zero/<...>.json
βββ run_full_protein_zero_go_zero.json # original 3-config run summary
βββ run_protein_noise.json # protein_noise rerun summary (after the CUDA-generator fix)
βββ cross_config_summary.json # per-config Jaccard / recall / size-ratio means
Round 2: ablation with ground truth (N=100, train split)
The round-1 results above are a sanity-check baseline β the test split
has no public ground truth, so we could only measure deviation from
baseline, not correctness. Round 2 swaps the test split for the train
split (cafa5_reasoning/train, which has real go_bp/go_mf/go_cc
lists), adds a protein_zero_go_zero "text-only floor" control, and
scores precision/recall/F1 per GO aspect.
Caveat: the BioReason-Pro RL checkpoint was trained on these proteins.
The full baseline is therefore near-ceiling, and absolute numbers
should not be read as held-out performance. The relative degradation
across ablation configs is what's interpretable.
Round 2 setup
- Split:
cafa5_reasoning/train, filtered to rows with at least one non-emptygo_bp/mf/cclist (--require_ground_truth true) - N=100, seed=23
- Configs:
full,protein_zero,protein_noise,go_zero,protein_zero_go_zero --max_new_tokens 1000,--gpu_memory_utilization 0.6(the first attempt at 1500 / 0.7 OOM'd; tightening both fixed it)- A100 80GB, ~15h total runtime (ablated configs run 2β5Γ slower than
fullbecause the model hedges and generates longer responses)
Round 2 results: overall precision / recall / F1 (N=100)
Predicted GO terms are extracted from the generated response with the
regex GO:\d{7}. Each is compared against the union of
go_bp βͺ go_mf βͺ go_cc ground-truth terms for the protein. Metrics are
micro-averaged (pooled across proteins).
| config | precision | recall | F1 | jaccard vs full | preds / protein |
|---|---|---|---|---|---|
full (baseline) |
0.245 | 0.010 | 0.018 | 1.000 | 2.00 |
go_zero |
0.196 | 0.007 | 0.014 | 0.281 | 1.94 |
protein_noise |
0.158 | 0.007 | 0.014 | 0.196 | 2.28 |
protein_zero |
0.118 | 0.004 | 0.007 | 0.250 | 1.61 |
protein_zero_go_zero |
0.126 | 0.004 | 0.008 | 0.223 | 1.75 |
Recall is universally tiny because the model predicts ~2 terms per protein while ground truth has ~50 terms per protein. The model isn't asked to enumerate, so this is more a property of the prompt template than of the modality. Precision is the meaningful axis here.
Round 2 results: per-aspect precision
GO terms are bucketed into MF / BP / CC using go-basic.obo namespaces.
| MF | BP | CC | |
|---|---|---|---|
full |
0.433 | 0.129 | 0.176 |
go_zero |
0.377 | 0.036 | 0.145 |
protein_noise |
0.278 | 0.053 | 0.154 |
protein_zero |
0.109 | 0.050 | 0.196 |
protein_zero_go_zero |
0.143 | 0.032 | 0.226 |
What the round-2 numbers say
Protein encoder is the primary driver of accuracy.
protein_zerodrops overall precision by 52% (0.245 β 0.118);go_zerodrops it by 20% (0.245 β 0.196). Protein matters about 2.6Γ more than GO for the prediction precision in this setup.The GO encoder contributes nothing once protein is dead.
protein_zero_go_zero(0.126) is statistically indistinguishable fromprotein_zeroalone (0.118). Either GO embeddings are downstream of protein embeddings (the GO encoder's contribution requires a meaningful protein representation to condition on), or the GO encoder is doing a small enough amount of work that protein-encoder noise dominates. The fact that add-on contribution of GO disappears when protein is ablated is the strongest architectural finding of this experiment.Molecular function is protein-shaped. MF precision falls 75% under
protein_zero(0.433 β 0.109) but only 13% undergo_zero(0.433 β 0.377). MF is the aspect closest to sequence β catalytic sites, binding pockets, enzymatic activity β and the model picks these up from the protein encoder.Biological process is GO-shaped. BP precision falls 72% under
go_zero(0.129 β 0.036) and 61% underprotein_zero(0.129 β 0.050). BP is ontological reasoning over pathways and processes, exactly what the GO graph encoder is designed for.Cellular component is modality-robust. CC precision stays in 0.145 β 0.226 across all five configs and is not consistently damaged by any single ablation. The most likely explanation is that CC information leaks from the text prompt: organism name + protein name + the prior the LLM acquired from pretraining are enough to guess "this is probably nuclear / cytoplasmic / membrane-bound." This is the kind of shortcut the ablation framework was designed to surface.
Noise > zero on precision.
protein_noise(0.158) is consistently better thanprotein_zero(0.118). Stat-matched Gaussian noise preserves some of the protein embedding's moments, and the model evidently uses at least some of that low-frequency information.
Answers to the originally-open questions
| Question | Round 2 answer |
|---|---|
| Does the ablation hurt accuracy? | Yes. All four ablations drop precision; the strongest hit is from protein_zero (β52%). |
| Which modality matters more? | Protein, by ~2.6Γ. Removing protein hurts precision more than removing GO. |
| Is the model shortcutting from text alone? | For CC, yes. Cellular-component predictions barely change across ablations, suggesting the text prompt (organism + protein name) carries most of that signal. For MF and BP the modalities are doing real work. |
| Per-aspect breakdown? | MF is protein-driven, BP is GO-driven, CC is text-driven. |
| Does the framework actually work? | Yes. Hook installation, encoder-output transformation, and the noise/zero/swap modes all execute without errors across N=500 inference calls (100 proteins Γ 5 configs). |
Caveats and what's still open
- Train leakage. All 100 proteins are in the model's training set.
The
fullbaseline is near-ceiling; the relative gaps are real but absolute precision is inflated. A held-out evaluation against a 2024+ SwissProt set (the project hasdata/018-temporal-holdout-ext.ipynbfor this) would test whether the per-aspect pattern holds out of domain. - One prompt template. Everything here uses
CAFA5_REASONING_TEMPLATE(no InterPro, no PPI, no GoGPT hints, no UniProt summary). Richer prompts may shift the protein-vs-GO balance β the GO encoder might do more work when the prompt already supplies some GO speculations. - Low recall is a prompt artifact, not a model property. The model is not asked to enumerate exhaustively; F-max under a multi-threshold CAFA-style protocol would change the numbers.
Round 2 directory layout
ablations_v2/
βββ full/<protein_id>_all_k00.json # 100 records per config
βββ protein_zero/<...>.json
βββ protein_noise/<...>.json
βββ go_zero/<...>.json
βββ protein_zero_go_zero/<...>.json
βββ run_summary.json # CLI args + per-config processed/error counts
βββ cross_config_summary.json # the per-config / per-aspect numbers tabled above
Each per-protein record additionally carries go_mf, go_bp, go_cc
ground-truth lists (not present in the round-1 records), which is what
makes the round-2 accuracy metrics possible.
Round 3: temporal holdout (N=100, 2025+ SwissProt)
Round 2 ran on training-set proteins, so the full baseline was
near-ceiling and the ablation drops we measured could be a mix of "real
modality reliance" and "the encoders memorized these proteins, and
breaking them reveals memorization loss." Round 3 fixes this with an
out-of-distribution split: reviewed SwissProt entries that were
created on or after 2025-01-01, which is after every plausible
training cutoff for the BioReason-Pro RL checkpoint, its base model
(Qwen3), and its protein encoder (ESM3).
Round 3 setup
- Built
temporal_holdout_2025config on this dataset by querying the UniProt REST API for(reviewed:true) AND (date_created:[2025-01-01 TO *]) AND (go:*). Resulting 1,784 entries published undertemporal_holdout_2025/test.parquet. - Per protein in the holdout, ground truth is ~5 GO terms (1.57 BP + 1.86 MF + 1.24 CC on average) β versus ~50 on train. Newly curated proteins have fewer annotations.
- Same 5 ablation configs, same N=100, same
--max_new_tokens 1000, same--gpu_memory_utilization 0.6. Total runtime 13.9h.
Round 3 results: overall
| config | precision | recall | F1 | jaccard vs full | preds / protein |
|---|---|---|---|---|---|
full (baseline) |
0.088 | 0.030 | 0.045 | 1.000 | 1.70 |
go_zero |
0.059 | 0.020 | 0.030 | 0.275 | 1.70 |
protein_noise |
0.056 | 0.024 | 0.034 | 0.177 | 2.16 |
protein_zero |
0.031 | 0.012 | 0.017 | 0.217 | 1.96 |
protein_zero_go_zero |
0.035 | 0.014 | 0.020 | 0.194 | 2.00 |
full precision drops from 0.245 (train) to 0.088 (holdout) β about a
2.8Γ memorization premium on the training set, confirming the
train-leakage caveat we flagged in round 2.
Round 3 results: per-aspect precision (the key chart)
| MF | BP | CC | |
|---|---|---|---|
full |
0.000 | 0.039 | 0.232 |
go_zero |
0.000 | 0.000 | 0.175 |
protein_noise |
0.027 | 0.000 | 0.152 |
protein_zero |
0.000 | 0.000 | 0.100 |
protein_zero_go_zero |
0.000 | 0.000 | 0.113 |
Side-by-side with train:
| aspect | train full |
holdout full |
meaning |
|---|---|---|---|
| MF | 0.433 | 0.000 | MF accuracy was almost entirely memorization. On unseen sequences the model produces 0/239 correct MF terms. |
| BP | 0.129 | 0.039 | BP accuracy was largely memorization (β70%) but a small residual generalizes. |
| CC | 0.176 | 0.232 | CC accuracy is robust to the trainβholdout shift. It is the only aspect the model actually generalizes on. |
What round 3 changes about the round-2 story
Round 2 framed the architecture as "protein encoder dominates, GO encoder is conditional, MF/BP/CC each have a primary modality." On held-out proteins:
- The MF reliance pattern collapses. "MF depends on the protein encoder" was true on train but vacuous on holdout β there is no MF signal to depend on. The protein encoder is not transferring MF knowledge to unseen sequences.
- The BP reliance pattern weakens. The GO encoder still matters
proportionally (
go_zerodrops BP precision to 0.000), but the absolute level is so low that "biggest aspect for GO" is more of a technicality than a useful capability. - The CC text-shortcut pattern strengthens. CC precision is the only aspect that's stable across all five configs and across train/holdout. Organism + protein name in the text prompt continues to dominate CC predictions, and this is the model's most reliable capability.
- The "GO adds nothing once protein is dead" finding survives.
protein_zero_go_zero(0.035) βprotein_zero(0.031), same qualitative pattern as on train (0.126 vs 0.118). This is now a cross-distribution architectural claim. protein_noise>protein_zerosurvives. 0.056 vs 0.031 on holdout; 0.158 vs 0.118 on train. The model uses statistical moments of the protein embedding even out of distribution.
Updated bottom line
The strongest claim that survives both runs:
The GO encoder's marginal contribution is conditional on a working protein representation, and CC predictions are dominated by a text shortcut (organism name) rather than the protein or GO encoders.
The claim that does not survive:
"The protein encoder is the primary driver of MF accuracy."Restated: the protein encoder produces MF predictions that score well on training proteins because those proteins are memorized. On novel sequences the model has near-zero MF capability regardless of which modality is ablated.
Round 3 directory layout
ablations_v3_holdout/
βββ full/<protein_id>_all_k00.json # 100 records per config
βββ protein_zero/<...>.json
βββ protein_noise/<...>.json
βββ go_zero/<...>.json
βββ protein_zero_go_zero/<...>.json
βββ run_summary.json
βββ cross_config_summary.json
Round 4A: organism scramble (N=100, holdout, 2 configs)
Round 3 concluded that "CC predictions are dominated by a text shortcut
(organism name) rather than the protein or GO encoders." Round 4A
tests that directly: take the same 100 holdout proteins, but randomly
permute the organism column across them (each protein gets some other
protein's organism β deterministic by seed+1). Sequences and GO
labels stay attached to the original protein. If CC really rides on
organism, CC precision should collapse to the "no encoders" floor.
Round 4A setup
- Same 100 holdout proteins as round 3 (
temporal_holdout_2025/test, same seed=23 selection). --scramble_organism trueβ adapter permutes theorganismfield with a derangement so no protein keeps its own organism.- Two configs:
full(test whetherfullCC depends on organism) andprotein_zero_go_zero(test whether the floor depends on organism). - All other settings identical to round 3:
--max_new_tokens 1000,--gpu_memory_utilization 0.6. Runtime 8.8h (model hedges harder when sequence and organism disagree, so generation is ~2Γ longer than unscrambled).
Round 4A results: precision
| config | overall | MF | BP | CC |
|---|---|---|---|---|
full unscrambled (round 3) |
0.088 | 0.000 | 0.039 | 0.232 |
full scrambled (round 4A) |
0.065 | 0.000 | 0.000 | 0.204 |
protein_zero_go_zero unscrambled (round 3) |
0.035 | 0.000 | 0.000 | 0.113 |
protein_zero_go_zero scrambled (round 4A) |
0.036 | 0.000 | 0.016 | 0.108 |
Decomposing the 0.232 CC precision
If we treat protein_zero_go_zero as the "encoders off" condition and
the scramble as "organism off," the round-3 + round-4A combination
lets us split CC precision into three sources:
| source | contribution to CC precision |
|---|---|
| base rate (encoders dead, organism wrong or right β doesn't matter) | ~0.108 |
| protein/GO encoders | 0.232 β 0.108 β 0.124 |
| organism string | 0.232 β 0.204 β 0.028 |
Encoders contribute ~4Γ more than the organism for CC. The encoder-dead floor is unchanged by organism scramble (0.113 β 0.108), which means that residual ~0.11 precision is not a text shortcut β it is base-rate luck on common CC terms like "cytoplasm" and "nucleus."
Round 4A revises the round-3 story
| round-3 claim | round-4A finding | revised claim |
|---|---|---|
| "CC predictions are dominated by a text shortcut (organism name)" | Scrambling organism drops CC by only 12% (0.232 β 0.204) | CC is encoder-driven; organism is a minor (~12%) modulator. |
| "The encoders' marginal contribution to CC is small" | At protein_zero_go_zero, CC = 0.113 unscrambled, 0.108 scrambled. Encoders contribute 0.124, organism contributes 0.028. |
Encoders contribute ~4Γ more than organism to CC. |
| "BP predictions have a small residual on holdout" | BP collapses from 0.039 to 0.000 under scramble | The BP residual on holdout was organism-dependent, not modality-dependent. |
What round 4A does not refute
- The OOD memorization story (round 3) is unchanged.
fullprecision on holdout is still ~3Γ lower than on train; MF predictions are still near-zero on novel proteins. - The GO-encoder-conditional-on-protein claim is unchanged. Both runs see
protein_zero_go_zeroβprotein_zeroin precision. - The "noise > zero" finding is unchanged (we didn't re-run protein_noise under scramble, but no reason to expect a change).
- CC remains the only useful aspect on holdout. Even under scramble, CC precision (0.20) far exceeds MF (0.00) or BP (0.00) β the model is much better at CC than the other aspects, and that excess is now attributed to the encoders rather than to the text.
Round 4A directory layout
ablations_v4_scramble/
βββ full/<protein_id>_all_k00.json # 100 records: organism scrambled, full encoders
βββ protein_zero_go_zero/<...>.json # 100 records: organism scrambled, both encoders dead
βββ run_summary.json
βββ cross_config_summary.json
The scramble itself is not stored separately β it is reproducible from
seed=23 plus --scramble_organism true against the same
temporal_holdout_2025 split. The input_prompt field on each
per-protein record shows the (mismatched) organism that was actually
used at generation time.
Each per-protein record contains the full generated response, the input
prompt (so the run is reproducible), the ablation config name, the
ground-truth string (placeholder on test split), and basic accounting
fields (sequence_length, success, etc.).
- Downloads last month
- 15