Skip to content

Turn any AI agent into an AI Scientist. The #1 Agent Skills library for science, used by 250,000+ scientists worldwide. 177 ready-to-use validated skills plus 100+ scientific databases covering biology, chemistry, medicine, and drug discovery. Compatible with Cursor, Claude Code, Codex, Pi, Antigravity, and the open Agent Skills standard.

Update Torchdrug and venue-templates skills

Timothy Kassis3b6f0e48b400
diff --git a/skills/torchdrug/SKILL.md b/skills/torchdrug/SKILL.md
index bfc4952b..a5d24387 100644
--- a/skills/torchdrug/SKILL.md
+++ b/skills/torchdrug/SKILL.md
@@ -1,459 +1,241 @@
---
name: torchdrug
-description: PyTorch-native graph neural networks for molecules and proteins. Use when building custom GNN architectures for drug discovery, protein modeling, or knowledge graph reasoning. Best for custom model development, protein property prediction, retrosynthesis. For pre-trained models and diverse featurizers use deepchem; for benchmark datasets use pytdc.
+description: Build and troubleshoot TorchDrug 0.2.1 workflows for molecular graphs, property prediction, self-supervised pretraining, molecule generation, retrosynthesis, protein representation learning, and knowledge graph reasoning. Use when code imports torchdrug or needs its datasets, models, tasks, or Engine.
license: Apache-2.0 license
-metadata: {"version": "1.0", "skill-author": "K-Dense Inc."}
+compatibility: TorchDrug 0.2.1 requires Python 3.7-3.10 and supports PyTorch 1.8-2.0. Apple Silicon is CPU-only; MPS is unsupported.
+allowed-tools: Read Write Edit Bash
+metadata:
+ version: "1.1"
+ skill-author: K-Dense Inc.
---
# TorchDrug
-## Overview
+Use TorchDrug as a modular PyTorch graph-learning stack:
-TorchDrug is a comprehensive PyTorch-based machine learning toolbox for drug discovery and molecular science. Apply graph neural networks, pre-trained models, and task definitions to molecules, proteins, and biological knowledge graphs, including molecular property prediction, protein modeling, knowledge graph reasoning, molecular generation, retrosynthesis planning, with 40+ curated datasets and 20+ model architectures.
+1. load a `datasets.*` dataset,
+2. choose a `models.*` representation model,
+3. wrap it in a `tasks.*` objective,
+4. train and evaluate it with `core.Engine`.
-## When to Use This Skill
+The current official documentation and latest release are both **0.2.1**. Treat
+newer Python or PyTorch combinations as unverified rather than silently assuming
+compatibility.
-This skill should be used when working with:
+## Start with the version guard
-**Data Types:**
-- SMILES strings or molecular structures
-- Protein sequences or 3D structures (PDB files)
-- Chemical reactions and retrosynthesis
-- Biomedical knowledge graphs
-- Drug discovery datasets
+Before generating or debugging code, inspect the environment:
-**Tasks:**
-- Predicting molecular properties (solubility, toxicity, activity)
-- Protein function or structure prediction
-- Drug-target binding prediction
-- Generating new molecular structures
-- Planning chemical synthesis routes
-- Link prediction in biomedical knowledge bases
-- Training graph neural networks on scientific data
+```bash
+python --version
+python -c "import torch; print(torch.__version__)"
+python -c "import torchdrug; print(torchdrug.__version__)"
+```
+
+The supported matrix for TorchDrug 0.2.1 is:
-**Libraries and Integration:**
-- TorchDrug is the primary library
-- Often used with RDKit for cheminformatics
-- Compatible with PyTorch and PyTorch Lightning
-- Integrates with AlphaFold and ESM for proteins
+- Python 3.7 through 3.10
+- PyTorch 1.8 through 2.0
+- Linux, Windows, or macOS
+- Apple Silicon: PyTorch 1.13 or later, CPU only; no MPS support
-## Getting Started
+If the project uses Python 3.11+ or PyTorch 2.1+, create a compatible environment
+or explicitly test a source build. Do not present such combinations as supported.
-### Installation
+## Installation
+
+Prefer a dedicated Python 3.10 environment and pin the TorchDrug release:
+
+```bash
+uv venv --python 3.10
+source .venv/bin/activate
+uv pip install "torch==2.0.0"
+```
-TorchDrug **0.2.1** (latest on PyPI, July 2023) requires **Python 3.7–3.10** and **PyTorch 1.8–2.0**. Install PyTorch and `torch-scatter` / `torch-cluster` first (wheel URL depends on your PyTorch and CUDA versions — see [installation docs](https://torchdrug.ai/docs/installation.html)).
+Install `torch-scatter` and `torch-cluster` wheels matched to the exact PyTorch
+and CUDA pair, following the
+[official installation page](https://torchdrug.ai/docs/installation.html). For a
+CPU-only PyTorch 2.0 environment, one reproducible wheel combination is:
```bash
-uv pip install torch
-# Match torch/CUDA in the URL, e.g. torch-2.0.0+cu118 or cpu
-uv pip install torch-scatter torch-cluster -f https://pytorch-geometric.com/whl/torch-2.0.0+cu118.html
-uv pip install torchdrug==0.2.1
+uv pip install "torch-scatter==2.1.1" "torch-cluster==1.6.1" \
+ --find-links "https://data.pyg.org/whl/torch-2.0.0+cpu.html"
+uv pip install "torchdrug==0.2.1"
```
-On Apple Silicon, compile scatter/cluster from source; TorchDrug runs on CPU only (no MPS). Conda: `conda install torchdrug -c milagraph -c conda-forge -c pytorch -c pyg`.
+Do not copy a CUDA wheel URL between environments. Match the PyTorch version,
+CUDA build, Python ABI, and platform. On Apple Silicon, the official docs require
+building `torch-scatter` and `torch-cluster` from source; pin reviewed source
+revisions and expect CPU execution.
+
+## Canonical property-prediction workflow
-### Quick Example
+Use the documented ClinTox → GIN → `PropertyPrediction` → `Engine` pattern:
```python
import torch
-from torchdrug import datasets, models, tasks
-from torch.utils.data import DataLoader
+from torchdrug import core, datasets, models, tasks
-# Load molecular dataset
-dataset = datasets.BBBP("~/molecule-datasets/")
-train_set, valid_set, test_set = dataset.split()
+dataset = datasets.ClinTox("~/molecule-datasets/")
+lengths = [int(0.8 * len(dataset)), int(0.1 * len(dataset))]
+lengths.append(len(dataset) - sum(lengths))
+train_set, valid_set, test_set = torch.utils.data.random_split(dataset, lengths)
-# Define GNN model
model = models.GIN(
input_dim=dataset.node_feature_dim,
- hidden_dims=[256, 256, 256],
- edge_input_dim=dataset.edge_feature_dim,
+ hidden_dims=[256, 256, 256, 256],
+ short_cut=True,
batch_norm=True,
- readout="mean"
+ concat_hidden=True,
)
-
-# Create property prediction task
task = tasks.PropertyPrediction(
model,
task=dataset.tasks,
criterion="bce",
- metric=["auroc", "auprc"]
+ metric=("auprc", "auroc"),
)
-# Train with PyTorch
optimizer = torch.optim.Adam(task.parameters(), lr=1e-3)
-train_loader = DataLoader(train_set, batch_size=32, shuffle=True)
-
-for epoch in range(100):
- for batch in train_loader:
- loss = task(batch)
- optimizer.zero_grad()
- loss.backward()
- optimizer.step()
-```
-
-## Core Capabilities
-
-### 1. Molecular Property Prediction
-
-Predict chemical, physical, and biological properties of molecules from structure.
-
-**Use Cases:**
-- Drug-likeness and ADMET properties
-- Toxicity screening
-- Quantum chemistry properties
-- Binding affinity prediction
-
-**Key Components:**
-- 20+ molecular datasets (BBBP, HIV, Tox21, QM9, etc.)
-- GNN models (GIN, GAT, SchNet)
-- PropertyPrediction and MultipleBinaryClassification tasks
-
-**Reference:** See `references/molecular_property_prediction.md` for:
-- Complete dataset catalog
-- Model selection guide
-- Training workflows and best practices
-- Feature engineering details
-
-### 2. Protein Modeling
-
-Work with protein sequences, structures, and properties.
-
-**Use Cases:**
-- Enzyme function prediction
-- Protein stability and solubility
-- Subcellular localization
-- Protein-protein interactions
-- Structure prediction
-
-**Key Components:**
-- 15+ protein datasets (EnzymeCommission, GeneOntology, PDBBind, etc.)
-- Sequence models (ESM, ProteinBERT, ProteinLSTM)
-- Structure models (GearNet, SchNet)
-- Multiple task types for different prediction levels
-
-**Reference:** See `references/protein_modeling.md` for:
-- Protein-specific datasets
-- Sequence vs structure models
-- Pre-training strategies
-- Integration with AlphaFold and ESM
-
-### 3. Knowledge Graph Reasoning
-
-Predict missing links and relationships in biological knowledge graphs.
-
-**Use Cases:**
-- Drug repurposing
-- Disease mechanism discovery
-- Gene-disease associations
-- Multi-hop biomedical reasoning
-
-**Key Components:**
-- General KGs (FB15k, WN18) and biomedical (Hetionet)
-- Embedding models (TransE, RotatE, ComplEx)
-- KnowledgeGraphCompletion task
-
-**Reference:** See `references/knowledge_graphs.md` for:
-- Knowledge graph datasets (including Hetionet with 45k biomedical entities)
-- Embedding model comparison
-- Evaluation metrics and protocols
-- Biomedical applications
-
-### 4. Molecular Generation
-
-Generate novel molecular structures with desired properties.
-
-**Use Cases:**
-- De novo drug design
-- Lead optimization
-- Chemical space exploration
-- Property-guided generation
-
-**Key Components:**
-- Autoregressive generation
-- GCPN (policy-based generation)
-- GraphAutoregressiveFlow
-- Property optimization workflows
-
-**Reference:** See `references/molecular_generation.md` for:
-- Generation strategies (unconditional, conditional, scaffold-based)
-- Multi-objective optimization
-- Validation and filtering
-- Integration with property prediction
-
-### 5. Retrosynthesis
-
-Predict synthetic routes from target molecules to starting materials.
-
-**Use Cases:**
-- Synthesis planning
-- Route optimization
-- Synthetic accessibility assessment
-- Multi-step planning
-
-**Key Components:**
-- USPTO-50k reaction dataset
-- CenterIdentification (reaction center prediction)
-- SynthonCompletion (reactant prediction)
-- End-to-end Retrosynthesis pipeline
-
-**Reference:** See `references/retrosynthesis.md` for:
-- Task decomposition (center ID → synthon completion)
-- Multi-step synthesis planning
-- Commercial availability checking
-- Integration with other retrosynthesis tools
-
-### 6. Graph Neural Network Models
-
-Comprehensive catalog of GNN architectures for different data types and tasks.
-
-**Available Models:**
-- General GNNs: GCN, GAT, GIN, RGCN, MPNN
-- 3D-aware: SchNet, GearNet
-- Protein-specific: ESM, ProteinBERT, GearNet
-- Knowledge graph: TransE, RotatE, ComplEx, SimplE
-- Generative: GraphAutoregressiveFlow
-
-**Reference:** See `references/models_architectures.md` for:
-- Detailed model descriptions
-- Model selection guide by task and dataset
-- Architecture comparisons
-- Implementation tips
-
-### 7. Datasets
-
-40+ curated datasets spanning chemistry, biology, and knowledge graphs.
-
-**Categories:**
-- Molecular properties (drug discovery, quantum chemistry)
-- Protein properties (function, structure, interactions)
-- Knowledge graphs (general and biomedical)
-- Retrosynthesis reactions
-
-**Reference:** See `references/datasets.md` for:
-- Complete dataset catalog with sizes and tasks
-- Dataset selection guide
-- Loading and preprocessing
-- Splitting strategies (random, scaffold)
-
-## Common Workflows
-
-### Workflow 1: Molecular Property Prediction
-
-**Scenario:** Predict blood-brain barrier penetration for drug candidates.
-
-**Steps:**
-1. Load dataset: `datasets.BBBP()`
-2. Choose model: GIN for molecular graphs
-3. Define task: `PropertyPrediction` with binary classification
-4. Train with scaffold split for realistic evaluation
-5. Evaluate using AUROC and AUPRC
-
-**Navigation:** `references/molecular_property_prediction.md` → Dataset selection → Model selection → Training
-
-### Workflow 2: Protein Function Prediction
-
-**Scenario:** Predict enzyme function from sequence.
-
-**Steps:**
-1. Load dataset: `datasets.EnzymeCommission()`
-2. Choose model: ESM (pre-trained) or GearNet (with structure)
-3. Define task: `PropertyPrediction` with multi-class classification
-4. Fine-tune pre-trained model or train from scratch
-5. Evaluate using accuracy and per-class metrics
-
-**Navigation:** `references/protein_modeling.md` → Model selection (sequence vs structure) → Pre-training strategies
-
-### Workflow 3: Drug Repurposing via Knowledge Graphs
-
-**Scenario:** Find new disease treatments in Hetionet.
-
-**Steps:**
-1. Load dataset: `datasets.Hetionet()`
-2. Choose model: RotatE or ComplEx
-3. Define task: `KnowledgeGraphCompletion`
-4. Train with negative sampling
-5. Query for "Compound-treats-Disease" predictions
-6. Filter by plausibility and mechanism
-
-**Navigation:** `references/knowledge_graphs.md` → Hetionet dataset → Model selection → Biomedical applications
-
-### Workflow 4: De Novo Molecule Generation
-
-**Scenario:** Generate drug-like molecules optimized for target binding.
-
-**Steps:**
-1. Train property predictor on activity data
-2. Choose generation approach: GCPN for RL-based optimization
-3. Define reward function combining affinity, drug-likeness, synthesizability
-4. Generate candidates with property constraints
-5. Validate chemistry and filter by drug-likeness
-6. Rank by multi-objective scoring
-
-**Navigation:** `references/molecular_generation.md` → Conditional generation → Multi-objective optimization
-
-### Workflow 5: Retrosynthesis Planning
-
-**Scenario:** Plan synthesis route for target molecule.
-
-**Steps:**
-1. Load dataset: `datasets.USPTO50k()`
-2. Train center identification model (RGCN)
-3. Train synthon completion model (GIN)
-4. Combine into end-to-end retrosynthesis pipeline
-5. Apply recursively for multi-step planning
-6. Check commercial availability of building blocks
-
-**Navigation:** `references/retrosynthesis.md` → Task types → Multi-step planning
-
-## Integration Patterns
-
-### With RDKit
-
-Convert between TorchDrug molecules and RDKit:
-```python
-from torchdrug import data
-from rdkit import Chem
-
-# SMILES → TorchDrug molecule
-smiles = "CCO"
-mol = data.Molecule.from_smiles(smiles)
-
-# TorchDrug → RDKit
-rdkit_mol = mol.to_molecule()
-
-# RDKit → TorchDrug
-rdkit_mol = Chem.MolFromSmiles(smiles)
-mol = data.Molecule.from_molecule(rdkit_mol)
-```
-
-### With AlphaFold/ESM
-
-Use predicted structures:
-```python
-from torchdrug import data
-
-# Load AlphaFold predicted structure
-protein = data.Protein.from_pdb("AF-P12345-F1-model_v4.pdb")
-
-# Build graph with spatial edges
-graph = protein.residue_graph(
- node_position="ca",
- edge_types=["sequential", "radius"],
- radius_cutoff=10.0
+solver = core.Engine(
+ task,
+ train_set,
+ valid_set,
+ test_set,
+ optimizer,
+ batch_size=1024,
)
+solver.train(num_epoch=100)
+solver.evaluate("valid")
```
-### With PyTorch Lightning
-
-Wrap tasks for Lightning training:
-```python
-import pytorch_lightning as pl
-
-class LightningTask(pl.LightningModule):
- def __init__(self, torchdrug_task):
- super().__init__()
- self.task = torchdrug_task
-
- def training_step(self, batch, batch_idx):
- return self.task(batch)
-
- def validation_step(self, batch, batch_idx):
- pred = self.task.predict(batch)
- target = self.task.target(batch)
- return {"pred": pred, "target": target}
-
- def configure_optimizers(self):
- return torch.optim.Adam(self.parameters(), lr=1e-3)
-```
-
-## Technical Details
-
-For deep dives into TorchDrug's architecture:
-
-**Core Concepts:** See `references/core_concepts.md` for:
-- Architecture philosophy (modular, configurable)
-- Data structures (Graph, Molecule, Protein, PackedGraph)
-- Model interface and forward function signature
-- Task interface (predict, target, forward, evaluate)
-- Training workflows and best practices
-- Loss functions and metrics
-- Common pitfalls and debugging
-
-## Quick Reference Cheat Sheet
-
-**Choose Dataset:**
-- Molecular property → `references/datasets.md` → Molecular section
-- Protein task → `references/datasets.md` → Protein section
-- Knowledge graph → `references/datasets.md` → Knowledge graph section
-
-**Choose Model:**
-- Molecules → `references/models_architectures.md` → GNN section → GIN/GAT/SchNet
-- Proteins (sequence) → `references/models_architectures.md` → Protein section → ESM
-- Proteins (structure) → `references/models_architectures.md` → Protein section → GearNet
-- Knowledge graph → `references/models_architectures.md` → KG section → RotatE/ComplEx
-
-**Common Tasks:**
-- Property prediction → `references/molecular_property_prediction.md` or `references/protein_modeling.md`
-- Generation → `references/molecular_generation.md`
-- Retrosynthesis → `references/retrosynthesis.md`
-- KG reasoning → `references/knowledge_graphs.md`
-
-**Understand Architecture:**
-- Data structures → `references/core_concepts.md` → Data Structures
-- Model design → `references/core_concepts.md` → Model Interface
-- Task design → `references/core_concepts.md` → Task Interface
-
-## Troubleshooting Common Issues
-
-**Issue: Dimension mismatch errors**
-→ Check `model.input_dim` matches `dataset.node_feature_dim`
-→ See `references/core_concepts.md` → Essential Attributes
-
-**Issue: Poor performance on molecular tasks**
-→ Use scaffold splitting, not random
-→ Try GIN instead of GCN
-→ See `references/molecular_property_prediction.md` → Best Practices
-
-**Issue: Protein model not learning**
-→ Use pre-trained ESM for sequence tasks
-→ Check edge construction for structure models
-→ See `references/protein_modeling.md` → Training Workflows
-
-**Issue: Memory errors with large graphs**
-→ Reduce batch size
-→ Use gradient accumulation
-→ See `references/core_concepts.md` → Memory Efficiency
-
-**Issue: Generated molecules are invalid**
-→ Add validity constraints
-→ Post-process with RDKit validation
-→ See `references/molecular_generation.md` → Validation and Filtering
-
-## Version Notes (0.2.1)
-
-- `PropertyPrediction.predict()` returns **original-scale** values (not standardized); code written for older TorchDrug may need metric/threshold updates ([release notes](https://github.com/DeepGraphLearning/torchdrug/releases/tag/v0.2.1)).
-- Dataset constructors prefer `atom_feature` / `bond_feature` / `mol_feature`; `node_feature` / `edge_feature` / `graph_feature` are deprecated aliases.
-- `EvolutionaryScaleModeling` supports ESM-2 checkpoints in addition to ESM-1b.
+Add `gpus=[0]` only when a supported CUDA device is available. Omit `gpus` for
+CPU execution.
+
+For binary classification, `task.predict(batch)` returns logits; apply
+`torch.sigmoid` when probabilities are needed. In 0.2.1, normalized regression
+predictions are returned on the original target scale, which is a breaking change
+from older releases.
-## Resources
+## Choose the official workflow
-**Official Documentation:** https://torchdrug.ai/docs/ (0.2.1)
-**GitHub:** https://github.com/DeepGraphLearning/torchdrug
-**Paper:** TorchDrug: A Powerful and Flexible Machine Learning Platform for Drug Discovery
+### Molecular property prediction
-## Summary
+- Dataset: `datasets.ClinTox`, `BBBP`, `Tox21`, `QM9`, or another documented
+ molecule dataset.
+- Model: start with `models.GIN`; use `edge_input_dim` when the selected feature
+ configuration supplies edge features.
+- Task: `tasks.PropertyPrediction`.
+- Read [molecular property prediction](references/molecular_property_prediction.md).
-Navigate to the appropriate reference file based on your task:
+### Self-supervised molecular pretraining
-1. **Molecular property prediction** → `molecular_property_prediction.md`
-2. **Protein modeling** → `protein_modeling.md`
-3. **Knowledge graphs** → `knowledge_graphs.md`
-4. **Molecular generation** → `molecular_generation.md`
-5. **Retrosynthesis** → `retrosynthesis.md`
-6. **Model selection** → `models_architectures.md`
-7. **Dataset selection** → `datasets.md`
-8. **Technical details** → `core_concepts.md`
+- InfoGraph: `models.InfoGraph(gin_model, separate_model=False)` wrapped by
+ `tasks.Unsupervised`.
+- Attribute masking: `tasks.AttributeMasking(model, mask_rate=0.15)`.
+- Recreate the same encoder for fine-tuning, then load the checkpoint with
+ `strict=False` before training `tasks.PropertyPrediction`.
+- Read [molecular property prediction](references/molecular_property_prediction.md).
-Each reference provides comprehensive coverage of its domain with examples, best practices, and common use cases.
+### Molecule generation
+- Dataset: `datasets.ZINC250k(..., kekulize=True, atom_feature="symbol")`.
+- GCPN: an `models.RGCN` encoder wrapped by `tasks.GCPNGeneration`.
+- GraphAF: node and edge `models.GraphAF` flows wrapped by
+ `tasks.AutoregressiveGeneration`.
+- Supported optimization tasks in the tutorial are `"qed"` and `"plogp"`;
+ criteria are `"nll"` and/or `"ppo"`.
+- Read [molecular generation](references/molecular_generation.md).
+
+### Retrosynthesis
+
+- Create two synchronized `datasets.USPTO50k` views: reaction mode for center
+ identification and `as_synthon=True` for synthon completion.
+- Train `tasks.CenterIdentification` and `tasks.SynthonCompletion` separately.
+- Combine the trained tasks with `tasks.Retrosynthesis`; do not pass raw models
+ directly to the end-to-end task.
+- Read [retrosynthesis](references/retrosynthesis.md).
+
+### Knowledge graph reasoning
+
+- Embedding workflow: `datasets.FB15k237` → `models.RotatE` →
+ `tasks.KnowledgeGraphCompletion`.
+- Neural reasoning workflow: `models.NeuralLP` with `fact_ratio=0.75`.
+- Read [knowledge graph reasoning](references/knowledge_graphs.md).
+
+### Protein modeling
+
+- Build proteins with `data.Protein.from_sequence`, `from_pdb`, or
+ `from_molecule`.
+- Sequence encoders include `models.ESM`, `ProteinCNN`, `ProteinResNet`,
+ `ProteinLSTM`, and `ProteinBERT`; structure encoders include `models.GearNet`.
+- Use documented graph-construction layers rather than a nonexistent
+ `protein.residue_graph()` convenience method.
+- Read [protein modeling](references/protein_modeling.md).
+
+## Rules for reliable TorchDrug code
+
+1. **Follow the 0.2.1 API.** The official docs are not a rolling latest-version
+ site.
+2. **Prefer documented feature names.** Use `atom_feature`, `bond_feature`,
+ `residue_feature`, and `mol_feature`; `node_feature`, `edge_feature`, and
+ `graph_feature` are deprecated aliases in relevant dataset constructors.
+3. **Let `Engine` preprocess tasks.** If composing pre-trained tasks without
+ constructing their solvers, call each task's `preprocess()` manually.
+4. **Keep paired splits synchronized.** For retrosynthesis, reset the same random
+ seed before splitting reaction and synthon datasets.
+5. **Use TorchDrug collation.** Use `data.graph_collate` or `core.Engine`;
+ generic PyTorch collation does not know how to pack TorchDrug graphs.
+6. **Separate model, task, and engine arguments.** A common source of invented
+ code is passing task options to a model or passing raw models where a composed
+ task is required.
+7. **Validate generated chemistry.** Treat model outputs as candidates, not as
+ experimentally valid or synthesizable compounds.
+
+## Troubleshooting
+
+### Installation or import failure
+
+Check Python, PyTorch, `torch-scatter`, and `torch-cluster` as one compatibility
+set. Most failures are binary-wheel mismatches, unsupported Python versions, or
+attempts to use MPS.
+
+### Feature dimension mismatch
+
+Build model dimensions from the loaded dataset:
+
+- `dataset.node_feature_dim`
+- `dataset.edge_feature_dim`
+- `dataset.num_bond_type`
+- `dataset.num_entity` and `dataset.num_relation` for knowledge graphs
+
+Do not hard-code dimensions copied from a different feature configuration.
+
+### Device mismatch
+
+Pass `gpus=[0]` to `core.Engine` for supported CUDA execution. For manual
+prediction, collate first and move the entire nested batch with `utils.cuda`.
+
+### Checkpoint mismatch
+
+Recreate the same model and feature configuration. For pretraining-to-fine-tuning
+transfer, load the checkpoint's `"model"` state with `strict=False`; for a complete
+solver, use `solver.save()` and `solver.load()`.
+
+## Reference index
+
+- [Core concepts and data structures](references/core_concepts.md)
+- [Datasets](references/datasets.md)
+- [Models and architectures](references/models_architectures.md)
+- [Molecular property prediction and pretraining](references/molecular_property_prediction.md)
+- [Protein modeling](references/protein_modeling.md)
+- [Molecular generation](references/molecular_generation.md)
+- [Retrosynthesis](references/retrosynthesis.md)
+- [Knowledge graph reasoning](references/knowledge_graphs.md)
+
+## Upstream sources
+
+- [TorchDrug 0.2.1 documentation](https://torchdrug.ai/docs/)
+- [Tutorial index](https://torchdrug.ai/docs/tutorials/)
+- [Installation](https://torchdrug.ai/docs/installation.html)
+- [Package reference](https://torchdrug.ai/docs/api/)
+- [TorchDrug 0.2.1 release notes](https://github.com/DeepGraphLearning/torchdrug/releases/tag/v0.2.1)
diff --git a/skills/torchdrug/references/core_concepts.md b/skills/torchdrug/references/core_concepts.md
index 6817f512..fd1827b8 100644
--- a/skills/torchdrug/references/core_concepts.md
+++ b/skills/torchdrug/references/core_concepts.md
@@ -1,588 +1,241 @@
-# Core Concepts and Technical Details
+# Core Concepts and Data Structures
-## Overview
+This reference follows the
+[TorchDrug 0.2.1 data API](https://torchdrug.ai/docs/api/data.html),
+[quick start](https://torchdrug.ai/docs/quick_start.html), and
+[notes](https://torchdrug.ai/docs/notes/).
-This reference covers TorchDrug's fundamental architecture, design principles, and technical implementation details.
+## Component hierarchy
-## Architecture Philosophy
+TorchDrug separates four concerns:
-### Modular Design
+- `torchdrug.data`: tensor-backed `Graph`, `Molecule`, `Protein`, and packed
+ variants.
+- `torchdrug.datasets`: downloadable datasets whose samples contain graphs and
+ targets.
+- `torchdrug.models`: reusable graph, sequence, embedding, flow, and
+ self-supervised encoders.
+- `torchdrug.tasks`: objectives that wrap models and implement prediction, loss,
+ and evaluation.
+- `torchdrug.core.Engine`: preprocessing, batching, optimization, checkpointing,
+ and evaluation.
-TorchDrug separates concerns into distinct modules:
+Keep these layers separate. A model creates representations; a task defines what
+to learn; an engine executes the experiment.
-1. **Representation Models** (models.py): Encode graphs into embeddings
-2. **Task Definitions** (tasks.py): Define learning objectives and evaluation
-3. **Data Handling** (data.py, datasets.py): Graph structures and datasets
-4. **Core Components** (core.py): Base classes and utilities
+## Graphs and molecules
-**Benefits:**
-- Reuse representations across tasks
-- Mix and match components
-- Easy experimentation and prototyping
-- Clear separation of concerns
-
-### Configurable System
-
-All components inherit from `core.Configurable`:
-- Serialize to configuration dictionaries
-- Reconstruct from configurations
-- Save and load complete pipelines
-- Reproducible experiments
-
-## Core Components
-
-### core.Configurable
-
-Base class for all TorchDrug components.
-
-**Key Methods:**
-- `config_dict()`: Serialize to dictionary
-- `load_config_dict(config)`: Load from dictionary
-- `save(file)`: Save to file
-- `load(file)`: Load from file
-
-**Example:**
```python
-from torchdrug import core, models
-
-model = models.GIN(input_dim=10, hidden_dims=[256, 256])
-
-# Save configuration
-config = model.config_dict()
-# {'class': 'GIN', 'input_dim': 10, 'hidden_dims': [256, 256], ...}
-
-# Reconstruct model
-model2 = core.Configurable.load_config_dict(config)
-```
-
-### core.Registry
-
-Decorator for registering models, tasks, and datasets.
+import torchdrug as td
+from torchdrug import data
-**Usage:**
-```python
-from torchdrug import core as core_td
+edge_list = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0]]
+graph = data.Graph(edge_list, num_node=6)
-@core_td.register("models.CustomModel")
-class CustomModel(nn.Module, core_td.Configurable):
- def __init__(self, input_dim, hidden_dim):
- super().__init__()
- self.linear = nn.Linear(input_dim, hidden_dim)
+mol = data.Molecule.from_smiles(
+ "CCOC(=O)N",
+ atom_feature="default",
+ bond_feature="default",
+)
+print(mol.node_feature.shape)
+print(mol.edge_feature.shape)
- def forward(self, graph, input, all_loss, metric):
- # Model implementation
- pass
+node_in, node_out, _ = mol.edge_list.t()
+carbon_edge = (mol.atom_type[node_in] == td.CARBON) | (
+ mol.atom_type[node_out] == td.CARBON
+)
+carbon_subgraph = mol.edge_mask(carbon_edge)
```
-**Benefits:**
-- Models automatically serializable
-- String-based model specification
-- Easy model lookup and instantiation
-
-## Data Structures
-
-### Graph
+Molecular bonds are represented by two directed edges. Do not assume a stable
+ordering of those edges.
-Core data structure representing molecular or protein graphs.
+Useful conversions:
-**Attributes:**
-- `num_node`: Number of nodes
-- `num_edge`: Number of edges
-- `node_feature`: Node feature tensor [num_node, feature_dim]
-- `edge_feature`: Edge feature tensor [num_edge, feature_dim]
-- `edge_list`: Edge connectivity [num_edge, 2 or 3]
-- `num_relation`: Number of edge types (for multi-relational)
+- `data.Molecule.from_smiles(smiles)`
+- `data.Molecule.from_molecule(rdkit_mol)`
+- `molecule.to_smiles()`
+- `molecule.to_molecule()`
+- `data.PackedMolecule.from_smiles(smiles_list)`
+- `data.PackedMolecule.from_molecule(rdkit_mols)`
-**Methods:**
-- `node_mask(mask)`: Select subset of nodes
-- `edge_mask(mask)`: Select subset of edges
-- `undirected()`: Make graph undirected
-- `directed()`: Make graph directed
+`PackedMolecule.to_smiles()` and `.to_molecule()` return lists.
-**Batching:**
-- Graphs batched into single disconnected graph
-- Automatic batching in DataLoader
-- Preserves node/edge indices per graph
+## Proteins
-### Molecule (extends Graph)
-
-Specialized graph for molecules.
-
-**Additional Attributes:**
-- `atom_type`: Atomic numbers
-- `bond_type`: Bond types (single, double, triple, aromatic)
-- `formal_charge`: Atomic formal charges
-- `explicit_hs`: Explicit hydrogen counts
-
-**Methods:**
-- `from_smiles(smiles)`: Create from SMILES string
-- `from_molecule(mol)`: Create from RDKit molecule
-- `to_smiles()`: Convert to SMILES
-- `to_molecule()`: Convert to RDKit molecule
-- `ion_to_molecule()`: Neutralize charges
-
-**Example:**
```python
from torchdrug import data
-# From SMILES
-mol = data.Molecule.from_smiles("CCO")
+sequence_protein = data.Protein.from_sequence(
+ "MKTAYIAKQRQISFVKSHFSRQ",
+ atom_feature=None,
+ bond_feature=None,
+ residue_feature="default",
+)
+structure_protein = data.Protein.from_pdb(
+ "protein.pdb",
+ residue_feature="default",
+)
-# Atom features
-print(mol.atom_type) # [6, 6, 8] (C, C, O)
-print(mol.bond_type) # [1, 1] (single bonds)
+print(sequence_protein.to_sequence())
```
-### Protein (extends Graph)
+For sequence-only work, setting `atom_feature=None` and `bond_feature=None`
+avoids constructing unnecessary atom-level features and can substantially reduce
+loading cost.
-Specialized graph for proteins.
+Documented protein constructors and conversions include:
-**Additional Attributes:**
-- `residue_type`: Amino acid types
-- `atom_name`: Atom names (CA, CB, etc.)
-- `atom_type`: Atomic numbers
-- `residue_number`: Residue numbering
-- `chain_id`: Chain identifiers
+- `Protein.from_sequence`
+- `Protein.from_pdb`
+- `Protein.from_molecule`
+- `Protein.to_sequence`
+- `Protein.to_pdb`
+- `Protein.to_molecule`
-**Methods:**
-- `from_pdb(pdb_file)`: Load from PDB file
-- `from_sequence(sequence)`: Create from sequence
-- `to_pdb(pdb_file)`: Save to PDB file
+Protein graph construction is handled by the documented geometry/graph
+construction layers. `Protein` does not provide a `residue_graph()` method in
+0.2.1.
-**Graph Construction:**
-- Nodes typically represent residues (not atoms)
-- Edges can be sequential, spatial (KNN), or contact-based
-- Configurable edge construction strategies
+## Packed graphs and collation
+
+Graphs of different sizes are packed into a block-diagonal representation:
-**Example:**
```python
from torchdrug import data
-# Load protein
-protein = data.Protein.from_pdb("1a3x.pdb")
-
-# Build graph with multiple edge types
-graph = protein.residue_graph(
- node_position="ca", # Use Cα positions
- edge_types=["sequential", "radius"] # Sequential + spatial edges
-)
+graphs = [
+ data.Molecule.from_smiles("CCO"),
+ data.Molecule.from_smiles("c1ccccc1"),
+]
+batch = data.Graph.pack(graphs)
+restored = batch.unpack()
```
-### PackedGraph
-
-Efficient batching structure for heterogeneous graphs.
-
-**Purpose:**
-- Batch graphs of different sizes
-- Single GPU memory allocation
-- Efficient parallel processing
-
-**Attributes:**
-- `num_nodes`: List of node counts per graph
-- `num_edges`: List of edge counts per graph
-- `graph_ind`: Graph index for each node
-
-**Use Cases:**
-- Automatic in DataLoader
-- Custom batching strategies
-- Multi-graph operations
-
-## Model Interface
-
-### Forward Function Signature
-
-All TorchDrug models follow a standardized interface:
+For dataset samples, use:
```python
-def forward(self, graph, input, all_loss=None, metric=None):
- """
- Args:
- graph (Graph): Batch of graphs
- input (Tensor): Node input features
- all_loss (Tensor, optional): Accumulator for losses
- metric (dict, optional): Dictionary for metrics
-
- Returns:
- dict: Output dictionary with representation keys
- """
- # Model computation
- output = self.layers(graph, input)
-
- return {
- "node_feature": output,
- "graph_feature": graph_pooling(output)
- }
+batch = data.graph_collate(samples)
```
-**Key Points:**
-- `graph`: Batched graph structure
-- `input`: Node features [num_node, input_dim]
-- `all_loss`: Accumulated loss (for multi-task)
-- `metric`: Shared metric dictionary
-- Returns dict with representation types
-
-### Essential Attributes
-
-**All models must define:**
-- `input_dim`: Expected input feature dimension
-- `output_dim`: Output representation dimension
+`graph_collate` recursively collates nested containers and uses `Graph.pack` for
+graph values. Prefer it to PyTorch's default collator for manual inference.
-**Purpose:**
-- Automatic dimension checking
-- Compose models in pipelines
-- Error checking and validation
+Packed graph operations include:
-**Example:**
-```python
-class CustomModel(nn.Module):
- def __init__(self, input_dim, hidden_dim):
- super().__init__()
- self.input_dim = input_dim
- self.output_dim = hidden_dim
- # ... layers ...
-```
-
-## Task Interface
+- `subbatch(index)` for selecting graphs
+- `node_mask(index, compact=...)`
+- `edge_mask(index)`
+- `graph_mask(index, compact=...)`
+- `repeat(count)` / `repeat_interleave(repeats)`
+- `unpack()`
-### Core Task Methods
+## Attributes and references
-All tasks implement these methods:
+TorchDrug graph attributes carry semantic scopes. When adding custom attributes,
+register them in the matching context:
```python
-class CustomTask(tasks.Task):
- def preprocess(self, train_set, valid_set, test_set):
- """Dataset-specific preprocessing (optional)"""
- pass
-
- def predict(self, batch):
- """Generate predictions for a batch"""
- graph, label = batch
- output = self.model(graph, graph.node_feature)
- pred = self.mlp(output["graph_feature"])
- return pred
-
- def target(self, batch):
- """Extract ground truth labels"""
- graph, label = batch
- return label
-
- def forward(self, batch):
- """Compute training loss"""
- pred = self.predict(batch)
- target = self.target(batch)
- loss = self.criterion(pred, target)
- return loss
-
- def evaluate(self, pred, target):
- """Compute evaluation metrics"""
- metrics = {}
- metrics["auroc"] = compute_auroc(pred, target)
- metrics["auprc"] = compute_auprc(pred, target)
- return metrics
-```
-
-### Task Components
-
-**Typical Task Structure:**
-1. **Representation Model**: Encodes graph to embeddings
-2. **Readout/Prediction Head**: Maps embeddings to predictions
-3. **Loss Function**: Training objective
-4. **Metrics**: Evaluation measures
+with mol.atom():
+ mol.is_carbon = mol.atom_type == td.CARBON
-**Example:**
-```python
-from torchdrug import tasks, models
-
-# Representation model
-model = models.GIN(input_dim=10, hidden_dims=[256, 256])
-
-# Task wraps model with prediction head
-task = tasks.PropertyPrediction(
- model=model,
- task=["task1", "task2"], # Multi-task
- criterion="bce",
- metric=["auroc", "auprc"],
- num_mlp_layer=2
-)
+with mol.edge():
+ mol.is_single_bond = mol.bond_type == td.SINGLE
```
-## Version Notes (0.2.1)
-
-- Pin installs with `uv pip install torchdrug==0.2.1` (Python 3.7–3.10, PyTorch 1.8–2.0).
-- `PropertyPrediction.predict()` returns unstandardized targets/predictions (breaking vs older releases).
-- Prefer `atom_feature` / `bond_feature` on dataset constructors; `node_feature` / `edge_feature` are deprecated aliases (dataset properties like `node_feature_dim` are unchanged).
+Use node, edge, graph, and reference contexts so masking, packing, and device
+transfer update custom values correctly. See
+[Deal with References](https://torchdrug.ai/docs/notes/reference.html).
-## Training Workflow
+## Model interface
-### Standard Training Loop
+Graph representation models use this general call shape:
```python
-import torch
-from torch.utils.data import DataLoader
-from torchdrug import core, models, tasks, datasets
-
-# 1. Load dataset
-dataset = datasets.BBBP("~/datasets/")
-train_set, valid_set, test_set = dataset.split()
-
-# 2. Create data loaders
-train_loader = DataLoader(train_set, batch_size=32, shuffle=True)
-valid_loader = DataLoader(valid_set, batch_size=32)
-
-# 3. Define model and task
-model = models.GIN(input_dim=dataset.node_feature_dim,
- hidden_dims=[256, 256, 256])
-task = tasks.PropertyPrediction(model, task=dataset.tasks,
- criterion="bce", metric=["auroc", "auprc"])
-
-# 4. Setup optimizer
-optimizer = torch.optim.Adam(task.parameters(), lr=1e-3)
-
-# 5. Training loop
-for epoch in range(100):
- # Train
- task.train()
- for batch in train_loader:
- loss = task(batch)
- optimizer.zero_grad()
- loss.backward()
- optimizer.step()
-
- # Validate (inference_mode disables autograd; train(False) disables dropout/BN)
- with torch.inference_mode():
- task.train(False)
- preds, targets = [], []
- for batch in valid_loader:
- pred = task.predict(batch)
- target = task.target(batch)
- preds.append(pred)
- targets.append(target)
-
- preds = torch.cat(preds)
- targets = torch.cat(targets)
- metrics = task.evaluate(preds, targets)
- print(f"Epoch {epoch}: {metrics}")
- task.train(True)
-```
-
-### Built-in Engine (`core.Engine`)
-
-For standard train/validate loops without hand-written epochs, use the configurable engine:
-
-```python
-from torchdrug import core
-
-solver = core.Engine(task, train_set, valid_set, test_set, optimizer,
- gpus=[0], batch_size=32)
-solver.train(num_epoch=100)
-solver.evaluate("valid")
+output = model(graph, graph.node_feature)
+graph_feature = output["graph_feature"]
+node_feature = output["node_feature"]
```
-### PyTorch Lightning Integration
+Protein sequence models may return `residue_feature` instead of `node_feature`.
+Inspect the selected model's API page rather than assuming every model returns
+the same keys.
-TorchDrug tasks are compatible with PyTorch Lightning:
+Most models accept optional `all_loss` and `metric` accumulators:
```python
-import pytorch_lightning as pl
-
-class LightningWrapper(pl.LightningModule):
- def __init__(self, task):
- super().__init__()
- self.task = task
- self._val_outputs = []
-
- def training_step(self, batch, batch_idx):
- loss = self.task(batch)
- return loss
-
- def validation_step(self, batch, batch_idx):
- pred = self.task.predict(batch)
- target = self.task.target(batch)
- self._val_outputs.append({"pred": pred, "target": target})
-
- def on_validation_epoch_end(self):
- preds = torch.cat([o["pred"] for o in self._val_outputs])
- targets = torch.cat([o["target"] for o in self._val_outputs])
- metrics = self.task.evaluate(preds, targets)
- self.log_dict(metrics)
- self._val_outputs.clear()
-
- def configure_optimizers(self):
- return torch.optim.Adam(self.parameters(), lr=1e-3)
+output = model(graph, graph.node_feature, all_loss=all_loss, metric=metric)
```
-## Loss Functions
-
-### Built-in Criteria
+Tasks use those accumulators for auxiliary losses and metrics.
-**Classification:**
-- `"bce"`: Binary cross-entropy
-- `"ce"`: Cross-entropy (multi-class)
+## Task and Engine lifecycle
-**Regression:**
-- `"mse"`: Mean squared error
-- `"mae"`: Mean absolute error
+The normal lifecycle is:
-**Knowledge Graph:**
-- `"bce"`: Binary classification of triples
-- `"ce"`: Cross-entropy ranking loss
-- `"margin"`: Margin-based ranking
+1. construct model,
+2. construct task,
+3. construct optimizer over `task.parameters()`,
+4. construct `core.Engine`,
+5. call `solver.train()` and `solver.evaluate()`.
-### Custom Loss
+When `Engine` is created, it calls task preprocessing against the supplied
+train/validation/test sets. This matters because tasks may infer target
+statistics or metadata during preprocessing.
```python
-class CustomTask(tasks.Task):
- def forward(self, batch):
- pred = self.predict(batch)
- target = self.target(batch)
-
- # Custom loss computation
- loss = custom_loss_function(pred, target)
-
- return loss
+optimizer = torch.optim.Adam(task.parameters(), lr=1e-3)
+solver = core.Engine(
+ task,
+ train_set,
+ valid_set,
+ test_set,
+ optimizer,
+ batch_size=128,
+)
+solver.train(num_epoch=10)
+metrics = solver.evaluate("valid")
```
-## Metrics
-
-### Common Metrics
-
-**Classification:**
-- **AUROC**: Area under ROC curve
-- **AUPRC**: Area under precision-recall curve
-- **Accuracy**: Overall accuracy
-- **F1**: Harmonic mean of precision and recall
-
-**Regression:**
-- **MAE**: Mean absolute error
-- **RMSE**: Root mean squared error
-- **R²**: Coefficient of determination
-- **Pearson**: Pearson correlation
+Use `gpus=[0]` for one supported CUDA device. Omit it on CPU. For manual nested
+batches, `torchdrug.utils.cuda(batch)` moves all tensors and graphs together.
-**Ranking (Knowledge Graph):**
-- **MR**: Mean rank
-- **MRR**: Mean reciprocal rank
-- **Hits@K**: Percentage in top K
+## Configuration and checkpoints
-### Multi-Task Metrics
-
-For multi-label or multi-task:
-- Metrics computed per task
-- Macro-average across tasks
-- Can weight by task importance
-
-## Data Transforms
-
-### Molecule Transforms
+`core.Configurable` serializes component constructor configuration:
```python
-from torchdrug import transforms
-
-# Add virtual node connected to all atoms
-transform1 = transforms.VirtualNode()
-
-# Add virtual edges
-transform2 = transforms.VirtualEdge()
-
-# Compose transforms
-transform = transforms.Compose([transform1, transform2])
-
-dataset = datasets.BBBP("~/datasets/", transform=transform)
-```
-
-### Protein Transforms
+import json
+from torchdrug import core
-```python
-# Add edges based on spatial proximity
-transform = transforms.TruncateProtein(max_length=500)
+with open("solver.json", "w") as fout:
+ json.dump(solver.config_dict(), fout)
+solver.save("solver.pth")
-dataset = datasets.Fold("~/datasets/", transform=transform)
+with open("solver.json") as fin:
+ restored_solver = core.Configurable.load_config_dict(json.load(fin))
+restored_solver.load("solver.pth")
```
-## Best Practices
-
-### Memory Efficiency
-
-1. **Gradient Accumulation**: For large models
-2. **Mixed Precision**: FP16 training
-3. **Batch Size Tuning**: Balance speed and memory
-4. **Data Loading**: Multiple workers for I/O
-
-### Reproducibility
-
-1. **Set Seeds**: PyTorch, NumPy, Python random
-2. **Deterministic Operations**: `torch.use_deterministic_algorithms(True)`
-3. **Save Configurations**: Use `core.Configurable`
-4. **Version Control**: Track TorchDrug version
-
-### Debugging
-
-1. **Check Dimensions**: Verify `input_dim` and `output_dim`
-2. **Validate Batching**: Print batch statistics
-3. **Monitor Gradients**: Watch for vanishing/exploding
-4. **Overfit Small Batch**: Ensure model capacity
-
-### Performance Optimization
+For transfer learning, a solver checkpoint stores model state under `"model"`:
-1. **GPU Utilization**: Monitor with `nvidia-smi`
-2. **Profile Code**: Use PyTorch profiler
-3. **Optimize Data Loading**: Prefetch, pin memory
-4. **Compile Models**: Use TorchScript if possible
-
-## Advanced Topics
-
-### Multi-Task Learning
-
-Train single model on multiple related tasks:
```python
-task = tasks.PropertyPrediction(
- model,
- task=["task1", "task2", "task3"],
- criterion="bce",
- metric=["auroc"],
- task_weight=[1.0, 1.0, 2.0] # Weight task 3 more
-)
+checkpoint = torch.load("pretrained.pth")["model"]
+task.load_state_dict(checkpoint, strict=False)
```
-### Transfer Learning
-
-1. Pre-train on large dataset
-2. Fine-tune on target dataset
-3. Optionally freeze early layers
-
-### Self-Supervised Pre-training
+Use `strict=False` only when intentionally transferring a compatible subset, such
+as a pretrained encoder into a property-prediction task.
-Use pre-training tasks:
-- `AttributeMasking`: Mask node features
-- `EdgePrediction`: Predict edge existence
-- `ContextPrediction`: Contrastive learning
+## Feature naming in 0.2.1
-### Custom Layers
-
-Extend TorchDrug with custom GNN layers:
-```python
-from torchdrug import layers
-
-class CustomConv(layers.MessagePassingBase):
- def message(self, graph, input):
- # Custom message function
- pass
-
- def aggregate(self, graph, message):
- # Custom aggregation
- pass
-
- def combine(self, input, update):
- # Custom combination
- pass
-```
+Prefer:
-## Common Pitfalls
+- `atom_feature`
+- `bond_feature`
+- `residue_feature`
+- `mol_feature`
-1. **Forgetting `input_dim` and `output_dim`**: Models won't compose
-2. **Not Batching Properly**: Use PackedGraph for variable-sized graphs
-3. **Data Leakage**: Be careful with scaffold splits and pre-training
-4. **Ignoring Edge Features**: Bonds/spatial info can be critical
-5. **Wrong Evaluation Metrics**: Match metrics to task (AUROC for imbalanced)
-6. **Insufficient Regularization**: Use dropout, weight decay, early stopping
-7. **Not Validating Chemistry**: Generated molecules must be valid
-8. **Overfitting Small Datasets**: Use pre-training or simpler models
+The older `node_feature`, `edge_feature`, and `graph_feature` constructor names
+are deprecated aliases where documented. Runtime properties such as
+`dataset.node_feature_dim` and `graph.node_feature` remain valid.
diff --git a/skills/torchdrug/references/datasets.md b/skills/torchdrug/references/datasets.md
index 078d05fb..f4839e12 100644
--- a/skills/torchdrug/references/datasets.md
+++ b/skills/torchdrug/references/datasets.md
@@ -1,380 +1,179 @@
-# Datasets Reference
-
-## Overview
-
-TorchDrug provides 40+ curated datasets across multiple domains: molecular property prediction, protein modeling, knowledge graph reasoning, and retrosynthesis. All datasets support lazy loading, automatic downloading, and customizable feature extraction.
-
-## Molecular Property Prediction Datasets
-
-### Drug Discovery Classification
-
-| Dataset | Size | Task | Classes | Description |
-|---------|------|------|---------|-------------|
-| **BACE** | 1,513 | Binary | 2 | β-secretase inhibition for Alzheimer's |
-| **BBBP** | 2,039 | Binary | 2 | Blood-brain barrier penetration |
-| **HIV** | 41,127 | Binary | 2 | Inhibition of HIV replication |
-| **ClinTox** | 1,478 | Multi-label | 2 | Clinical trial toxicity |
-| **SIDER** | 1,427 | Multi-label | 27 | Side effects by system organ class |
-| **Tox21** | 7,831 | Multi-label | 12 | Toxicity across 12 targets |
-| **ToxCast** | 8,576 | Multi-label | 617 | High-throughput toxicology |
-| **MUV** | 93,087 | Multi-label | 17 | Unbiased validation for screening |
-
-**Key Features:**
-- All use scaffold splits for realistic evaluation
-- Binary classification metrics: AUROC, AUPRC
-- Multi-label handles missing values
-
-**Use Cases:**
-- Drug safety prediction
-- Virtual screening
-- ADMET property prediction
-
-### Drug Discovery Regression
-
-| Dataset | Size | Property | Units | Description |
-|---------|------|----------|-------|-------------|
-| **ESOL** | 1,128 | Solubility | log(mol/L) | Water solubility |
-| **FreeSolv** | 642 | Hydration | kcal/mol | Hydration free energy |
-| **Lipophilicity** | 4,200 | LogD | - | Octanol/water distribution |
-| **SAMPL** | 643 | Solvation | kcal/mol | Solvation free energies |
-
-**Metrics:** MAE, RMSE, R²
-**Use Cases:** ADME optimization, lead optimization
-
-### Quantum Chemistry
-
-| Dataset | Size | Properties | Description |
-|---------|------|------------|-------------|
-| **QM7** | 7,165 | 1 | Atomization energy |
-| **QM8** | 21,786 | 12 | Electronic spectra, excited states |
-| **QM9** | 133,885 | 12 | Geometric, energetic, electronic, thermodynamic |
-| **PCQM4M** | 3.8M | 1 | Large-scale HOMO-LUMO gap |
-
-**Properties (QM9):**
-- Dipole moment
-- Isotropic polarizability
-- HOMO/LUMO energies
-- Internal energy, enthalpy, free energy
-- Heat capacity
-- Electronic spatial extent
-
-**Use Cases:**
-- Quantum property prediction
-- Method development benchmarking
-- Pre-training molecular models
-
-### Large Molecule Databases
-
-| Dataset | Size | Description | Use Case |
-|---------|------|-------------|----------|
-| **ZINC250k** | 250,000 | Drug-like molecules | Generative model training |
-| **ZINC2M** | 2,000,000 | Drug-like molecules | Large-scale pre-training |
-| **ChEMBL** | Millions | Bioactive molecules | Property prediction, generation |
-
-## Protein Datasets
-
-### Function Prediction
-
-| Dataset | Size | Task | Classes | Description |
-|---------|------|------|---------|-------------|
-| **EnzymeCommission** | 17,562 | Multi-class | 7 levels | EC number classification |
-| **GeneOntology** | 46,796 | Multi-label | 489 | GO term prediction (BP/MF/CC) |
-| **BetaLactamase** | 5,864 | Regression | - | Enzyme activity levels |
-| **Fluorescence** | 54,025 | Regression | - | GFP fluorescence intensity |
-| **Stability** | 53,614 | Regression | - | Thermostability (ΔΔG) |
-
-**Features:**
-- Sequence and/or structure input
-- Evolutionary information available
-- Multiple train/test splits
-
-**Use Cases:**
-- Protein engineering
-- Function annotation
-- Enzyme design
-
-### Localization and Solubility
-
-| Dataset | Size | Task | Classes | Description |
-|---------|------|------|---------|-------------|
-| **Solubility** | 62,478 | Binary | 2 | Protein solubility |
-| **BinaryLocalization** | 22,168 | Binary | 2 | Membrane vs soluble |
-| **SubcellularLocalization** | 8,943 | Multi-class | 10 | Subcellular compartment |
-
-**Use Cases:**
-- Protein expression optimization
-- Target identification
-- Cell biology
-
-### Structure Prediction
-
-| Dataset | Size | Task | Description |
-|---------|------|------|-------------|
-| **Fold** | 16,712 | Multi-class (1,195) | Structural fold recognition |
-| **SecondaryStructure** | 8,678 | Sequence labeling | 3-state or 8-state prediction |
-| **ProteinNet** | Varied | Contact prediction | Residue-residue contacts |
-
-**Use Cases:**
-- Structure prediction pipelines
-- Fold recognition
-- Contact map generation
-
-### Protein Interactions
-
-| Dataset | Size | Positives | Negatives | Description |
-|---------|------|-----------|-----------|-------------|
-| **HumanPPI** | 1,412 proteins | 6,584 | - | Human protein interactions |
-| **YeastPPI** | 2,018 proteins | 6,451 | - | Yeast protein interactions |
-| **PPIAffinity** | 2,156 pairs | - | - | Binding affinity values |
-
-**Use Cases:**
-- PPI prediction
-- Network biology
-- Drug target identification
-
-### Protein-Ligand Binding
-
-| Dataset | Size | Type | Description |
-|---------|------|------|-------------|
-| **BindingDB** | ~1.5M | Affinity | Comprehensive binding data |
-| **PDBBind** | 20,000+ | 3D complexes | Structure-based binding |
-| - Refined Set | 5,316 | High quality | Curated crystal structures |
-| - Core Set | 285 | Benchmark | Diverse test set |
-
-**Use Cases:**
-- Binding affinity prediction
-- Structure-based drug design
-- Scoring function development
-
-### Large Protein Databases
-
-| Dataset | Size | Description |
-|---------|------|-------------|
-| **AlphaFoldDB** | 200M+ | Predicted structures for most known proteins |
-| **UniProt** | Integration | Sequence and annotation data |
-
-## Knowledge Graph Datasets
-
-### General Knowledge
-
-| Dataset | Entities | Relations | Triples | Domain |
-|---------|----------|-----------|---------|--------|
-| **FB15k** | 14,951 | 1,345 | 592,213 | Freebase (general knowledge) |
-| **FB15k-237** | 14,541 | 237 | 310,116 | Filtered Freebase |
-| **WN18** | 40,943 | 18 | 151,442 | WordNet (lexical) |
-| **WN18RR** | 40,943 | 11 | 93,003 | Filtered WordNet |
-
-**Relation Types (FB15k-237):**
-- `/people/person/nationality`
-- `/film/film/genre`
-- `/location/location/contains`
-- `/business/company/founders`
-- Many more...
-
-**Use Cases:**
-- Link prediction
-- Relation extraction
-- Knowledge base completion
-
-### Biomedical Knowledge
-
-| Dataset | Entities | Relations | Triples | Description |
-|---------|----------|-----------|---------|-------------|
-| **Hetionet** | 45,158 | 24 | 2,250,197 | Integrates 29 biomedical databases |
-
-**Entity Types in Hetionet:**
-- Genes (20,945)
-- Compounds (1,552)
-- Diseases (137)
-- Anatomy (400)
-- Pathways (1,822)
-- Pharmacologic classes
-- Side effects
-- Symptoms
-- Molecular functions
-- Biological processes
-- Cellular components
-
-**Relation Types:**
-- Compound-binds-Gene
-- Gene-associates-Disease
-- Disease-presents-Symptom
-- Compound-treats-Disease
-- Compound-causes-Side effect
-- Gene-participates-Pathway
-- And 18 more...
-
-**Use Cases:**
-- Drug repurposing
-- Disease mechanism discovery
-- Target identification
-- Multi-hop reasoning in biomedicine
-
-## Citation Network Datasets
-
-| Dataset | Nodes | Edges | Classes | Description |
-|---------|-------|-------|---------|-------------|
-| **Cora** | 2,708 | 5,429 | 7 | Machine learning papers |
-| **CiteSeer** | 3,327 | 4,732 | 6 | Computer science papers |
-| **PubMed** | 19,717 | 44,338 | 3 | Biomedical papers |
-
-**Use Cases:**
-- Node classification
-- GNN baseline comparisons
-- Method development
-
-## Retrosynthesis Datasets
-
-| Dataset | Size | Description |
-|---------|------|-------------|
-| **USPTO-50k** | 50,017 | Curated patent reactions, single-step |
-
-**Features:**
-- Product → Reactants mapping
-- Atom mapping for reaction centers
-- Canonicalized SMILES
-- Balanced across reaction types
-
-**Splits:**
-- Train: ~40,000
-- Validation: ~5,000
-- Test: ~5,000
-
-**Use Cases:**
-- Retrosynthesis prediction
-- Reaction type classification
-- Synthetic route planning
-
-## Dataset Usage Patterns
-
-### Loading Datasets
+# Datasets
+
+Use the
+[TorchDrug 0.2.1 dataset reference](https://torchdrug.ai/docs/api/datasets.html)
+as the class inventory and signature source. Dataset constructors download and
+cache data under the path supplied by the caller.
+
+## Dataset families
+
+### Molecule property prediction
+
+Documented classes include:
+
+- Classification: `BACE`, `BBBP`, `ClinTox`, `HIV`, `MUV`, `SIDER`, `Tox21`,
+ `ToxCast`
+- Regression / quantum properties: `FreeSolv`, `Lipophilicity`, `QM8`, `QM9`,
+ `PCQM4M`
+- Pretraining / generation: `ChEMBLFiltered`, `ZINC250k`, `ZINC2m`, `MOSES`
+
+The official property tutorial uses `ClinTox`; the pretraining tutorial uses
+`ClinTox` for a small demonstration and recommends larger data such as `ZINC2m`
+for real pretraining; the generation tutorial uses `ZINC250k`.
```python
from torchdrug import datasets
-# Basic loading
-dataset = datasets.BBBP("~/molecule-datasets/")
+dataset = datasets.ClinTox(
+ "~/molecule-datasets/",
+ atom_feature="default",
+ bond_feature="default",
+)
+print(dataset.tasks)
+print(dataset.node_feature_dim)
+print(dataset.edge_feature_dim)
+```
-# With transforms
-from torchdrug import transforms
-transform = transforms.VirtualNode()
-dataset = datasets.BBBP("~/molecule-datasets/", transform=transform)
+Common molecule options include `atom_feature`, `bond_feature`, `mol_feature`,
+`with_hydrogen`, and `kekulize`. Availability varies by class; inspect the class
+signature before adding options.
-# Protein dataset
-dataset = datasets.EnzymeCommission("~/protein-datasets/")
+### Protein properties and structure
-# Knowledge graph
-dataset = datasets.FB15k237("~/kg-datasets/")
+Documented families include:
+
+- Sequence / property: `BetaLactamase`, `BinaryLocalization`,
+ `SubcellularLocalization`
+- Structure / function: `EnzymeCommission`, `GeneOntology`, `AlphaFoldDB`
+- Structure labels: `Fold`, `SecondaryStructure`
+- Protein-protein: `HumanPPI`, `YeastPPI`, `PPIAffinity`
+- Protein-ligand: `BindingDB`, `PDBBind`
+
+```python
+dataset = datasets.EnzymeCommission(
+ "~/protein-datasets/",
+ atom_feature=None,
+ bond_feature=None,
+ residue_feature="default",
+)
+train_set, valid_set, test_set = dataset.split()
```
-### Data Splitting
+Protein datasets can be expensive to parse. Where supported, `lazy=True` trades
+lower startup memory for slower item loading. For sequence-only models, omitting
+atom and bond features avoids unnecessary atom-level construction.
+
+### Knowledge graphs
+
+Documented classes:
+
+- `FB15k`
+- `FB15k237`
+- `WN18`
+- `WN18RR`
+- `Hetionet`
```python
-# Random split
-train, valid, test = dataset.split([0.8, 0.1, 0.1])
+dataset = datasets.FB15k237("~/kg-datasets/")
+train_set, valid_set, test_set = dataset.split()
+
+print(dataset.num_entity)
+print(dataset.num_relation)
+```
+
+These datasets provide predefined benchmark splits. Preserve those splits for
+comparable evaluation.
-# Scaffold split (for molecules)
-from torchdrug import utils
-train, valid, test = dataset.split(
- utils.scaffold_split(dataset, [0.8, 0.1, 0.1])
+### Retrosynthesis
+
+`USPTO50k` contains 50,017 reactions across 10 reaction classes. The official
+G2Gs workflow loads two views:
+
+```python
+reaction_dataset = datasets.USPTO50k(
+ "~/molecule-datasets/",
+ atom_feature="center_identification",
+ kekulize=True,
)
+synthon_dataset = datasets.USPTO50k(
+ "~/molecule-datasets/",
+ as_synthon=True,
+ atom_feature="synthon_completion",
+ kekulize=True,
+)
+```
+
+Reaction mode yields reactant/product pairs for center identification. Synthon
+mode yields reactant/synthon pairs for synthon completion.
-# Predefined splits (some datasets)
-train, valid, test = dataset.split()
+## Splitting correctly
+
+Some benchmark datasets expose predefined splits:
+
+```python
+train_set, valid_set, test_set = dataset.split()
+```
+
+For the property-prediction tutorial's random 80/10/10 split, use PyTorch:
+
+```python
+import torch
+
+lengths = [int(0.8 * len(dataset)), int(0.1 * len(dataset))]
+lengths.append(len(dataset) - sum(lengths))
+train_set, valid_set, test_set = torch.utils.data.random_split(dataset, lengths)
+```
+
+Do not assume `dataset.split([0.8, 0.1, 0.1])` is a documented universal API.
+
+For paired retrosynthesis views, reset the same seed before each `split()`:
+
+```python
+torch.manual_seed(1)
+reaction_train, reaction_valid, reaction_test = reaction_dataset.split()
+torch.manual_seed(1)
+synthon_train, synthon_valid, synthon_test = synthon_dataset.split()
```
-### Feature Extraction
-
-**Node Features (Molecules):**
-- Atom type (one-hot or embedding)
-- Formal charge
-- Hybridization
-- Aromaticity
-- Number of hydrogens
-- Chirality
-
-**Edge Features (Molecules):**
-- Bond type (single, double, triple, aromatic)
-- Stereochemistry
-- Conjugation
-- Ring membership
-
-**Node Features (Proteins):**
-- Amino acid type (one-hot)
-- Physicochemical properties
-- Position in sequence
-- Secondary structure
-- Solvent accessibility
-
-**Edge Features (Proteins):**
-- Edge type (sequential, spatial, contact)
-- Distance
-- Angles and dihedrals
-
-## Choosing Datasets
-
-### By Task
-
-**Molecular Property Prediction:**
-- Start with BBBP or HIV (medium size, clear task)
-- Use QM9 for quantum properties
-- ESOL/FreeSolv for regression
-
-**Protein Function:**
-- EnzymeCommission (well-defined classes)
-- GeneOntology (comprehensive annotations)
-
-**Drug Safety:**
-- Tox21 (standard benchmark)
-- ClinTox (clinical relevance)
-
-**Structure-Based:**
-- PDBBind (protein-ligand)
-- ProteinNet (structure prediction)
-
-**Knowledge Graph:**
-- FB15k-237 (standard benchmark)
-- Hetionet (biomedical applications)
-
-**Generation:**
-- ZINC250k (training)
-- QM9 (with properties)
-
-**Retrosynthesis:**
-- USPTO-50k (only choice)
-
-### By Size and Resources
-
-**Small (<5k, for testing):**
-- BACE, FreeSolv, ClinTox
-- Core set of PDBBind
-
-**Medium (5k-100k):**
-- BBBP, HIV, ESOL, Tox21
-- EnzymeCommission, Fold
-- FB15k-237, WN18RR
-
-**Large (>100k):**
-- QM9, MUV, PCQM4M
-- GeneOntology, AlphaFoldDB
-- ZINC2M, BindingDB
-
-### By Domain
-
-**Drug Discovery:** BBBP, HIV, Tox21, ESOL, ZINC
-**Quantum Chemistry:** QM7, QM8, QM9, PCQM4M
-**Protein Engineering:** Fluorescence, Stability, Solubility
-**Structural Biology:** Fold, PDBBind, ProteinNet, AlphaFoldDB
-**Biomedical:** Hetionet, GeneOntology, EnzymeCommission
-**Retrosynthesis:** USPTO-50k
-
-## Best Practices
-
-1. **Start Small**: Test on small datasets before scaling
-2. **Scaffold Split**: Use for realistic drug discovery evaluation
-3. **Balanced Metrics**: Use AUROC + AUPRC for imbalanced data
-4. **Multiple Runs**: Report mean ± std over multiple random seeds
-5. **Data Leakage**: Be careful with pre-trained models
-6. **Domain Knowledge**: Understand what you're predicting
-7. **Validation**: Always use held-out test set
-8. **Preprocessing**: Standardize features, handle missing values
+This preserves sample alignment.
+
+## Feature configuration
+
+Dataset dimensions depend on feature choices. Construct models from the loaded
+dataset rather than hard-coding dimensions:
+
+```python
+model = models.GIN(
+ input_dim=dataset.node_feature_dim,
+ hidden_dims=[256, 256, 256],
+ edge_input_dim=dataset.edge_feature_dim,
+)
+```
+
+Generation and retrosynthesis often require specialized feature sets:
+
+- Pretraining: `atom_feature="pretrain"`, `bond_feature="pretrain"`
+- GCPN / GraphAF: `atom_feature="symbol"`, `kekulize=True`
+- Center identification: `atom_feature="center_identification"`
+- Synthon completion: `atom_feature="synthon_completion"`
+
+Do not mix checkpoint weights across incompatible feature configurations.
+
+## Data integrity and evaluation
+
+- Cache datasets in a controlled project or user data directory.
+- Record TorchDrug version, feature arguments, split method, and random seed.
+- Preserve predefined KG splits.
+- For molecular benchmarks, use the split protocol required by the benchmark;
+ do not claim a random split is a scaffold split.
+- Inspect downloaded data licenses and provenance before redistribution.
+- Validate labels, missing-value masks, and task names before training.
+
+## Source links
+
+- [Dataset API](https://torchdrug.ai/docs/api/datasets.html)
+- [Property prediction tutorial](https://torchdrug.ai/docs/tutorials/property_prediction.html)
+- [Pretraining tutorial](https://torchdrug.ai/docs/tutorials/pretrain.html)
+- [Generation tutorial](https://torchdrug.ai/docs/tutorials/generation.html)
+- [Retrosynthesis tutorial](https://torchdrug.ai/docs/tutorials/retrosynthesis.html)
+- [Knowledge graph tutorial](https://torchdrug.ai/docs/tutorials/reasoning.html)
diff --git a/skills/torchdrug/references/knowledge_graphs.md b/skills/torchdrug/references/knowledge_graphs.md
index f3163e6e..58b19a18 100644
--- a/skills/torchdrug/references/knowledge_graphs.md
+++ b/skills/torchdrug/references/knowledge_graphs.md
@@ -1,320 +1,226 @@
# Knowledge Graph Reasoning
-## Overview
+The official
+[TorchDrug 0.2.1 reasoning tutorial](https://torchdrug.ai/docs/tutorials/reasoning.html)
+covers two workflows:
-Knowledge graphs represent structured information as entities and relations in a graph format. TorchDrug provides comprehensive support for knowledge graph completion (link prediction) using embedding-based models and neural reasoning approaches.
+- knowledge graph embeddings with RotatE,
+- neural inductive logic programming with NeuralLP.
-## Available Datasets
+Both use `tasks.KnowledgeGraphCompletion`.
-### General Knowledge Graphs
-
-**FB15k (Freebase subset):**
-- 14,951 entities
-- 1,345 relation types
-- 592,213 triples
-- General world knowledge from Freebase
+## Datasets
-**FB15k-237:**
-- 14,541 entities
-- 237 relation types
-- 310,116 triples
-- Filtered version removing inverse relations
-- More challenging benchmark
-
-**WN18 (WordNet):**
-- 40,943 entities (word senses)
-- 18 relation types (lexical relations)
-- 151,442 triples
-- Linguistic knowledge graph
+Documented knowledge graph datasets:
-**WN18RR:**
-- 40,943 entities
-- 11 relation types
-- 93,003 triples
-- Filtered WordNet removing easy inverse patterns
+- `FB15k`: 14,951 entities, 1,345 relations, 592,213 triplets
+- `FB15k237`: 14,541 entities, 237 relations, 310,116 triplets
+- `WN18`: 40,943 entities, 18 relations, 151,442 triplets
+- `WN18RR`: 40,943 entities, 11 relations, 93,003 triplets
+- `Hetionet`: 45,158 entities, 24 relations, 2,025,177 triplets
-### Biomedical Knowledge Graphs
+Use predefined splits:
-**Hetionet:**
-- 45,158 entities (genes, compounds, diseases, pathways, etc.)
-- 24 relation types (treats, causes, binds, etc.)
-- 2,250,197 edges
-- Integrates 29 public biomedical databases
-- Designed for drug repurposing and disease understanding
-
-## Task: KnowledgeGraphCompletion
-
-The primary task for knowledge graphs is link prediction - given a head entity and relation, predict the tail entity (or vice versa).
-
-### Task Modes
-
-**Head Prediction:**
-- Given (?, relation, tail), predict head entity
-- "What can cause Disease X?"
-
-**Tail Prediction:**
-- Given (head, relation, ?), predict tail entity
-- "What diseases does Gene X cause?"
-
-**Both:**
-- Predict both head and tail
-- Standard evaluation protocol
-
-### Evaluation Metrics
-
-**Ranking Metrics:**
-- **Mean Rank (MR)**: Average rank of correct entity
-- **Mean Reciprocal Rank (MRR)**: Average of 1/rank
-- **Hits@K**: Percentage of correct entities in top K predictions
- - Typically reported for K=1, 3, 10
-
-**Filtered vs Raw:**
-- **Filtered**: Remove other known true triples from ranking
-- **Raw**: Rank among all possible entities
-- Filtered is standard for evaluation
-
-## Embedding Models
-
-### Translational Models
-
-**TransE (Translation Embedding):**
-- Represents relations as translations in embedding space
-- h + r ≈ t (head + relation ≈ tail)
-- Simple and effective baseline
-- Works well for 1-to-1 relations
-- Struggles with N-to-N relations
-
-**RotatE (Rotation Embedding):**
-- Relations as rotations in complex space
-- Better handles symmetric and inverse relations
-- State-of-the-art on many benchmarks
-- Can model composition patterns
-
-### Semantic Matching Models
-
-**DistMult:**
-- Bilinear scoring function
-- Handles symmetric relations naturally
-- Cannot model asymmetric relations
-- Fast and memory efficient
-
-**ComplEx:**
-- Complex-valued embeddings
-- Models asymmetric and inverse relations
-- Better than DistMult for most graphs
-- Balances expressiveness and efficiency
-
-**SimplE:**
-- Extends DistMult with inverse relations
-- Fully expressive (can represent any relation pattern)
-- Two embeddings per entity (canonical and inverse)
-
-### Neural Logic Models
-
-**NeuralLP (Neural Logic Programming):**
-- Learns logical rules through differentiable operations
-- Interprets predictions via learned rules
-- Good for sparse knowledge graphs
-- Computationally more expensive
+```python
+from torchdrug import datasets
-**KBGAT (Knowledge Base Graph Attention):**
-- Graph attention networks for KG completion
-- Learns entity representations from neighborhood
-- Handles unseen entities through inductive learning
-- Better for incomplete graphs
+dataset = datasets.FB15k237("~/kg-datasets/")
+train_set, valid_set, test_set = dataset.split()
+```
-## Training Workflow
+## RotatE embedding workflow
-### Basic Pipeline
+### Model
```python
-from torchdrug import datasets, models, tasks, core
-
-# Load dataset
-dataset = datasets.FB15k237("~/kg-datasets/")
+import torch
+from torchdrug import core, models, tasks
-# Define model
model = models.RotatE(
num_entity=dataset.num_entity,
num_relation=dataset.num_relation,
- embedding_dim=2000,
- max_score=9
+ embedding_dim=2048,
+ max_score=9,
)
+```
+
+`embedding_dim=2048` follows the tutorial and may be reduced for memory or speed.
-# Define task
+### Task
+
+```python
task = tasks.KnowledgeGraphCompletion(
model,
- num_negative=128,
- adversarial_temperature=2,
- criterion="bce"
+ num_negative=256,
+ adversarial_temperature=1,
)
-
-# Train with PyTorch Lightning or custom loop
```
-### Negative Sampling
+- `num_negative` controls negative samples per positive.
+- `adversarial_temperature` enables score-weighted negative sampling.
-**Strategies:**
-- **Uniform**: Sample entities uniformly at random
-- **Self-Adversarial**: Weight samples by current model's scores
-- **Type-Constrained**: Sample only valid entity types for relation
+### Train and evaluate
-**Parameters:**
-- `num_negative`: Number of negative samples per positive triple
-- `adversarial_temperature`: Temperature for self-adversarial weighting
-- Higher temperature = more focus on hard negatives
-
-### Loss Functions
-
-**Binary Cross-Entropy (BCE):**
-- Treats each triple independently
-- Balanced classification between positive and negative
+```python
+optimizer = torch.optim.Adam(task.parameters(), lr=2e-5)
+solver = core.Engine(
+ task,
+ train_set,
+ valid_set,
+ test_set,
+ optimizer,
+ batch_size=1024,
+)
+solver.train(num_epoch=200)
+solver.evaluate("valid")
+```
-**Margin Loss:**
-- Ensures positive scores higher than negative by margin
-- `max(0, margin + score_neg - score_pos)`
+Add `gpus=[0]` for a supported CUDA device. Reduce the epoch count for smoke
+tests.
-**Logistic Loss:**
-- Smooth version of margin loss
-- Better gradient properties
+## NeuralLP workflow
-## Model Selection Guide
+NeuralLP learns weighted chain-like rules up to a configured maximum length.
-### By Relation Patterns
+```python
+model = models.NeuralLP(
+ num_relation=dataset.num_relation,
+ hidden_dim=128,
+ num_step=3,
+ num_lstm_layer=2,
+)
-**1-to-1 Relations:**
-- TransE works well
-- Any model will likely succeed
+task = tasks.KnowledgeGraphCompletion(
+ model,
+ fact_ratio=0.75,
+ num_negative=256,
+ sample_weight=False,
+)
+```
-**1-to-N Relations:**
-- DistMult, ComplEx, SimplE
-- Avoid TransE
+`fact_ratio=0.75` reserves 75% of training facts for the background graph used
+for reasoning.
-**N-to-1 Relations:**
-- DistMult, ComplEx, SimplE
-- Avoid TransE
+```python
+optimizer = torch.optim.Adam(task.parameters(), lr=1e-3)
+solver = core.Engine(
+ task,
+ train_set,
+ valid_set,
+ test_set,
+ optimizer,
+ batch_size=64,
+)
+solver.train(num_epoch=10)
+solver.evaluate("valid")
+```
-**N-to-N Relations:**
-- ComplEx, SimplE, RotatE
-- Most challenging pattern
+## Other documented models
-**Symmetric Relations:**
-- DistMult, ComplEx
-- RotatE with proper initialization
+Embedding models:
-**Antisymmetric Relations:**
-- ComplEx, SimplE, RotatE
-- Avoid DistMult
+- `models.TransE`
+- `models.DistMult`
+- `models.ComplEx`
+- `models.SimplE`
+- `models.RotatE`
-**Inverse Relations:**
-- ComplEx, SimplE, RotatE
-- Important for bidirectional reasoning
+Graph-attention model:
-**Composition:**
-- RotatE (best)
-- TransE (reasonable)
-- Captures multi-hop paths
+- `models.KBGAT`
-### By Dataset Characteristics
+Verify each constructor in the
+[model API](https://torchdrug.ai/docs/api/models.html#knowledge-graph-reasoning-models).
+Do not transfer argument names from PyKEEN, DGL-KE, or PyTorch Geometric.
-**Small Graphs (< 50k entities):**
-- ComplEx or SimplE
-- Lower embedding dimensions (200-500)
+## Task behavior
-**Large Graphs (> 100k entities):**
-- DistMult for efficiency
-- RotatE for accuracy
-- Higher dimensions (500-2000)
+`KnowledgeGraphCompletion` owns:
-**Sparse Graphs:**
-- NeuralLP (learns rules from limited data)
-- Pre-train embeddings on larger graphs
+- negative sampling,
+- fact-graph construction,
+- loss computation,
+- head and tail prediction,
+- filtered ranking evaluation.
-**Dense, Complete Graphs:**
-- Any embedding model works well
-- Choose based on relation patterns
+Important constructor options include:
-**Biomedical/Domain Graphs:**
-- Consider type constraints in sampling
-- Use domain-specific negative sampling
-- Hetionet benefits from relation-specific models
+- `criterion`
+- `metric`
+- `num_negative`
+- `margin`
+- `adversarial_temperature`
+- `strict_negative`
+- `fact_ratio`
+- `sample_weight`
+- `full_batch_eval`
-## Advanced Techniques
+TorchDrug 0.2.1 added full-batch evaluation support. Choose it according to graph
+size and available memory.
-### Multi-Hop Reasoning
+## Evaluation
-Chain multiple relations to answer complex queries:
-- "What drugs treat diseases caused by gene X?"
-- Requires path-based or rule-based reasoning
-- NeuralLP naturally supports this
+Use filtered ranking metrics:
-### Temporal Knowledge Graphs
+- mean rank (MR)
+- mean reciprocal rank (MRR)
+- Hits@1
+- Hits@3
+- Hits@10
-Extend to time-varying facts:
-- Add temporal information to triples
-- Predict future facts
-- Requires temporal encoding in models
+Filtered evaluation removes other known true triples before ranking. Preserve
+training, validation, and test facts exactly as the task expects to avoid leakage
+or incorrect filtering.
-### Few-Shot Learning
+Also report:
-Handle relations with few examples:
-- Meta-learning approaches
-- Transfer from related relations
-- Important for emerging knowledge
+- results by relation,
+- head vs tail prediction,
+- variance across seeds,
+- memory/runtime settings,
+- whether reciprocal relations were added.
-### Inductive Learning
+## Biomedical use
-Generalize to unseen entities:
-- KBGAT and other GNN-based methods
-- Use entity features/descriptions
-- Critical for evolving knowledge graphs
+Hetionet supports biomedical link-prediction experiments, but a high model score
+does not establish a new treatment, causal mechanism, or validated association.
-## Biomedical Applications
+For drug-repurposing analysis:
-### Drug Repurposing
+1. define the exact relation being predicted,
+2. preserve entity and relation type constraints,
+3. exclude known positives correctly,
+4. check for train/test leakage through inverse or duplicate relations,
+5. calibrate or rank model scores,
+6. validate candidates against independent evidence and domain experts.
-Predict "drug treats disease" links in Hetionet:
-1. Train on known drug-disease associations
-2. Predict new treatment candidates
-3. Filter by mechanism (gene, pathway involvement)
-4. Validate predictions experimentally
+TorchDrug's generic `KnowledgeGraphCompletion` API does not automatically apply
+biomedical type constraints or causal interpretation.
-### Disease Gene Discovery
+## Common failures
-Identify genes associated with diseases:
-1. Model gene-disease-pathway networks
-2. Predict missing gene-disease links
-3. Incorporate protein interactions, expression data
-4. Prioritize candidates for validation
+### Entity/relation mismatch
-### Protein Function Prediction
+Build model sizes from `dataset.num_entity` and `dataset.num_relation`.
-Link proteins to biological processes:
-1. Integrate protein interactions, GO terms
-2. Predict missing GO annotations
-3. Transfer function from similar proteins
+### Evaluation out of memory
-## Common Issues and Solutions
+Lower batch size or disable full-batch evaluation. Reducing negative samples
+mainly affects training, not the size of all-entity ranking.
-**Issue: Poor performance on specific relation types**
-- Solution: Analyze relation patterns, choose appropriate model, or use relation-specific models
+### NeuralLP produces invalid shapes
-**Issue: Overfitting on small graphs**
-- Solution: Reduce embedding dimension, increase regularization, or use simpler models
+Use `num_relation=dataset.num_relation` and let
+`KnowledgeGraphCompletion.preprocess()` construct the fact graph.
-**Issue: Slow training on large graphs**
-- Solution: Reduce negative samples, use DistMult for efficiency, or implement mini-batch training
+### Inflated metrics
-**Issue: Cannot handle new entities**
-- Solution: Use inductive models (KBGAT), incorporate entity features, or pre-compute embeddings for new entities based on their neighbors
+Check for inverse-relation leakage, duplicate triples, accidental use of test
+facts, and raw rather than filtered ranking.
-## Best Practices
+## Source links
-1. Start with ComplEx or RotatE for most tasks
-2. Use self-adversarial negative sampling
-3. Tune embedding dimension (typically 500-2000)
-4. Apply regularization to prevent overfitting
-5. Use filtered evaluation metrics
-6. Analyze performance per relation type
-7. Consider relation-specific models for heterogeneous graphs
-8. Validate predictions with domain experts
+- [Reasoning tutorial](https://torchdrug.ai/docs/tutorials/reasoning.html)
+- [Knowledge graph datasets](https://torchdrug.ai/docs/api/datasets.html#knowledge-graph-datasets)
+- [Knowledge graph models](https://torchdrug.ai/docs/api/models.html#knowledge-graph-reasoning-models)
+- [KnowledgeGraphCompletion task](https://torchdrug.ai/docs/api/tasks.html#knowledge-graph-completion)
diff --git a/skills/torchdrug/references/models_architectures.md b/skills/torchdrug/references/models_architectures.md
index 4b64b45d..456da832 100644
--- a/skills/torchdrug/references/models_architectures.md
+++ b/skills/torchdrug/references/models_architectures.md
@@ -1,541 +1,223 @@
# Models and Architectures
-## Overview
-
-TorchDrug provides a comprehensive collection of pre-built model architectures for various graph-based learning tasks. This reference catalogs all available models with their characteristics, use cases, and implementation details.
-
-## Graph Neural Networks
-
-### GCN (Graph Convolutional Network)
-
-**Type:** Spatial message passing
-**Paper:** Semi-Supervised Classification with Graph Convolutional Networks (Kipf & Welling, 2017)
-
-**Characteristics:**
-- Simple and efficient aggregation
-- Normalized adjacency matrix convolution
-- Works well for homophilic graphs
-- Good baseline for many tasks
-
-**Best For:**
-- Initial experiments and baselines
-- When computational efficiency is important
-- Graphs with clear local structure
-
-**Parameters:**
-- `input_dim`: Node feature dimension
-- `hidden_dims`: List of hidden layer dimensions
-- `edge_input_dim`: Edge feature dimension (optional)
-- `batch_norm`: Apply batch normalization
-- `activation`: Activation function (relu, elu, etc.)
-- `dropout`: Dropout rate
-
-**Use Cases:**
-- Molecular property prediction
-- Citation network classification
-- Social network analysis
-
-### GAT (Graph Attention Network)
-
-**Type:** Attention-based message passing
-**Paper:** Graph Attention Networks (Veličković et al., 2018)
-
-**Characteristics:**
-- Learns attention weights for neighbors
-- Different importance for different neighbors
-- Multi-head attention for robustness
-- Handles varying node degrees naturally
-
-**Best For:**
-- When neighbor importance varies
-- Heterogeneous graphs
-- Interpretable predictions
-
-**Parameters:**
-- `input_dim`, `hidden_dims`: Standard dimensions
-- `num_heads`: Number of attention heads
-- `negative_slope`: LeakyReLU slope
-- `concat`: Concatenate or average multi-head outputs
-
-**Use Cases:**
-- Protein-protein interaction prediction
-- Molecule generation with attention to reactive sites
-- Knowledge graph reasoning with relation importance
-
-### GIN (Graph Isomorphism Network)
-
-**Type:** Maximally powerful message passing
-**Paper:** How Powerful are Graph Neural Networks? (Xu et al., 2019)
-
-**Characteristics:**
-- Theoretically most expressive GNN architecture
-- Injective aggregation function
-- Can distinguish graph structures GCN cannot
-- Often best performance on molecular tasks
-
-**Best For:**
-- Molecular property prediction (state-of-the-art)
-- Tasks requiring structural discrimination
-- Graph classification
-
-**Parameters:**
-- `input_dim`, `hidden_dims`: Standard dimensions
-- `edge_input_dim`: Include edge features
-- `batch_norm`: Typically use true
-- `readout`: Graph pooling ("sum", "mean", "max")
-- `eps`: Learnable or fixed epsilon
-
-**Use Cases:**
-- Drug property prediction (BBBP, HIV, etc.)
-- Molecular generation
-- Reaction prediction
-
-### RGCN (Relational Graph Convolutional Network)
-
-**Type:** Multi-relational message passing
-**Paper:** Modeling Relational Data with Graph Convolutional Networks (Schlichtkrull et al., 2018)
-
-**Characteristics:**
-- Handles multiple edge/relation types
-- Relation-specific weight matrices
-- Basis decomposition for parameter efficiency
-- Essential for knowledge graphs
-
-**Best For:**
-- Knowledge graph reasoning
-- Heterogeneous molecular graphs
-- Multi-relational data
-
-**Parameters:**
-- `num_relation`: Number of relation types
-- `hidden_dims`: Layer dimensions
-- `num_bases`: Basis decomposition (reduce parameters)
-
-**Use Cases:**
-- Knowledge graph completion
-- Retrosynthesis (different bond types)
-- Protein interaction networks
-
-### MPNN (Message Passing Neural Network)
-
-**Type:** General message passing framework
-**Paper:** Neural Message Passing for Quantum Chemistry (Gilmer et al., 2017)
-
-**Characteristics:**
-- Flexible message and update functions
-- Edge features in message computation
-- GRU updates for node hidden states
-- Set2Set readout for graph representation
-
-**Best For:**
-- Quantum chemistry predictions
-- Tasks with important edge information
-- When node states evolve over multiple iterations
-
-**Parameters:**
-- `input_dim`, `hidden_dim`: Feature dimensions
-- `edge_input_dim`: Edge feature dimension
-- `num_layer`: Message passing iterations
-- `num_mlp_layer`: MLP layers in message function
-
-**Use Cases:**
-- QM9 quantum property prediction
-- Molecular dynamics
-- 3D conformation-aware tasks
-
-### SchNet (Continuous-Filter Convolutional Network)
-
-**Type:** 3D geometry-aware convolution
-**Paper:** SchNet: A continuous-filter convolutional neural network (Schütt et al., 2017)
-
-**Characteristics:**
-- Operates on 3D atomic coordinates
-- Continuous filter convolutions
-- Rotation and translation invariant
-- Excellent for quantum chemistry
-
-**Best For:**
-- 3D molecular structure tasks
-- Quantum property prediction
-- Protein structure analysis
-- Energy and force prediction
-
-**Parameters:**
-- `input_dim`: Atom features
-- `hidden_dims`: Layer dimensions
-- `num_gaussian`: RBF basis functions for distances
-- `cutoff`: Interaction cutoff distance
-
-**Use Cases:**
-- QM9 property prediction
-- Molecular dynamics simulations
-- Protein-ligand binding with structures
-- Crystal property prediction
-
-### ChebNet (Chebyshev Spectral CNN)
-
-**Type:** Spectral convolution
-**Paper:** Convolutional Neural Networks on Graphs (Defferrard et al., 2016)
-
-**Characteristics:**
-- Spectral graph convolution
-- Chebyshev polynomial approximation
-- Captures global graph structure
-- Computationally efficient
-
-**Best For:**
-- Tasks requiring global information
-- When graph Laplacian is informative
-- Theoretical analysis
-
-**Parameters:**
-- `input_dim`, `hidden_dims`: Dimensions
-- `num_cheb`: Order of Chebyshev polynomial
-
-**Use Cases:**
-- Citation network classification
-- Brain network analysis
-- Signal processing on graphs
-
-### NFP (Neural Fingerprint)
-
-**Type:** Molecular fingerprint learning
-**Paper:** Convolutional Networks on Graphs for Learning Molecular Fingerprints (Duvenaud et al., 2015)
-
-**Characteristics:**
-- Learns differentiable molecular fingerprints
-- Alternative to hand-crafted fingerprints (ECFP)
-- Circular convolutions like ECFP
-- Interpretable learned features
-
-**Best For:**
-- Molecular similarity learning
-- Property prediction with limited data
-- When interpretability is important
-
-**Parameters:**
-- `input_dim`, `output_dim`: Feature dimensions
-- `hidden_dims`: Layer dimensions
-- `num_layer`: Circular convolution depth
-
-**Use Cases:**
-- Virtual screening
-- Molecular similarity search
-- QSAR modeling
-
-## Protein-Specific Models
-
-### GearNet (Geometry-Aware Relational Graph Network)
-
-**Type:** Protein structure encoder
-**Paper:** Protein Representation Learning by Geometric Structure Pretraining (Zhang et al., 2023)
-
-**Characteristics:**
-- Incorporates 3D geometric information
-- Multiple edge types (sequential, spatial, KNN)
-- Designed specifically for proteins
-- State-of-the-art on protein tasks
-
-**Best For:**
-- Protein structure prediction
-- Protein function prediction
-- Protein-protein interaction
-- Any task with protein 3D structures
-
-**Parameters:**
-- `input_dim`: Residue features
-- `hidden_dims`: Layer dimensions
-- `num_relation`: Edge types (sequence, radius, KNN)
-- `edge_input_dim`: Geometric features (distances, angles)
-- `batch_norm`: Typically true
-
-**Use Cases:**
-- Enzyme function prediction (EnzymeCommission)
-- Protein fold recognition
-- Contact prediction
-- Binding site identification
-
-### ESM (Evolutionary Scale Modeling)
-
-**Type:** Protein language model (transformer)
-**Paper:** Biological structure and function emerge from scaling unsupervised learning (Rives et al., 2021)
-
-**Characteristics:**
-- Pre-trained on 250M+ protein sequences
-- Captures evolutionary and structural information
-- Transformer architecture
-- Transfer learning for downstream tasks
-
-**Best For:**
-- Any sequence-based protein task
-- When no structure available
-- Transfer learning with limited data
+This is a selection guide for the
+[TorchDrug 0.2.1 model API](https://torchdrug.ai/docs/api/models.html). Verify
+constructor signatures on that page before generating code; similarly named
+models in other graph libraries are not API-compatible.
+
+## Graph representation models
+
+Documented graph neural networks include:
+
+- `models.GCN`
+- `models.GAT`
+- `models.GIN`
+- `models.MPNN`
+- `models.NFP`
+- `models.RGCN`
+- `models.ChebNet`
+- `models.SchNet`
+- `models.GearNet`
-**Variants:**
-- ESM-1b: 650M parameters
-- ESM-2: Multiple sizes (8M to 15B parameters)
-
-**Use Cases:**
-- Protein function prediction
-- Variant effect prediction
-- Protein design
-- Structure prediction (ESMFold)
-
-### ProteinBERT
+Their forward methods generally accept:
-**Type:** Masked language model for proteins
+```python
+output = model(graph, input, all_loss=None, metric=None)
+```
-**Characteristics:**
-- BERT-style pre-training
-- Masked amino acid prediction
-- Bidirectional context
-- Good for sequence-based tasks
+Graph encoders return a dictionary containing node- and/or graph-level
+representations. Inspect the selected model's documented return fields.
-**Use Cases:**
-- Function annotation
-- Subcellular localization
-- Stability prediction
+### GIN for molecular properties
-### ProteinCNN / ProteinResNet
+The official property tutorial uses:
-**Type:** Convolutional networks for sequences
+```python
+model = models.GIN(
+ input_dim=dataset.node_feature_dim,
+ hidden_dims=[256, 256, 256, 256],
+ short_cut=True,
+ batch_norm=True,
+ concat_hidden=True,
+)
+```
-**Characteristics:**
-- 1D convolutions on sequences
-- Local pattern recognition
-- Faster than transformers
-- Good for motif detection
+The pretraining tutorial includes bond features:
+
+```python
+model = models.GIN(
+ input_dim=dataset.node_feature_dim,
+ hidden_dims=[300, 300, 300, 300, 300],
+ edge_input_dim=dataset.edge_feature_dim,
+ batch_norm=True,
+ readout="mean",
+)
+```
-**Use Cases:**
-- Binding site prediction
-- Secondary structure prediction
-- Domain identification
+Use the exact feature configuration that produced
+`dataset.node_feature_dim` and `dataset.edge_feature_dim`.
-### ProteinLSTM
+### RGCN for typed edges
-**Type:** Recurrent network for sequences
+The official generation and retrosynthesis tutorials use `RGCN`:
-**Characteristics:**
-- Bidirectional LSTM
-- Captures long-range dependencies
-- Sequential processing
-- Good baseline for sequence tasks
+```python
+model = models.RGCN(
+ input_dim=dataset.node_feature_dim,
+ hidden_dims=[256, 256, 256, 256],
+ num_relation=dataset.num_bond_type,
+ batch_norm=False,
+)
+```
-**Use Cases:**
-- Order prediction
-- Sequential annotation
-- Time-series protein data
+`num_relation` must match the graph relation vocabulary. For molecule graphs in
+these tutorials, it comes from `dataset.num_bond_type`.
-## Knowledge Graph Models
+### 3D and protein structure models
-### TransE (Translation Embedding)
+- `SchNet` requires a `node_position` graph attribute.
+- `GearNet` is the documented geometry-aware relational model for protein
+ structures.
-**Type:** Translation-based embedding
-**Paper:** Translating Embeddings for Modeling Multi-relational Data (Bordes et al., 2013)
+Use graph-construction layers to create required spatial and sequential edges;
+do not assume loading a PDB automatically creates every relation a structure
+model expects.
-**Characteristics:**
-- h + r ≈ t (head + relation ≈ tail)
-- Simple and interpretable
-- Works well for 1-to-1 relations
-- Memory efficient
+## Protein sequence encoders
-**Best For:**
-- Large knowledge graphs
-- Initial experiments
-- Interpretable embeddings
+Documented classes and aliases include:
-**Parameters:**
-- `num_entity`, `num_relation`: Graph size
-- `embedding_dim`: Embedding dimensions (typically 50-500)
+- `models.ESM` (`EvolutionaryScaleModeling`)
+- `models.ProteinCNN`
+- `models.ProteinResNet`
+- `models.ProteinLSTM`
+- `models.ProteinBERT`
-### RotatE (Rotation Embedding)
+The 0.2.1 ESM constructor is:
-**Type:** Rotation in complex space
-**Paper:** RotatE: Knowledge Graph Embedding by Relational Rotation in Complex Space (Sun et al., 2019)
+```python
+model = models.ESM(
+ path="~/model-weights/esm/",
+ model="ESM-1b",
+ readout="mean",
+)
+```
-**Characteristics:**
-- Relations as rotations in complex space
-- Handles symmetric, antisymmetric, inverse, composition
-- State-of-the-art on many benchmarks
+The release notes add ESM-2 support, but checkpoint names and availability
+should be verified against the API/source before use. Do not use the unsupported
+pattern `models.ESM(path="checkpoint-file.pt")`; `path` is the directory where
+TorchDrug stores model weights.
-**Best For:**
-- Most knowledge graph tasks
-- Complex relation patterns
-- When accuracy is critical
+Protein sequence encoders return residue and graph features. Respect the model's
+maximum input length and tokenization behavior.
-**Parameters:**
-- `num_entity`, `num_relation`: Graph size
-- `embedding_dim`: Must be even (complex embeddings)
-- `max_score`: Score clipping value
+## Knowledge graph models
-### DistMult
+Embedding models:
-**Type:** Bilinear model
+- `models.TransE`
+- `models.DistMult`
+- `models.ComplEx`
+- `models.SimplE`
+- `models.RotatE`
-**Characteristics:**
-- Symmetric relation modeling
-- Fast and efficient
-- Cannot model antisymmetric relations
+Neural reasoning models:
-**Best For:**
-- Symmetric relations (e.g., "similar to")
-- When speed is critical
-- Large-scale graphs
+- `models.NeuralLP` (alias of `NeuralLogicProgramming`)
+- `models.KBGAT`
-### ComplEx
+The official embedding tutorial uses:
-**Type:** Complex-valued embeddings
+```python
+model = models.RotatE(
+ num_entity=dataset.num_entity,
+ num_relation=dataset.num_relation,
+ embedding_dim=2048,
+ max_score=9,
+)
+```
-**Characteristics:**
-- Handles asymmetric and symmetric relations
-- Better than DistMult for most graphs
-- Good balance of expressiveness and efficiency
+The official NeuralLP tutorial uses:
-**Best For:**
-- General knowledge graph completion
-- Mixed relation types
-- When RotatE is too complex
+```python
+model = models.NeuralLP(
+ num_relation=dataset.num_relation,
+ hidden_dim=128,
+ num_step=3,
+ num_lstm_layer=2,
+)
+```
-### SimplE
+Both are wrapped by `tasks.KnowledgeGraphCompletion`; model construction alone
+does not define negative sampling or evaluation.
-**Type:** Enhanced embedding model
+## Generative and self-supervised models
-**Characteristics:**
-- Two embeddings per entity (canonical + inverse)
-- Fully expressive
-- Slightly more parameters than ComplEx
+### GCPN
-**Best For:**
-- When full expressiveness needed
-- Inverse relations are important
+GCPN is exposed as a task rather than a `models.GCPN` class:
-## Generative Models
+```python
+task = tasks.GCPNGeneration(
+ model,
+ dataset.atom_types,
+ max_edge_unroll=12,
+ max_node=38,
+ criterion="nll",
+)
+```
-### GraphAutoregressiveFlow
+The `model` argument is the graph representation model, normally `RGCN` in the
+official tutorial.
-**Type:** Normalizing flow for molecules
+### GraphAF
-**Characteristics:**
-- Exact likelihood computation
-- Invertible transformations
-- Stable training (no adversarial)
-- Conditional generation support
+GraphAF uses two flow models:
-**Best For:**
-- Molecular generation
-- Density estimation
-- Interpolation between molecules
+- node flow: `models.GraphAF(..., use_edge=False, ...)`
+- edge flow: `models.GraphAF(..., use_edge=True, ...)`
-**Parameters:**
-- `input_dim`: Atom features
-- `hidden_dims`: Coupling layers
-- `num_flow`: Number of flow transformations
+Wrap both in:
-**Use Cases:**
-- De novo drug design
-- Chemical space exploration
-- Property-targeted generation
+```python
+task = tasks.AutoregressiveGeneration(
+ node_flow,
+ edge_flow,
+ max_node=38,
+ max_edge_unroll=12,
+ criterion="nll",
+)
+```
-## Pre-training Models
+`models.GraphAF` is an alias for `GraphAutoregressiveFlow`. It is not itself the
+training task.
-### InfoGraph
+### Self-supervised encoders
-**Type:** Contrastive learning
+The official pretraining tutorial documents:
-**Characteristics:**
-- Maximizes mutual information
-- Graph-level and node-level contrast
-- Unsupervised pre-training
-- Good for small datasets
+- `models.InfoGraph` wrapped by `tasks.Unsupervised`
+- a base GNN wrapped directly by `tasks.AttributeMasking`
-**Use Cases:**
-- Pre-train molecular encoders
-- Few-shot learning
-- Transfer learning
+Other API-documented self-supervised components include `MultiviewContrast`.
+Do not infer a task constructor from a paper name; check whether the component
+lives under `models` or `tasks`.
-### MultiviewContrast
+## Model selection checklist
-**Type:** Multi-view contrastive learning for proteins
+1. Identify the graph/data type.
+2. Check required graph attributes and relation counts.
+3. Build dimensions from the loaded dataset.
+4. Confirm whether the algorithm is a model or a task.
+5. Match checkpoint architecture and feature configuration exactly.
+6. Wrap the model in the task used by the official tutorial or API.
+7. Start with a small batch and one epoch before scaling.
-**Characteristics:**
-- Contrasts different views of proteins
-- Geometric pre-training
-- Uses 3D structure information
-- Excellent for protein models
+## Source links
-**Use Cases:**
-- Pre-train GearNet on protein structures
-- Transfer to property prediction
-- Limited labeled data scenarios
-
-## Model Selection Guide
-
-### By Task Type
-
-**Molecular Property Prediction:**
-1. GIN (first choice)
-2. GAT (interpretability)
-3. SchNet (3D available)
-
-**Protein Tasks:**
-1. ESM (sequence only)
-2. GearNet (structure available)
-3. ProteinBERT (sequence, lighter than ESM)
-
-**Knowledge Graphs:**
-1. RotatE (best performance)
-2. ComplEx (good balance)
-3. TransE (large graphs, efficiency)
-
-**Molecular Generation:**
-1. GraphAutoregressiveFlow (exact likelihood)
-2. GCPN with GIN backbone (property optimization)
-
-**Retrosynthesis:**
-1. GIN (synthon completion)
-2. RGCN (center identification with bond types)
-
-### By Dataset Size
-
-**Small (< 1k):**
-- Use pre-trained models (ESM for proteins)
-- Simpler architectures (GCN, ProteinCNN)
-- Heavy regularization
-
-**Medium (1k-100k):**
-- GIN for molecules
-- GAT for interpretability
-- Standard training
-
-**Large (> 100k):**
-- Any model works
-- Deeper architectures
-- Can train from scratch
-
-### By Computational Budget
-
-**Low:**
-- GCN (simplest)
-- DistMult (KG)
-- ProteinLSTM
-
-**Medium:**
-- GIN
-- GAT
-- ComplEx
-
-**High:**
-- ESM (large)
-- SchNet (3D)
-- RotatE with high dim
-
-## Implementation Tips
-
-1. **Start Simple**: Begin with GCN or GIN baseline
-2. **Use Pre-trained**: ESM for proteins, InfoGraph for molecules
-3. **Tune Depth**: 3-5 layers typically sufficient
-4. **Batch Normalization**: Usually helps (except KG embeddings)
-5. **Residual Connections**: Important for deep networks
-6. **Readout Function**: "mean" usually works well
-7. **Edge Features**: Include when available (bonds, distances)
-8. **Regularization**: Dropout, weight decay, early stopping
+- [Model API](https://torchdrug.ai/docs/api/models.html)
+- [Task API](https://torchdrug.ai/docs/api/tasks.html)
+- [Property tutorial](https://torchdrug.ai/docs/tutorials/property_prediction.html)
+- [Pretraining tutorial](https://torchdrug.ai/docs/tutorials/pretrain.html)
+- [Generation tutorial](https://torchdrug.ai/docs/tutorials/generation.html)
+- [Reasoning tutorial](https://torchdrug.ai/docs/tutorials/reasoning.html)
diff --git a/skills/torchdrug/references/molecular_generation.md b/skills/torchdrug/references/molecular_generation.md
index 47e7f3d5..9e56ef96 100644
--- a/skills/torchdrug/references/molecular_generation.md
+++ b/skills/torchdrug/references/molecular_generation.md
@@ -1,352 +1,246 @@
# Molecular Generation
-## Overview
+The official
+[TorchDrug 0.2.1 generation tutorial](https://torchdrug.ai/docs/tutorials/generation.html)
+implements GCPN and GraphAF on ZINC250k. It pretrains with negative
+log-likelihood (NLL), then optionally fine-tunes with proximal policy optimization
+(PPO) for QED or penalized logP.
-Molecular generation involves creating novel molecular structures with desired properties. TorchDrug supports both unconditional generation (exploring chemical space) and conditional generation (optimizing for specific properties).
+## Shared dataset
-## Task Types
-
-### AutoregressiveGeneration
-
-Generates molecules step-by-step by sequentially adding atoms and bonds. This approach enables fine-grained control and property optimization during generation.
-
-**Key Features:**
-- Sequential atom-by-bond construction
-- Supports property optimization during generation
-- Can incorporate chemical validity constraints
-- Enables multi-objective optimization
+```python
+from torchdrug import datasets
-**Generation Strategies:**
-1. **Beam Search**: Keep top-k candidates at each step
-2. **Sampling**: Probabilistic selection for diversity
-3. **Greedy**: Always select highest probability action
+dataset = datasets.ZINC250k(
+ "~/molecule-datasets/",
+ kekulize=True,
+ atom_feature="symbol",
+)
+```
-**Property Optimization:**
-- Reward shaping based on desired properties
-- Real-time constraint satisfaction
-- Multi-objective balancing (e.g., potency + drug-likeness)
+The tutorial assumes:
-### GCPNGeneration (Graph Convolutional Policy Network)
+- maximum graph size: 38 atoms
+- 9 atom types
+- 3 bond types
+- `max_edge_unroll=12`
-Uses reinforcement learning to generate molecules optimized for specific properties.
+If using another dataset, recompute these assumptions instead of copying the
+ZINC250k values.
-**Components:**
-1. **Policy Network**: Decides which action to take (add atom, add bond)
-2. **Reward Function**: Evaluates generated molecule quality
-3. **Training**: Reinforcement learning with policy gradient
+## GCPN
-**Advantages:**
-- Direct optimization of non-differentiable objectives
-- Can incorporate complex domain knowledge
-- Balances exploration and exploitation
+### Pretraining task
-**Applications:**
-- Drug design with specific targets
-- Material discovery with property constraints
-- Multi-objective molecular optimization
+```python
+import torch
+from torchdrug import core, models, tasks
+
+model = models.RGCN(
+ input_dim=dataset.node_feature_dim,
+ num_relation=dataset.num_bond_type,
+ hidden_dims=[256, 256, 256, 256],
+ batch_norm=False,
+)
+task = tasks.GCPNGeneration(
+ model,
+ dataset.atom_types,
+ max_edge_unroll=12,
+ max_node=38,
+ criterion="nll",
+)
-## Generative Models
+optimizer = torch.optim.Adam(task.parameters(), lr=1e-3)
+solver = core.Engine(
+ task,
+ dataset,
+ None,
+ None,
+ optimizer,
+ batch_size=128,
+ log_interval=10,
+)
+solver.train(num_epoch=1)
+solver.save("gcpn-zinc250k.pth")
+```
-### GraphAutoregressiveFlow
+Use `gpus=(0,)` or `gpus=[0]` only on supported CUDA hardware.
-Normalizing flow model for molecular generation with exact likelihood computation.
+### Generate samples
-**Architecture:**
-- Coupling layers transform simple distribution to complex molecular distribution
-- Invertible transformations enable density estimation
-- Supports conditional generation
+```python
+solver.load("gcpn-zinc250k.pth")
+results = task.generate(num_sample=32, max_resample=5)
+print(results.to_smiles())
+```
-**Key Features:**
-- Exact likelihood computation (vs. VAE's approximate likelihood)
-- Stable training (vs. GAN's adversarial training)
-- Efficient sampling through invertible transformations
-- Can generate molecules with specified properties
+`results` is a packed molecule object. Validate all returned structures before
+downstream use.
-**Training:**
-- Maximum likelihood on molecule dataset
-- Optional property prediction head for conditional generation
-- Typically trained on ZINC or QM9
+### Goal-directed fine-tuning
-**Use Cases:**
-- Generating diverse drug-like molecules
-- Interpolation between known molecules
-- Density estimation for molecular space
+The documented optimization tasks are `"qed"` and `"plogp"`. The task does not
+accept an arbitrary `reward_function=` callback in 0.2.1.
-## Generation Workflows
+```python
+task = tasks.GCPNGeneration(
+ model,
+ dataset.atom_types,
+ max_edge_unroll=12,
+ max_node=38,
+ task="plogp",
+ criterion="ppo",
+ reward_temperature=1,
+ agent_update_interval=3,
+ gamma=0.9,
+)
-### Unconditional Generation
+optimizer = torch.optim.Adam(task.parameters(), lr=1e-5)
+solver = core.Engine(
+ task,
+ dataset,
+ None,
+ None,
+ optimizer,
+ batch_size=16,
+ log_interval=10,
+)
+solver.load("gcpn-zinc250k.pth", load_optimizer=False)
+solver.train(num_epoch=10)
+```
-Generate diverse molecules without specific property targets.
+For mixed supervised/RL training, the tutorial also uses:
-**Workflow:**
-1. Train generative model on molecule dataset (e.g., ZINC250k)
-2. Sample from learned distribution
-3. Post-process for validity and uniqueness
-4. Evaluate diversity metrics
+```python
+criterion = ("ppo", "nll")
+```
-**Evaluation Metrics:**
-- **Validity**: Percentage of chemically valid molecules
-- **Uniqueness**: Percentage of unique molecules among valid
-- **Novelty**: Percentage not in training set
-- **Diversity**: Internal diversity using fingerprint similarity
+or a weighted criterion mapping where supported by the task.
-### Conditional Generation
+## GraphAF
-Generate molecules optimized for specific properties.
+GraphAF has three distinct layers:
-**Property Targets:**
-- **Drug-likeness**: LogP, QED, Lipinski's rule of five
-- **Synthesizability**: SA score, retrosynthesis feasibility
-- **Bioactivity**: Predicted IC50, binding affinity
-- **ADMET**: Absorption, distribution, metabolism, excretion, toxicity
-- **Multi-objective**: Balance multiple properties simultaneously
+1. an `RGCN` representation model,
+2. node and edge flow models exposed as `models.GraphAF`,
+3. `tasks.AutoregressiveGeneration` as the training objective.
-**Workflow:**
-1. Define reward function combining property objectives
-2. Train GCPN or condition flow model on properties
-3. Generate molecules with desired property ranges
-4. Validate generated molecules (in silico → wet lab)
+The representation model uses discrete atom-type input:
-### Scaffold-Based Generation
+```python
+model = models.RGCN(
+ input_dim=dataset.num_atom_type,
+ num_relation=dataset.num_bond_type,
+ hidden_dims=[256, 256, 256],
+ batch_norm=True,
+)
+```
-Generate molecules around a fixed scaffold or core structure.
+Create the node and edge priors exactly as shown in the upstream tutorial, then
+construct one flow for nodes and one for edges:
-**Applications:**
-- Lead optimization keeping core pharmacophore
-- R-group enumeration for SAR studies
-- Fragment linking and growing
+```python
+from torchdrug.layers import distribution
-**Approaches:**
-- Mask scaffold during training
-- Condition generation on scaffold
-- Post-generation grafting
+num_atom_type = dataset.num_atom_type
+num_bond_type = dataset.num_bond_type + 1 # one extra class for no edge
-### Fragment-Based Generation
+node_prior = distribution.IndependentGaussian(
+ torch.zeros(num_atom_type),
+ torch.ones(num_atom_type),
+)
+edge_prior = distribution.IndependentGaussian(
+ torch.zeros(num_bond_type),
+ torch.ones(num_bond_type),
+)
+node_flow = models.GraphAF(
+ model,
+ node_prior,
+ num_layer=12,
+)
+edge_flow = models.GraphAF(
+ model,
+ edge_prior,
+ use_edge=True,
+ num_layer=12,
+)
-Build molecules from validated fragments.
+task = tasks.AutoregressiveGeneration(
+ node_flow,
+ edge_flow,
+ max_node=38,
+ max_edge_unroll=12,
+ criterion="nll",
+)
+```
-**Benefits:**
-- Ensures drug-like substructures
-- Reduces search space
-- Incorporates medicinal chemistry knowledge
+Do not omit the documented prior construction. The node and edge prior shapes
+must match the dataset's atom and bond vocabularies.
-**Methods:**
-- Fragment library as building blocks
-- Vocabulary-based generation
-- Fragment linking with learned linkers
+Train and generate through the task:
-## Property Optimization Strategies
+```python
+optimizer = torch.optim.Adam(task.parameters(), lr=1e-3)
+solver = core.Engine(
+ task,
+ dataset,
+ None,
+ None,
+ optimizer,
+ batch_size=128,
+ log_interval=10,
+)
+solver.train(num_epoch=10)
+solver.save("graphaf-zinc250k.pth")
-### Single-Objective Optimization
+solver.load("graphaf-zinc250k.pth")
+results = task.generate(num_sample=32)
+print(results.to_smiles())
+```
-Maximize or minimize a single property (e.g., binding affinity).
+For PPO fine-tuning, rebuild `AutoregressiveGeneration` with `task="qed"` or
+`task="plogp"`, a PPO criterion, and the tutorial's reward/baseline settings;
+then load the pretrained checkpoint with `load_optimizer=False`.
-**Approach:**
-- Define scalar reward function
-- Use GCPN with RL training
-- Generate and rank candidates
+## What the API does not provide
-**Challenges:**
-- May sacrifice other important properties
-- Risk of adversarial examples (valid but non-drug-like)
-- Need constraints on drug-likeness
+Avoid these unsupported patterns:
-### Multi-Objective Optimization
+```python
+# Not a TorchDrug 0.2.1 API
+tasks.GCPNGeneration(model, reward_function=my_reward, criterion="ppo")
+```
-Balance multiple competing objectives (e.g., potency, selectivity, synthesizability).
+TorchDrug 0.2.1's built-in generation task names are limited to QED and penalized
+logP. A custom objective requires extending the task implementation rather than
+passing a callback shown in another library.
-**Weighting Approaches:**
-- **Linear combination**: w1×prop1 + w2×prop2 + ...
-- **Pareto optimization**: Find non-dominated solutions
-- **Constraint satisfaction**: Threshold on secondary objectives
+The tutorial does not document generic scaffold-conditioned or
+fragment-conditioned constructors. Do not claim those capabilities without a
+separate implementation.
-**Example Objectives:**
-- High binding affinity (target)
-- Low binding affinity (off-targets)
-- High synthesizability (SA score)
-- Drug-like properties (QED)
-- Low molecular weight
+## Evaluation and safety
-**Workflow:**
-```python
-from torchdrug import tasks
+At minimum report:
-# Define multi-objective reward
-def reward_function(mol):
- affinity_score = predict_binding(mol)
- druglikeness = calculate_qed(mol)
- synthesizability = sa_score(mol)
+- validity
+- uniqueness
+- novelty against the training set
+- duplicate-aware property distributions
+- failure and resampling rates
- # Weighted combination
- reward = 0.5 * affinity_score + 0.3 * druglikeness + 0.2 * (1 - synthesizability)
- return reward
+Also:
-# GCPN task with custom reward
-task = tasks.GCPNGeneration(
- model,
- reward_function=reward_function,
- criterion="ppo" # Proximal policy optimization
-)
-```
+- canonicalize and sanitize with a chemistry toolkit,
+- reject disconnected or chemically implausible structures as appropriate,
+- screen structural alerts and undesirable substructures,
+- assess synthetic accessibility separately,
+- avoid presenting QED or penalized logP as evidence of efficacy or safety,
+- keep generated structures out of automated synthesis without expert review.
-### Constraint-Based Generation
+## Source links
-Generate molecules satisfying hard constraints.
-
-**Common Constraints:**
-- Molecular weight range
-- LogP range
-- Number of rotatable bonds
-- Ring count limits
-- Substructure inclusion/exclusion
-- Synthetic accessibility threshold
-
-**Implementation:**
-- Validity checking during generation
-- Early stopping for invalid molecules
-- Penalty terms in reward function
-
-## Training Considerations
-
-### Dataset Selection
-
-**ZINC (Drug-like compounds):**
-- ZINC250k: 250,000 compounds
-- ZINC2M: 2 million compounds
-- Pre-filtered for drug-likeness
-- Good for drug discovery applications
-
-**QM9 (Small organic molecules):**
-- 133,885 molecules
-- Includes quantum properties
-- Good for property prediction models
-
-**ChEMBL (Bioactive molecules):**
-- Millions of bioactive compounds
-- Activity data available
-- Target-specific generation
-
-**Custom Datasets:**
-- Focus on specific chemical space
-- Include expert knowledge
-- Domain-specific constraints
-
-### Data Augmentation
-
-**SMILES Augmentation:**
-- Generate multiple SMILES for same molecule
-- Helps model learn canonical representations
-- Improves robustness
-
-**Graph Augmentation:**
-- Random node/edge masking
-- Subgraph sampling
-- Motif substitution
-
-### Model Architecture Choices
-
-**For Small Molecules (<30 atoms):**
-- Simpler architectures sufficient
-- Faster training and generation
-- GCN or GIN backbone
-
-**For Drug-like Molecules:**
-- Deeper architectures (4-6 layers)
-- Attention mechanisms help
-- Consider molecular fingerprints
-
-**For Macrocycles/Polymers:**
-- Handle larger graphs
-- Ring closure mechanisms important
-- Long-range dependencies
-
-## Validation and Filtering
-
-### In Silico Validation
-
-**Chemical Validity:**
-- Valence rules
-- Aromaticity rules
-- Charge neutrality
-- Stable substructures
-
-**Drug-likeness Filters:**
-- Lipinski's rule of five
-- Veber's rules
-- PAINS filters (pan-assay interference compounds)
-- BRENK filters (toxic/reactive substructures)
-
-**Synthesizability:**
-- SA score (synthetic accessibility)
-- Retrosynthesis prediction
-- Commercial availability of precursors
-
-**Property Prediction:**
-- ADMET properties
-- Toxicity prediction
-- Off-target binding
-- Metabolic stability
-
-### Ranking and Selection
-
-**Criteria:**
-1. Predicted target affinity
-2. Drug-likeness score
-3. Synthesizability
-4. Novelty (dissimilarity to known actives)
-5. Diversity (within generated set)
-6. Predicted ADMET properties
-
-**Selection Strategies:**
-- Pareto frontier selection
-- Weighted scoring
-- Clustering and representative selection
-- Active learning for wet lab validation
-
-## Best Practices
-
-1. **Start Simple**: Begin with unconditional generation, then add constraints
-2. **Validate Chemistry**: Always check for valid molecules and drug-likeness
-3. **Diverse Training Data**: Use large, diverse datasets for better generalization
-4. **Multi-Objective**: Consider multiple properties from the start
-5. **Iterative Refinement**: Generate → validate → retrain with feedback
-6. **Domain Expert Review**: Consult medicinal chemists before synthesis
-7. **Benchmark**: Compare against known actives and random samples
-8. **Synthesizability**: Prioritize molecules that can actually be made
-9. **Explainability**: Understand why model generates certain structures
-10. **Wet Lab Validation**: Ultimately validate promising candidates experimentally
-
-## Common Applications
-
-### Drug Discovery
-- Lead generation for novel targets
-- Lead optimization around active scaffolds
-- Bioisostere replacement
-- Fragment elaboration
-
-### Materials Science
-- Polymer design with target properties
-- Catalyst discovery
-- Energy storage materials
-- Photovoltaic materials
-
-### Chemical Biology
-- Probe molecule design
-- Degrader (PROTAC) design
-- Molecular glue discovery
-
-## Integration with Other Tools
-
-**Docking:**
-- Generate molecules → Dock to target → Retrain with docking scores
-
-**Retrosynthesis:**
-- Filter generated molecules by synthetic accessibility
-- Plan synthesis routes for top candidates
-
-**Property Prediction:**
-- Use trained property prediction models as reward functions
-- Multi-task learning with generation and prediction
-
-**Active Learning:**
-- Generate candidates → Predict properties → Synthesize best → Retrain
+- [Generation tutorial](https://torchdrug.ai/docs/tutorials/generation.html)
+- [Generation benchmark](https://torchdrug.ai/docs/benchmark/generation.html)
+- [Generation task API](https://torchdrug.ai/docs/api/tasks.html#molecule-generation-tasks)
+- [Flow model API](https://torchdrug.ai/docs/api/models.html#normalizing-flows)
diff --git a/skills/torchdrug/references/molecular_property_prediction.md b/skills/torchdrug/references/molecular_property_prediction.md
index 38757915..233f649a 100644
--- a/skills/torchdrug/references/molecular_property_prediction.md
+++ b/skills/torchdrug/references/molecular_property_prediction.md
@@ -1,171 +1,239 @@
-# Molecular Property Prediction
+# Molecular Property Prediction and Pretraining
-## Overview
+Follow the official
+[property prediction](https://torchdrug.ai/docs/tutorials/property_prediction.html)
+and
+[pretrained molecular representations](https://torchdrug.ai/docs/tutorials/pretrain.html)
+tutorials for TorchDrug 0.2.1.
-Molecular property prediction involves predicting chemical, physical, or biological properties of molecules from their structure. TorchDrug provides comprehensive support for both classification and regression tasks on molecular graphs.
+## Supervised property prediction
-## Available Datasets
+### 1. Load and split data
-### Drug Discovery Datasets
+The official tutorial uses a random 80/10/10 ClinTox split:
-**Classification Tasks:**
-- **BACE** (1,513 molecules): Binary classification for β-secretase inhibition
-- **BBBP** (2,039 molecules): Blood-brain barrier penetration prediction
-- **HIV** (41,127 molecules): Ability to inhibit HIV replication
-- **Tox21** (7,831 molecules): Toxicity prediction across 12 targets
-- **ToxCast** (8,576 molecules): Toxicology screening
-- **ClinTox** (1,478 molecules): Clinical trial toxicity
-- **SIDER** (1,427 molecules): Drug side effects (27 system organ classes)
-- **MUV** (93,087 molecules): Maximum unbiased validation for virtual screening
+```python
+import torch
+from torchdrug import datasets
-**Regression Tasks:**
-- **ESOL** (1,128 molecules): Water solubility prediction
-- **FreeSolv** (642 molecules): Hydration free energy
-- **Lipophilicity** (4,200 molecules): Octanol/water distribution coefficient
-- **SAMPL** (643 molecules): Solvation free energies
+dataset = datasets.ClinTox("~/molecule-datasets/")
+lengths = [int(0.8 * len(dataset)), int(0.1 * len(dataset))]
+lengths.append(len(dataset) - sum(lengths))
+train_set, valid_set, test_set = torch.utils.data.random_split(dataset, lengths)
+```
-### Large-Scale Datasets
+This is a random split, not a scaffold split. If a benchmark requires a scaffold
+split, implement or import that protocol explicitly and record it in the
+experiment configuration.
-- **QM7** (7,165 molecules): Quantum mechanical properties
-- **QM8** (21,786 molecules): Electronic spectra and excited state properties
-- **QM9** (133,885 molecules): Geometric, energetic, electronic, and thermodynamic properties
-- **PCQM4M** (3,803,453 molecules): Large-scale quantum chemistry dataset
-- **ZINC250k/2M** (250k/2M molecules): Drug-like compounds for generative modeling
+### 2. Define the representation model
-## Task Types
+```python
+from torchdrug import models
+
+model = models.GIN(
+ input_dim=dataset.node_feature_dim,
+ hidden_dims=[256, 256, 256, 256],
+ short_cut=True,
+ batch_norm=True,
+ concat_hidden=True,
+)
+```
-### PropertyPrediction
+### 3. Define the task
-Standard task for graph-level property prediction supporting both classification and regression.
+```python
+from torchdrug import tasks
+
+task = tasks.PropertyPrediction(
+ model,
+ task=dataset.tasks,
+ criterion="bce",
+ metric=("auprc", "auroc"),
+)
+```
-**TorchDrug 0.2.1+:** `predict()` returns values on the **original scale** (not standardized). Update thresholds and downstream metrics if migrating from older versions.
+`task` means the target field name(s) or a mapping of target names to weights. It
+does not mean `"node"`, `"edge"`, or `"graph"`.
-**Key Parameters:**
-- `model`: Graph representation model (GNN)
-- `task`: "node", "edge", or "graph" level prediction
-- `criterion`: Loss function ("mse", "bce", "ce")
-- `metric`: Evaluation metrics ("mae", "rmse", "auroc", "auprc")
-- `num_mlp_layer`: Number of MLP layers for readout
+Documented `PropertyPrediction` criteria are:
-**Example Workflow:**
-```python
-import torch
-from torchdrug import core, models, tasks, datasets
+- `"mse"`
+- `"bce"`
+- `"ce"`
-# Load dataset
-dataset = datasets.BBBP("~/molecule-datasets/")
+Documented metrics are:
-# Define model
-model = models.GIN(input_dim=dataset.node_feature_dim,
- hidden_dims=[256, 256, 256, 256],
- edge_input_dim=dataset.edge_feature_dim,
- batch_norm=True, readout="mean")
+- `"mae"`
+- `"rmse"`
+- `"auprc"`
+- `"auroc"`
-# Define task
-task = tasks.PropertyPrediction(model, task=dataset.tasks,
- criterion="bce",
- metric=("auprc", "auroc"))
-```
+Other useful constructor options include `num_mlp_layer`, `normalization`,
+`num_class`, `mlp_batch_norm`, `mlp_dropout`, and
+`graph_construction_model`.
-### MultipleBinaryClassification
+For large multi-label problems, inspect `tasks.MultipleBinaryClassification`,
+which has its own task IDs, metrics, and reweighting behavior.
-Specialized task for multi-label scenarios where each molecule can have multiple binary labels (e.g., Tox21, SIDER).
+### 4. Train with Engine
-**Key Features:**
-- Handles missing labels gracefully
-- Computes metrics per label and averaged
-- Supports weighted loss for imbalanced datasets
+```python
+from torchdrug import core
+
+optimizer = torch.optim.Adam(task.parameters(), lr=1e-3)
+solver = core.Engine(
+ task,
+ train_set,
+ valid_set,
+ test_set,
+ optimizer,
+ batch_size=1024,
+)
+solver.train(num_epoch=100)
+solver.evaluate("valid")
+```
-## Model Selection
+Add `gpus=[0]` only for supported CUDA execution. Start with one epoch and a
+smaller batch for a smoke test.
-### Recommended Models by Task
+## Manual prediction
-**Small Molecules (< 1000 molecules):**
-- GIN (Graph Isomorphism Network)
-- SchNet (for 3D structures)
+Use TorchDrug collation:
-**Medium Datasets (1k-100k molecules):**
-- GCN, GAT, or GIN
-- NFP (Neural Fingerprint)
-- MPNN (Message Passing Neural Network)
+```python
+from torch.nn import functional as F
+from torchdrug import data
-**Large Datasets (> 100k molecules):**
-- Pre-trained models with fine-tuning
-- InfoGraph or MultiviewContrast for self-supervised pre-training
-- GIN with deeper architectures
+batch = data.graph_collate(valid_set[:8])
+logits = task.predict(batch)
+probabilities = F.sigmoid(logits)
+targets = task.target(batch)
+```
-**3D Structure Available:**
-- SchNet (continuous-filter convolutions)
-- GearNet (geometry-aware relational graph)
+For binary classification, `predict()` returns logits and the tutorial applies
+sigmoid. For normalized regression, TorchDrug 0.2.1 returns predictions on the
+original target scale; this changed from earlier releases.
-## Feature Engineering
+When predicting on CUDA manually, move the whole nested batch:
-### Node Features
+```python
+from torchdrug import utils
-TorchDrug automatically extracts atom features:
-- Atom type
-- Formal charge
-- Explicit/implicit hydrogens
-- Hybridization
-- Aromaticity
-- Chirality
+batch = utils.cuda(batch)
+```
-### Edge Features
+## Self-supervised pretraining
-Bond features include:
-- Bond type (single, double, triple, aromatic)
-- Stereochemistry
-- Conjugation
-- Ring membership
+The tutorial uses ClinTox only as a small illustration and recommends a larger
+unlabeled corpus such as ZINC2m for real pretraining.
-### Custom Features
+Use matching pretraining features:
-Add custom node/edge features using transforms:
```python
-from torchdrug import data, transforms
-
-# Add custom features
-transform = transforms.VirtualNode() # Add virtual node
-dataset = datasets.BBBP("~/molecule-datasets/",
- transform=transform)
+dataset = datasets.ClinTox(
+ "~/molecule-datasets/",
+ atom_feature="pretrain",
+ bond_feature="pretrain",
+)
```
-## Training Workflow
+### InfoGraph
-### Basic Pipeline
+```python
+from torchdrug import core, models, tasks
+
+gin_model = models.GIN(
+ input_dim=dataset.node_feature_dim,
+ hidden_dims=[300, 300, 300, 300, 300],
+ edge_input_dim=dataset.edge_feature_dim,
+ batch_norm=True,
+ readout="mean",
+)
+model = models.InfoGraph(gin_model, separate_model=False)
+task = tasks.Unsupervised(model)
+
+optimizer = torch.optim.Adam(task.parameters(), lr=1e-3)
+solver = core.Engine(
+ task,
+ dataset,
+ None,
+ None,
+ optimizer,
+ batch_size=256,
+)
+solver.train(num_epoch=100)
+solver.save("gin-infograph.pth")
+```
-1. **Load Dataset**: Choose appropriate dataset
-2. **Split Data**: Use scaffold split for drug discovery
-3. **Define Model**: Select GNN architecture
-4. **Create Task**: Configure loss and metrics
-5. **Setup Optimizer**: Adam typically works well
-6. **Train**: Use PyTorch Lightning or custom loop
+### Attribute masking
-### Data Splitting Strategies
+```python
+model = models.GIN(
+ input_dim=dataset.node_feature_dim,
+ hidden_dims=[300, 300, 300, 300, 300],
+ edge_input_dim=dataset.edge_feature_dim,
+ batch_norm=True,
+ readout="mean",
+)
+task = tasks.AttributeMasking(model, mask_rate=0.15)
+
+optimizer = torch.optim.Adam(task.parameters(), lr=1e-3)
+solver = core.Engine(
+ task,
+ dataset,
+ None,
+ None,
+ optimizer,
+ batch_size=256,
+)
+solver.train(num_epoch=100)
+solver.save("gin-attribute-masking.pth")
+```
-**Random Split**: Standard train/val/test split
-**Scaffold Split**: Group molecules by Bemis-Murcko scaffolds (recommended for drug discovery)
-**Stratified Split**: Maintain label distribution across splits
+### Fine-tune the encoder
-### Best Practices
+Recreate the same GIN architecture and feature dimensions, then wrap it in the
+supervised task:
-- Use scaffold splitting for realistic drug discovery evaluation
-- Apply data augmentation (virtual nodes, edges) for small datasets
-- Monitor multiple metrics (AUROC, AUPRC for classification; MAE, RMSE for regression)
-- Use early stopping based on validation performance
-- Consider ensemble methods for critical applications
-- Pre-train on large datasets before fine-tuning on small datasets
+```python
+model = models.GIN(
+ input_dim=dataset.node_feature_dim,
+ hidden_dims=[300, 300, 300, 300, 300],
+ edge_input_dim=dataset.edge_feature_dim,
+ batch_norm=True,
+ readout="mean",
+)
+task = tasks.PropertyPrediction(
+ model,
+ task=dataset.tasks,
+ criterion="bce",
+ metric=("auprc", "auroc"),
+)
+
+checkpoint = torch.load("gin-attribute-masking.pth")["model"]
+task.load_state_dict(checkpoint, strict=False)
+```
-## Common Issues and Solutions
+Then construct a new optimizer and supervised `Engine`. `strict=False` is
+intentional because the pretraining and supervised task heads differ. Review
+missing and unexpected keys if changing the architecture.
-**Issue: Poor performance on imbalanced datasets**
-- Solution: Use weighted loss, focal loss, or over/under-sampling
+## Experiment checks
-**Issue: Overfitting on small datasets**
-- Solution: Increase regularization, use simpler models, apply data augmentation, or pre-train on larger datasets
+- Confirm `dataset.tasks` names and label shapes.
+- Confirm classification vs regression before choosing criterion and metrics.
+- Record the exact split protocol; do not mislabel random splits as scaffold
+ splits.
+- Use AUPRC as well as AUROC for heavily imbalanced binary tasks.
+- Keep feature arguments identical when loading pretrained weights.
+- Fit preprocessing only on the training split.
+- Reserve the test split until model selection is complete.
-**Issue: Large memory consumption**
-- Solution: Reduce batch size, use gradient accumulation, or implement graph sampling
+## Source links
-**Issue: Slow training**
-- Solution: Use GPU acceleration, optimize data loading with multiple workers, or use mixed precision training
+- [Property tutorial](https://torchdrug.ai/docs/tutorials/property_prediction.html)
+- [Pretraining tutorial](https://torchdrug.ai/docs/tutorials/pretrain.html)
+- [Property task API](https://torchdrug.ai/docs/api/tasks.html#property-prediction-tasks)
+- [Molecule dataset API](https://torchdrug.ai/docs/api/datasets.html#molecule-property-prediction-datasets)
+- [0.2.1 release notes](https://github.com/DeepGraphLearning/torchdrug/releases/tag/v0.2.1)
diff --git a/skills/torchdrug/references/protein_modeling.md b/skills/torchdrug/references/protein_modeling.md
index 7c6529c2..17f49db1 100644
--- a/skills/torchdrug/references/protein_modeling.md
+++ b/skills/torchdrug/references/protein_modeling.md
@@ -1,272 +1,221 @@
# Protein Modeling
-## Overview
+TorchDrug 0.2.1 documents protein data structures, datasets, sequence encoders,
+and geometry-aware graph models in its
+[data](https://torchdrug.ai/docs/api/data.html),
+[dataset](https://torchdrug.ai/docs/api/datasets.html), and
+[model](https://torchdrug.ai/docs/api/models.html) APIs. The primary tutorial
+index focuses on molecular and knowledge-graph workflows, so avoid inventing a
+protein tutorial API that upstream does not provide.
-TorchDrug provides extensive support for protein-related tasks including sequence analysis, structure prediction, property prediction, and protein-protein interactions. Proteins are represented as graphs where nodes are amino acid residues and edges represent spatial or sequential relationships.
+## Build protein objects
-## Available Datasets
+### From sequence
-### Protein Function Prediction
-
-**Enzyme Function:**
-- **EnzymeCommission** (17,562 proteins): EC number classification (7 levels)
-- **BetaLactamase** (5,864 sequences): Enzyme activity prediction
-
-**Protein Characteristics:**
-- **Fluorescence** (54,025 sequences): GFP fluorescence intensity
-- **Stability** (53,614 sequences): Thermostability prediction
-- **Solubility** (62,478 sequences): Protein solubility classification
-- **BinaryLocalization** (22,168 proteins): Subcellular localization (membrane vs. soluble)
-- **SubcellularLocalization** (8,943 proteins): 10-class localization prediction
-
-**Gene Ontology:**
-- **GeneOntology** (46,796 proteins): GO term prediction across biological process, molecular function, and cellular component
-
-### Protein Structure Prediction
-
-- **Fold** (16,712 proteins): Structural fold classification (1,195 classes)
-- **SecondaryStructure** (8,678 proteins): 3-state or 8-state secondary structure prediction
-- **ContactPrediction** via ProteinNet: Residue-residue contact maps
-
-### Protein Interaction
-
-**Protein-Protein Interactions:**
-- **HumanPPI** (1,412 proteins, 6,584 interactions): Human protein interaction network
-- **YeastPPI** (2,018 proteins, 6,451 interactions): Yeast protein interaction network
-- **PPIAffinity** (2,156 protein pairs): Binding affinity measurements
-
-**Protein-Ligand Binding:**
-- **BindingDB** (~1.5M entries): Comprehensive binding affinity database
-- **PDBBind** (20,000+ complexes): 3D structure-based binding data
- - Refined set: High-quality crystal structures
- - Core set: Diverse benchmark set
-
-### Large-Scale Protein Databases
-
-- **AlphaFoldDB**: Access to 200M+ predicted protein structures
-- **ProteinNet**: Standardized dataset for structure prediction
+```python
+from torchdrug import data
-## Task Types
+protein = data.Protein.from_sequence(
+ "MKTAYIAKQRQISFVKSHFSRQ",
+ atom_feature=None,
+ bond_feature=None,
+ residue_feature="default",
+)
+print(protein.to_sequence())
+```
-### NodePropertyPrediction
+For sequence-only work, setting atom and bond features to `None` avoids the cost
+of constructing a full atom-level representation.
-Predict properties at the residue (node) level, such as secondary structure or contact maps.
+### From PDB
-**Use Cases:**
-- Secondary structure prediction (helix, sheet, coil)
-- Residue-level disorder prediction
-- Post-translational modification sites
-- Binding site prediction
+```python
+protein = data.Protein.from_pdb(
+ "protein.pdb",
+ atom_feature="default",
+ bond_feature="default",
+ residue_feature="default",
+)
+```
-### PropertyPrediction
+Use trusted local PDB files and validate chain selection, missing residues,
+alternate locations, and nonstandard residues before training.
-Predict protein-level properties like function, stability, or localization.
+Documented conversion methods include:
-**Use Cases:**
-- Enzyme function classification
-- Subcellular localization
-- Protein stability prediction
-- Gene ontology term prediction
+- `Protein.from_sequence`
+- `Protein.from_pdb`
+- `Protein.from_molecule`
+- `Protein.to_sequence`
+- `Protein.to_pdb`
+- `Protein.to_molecule`
-### InteractionPrediction
+Packed equivalents operate on lists:
-Predict interactions between protein pairs or protein-ligand pairs.
+- `PackedProtein.from_sequence(sequences)`
+- `PackedProtein.from_pdb(pdb_files)`
+- `PackedProtein.from_molecule(mols)`
-**Key Features:**
-- Handles both sequence and structure inputs
-- Supports symmetric (PPI) and asymmetric (protein-ligand) interactions
-- Multiple negative sampling strategies
+## Protein datasets
-### ContactPrediction
+Documented dataset families include:
-Specialized task for predicting spatial proximity between residues in folded structures.
+- Property / sequence: `BetaLactamase`, `BinaryLocalization`,
+ `SubcellularLocalization`
+- Function / structure: `EnzymeCommission`, `GeneOntology`, `AlphaFoldDB`
+- Structure labels: `Fold`, `SecondaryStructure`
+- Protein-protein: `HumanPPI`, `YeastPPI`, `PPIAffinity`
+- Protein-ligand: `BindingDB`, `PDBBind`
-**Applications:**
-- Structure prediction from sequence
-- Protein folding pathway analysis
-- Validation of predicted structures
+Example:
-## Protein Representation Models
+```python
+from torchdrug import datasets
-### Sequence-Based Models
+dataset = datasets.EnzymeCommission(
+ "~/protein-datasets/",
+ atom_feature=None,
+ bond_feature=None,
+ residue_feature="default",
+)
+train_set, valid_set, test_set = dataset.split()
+```
-**ESM (Evolutionary Scale Modeling):**
-- Pre-trained transformer via `models.EvolutionaryScaleModeling` (ESM-1b and ESM-2; TorchDrug 0.2.1+)
-- State-of-the-art for sequence-only tasks
-- Available in multiple sizes (ESM-1b, ESM-2)
-- Captures evolutionary and structural information
+Class signatures differ. Options such as `branch`, `test_cutoff`, `lazy`, or
+species/split IDs are dataset-specific; check the API before using them.
-**ProteinBERT:**
-- BERT-style masked language model
-- Pre-trained on UniProt sequences
-- Good for transfer learning
+## Sequence encoders
-**ProteinLSTM:**
-- Bidirectional LSTM for sequence encoding
-- Lightweight and fast
-- Good baseline for sequence tasks
+### ESM
-**ProteinCNN / ProteinResNet:**
-- Convolutional architectures
-- Capture local sequence patterns
-- Faster than transformer models
+`models.ESM` is the alias for `EvolutionaryScaleModeling`. The constructor takes
+a directory for downloaded weights, not a checkpoint filename:
-### Structure-Based Models
+```python
+from torchdrug import models
-**GearNet (Geometry-Aware Relational Graph Network):**
-- Incorporates 3D geometric information
-- Edge types based on sequential, radius, and K-nearest neighbors
-- State-of-the-art for structure-based tasks
-- Supports both backbone and full-atom representations
+model = models.ESM(
+ path="~/model-weights/esm/",
+ model="ESM-2-150M",
+ readout="mean",
+)
+```
-**GCN/GAT/GIN on Protein Graphs:**
-- Standard GNN architectures adapted for proteins
-- Flexible edge definitions (sequence, spatial, contact)
+TorchDrug 0.2.1 supports these ESM-2 names:
-**SchNet:**
-- Continuous-filter convolutions
-- Handles 3D coordinates directly
-- Good for structure prediction and protein-ligand binding
+- `ESM-2-8M`
+- `ESM-2-35M`
+- `ESM-2-150M`
+- `ESM-2-650M`
+- `ESM-2-3B`
+- `ESM-2-15B`
-### Feature-Based Models
+It also supports `ESM-1b` and `ESM-1v`. Maximum sequence input is 1022 residues
+before special tokens. Large checkpoints require substantial memory; start with
+`ESM-2-8M` or `ESM-2-35M` for pipeline validation.
-**Statistic Features:**
-- Amino acid composition
-- Sequence length statistics
-- Motif counts
+### Other sequence models
-**Physicochemical Features:**
-- Hydrophobicity scales
-- Charge properties
-- Secondary structure propensity
-- Molecular weight, pI
+Documented classes include:
-## Protein Graph Construction
+- `models.ProteinCNN`
+- `models.ProteinResNet`
+- `models.ProteinLSTM`
+- `models.ProteinBERT`
-### Edge Types
+These models require explicit input/hidden dimensions. Derive input dimensions
+from the dataset's residue feature configuration.
-**Sequential Edges:**
-- Connect adjacent residues in sequence
-- Captures primary structure
+## Structure encoders
-**Spatial Edges:**
-- K-nearest neighbors in 3D space
-- Radius cutoff (e.g., Cα atoms within 10Å)
-- Captures tertiary structure
+Documented structure-aware models include:
-**Contact Edges:**
-- Based on heavy atom distances
-- Typically < 8Å threshold
+- `models.GearNet`
+- `models.SchNet`
+- general graph models such as `GCN`, `GAT`, `GIN`, and `RGCN`
-### Node Features
+`SchNet` requires `node_position`. `GearNet` requires a graph whose relation and
+geometric feature configuration matches its constructor.
-**Residue Identity:**
-- One-hot encoding of 20 amino acids
-- Learned embeddings
+Use TorchDrug graph-construction and geometry layers to create sequential,
+radius, and nearest-neighbor relations. Do not use a nonexistent
+`protein.residue_graph(...)` method.
-**Position Information:**
-- 3D coordinates (Cα, N, C, O)
-- Backbone angles (phi, psi, omega)
-- Relative spatial position encodings
+Before training a structure model, inspect:
-**Physicochemical Properties:**
-- Hydrophobicity
-- Charge
-- Size
-- Secondary structure
+```python
+print(protein.num_node)
+print(protein.num_residue)
+print(protein.node_position.shape)
+print(protein.residue_feature.shape)
+```
-## Training Workflows
+Confirm whether nodes represent atoms or residues and ensure the model input
+matches that choice.
-### Pre-training Strategies
+## Property-prediction task
-**Self-Supervised Pre-training:**
-- Masked residue prediction (like BERT)
-- Distance prediction between residues
-- Angle prediction (phi, psi, omega)
-- Dihedral angle prediction
-- Contact map prediction
+Protein-level classification or regression can use the same task abstraction as
+molecules:
-**Pre-trained Model Usage:**
```python
-from torchdrug import models
+from torchdrug import tasks
-# Load pre-trained ESM
-model = models.ESM(path="esm1b_t33_650M_UR50S.pt")
-
-# Fine-tune on downstream task
task = tasks.PropertyPrediction(
- model, task=["stability"],
- criterion="mse", metric=["mae", "rmse"]
+ model,
+ task=dataset.tasks,
+ criterion="bce",
+ metric=("auprc", "auroc"),
)
```
-### Multi-Task Learning
-
-Train on multiple related tasks simultaneously:
-- Joint prediction of function, localization, and stability
-- Improves generalization and data efficiency
-- Shares representations across tasks
-
-### Best Practices
-
-**For Sequence-Only Tasks:**
-1. Start with pre-trained ESM or ProteinBERT
-2. Fine-tune with small learning rate (1e-5 to 1e-4)
-3. Use frozen embeddings for small datasets
-4. Apply dropout for regularization
+Choose criterion and metrics from the actual dataset target:
-**For Structure-Based Tasks:**
-1. Use GearNet with multiple edge types
-2. Include geometric features (angles, dihedrals)
-3. Pre-train on large structure databases
-4. Use data augmentation (rotations, crops)
+- binary or multi-label classification: BCE, AUPRC/AUROC
+- multiclass classification: CE and the documented compatible metrics
+- regression: MSE, MAE/RMSE
-**For Small Datasets:**
-1. Transfer learning from pre-trained models
-2. Multi-task learning with related tasks
-3. Data augmentation (sequence mutations, structure perturbations)
-4. Strong regularization (dropout, weight decay)
+For large multi-label ontology tasks, inspect
+`tasks.MultipleBinaryClassification` rather than treating labels as one
+multiclass target.
-## Common Use Cases
+## Workflow checks
-### Enzyme Engineering
-- Predict enzyme activity from sequence
-- Design mutations to improve stability
-- Screen for desired catalytic properties
+1. Decide sequence-only versus structure-aware modeling.
+2. Configure protein features to match that representation.
+3. Verify dataset splits and sequence identity cutoffs.
+4. Check maximum sequence length before selecting ESM.
+5. Build graph relations explicitly for structure models.
+6. Derive dimensions from the loaded dataset.
+7. Smoke-test one batch before long training.
+8. Record checkpoint name, feature settings, split, and TorchDrug version.
-### Antibody Design
-- Predict binding affinity
-- Optimize antibody sequences
-- Predict immunogenicity
+## Common failures
-### Drug Target Identification
-- Predict protein function
-- Identify druggable sites
-- Analyze protein-ligand interactions
+### ESM constructor error
-### Protein Structure Prediction
-- Predict secondary structure from sequence
-- Generate contact maps for tertiary structure
-- Refine AlphaFold predictions
+Use `models.ESM(path=<directory>, model=<supported-name>)`. Do not pass a
+downloaded `.pt` filename as `path`.
-## Integration with Other Tools
+### Out-of-memory error
-### AlphaFold Integration
+Choose a smaller ESM model, reduce batch size, crop or filter long sequences, or
+freeze the encoder and precompute embeddings.
-Load AlphaFold-predicted structures:
-```python
-from torchdrug import data
+### Missing coordinates
-# Load AlphaFold structure
-protein = data.Protein.from_pdb("alphafold_structure.pdb")
-
-# Use in TorchDrug workflows
-```
+Sequence-created proteins do not acquire experimental 3D coordinates. Load a PDB
+or another validated structure source before using coordinate-dependent models.
-### ESMFold Integration
+### Relation mismatch
-Use ESMFold for structure prediction, then analyze with TorchDrug models.
+Build the same relation types expected by the structure model and set
+`num_relation` accordingly.
-### Rosetta/PyRosetta
+## Source links
-Generate structures with Rosetta, import to TorchDrug for analysis.
+- [Protein data API](https://torchdrug.ai/docs/api/data.html#protein)
+- [Protein datasets](https://torchdrug.ai/docs/api/datasets.html#protein-property-prediction-datasets)
+- [Protein sequence encoders](https://torchdrug.ai/docs/api/models.html#protein-sequence-encoders)
+- [Graph neural networks](https://torchdrug.ai/docs/api/models.html#graph-neural-networks)
+- [TorchDrug 0.2.1 release notes](https://github.com/DeepGraphLearning/torchdrug/releases/tag/v0.2.1)
diff --git a/skills/torchdrug/references/retrosynthesis.md b/skills/torchdrug/references/retrosynthesis.md
index 20c97f4e..7e60bb32 100644
--- a/skills/torchdrug/references/retrosynthesis.md
+++ b/skills/torchdrug/references/retrosynthesis.md
@@ -1,436 +1,247 @@
# Retrosynthesis
-## Overview
+The official
+[TorchDrug 0.2.1 retrosynthesis tutorial](https://torchdrug.ai/docs/tutorials/retrosynthesis.html)
+implements the G2Gs workflow:
-Retrosynthesis is the process of planning synthetic routes from target molecules back to commercially available starting materials. TorchDrug provides tools for learning-based retrosynthesis prediction, breaking down the complex task into manageable subtasks.
+1. identify reaction centers,
+2. split products into synthons,
+3. complete synthons into reactants,
+4. combine both trained tasks for end-to-end prediction.
-## Available Datasets
+This is a single-step reactant prediction pipeline. Multi-step route search,
+commercial availability, conditions, yields, and cost optimization are not
+provided by `tasks.Retrosynthesis`.
-### USPTO-50K
+## Prepare synchronized datasets
-The standard benchmark dataset for retrosynthesis derived from US patent literature.
-
-**Statistics:**
-- 50,017 reaction examples
-- Single-step reactions
-- Filtered for quality and canonicalization
-- Contains atom mapping for reaction center identification
-
-**Reaction Types:**
-- Diverse organic reactions
-- Drug-like transformations
-- Well-balanced across common reaction classes
-
-**Data Splits:**
-- Training: ~40k reactions
-- Validation: ~5k reactions
-- Test: ~5k reactions
-
-**Format:**
-- Product → Reactants
-- SMILES representation
-- Atom-mapped reactions for training
-
-## Task Types
-
-TorchDrug decomposes retrosynthesis into a multi-step pipeline:
-
-### 1. CenterIdentification
-
-Identifies the reaction center - which bonds were formed/broken in the forward reaction.
-
-**Input:** Product molecule
-**Output:** Probability for each bond of being part of reaction center
-
-**Purpose:**
-- Locate where chemistry happened
-- Guide subsequent synthon generation
-- Reduce search space dramatically
-
-**Model Architecture:**
-- Graph neural network on product molecule
-- Edge-level classification
-- Attention mechanisms to highlight reactive regions
-
-**Evaluation Metrics:**
-- **Top-K Accuracy**: Correct reaction center in top K predictions
-- **Bond-level F1**: Precision and recall for bond predictions
-
-### 2. SynthonCompletion
-
-Given the product and identified reaction center, predict the reactant structures (synthons).
-
-**Input:**
-- Product molecule
-- Identified reaction center (broken/formed bonds)
-
-**Output:**
-- Predicted reactant molecules (synthons)
-
-**Process:**
-1. Break bonds at reaction center
-2. Modify atom environments (valence, charges)
-3. Determine leaving groups and protecting groups
-4. Generate complete reactant structures
-
-**Challenges:**
-- Multiple valid reactant sets
-- Stereospecificity
-- Atom environment changes (hybridization, charge)
-- Leaving group selection
-
-**Evaluation:**
-- **Exact Match**: Generated reactants exactly match ground truth
-- **Top-K Accuracy**: Correct reactants in top K predictions
-- **Chemical Validity**: Generated molecules are valid
-
-### 3. Retrosynthesis (End-to-End)
+```python
+import torch
+from torchdrug import datasets
-Combines center identification and synthon completion into a unified pipeline.
+reaction_dataset = datasets.USPTO50k(
+ "~/molecule-datasets/",
+ atom_feature="center_identification",
+ kekulize=True,
+)
+synthon_dataset = datasets.USPTO50k(
+ "~/molecule-datasets/",
+ as_synthon=True,
+ atom_feature="synthon_completion",
+ kekulize=True,
+)
-**Input:** Target product molecule
-**Output:** Ranked list of reactant sets (synthesis pathways)
+torch.manual_seed(1)
+reaction_train, reaction_valid, reaction_test = reaction_dataset.split()
+torch.manual_seed(1)
+synthon_train, synthon_valid, synthon_test = synthon_dataset.split()
+```
-**Workflow:**
-1. Identify top-K reaction centers
-2. For each center, generate reactant candidates
-3. Rank combinations by model confidence
-4. Filter for commercial availability and feasibility
+The repeated seed is required to align the reaction and synthon splits.
-**Advantages:**
-- Single model to train and deploy
-- Joint optimization of subtasks
-- Error propagation from center identification accounted for
+- Reaction mode stores `(reactants, product)` pairs.
+- Synthon mode stores `(reactant, synthon)` pairs.
-## Training Workflows
+## Center identification
-### Basic Pipeline
+The official tutorial uses RGCN and three feature groups:
```python
-from torchdrug import datasets, models, tasks
-
-# Load dataset
-dataset = datasets.USPTO50k("~/retro-datasets/")
+from torchdrug import core, models, tasks
-# For center identification
-model_center = models.RGCN(
- input_dim=dataset.node_feature_dim,
- num_relation=dataset.num_bond_type,
- hidden_dims=[256, 256, 256]
+reaction_model = models.RGCN(
+ input_dim=reaction_dataset.node_feature_dim,
+ hidden_dims=[256, 256, 256, 256, 256, 256],
+ num_relation=reaction_dataset.num_bond_type,
+ concat_hidden=True,
)
-
-task_center = tasks.CenterIdentification(
- model_center,
- top_k=3 # Consider top 3 reaction centers
+reaction_task = tasks.CenterIdentification(
+ reaction_model,
+ feature=("graph", "atom", "bond"),
)
-# For synthon completion
-model_synthon = models.GIN(
- input_dim=dataset.node_feature_dim,
- hidden_dims=[256, 256, 256]
+reaction_optimizer = torch.optim.Adam(
+ reaction_task.parameters(),
+ lr=1e-3,
)
-
-task_synthon = tasks.SynthonCompletion(
- model_synthon,
- center_topk=3, # Use top 3 from center identification
- num_synthon_beam=5 # Beam search for synthon generation
-)
-
-# End-to-end
-task_retro = tasks.Retrosynthesis(
- model=model_center,
- synthon_model=model_synthon,
- center_topk=5,
- num_synthon_beam=10
+reaction_solver = core.Engine(
+ reaction_task,
+ reaction_train,
+ reaction_valid,
+ reaction_test,
+ reaction_optimizer,
+ batch_size=128,
)
+reaction_solver.train(num_epoch=50)
+reaction_solver.evaluate("valid")
+reaction_solver.save("g2gs-reaction.pth")
```
-### Transfer Learning
-
-Pre-train on large reaction datasets (e.g., USPTO-full with 1M+ reactions), then fine-tune on specific reaction classes.
-
-**Benefits:**
-- Better generalization to rare reaction types
-- Improved performance on small datasets
-- Learn general reaction patterns
-
-### Multi-Task Learning
-
-Train jointly on:
-- Forward reaction prediction
-- Retrosynthesis
-- Reaction type classification
-- Yield prediction
-
-**Advantages:**
-- Shared representations of chemistry
-- Better sample efficiency
-- Improved robustness
-
-## Model Architectures
-
-### Graph Neural Networks
-
-**RGCN (Relational Graph Convolutional Network):**
-- Handles multiple bond types (single, double, triple, aromatic)
-- Edge-type-specific transformations
-- Good for reaction center identification
-
-**GIN (Graph Isomorphism Network):**
-- Powerful message passing
-- Captures structural patterns
-- Works well for synthon completion
-
-**GAT (Graph Attention Network):**
-- Attention weights highlight important atoms/bonds
-- Interpretable reaction center predictions
-- Flexible for various reaction types
-
-### Sequence-Based Models
+`CenterIdentification` predicts reaction centers. Its
+`predict_synthon(batch, k=...)` method returns top-k records containing synthons,
+reaction centers, reaction metadata, and log likelihoods.
-**Transformer Models:**
-- SMILES-to-SMILES translation
-- Can capture long-range dependencies
-- Require large datasets
+## Synthon completion
-**LSTM/GRU:**
-- Sequence generation for reactants
-- Autoregressive decoding
-- Good for small molecules
+The official tutorial again uses RGCN:
-### Hybrid Approaches
-
-Combine graph and sequence representations:
-- Graph encoder for products
-- Sequence decoder for reactants
-- Best of both representations
-
-## Reaction Chemistry Considerations
-
-### Reaction Classes
-
-**Common Transformations:**
-- C-C bond formation (coupling, addition)
-- Functional group interconversions (oxidation, reduction)
-- Heterocycle synthesis (cyclizations)
-- Protection/deprotection
-- Aromatic substitutions
-
-**Rare Reactions:**
-- Novel coupling methods
-- Complex rearrangements
-- Multi-component reactions
-
-### Selectivity Issues
-
-**Regioselectivity:**
-- Which position reacts on molecule
-- Requires understanding of electronics and sterics
-
-**Stereoselectivity:**
-- Control of stereochemistry
-- Diastereoselectivity and enantioselectivity
-- Critical for drug synthesis
-
-**Chemoselectivity:**
-- Which functional group reacts
-- Requires protecting group strategies
-
-### Reaction Conditions
-
-While TorchDrug focuses on reaction connectivity, consider:
-- Temperature and pressure
-- Catalysts and reagents
-- Solvents
-- Reaction time
-- Work-up and purification
-
-## Multi-Step Synthesis Planning
-
-### Single-Step Retrosynthesis
-
-Predict immediate precursors for target molecule.
-
-**Use Case:**
-- Late-stage transformations
-- Simple molecules (1-2 steps from commercial)
-- Initial route scouting
-
-### Multi-Step Planning
-
-Recursively apply retrosynthesis to each predicted reactant until reaching commercial building blocks.
-
-**Tree Search Strategies:**
-
-**Breadth-First Search:**
-- Explore all routes to same depth
-- Find shortest routes
-- Memory intensive
-
-**Depth-First Search:**
-- Follow each route to completion
-- Memory efficient
-- May miss optimal routes
-
-**Monte Carlo Tree Search (MCTS):**
-- Balance exploration and exploitation
-- Guided by model confidence
-- State-of-the-art for multi-step planning
-
-**A\* Search:**
-- Heuristic-guided search
-- Optimizes for cost, complexity, or feasibility
-- Efficient for finding best routes
-
-### Route Scoring
+```python
+synthon_model = models.RGCN(
+ input_dim=synthon_dataset.node_feature_dim,
+ hidden_dims=[256, 256, 256, 256, 256, 256],
+ num_relation=synthon_dataset.num_bond_type,
+ concat_hidden=True,
+)
+synthon_task = tasks.SynthonCompletion(
+ synthon_model,
+ feature=("graph",),
+)
-Rank synthetic routes by:
-1. **Number of Steps**: Fewer is better (efficiency)
-2. **Convergent vs Linear**: Convergent routes preferred
-3. **Commercial Availability**: How many steps to buyable compounds
-4. **Reaction Feasibility**: Likelihood each step works
-5. **Overall Yield**: Estimated end-to-end yield
-6. **Cost**: Reagents, labor, equipment
-7. **Green Chemistry**: Environmental impact, safety
+synthon_optimizer = torch.optim.Adam(
+ synthon_task.parameters(),
+ lr=1e-3,
+)
+synthon_solver = core.Engine(
+ synthon_task,
+ synthon_train,
+ synthon_valid,
+ synthon_test,
+ synthon_optimizer,
+ batch_size=128,
+)
+synthon_solver.train(num_epoch=10)
+synthon_solver.evaluate("valid")
+synthon_solver.save("g2gs-synthon.pth")
+```
-### Stopping Criteria
+Do not substitute a GIN constructor copied from another implementation unless
+you intentionally redesign and validate the model.
-Stop retrosynthesis when reaching:
-- **Commercial Compounds**: Available from vendors (e.g., Sigma-Aldrich, Enamine)
-- **Building Blocks**: Standard synthetic intermediates
-- **Max Depth**: e.g., 6-10 steps
-- **Low Confidence**: Model uncertainty too high
+## End-to-end task
-## Validation and Filtering
+Combine the **tasks**, not the raw models:
-### Chemical Validity
+```python
+task = tasks.Retrosynthesis(
+ reaction_task,
+ synthon_task,
+ center_topk=2,
+ num_synthon_beam=5,
+ max_prediction=10,
+)
+```
-Check each predicted reaction:
-- Reactants are valid molecules
-- Reaction is chemically reasonable
-- Atom mapping is consistent
-- Stoichiometry balances
+If neither subtask has been attached to an `Engine`, preprocess them manually
+before composition:
-### Synthetic Feasibility
+```python
+reaction_task.preprocess(reaction_train, None, None)
+synthon_task.preprocess(synthon_train, None, None)
+```
-**Filters:**
-- Reaction precedent (literature examples)
-- Functional group compatibility
-- Typical reaction conditions
-- Expected yield ranges
+The `Retrosynthesis` constructor accepts:
-**Expert Systems:**
-- Rule-based validation (e.g., ARChem Route Designer)
-- Check for incompatible functional groups
-- Identify protection/deprotection needs
+- `center_identification`
+- `synthon_completion`
+- `center_topk`
+- `num_synthon_beam`
+- `max_prediction`
+- top-k metrics
-### Commercial Availability
+It does not accept `model=`, `synthon_model=`, or a raw GNN pair.
-**Databases:**
-- eMolecules: 10M+ commercial compounds
-- ZINC: Annotated with vendor info
-- Reaxys: Commercially available building blocks
+## Checkpoint loading
-**Considerations:**
-- Cost per gram
-- Purity and quality
-- Lead time for delivery
-- Minimum order quantities
+The official workflow saves each subtask and loads checkpoints without optimizer
+state when composing the pipeline:
-## Integration with Other Tools
+```python
+optimizer = torch.optim.Adam(task.parameters(), lr=1e-3)
+solver = core.Engine(
+ task,
+ reaction_train,
+ reaction_valid,
+ reaction_test,
+ optimizer,
+ batch_size=32,
+)
+solver.load("g2gs-reaction.pth", load_optimizer=False)
+solver.load("g2gs-synthon.pth", load_optimizer=False)
+solver.evaluate("valid")
+```
-### Reaction Prediction (Forward)
+Keep model architectures, feature sets, and dataset metadata identical to the
+training run. Inspect missing or unexpected keys if adapting this pattern.
-Train forward reaction prediction models to validate retrosynthetic proposals:
-- Predict products from proposed reactants
-- Validate reaction feasibility
-- Estimate yields
+## Prediction output
-### Retrosynthesis Software
+The end-to-end task returns packed reactant predictions and a count per input:
-**Integration with:**
-- SciFinder (CAS)
-- Reaxys (Elsevier)
-- ARChem Route Designer
-- IBM RXN for Chemistry
+```python
+from torchdrug import data, utils
-**TorchDrug as Component:**
-- Use TorchDrug models within larger planning systems
-- Combine ML predictions with rule-based systems
-- Hybrid AI + expert system approaches
+batch = data.graph_collate(reaction_valid[:4])
+batch = utils.cuda(batch)
+predictions, num_prediction = task.predict(batch)
-### Experimental Validation
+top1_index = num_prediction.cumsum(0) - num_prediction
+for index in top1_index.tolist():
+ reactants = predictions[index].connected_components()[0]
+ print(reactants.to_smiles())
+```
-**High-Throughput Screening:**
-- Rapid testing of predicted reactions
-- Automated synthesis platforms
-- Feedback loop to improve models
+Call `utils.cuda` only when the task/models are on CUDA. Keep the batch on CPU
+for CPU execution.
-**Robotic Synthesis:**
-- Automated execution of planned routes
-- Real-time optimization
-- Data generation for model improvement
+## Evaluation
-## Best Practices
+The end-to-end task supports top-k exact-match metrics such as top-1, top-3,
+top-5, and top-10. Also inspect:
-1. **Ensemble Predictions**: Use multiple models for robustness
-2. **Reaction Validation**: Always validate with chemistry rules
-3. **Commercial Check**: Verify building block availability early
-4. **Diversity**: Generate multiple diverse routes, not just top-1
-5. **Expert Review**: Have chemists evaluate proposed routes
-6. **Literature Search**: Check for precedents of key steps
-7. **Iterative Refinement**: Update models with experimental feedback
-8. **Interpretability**: Understand why model suggests each step
-9. **Edge Cases**: Handle unusual functional groups and scaffolds
-10. **Benchmarking**: Compare against known synthesis routes
+- chemical validity,
+- duplicate predictions,
+- performance by reaction class,
+- atom-map consistency,
+- stereochemistry retention,
+- uncertainty or score gaps.
-## Common Applications
+Top-k exact match against USPTO50k is not proof that a reaction is practical.
-### Drug Synthesis Planning
+## Scope and safety
-- Small molecule drugs
-- Natural product total synthesis
-- Late-stage functionalization strategies
+TorchDrug's tutorial predicts reactant connectivity. It does not directly
+predict:
-### Library Enumeration
+- reagents, catalysts, solvent, temperature, or pressure,
+- yield or selectivity,
+- commercial availability,
+- multi-step search trees,
+- process safety or scale-up feasibility.
-- Virtual library design
-- Retrosynthetic filtering of generated molecules
-- Prioritize synthesizable compounds
+Treat outputs as model proposals requiring forward validation, literature
+precedent, and expert chemistry review.
-### Process Chemistry
+## Common failures
-- Route scouting for large-scale synthesis
-- Cost optimization
-- Green chemistry alternatives
+### Reaction and synthon samples do not align
-### Synthetic Method Development
+Reset the same seed immediately before each `split()`.
-- Identify gaps in synthetic methodology
-- Guide development of new reactions
-- Expand retrosynthesis model capabilities
+### Feature dimension mismatch
-## Challenges and Future Directions
+Use the dedicated `center_identification` and `synthon_completion` atom features
+and derive model dimensions from each corresponding dataset.
-### Current Limitations
+### End-to-end constructor error
-- Limited to single-step predictions (most models)
-- Doesn't consider reaction conditions explicitly
-- Stereochemistry handling is challenging
-- Rare reaction types underrepresented
+Pass `reaction_task` and `synthon_task`, not their models.
-### Active Research Areas
+### Uninitialized metadata
-- End-to-end multi-step planning
-- Incorporation of reaction conditions
-- Stereoselective retrosynthesis
-- Integration with robotics for closed-loop optimization
-- Semi-template methods (balance templates and templates-free)
-- Uncertainty quantification for predictions
+Construct each subtask's engine first or call `preprocess()` manually.
-### Emerging Techniques
+## Source links
-- Large language models for chemistry (ChemGPT, MolT5)
-- Reinforcement learning for route optimization
-- Graph transformers for long-range interactions
-- Self-supervised pre-training on reaction databases
+- [Retrosynthesis tutorial](https://torchdrug.ai/docs/tutorials/retrosynthesis.html)
+- [Retrosynthesis tasks](https://torchdrug.ai/docs/api/tasks.html#retrosynthesis-tasks)
+- [USPTO50k dataset](https://torchdrug.ai/docs/api/datasets.html#uspto50k)
diff --git a/skills/venue-templates/SKILL.md b/skills/venue-templates/SKILL.md
index e857e14f..00ea7f66 100644
--- a/skills/venue-templates/SKILL.md
+++ b/skills/venue-templates/SKILL.md
@@ -1,687 +1,269 @@
---
name: venue-templates
-description: Access comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
-allowed-tools: Read Write Edit Bash
+description: Prepare journal manuscripts, conference papers, research posters, and grant documents using venue-specific formatting guidance and bundled LaTeX scaffolds. Use when selecting an official template, checking current page or anonymity rules, adapting academic writing to a venue, or inspecting a submission PDF.
license: MIT license
-required_environment_variables: [{"name": "OPENROUTER_API_KEY", "prompt": "OpenRouter API key for the skill's LLM-powered steps.", "required_for": "optional features"}]
-metadata: {"version": "1.1", "skill-author": "K-Dense Inc.", "openclaw": {"primaryEnv": "OPENROUTER_API_KEY", "envVars": [{"name": "OPENROUTER_API_KEY", "required": false, "description": "OpenRouter API key for the skill's LLM-powered steps."}]}}
+compatibility: Requires Python 3.11+ for helper scripts; LaTeX and Poppler command-line tools are optional for compilation and PDF inspection.
+metadata:
+ version: "1.2"
+ skill-author: K-Dense Inc.
---
# Venue Templates
-## Overview
+Prepare publication and funding documents without treating stale formatting details as authoritative. This skill combines:
-Access comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues, academic conferences, research posters, and grant proposals. This skill provides ready-to-use templates and detailed specifications for successful academic submissions across disciplines.
+- a verification-first workflow for current venue rules;
+- bundled LaTeX scaffolds for a small, explicit set of document types;
+- writing-style and reviewer-expectation guides; and
+- local helpers for discovering, copying, and inspecting templates.
-Use this skill when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
+## Mandatory Currency Rule
-## When to Use This Skill
+Venue requirements are time-sensitive. Before giving exact page limits, deadlines, style-file names, anonymity rules, or required sections:
-This skill should be used when:
-- Preparing a manuscript for submission to a specific journal (Nature, Science, PLOS, IEEE, etc.)
-- Writing a conference paper with specific formatting requirements (NeurIPS, ICML, CHI, etc.)
-- Creating an academic research poster for conferences
-- Drafting grant proposals for federal agencies (NSF, NIH, DOE, DARPA) or private foundations
-- Checking formatting requirements and page limits for target venues
-- Customizing templates with author information and project details
-- Verifying document compliance with venue specifications
+1. Identify the exact venue, year or funding cycle, track, and article or proposal type.
+2. Open the official author instructions, call, solicitation, notice of funding opportunity (NOFO), or policy guide.
+3. Record the source URL and the date checked.
+4. Distinguish initial submission, revision/rebuttal, and camera-ready rules.
+5. Treat bundled files as scaffolds unless this skill explicitly says they are a copy of an official template.
-## Visual Enhancement with Scientific Schematics
+Never infer a current style-file name by changing the year in an old filename. Never present a generic scaffold as an official venue template.
-**When creating documents with this skill, always consider adding scientific diagrams and schematics to enhance visual communication.**
+## When to Use
-If your document does not already contain schematics or diagrams:
-- Use the **scientific-schematics** skill to generate AI-powered publication-quality diagrams
-- Simply describe your desired diagram in natural language
-- Nano Banana Pro will automatically generate, review, and refine the schematic
+Use this skill for:
-**For new documents:** Scientific schematics should be generated by default to visually represent key concepts, workflows, architectures, or relationships described in the text.
+- locating official journal or conference author instructions;
+- checking page limits, required sections, anonymity, supplemental-material rules, or citation style;
+- choosing and adapting a bundled LaTeX scaffold;
+- preparing NSF, NIH, DOE, DARPA, or foundation proposal documents;
+- designing a research poster after checking event-specific dimensions;
+- adapting prose to a venue's audience and reviewer expectations; or
+- inspecting a PDF's page count and embedded fonts.
-**How to generate schematics:**
-```bash
-python scripts/generate_schematic.py "your diagram description" -o figures/output.png
-```
+## Verification-First Workflow
-The AI will automatically:
-- Create publication-quality images with proper formatting
-- Review and refine through multiple iterations
-- Ensure accessibility (colorblind-friendly, high contrast)
-- Save outputs in the figures/ directory
+### 1. Resolve the exact target
-**When to add schematics:**
-- Methodology flowcharts for papers
-- Conceptual framework diagrams
-- System architecture illustrations
-- Data flow diagrams
-- Experimental design visualizations
-- Research workflow diagrams
-- Any complex concept that benefits from visualization
+Ask for or derive:
-For detailed guidance on creating schematics, refer to the scientific-schematics skill documentation.
-
----
+- venue or funding agency;
+- year/cycle and track;
+- document type, such as research article, short paper, main track, R01, or R21;
+- submission stage; and
+- authoring format, such as LaTeX or Word.
-## Core Capabilities
+Do not combine rules from similarly named venues or tracks.
-### 1. Journal Article Templates
-
-Access LaTeX templates and formatting guidelines for 50+ major scientific journals across disciplines:
-
-**Nature Portfolio**:
-- Nature, Nature Methods, Nature Biotechnology, Nature Machine Intelligence
-- Nature Communications, Nature Protocols
-- Scientific Reports
-
-**Science Family**:
-- Science, Science Advances, Science Translational Medicine
-- Science Immunology, Science Robotics
-
-**PLOS (Public Library of Science)**:
-- PLOS ONE, PLOS Biology, PLOS Computational Biology
-- PLOS Medicine, PLOS Genetics
-
-**Cell Press**:
-- Cell, Neuron, Immunity, Cell Reports
-- Molecular Cell, Developmental Cell
-
-**IEEE Publications**:
-- IEEE Transactions (various disciplines)
-- IEEE Access, IEEE Journal templates
-
-**ACM Publications**:
-- ACM Transactions, Communications of the ACM
-- ACM conference proceedings
-
-**Other Major Publishers**:
-- Springer journals (various disciplines)
-- Elsevier journals (custom templates)
-- Wiley journals
-- BMC journals
-- Frontiers journals
-
-### 2. Conference Paper Templates
-
-Conference-specific templates with proper formatting for major academic conferences:
-
-**Machine Learning & AI**:
-- NeurIPS (Neural Information Processing Systems)
-- ICML (International Conference on Machine Learning)
-- ICLR (International Conference on Learning Representations)
-- CVPR (Computer Vision and Pattern Recognition)
-- AAAI (Association for the Advancement of Artificial Intelligence)
-
-**Computer Science**:
-- ACM CHI (Human-Computer Interaction)
-- SIGKDD (Knowledge Discovery and Data Mining)
-- EMNLP (Empirical Methods in Natural Language Processing)
-- SIGIR (Information Retrieval)
-- USENIX conferences
-
-**Biology & Bioinformatics**:
-- ISMB (Intelligent Systems for Molecular Biology)
-- RECOMB (Research in Computational Molecular Biology)
-- PSB (Pacific Symposium on Biocomputing)
-
-**Engineering**:
-- IEEE conference templates (various disciplines)
-- ASME, AIAA conferences
-
-### 3. Research Poster Templates
-
-Academic poster templates for conference presentations:
-
-**Standard Formats**:
-- A0 (841 × 1189 mm / 33.1 × 46.8 in)
-- A1 (594 × 841 mm / 23.4 × 33.1 in)
-- 36" × 48" (914 × 1219 mm) - Common US size
-- 42" × 56" (1067 × 1422 mm)
-- 48" × 36" (landscape orientation)
-
-**Template Packages**:
-- **beamerposter**: Classic academic poster template
-- **tikzposter**: Modern, colorful poster design
-- **baposter**: Structured multi-column layout
-
-**Design Features**:
-- Optimal font sizes for readability at distance
-- Color schemes (colorblind-safe palettes)
-- Grid layouts and column structures
-- QR code integration for supplementary materials
-
-### 4. Grant Proposal Templates
-
-Templates and formatting requirements for major funding agencies:
-
-**NSF (National Science Foundation)**:
-- Full proposal template (15-page project description)
-- Project Summary (1 page: Overview, Intellectual Merit, Broader Impacts)
-- Budget and budget justification
-- Biographical sketch (3-page limit)
-- Facilities, Equipment, and Other Resources
-- Data Management Plan
-
-**NIH (National Institutes of Health)**:
-- R01 Research Grant (multi-year)
-- R21 Exploratory/Developmental Grant
-- K Awards (Career Development)
-- Specific Aims Page (1 page, most critical component)
-- Research Strategy (Significance, Innovation, Approach)
-- Biographical sketches (5-page limit)
-
-**DOE (Department of Energy)**:
-- Office of Science proposals
-- ARPA-E templates
-- Technology Readiness Level (TRL) descriptions
-- Commercialization and impact sections
-
-**DARPA (Defense Advanced Research Projects Agency)**:
-- BAA (Broad Agency Announcement) responses
-- Heilmeier Catechism framework
-- Technical approach and milestones
-- Transition planning
-
-**Private Foundations**:
-- Gates Foundation
-- Wellcome Trust
-- Howard Hughes Medical Institute (HHMI)
-- Chan Zuckerberg Initiative (CZI)
-
-## Workflow: Finding and Using Templates
-
-### Step 1: Identify Target Venue
-
-Determine the specific publication venue, conference, or funding agency:
+### 2. Consult the right reference
-```
-Example queries:
-- "I need to submit to Nature"
-- "What are the requirements for NeurIPS 2025?"
-- "Show me NSF proposal formatting"
-- "I'm creating a poster for ISMB"
-```
+| Need | Reference |
+|---|---|
+| Journal submission and official publisher resources | `references/journals_formatting.md` |
+| Conference rules and 2026 verified snapshots | `references/conferences_formatting.md` |
+| Poster sizes, layout, and accessibility | `references/posters_guidelines.md` |
+| NSF, NIH, DOE, DARPA, and foundation proposals | `references/grants_requirements.md` |
+| Cross-venue writing comparison | `references/venue_writing_styles.md` |
+| Nature and Science writing | `references/nature_science_style.md` |
+| Cell Press writing | `references/cell_press_style.md` |
+| Medical journal writing | `references/medical_journal_styles.md` |
+| ML and computer-vision conference writing | `references/ml_conference_style.md` |
+| ACL, EMNLP, CHI, and other CS writing | `references/cs_conference_style.md` |
+| Review criteria and rebuttals | `references/reviewer_expectations.md` |
-### Step 2: Query Template and Requirements
+Reference files summarize rules but do not override the current official source.
-Access venue-specific templates and formatting guidelines:
+### 3. Capture a compliance note
-**For Journals**:
-```bash
-# Load journal formatting requirements
-Reference: references/journals_formatting.md
-Search for: "Nature" or specific journal name
+Before editing, write a short note in the working document or task log:
-# Retrieve template
-Template: assets/journals/nature_article.tex
+```text
+Target: ICML 2026 main track, initial submission
+Official source: https://icml.cc/Conferences/2026/AuthorInstructions
+Checked: 2026-07-20
+Main-text limit: 8 pages
+References/appendices: additional pages allowed in the same PDF
+Anonymity: required
+Official template: ICML 2026 style package linked by the author instructions
```
-**For Conferences**:
-```bash
-# Load conference formatting
-Reference: references/conferences_formatting.md
-Search for: "NeurIPS" or specific conference
+This makes later validation reproducible.
-# Retrieve template
-Template: assets/journals/neurips_article.tex
-```
+### 4. Start from the official template
-**For Posters**:
-```bash
-# Load poster guidelines
-Reference: references/posters_guidelines.md
+For annual conferences and publisher-managed workflows:
-# Retrieve template
-Template: assets/posters/beamerposter_academic.tex
-```
+1. Download the template from the official source.
+2. Keep its class/style files unchanged.
+3. Add content without overriding margins, font sizes, spacing, or headers.
+4. Use a bundled scaffold only for drafting or when the official source explicitly permits it.
-**For Grants**:
-```bash
-# Load grant requirements
-Reference: references/grants_requirements.md
-Search for: "NSF" or specific agency
+For grants, many components are entered or uploaded separately. Do not submit a combined bundled `.tex` file as if it were an agency-issued form.
-# Retrieve template
-Template: assets/grants/nsf_proposal_template.tex
-```
-
-### Step 3: Review Formatting Requirements
+### 5. Validate manually and mechanically
-Check critical specifications before customizing:
+Verify at least:
-**Key Requirements to Verify**:
-- Page limits (varies by venue)
-- Font size and family
-- Margin specifications
-- Line spacing
-- Citation style (APA, Vancouver, Nature, etc.)
-- Figure/table requirements
-- File format (PDF, Word, LaTeX source)
-- Anonymization (for double-blind review)
-- Supplementary material limits
+- main-text and total-file page rules;
+- font, margin, line-spacing, and paper-size rules;
+- anonymity and metadata;
+- required sections, statements, checklists, and disclosures;
+- figure/table placement and accessibility;
+- reference and supplemental-material treatment; and
+- source-package and PDF requirements.
-### Step 4: Customize Template
+The helper can inspect page totals and embedded fonts, but it cannot prove that margins, font sizes, excluded sections, or hidden metadata comply.
-Use helper scripts or manual customization:
+## Bundled Assets
-**Option 1: Helper Script (Recommended)**:
-```bash
-python scripts/customize_template.py \
- --template assets/journals/nature_article.tex \
- --title "Your Paper Title" \
- --authors "First Author, Second Author" \
- --affiliations "University Name" \
- --output my_nature_paper.tex
-```
+The repository intentionally bundles only the following templates. Other venues listed in references require an official external template.
-**Option 2: Manual Editing**:
-- Open template file
-- Replace placeholder text (marked with comments)
-- Fill in title, authors, affiliations, abstract
-- Add your content to each section
+### Journal and conference scaffolds
-### Step 5: Validate Format
+| File | Status |
+|---|---|
+| `assets/journals/nature_article.tex` | Generic Nature-oriented writing scaffold; not an official Nature template |
+| `assets/journals/plos_one.tex` | PLOS ONE-oriented scaffold; compare with the current official PLOS LaTeX package |
+| `assets/journals/neurips_article.tex` | NeurIPS 2026 wrapper; requires the official `neurips_2026.sty` |
+| `assets/journals/elsarticle-template-num.tex` | Elsevier `elsarticle` numeric example |
+| `assets/journals/elsarticle-template-num-names.tex` | Elsevier `elsarticle` numbered/name example |
+| `assets/journals/elsarticle-template-harv.tex` | Elsevier `elsarticle` author-year example |
-Check compliance with venue requirements:
+The matching Elsevier `.bst` files are in `assets/journals/`.
-```bash
-python scripts/validate_format.py \
- --file my_paper.pdf \
- --venue "Nature" \
- --check-all
-```
+### Grant scaffolds
-**Validation Checks**:
-- Page count within limits
-- Font sizes correct
-- Margins meet specifications
-- References formatted correctly
-- Figures meet resolution requirements
+| File | Status |
+|---|---|
+| `assets/grants/nsf_proposal_template.tex` | Planning scaffold for common NSF narrative components; upload components separately |
+| `assets/grants/nih_specific_aims.tex` | Writing scaffold for a one-page NIH Specific Aims attachment |
-### Step 6: Compile and Review
+Use SciENcv and agency-provided common forms where required. Do not recreate biosketch or current-support forms in LaTeX.
-Compile LaTeX and review output:
+### Poster scaffold
-```bash
-# Compile LaTeX
-pdflatex my_paper.tex
-bibtex my_paper
-pdflatex my_paper.tex
-pdflatex my_paper.tex
-
-# Or use latexmk for automated compilation
-latexmk -pdf my_paper.tex
-```
+| File | Status |
+|---|---|
+| `assets/posters/beamerposter_academic.tex` | Venue-agnostic beamerposter scaffold; set dimensions from the event's current presenter instructions |
-Review checklist:
-- [ ] All sections present and properly formatted
-- [ ] Citations render correctly
-- [ ] Figures appear with proper captions
-- [ ] Page count within limits
-- [ ] Author guidelines followed
-- [ ] Supplementary materials prepared (if needed)
-
-## Integration with Other Skills
-
-This skill works seamlessly with other scientific skills:
-
-### Scientific Writing
-- Use **scientific-writing** skill for content guidance (IMRaD structure, clarity, precision)
-- Apply venue-specific templates from this skill for formatting
-- Combine for complete manuscript preparation
-
-### Literature Review
-- Use **literature-review** skill for systematic literature search and synthesis
-- Apply appropriate citation style from venue requirements
-- Format references according to template specifications
-
-### Peer Review
-- Use **peer-review** skill to evaluate manuscript quality
-- Use this skill to verify formatting compliance
-- Ensure adherence to reporting guidelines (CONSORT, STROBE, etc.)
-
-### Research Grants
-- Cross-reference with **research-grants** skill for content strategy
-- Use this skill for agency-specific templates and formatting
-- Combine for comprehensive grant proposal preparation
-
-### LaTeX Posters
-- This skill provides venue-agnostic poster templates
-- Use for conference-specific poster requirements
-- Integrate with visualization skills for figure creation
-
-## Template Categories
-
-### By Document Type
-
-| Category | Template Count | Common Venues |
-|----------|---------------|---------------|
-| **Journal Articles** | 30+ | Nature, Science, PLOS, IEEE, ACM, Cell Press |
-| **Conference Papers** | 20+ | NeurIPS, ICML, CVPR, CHI, ISMB |
-| **Research Posters** | 10+ | A0, A1, 36×48, various packages |
-| **Grant Proposals** | 15+ | NSF, NIH, DOE, DARPA, foundations |
-
-### By Discipline
-
-| Discipline | Supported Venues |
-|------------|------------------|
-| **Life Sciences** | Nature, Cell Press, PLOS, ISMB, RECOMB |
-| **Physical Sciences** | Science, Physical Review, ACS, APS |
-| **Engineering** | IEEE, ASME, AIAA, ACM |
-| **Computer Science** | ACM, IEEE, NeurIPS, ICML, ICLR |
-| **Medicine** | NEJM, Lancet, JAMA, BMJ |
-| **Interdisciplinary** | PNAS, Nature Communications, Science Advances |
+## Common Workflows
-## Helper Scripts
+### Annual conference paper
-### query_template.py
+1. Open `references/conferences_formatting.md`.
+2. Follow the official link for the exact year and track.
+3. Download the official author kit.
+4. Draft in the official template.
+5. Keep identifying information out of every submitted file when review is blind.
+6. Check the paper checklist, supplement, rebuttal, and camera-ready rules separately.
-Search and retrieve templates by venue name, type, or keywords:
+For NeurIPS 2026, the bundled wrapper can be copied after downloading the official style file:
```bash
-# Find templates for a specific journal
-python scripts/query_template.py --venue "Nature" --type "article"
+python scripts/customize_template.py \
+ --template neurips_article.tex \
+ --output my_neurips_2026_paper.tex
+```
-# Search by keyword
-python scripts/query_template.py --keyword "machine learning"
+### Journal manuscript
-# List all available templates
-python scripts/query_template.py --list-all
+1. Resolve the exact journal and article type.
+2. Determine whether initial submission is format-flexible.
+3. Use the journal's official template or submission format when required.
+4. Apply the appropriate writing-style reference.
+5. Recheck final-production instructions only after acceptance or revision.
-# Get requirements for a venue
-python scripts/query_template.py --venue "NeurIPS" --requirements
-```
+Do not apply a publisher-wide template when the journal provides its own Guide for Authors.
-### customize_template.py
+### Grant proposal
-Customize templates with author and project information:
+1. Read the solicitation or NOFO before general agency guidance.
+2. Confirm the effective policy guide and form set.
+3. Map every required component to its page limit and upload field.
+4. Use agency systems and common forms for biosketches and support disclosures.
+5. Use bundled `.tex` files only as drafting aids.
+6. Have the institution's sponsored-research office review the final package.
-```bash
-# Basic customization
-python scripts/customize_template.py \
- --template assets/journals/nature_article.tex \
- --output my_paper.tex
+### Research poster
-# With author information
-python scripts/customize_template.py \
- --template assets/journals/nature_article.tex \
- --title "Novel Approach to Protein Folding" \
- --authors "Jane Doe, John Smith, Alice Johnson" \
- --affiliations "MIT, Stanford, Harvard" \
- --email "[email protected]" \
- --output my_paper.tex
+1. Read the event's presenter instructions.
+2. Confirm physical dimensions, orientation, file format, and upload deadline.
+3. Set the poster dimensions in the scaffold.
+4. Use readable type, high contrast, color-independent encodings, and a logical reading order.
+5. Export and inspect the PDF at final size.
-# Interactive mode
-python scripts/customize_template.py --interactive
-```
+## Helper Scripts
-### validate_format.py
+Run scripts from the skill directory.
-Check document compliance with venue requirements:
+### List bundled templates
```bash
-# Validate a compiled PDF
-python scripts/validate_format.py \
- --file my_paper.pdf \
- --venue "Nature" \
- --check-all
-
-# Check specific aspects
-python scripts/validate_format.py \
- --file my_paper.pdf \
- --venue "NeurIPS" \
- --check page-count,margins,fonts
-
-# Generate validation report
-python scripts/validate_format.py \
- --file my_paper.pdf \
- --venue "Science" \
- --report validation_report.txt
+python scripts/query_template.py --list-all
+python scripts/query_template.py --venue NeurIPS --requirements
+python scripts/query_template.py --type grants
```
-## Best Practices
-
-### Template Selection
-1. **Verify currency**: Check template date and compare with latest author guidelines
-2. **Check official sources**: Many journals provide official LaTeX classes
-3. **Test compilation**: Compile template before adding content
-4. **Read comments**: Templates include helpful inline comments
-
-### Customization
-1. **Preserve structure**: Don't remove required sections or packages
-2. **Follow placeholders**: Replace marked placeholder text systematically
-3. **Maintain formatting**: Don't override venue-specific formatting
-4. **Keep backups**: Save original template before customization
-
-### Compliance
-1. **Check page limits**: Verify before final submission
-2. **Validate citations**: Use correct citation style for venue
-3. **Test figures**: Ensure figures meet resolution requirements
-4. **Review anonymization**: Remove identifying information if required
-
-### Submission
-1. **Follow instructions**: Read complete author guidelines
-2. **Include all files**: LaTeX source, figures, bibliography
-3. **Generate properly**: Use recommended compilation method
-4. **Check output**: Verify PDF matches expectations
-
-## Common Formatting Requirements
-
-### Page Limits (Typical)
-
-| Venue Type | Typical Limit | Notes |
-|------------|---------------|-------|
-| **Nature Article** | 5 pages | ~3000 words excluding refs |
-| **Science Report** | 5 pages | Figures count toward limit |
-| **PLOS ONE** | No limit | Unlimited length |
-| **NeurIPS** | 8 pages | + unlimited refs/appendix |
-| **ICML** | 8 pages | + unlimited refs/appendix |
-| **NSF Proposal** | 15 pages | Project description only |
-| **NIH R01** | 12 pages | Research strategy |
-
-### Citation Styles by Venue
-
-| Venue | Citation Style | Format |
-|-------|---------------|--------|
-| **Nature** | Numbered (superscript) | Nature style |
-| **Science** | Numbered (superscript) | Science style |
-| **PLOS** | Numbered (brackets) | Vancouver |
-| **Cell Press** | Author-year | Cell style |
-| **ACM** | Numbered | ACM style |
-| **IEEE** | Numbered (brackets) | IEEE style |
-| **APA journals** | Author-year | APA 7th |
-
-### Figure Requirements
-
-| Venue | Resolution | Format | Color |
-|-------|-----------|--------|-------|
-| **Nature** | 300+ dpi | TIFF, EPS, PDF | RGB or CMYK |
-| **Science** | 300+ dpi | TIFF, PDF | RGB |
-| **PLOS** | 300-600 dpi | TIFF, EPS | RGB |
-| **IEEE** | 300+ dpi | EPS, PDF | RGB or Grayscale |
-
-## Writing Style Guides
-
-Beyond formatting, this skill provides comprehensive **writing style guides** that capture how papers should *read* at different venues—not just how they should look.
-
-### Why Style Matters
-
-The same research written for Nature will read very differently than when written for NeurIPS:
-- **Nature/Science**: Accessible to non-specialists, story-driven, broad significance
-- **Cell Press**: Mechanistic depth, comprehensive data, graphical abstract required
-- **Medical journals**: Patient-centered, evidence-graded, structured abstracts
-- **ML conferences**: Contribution bullets, ablation studies, reproducibility focus
-- **CS conferences**: Field-specific conventions, varying evaluation standards
-
-### Available Style Guides
-
-| Guide | Covers | Key Topics |
-|-------|--------|------------|
-| `venue_writing_styles.md` | Master overview | Style spectrum, quick reference |
-| `nature_science_style.md` | Nature, Science, PNAS | Accessibility, story-telling, broad impact |
-| `cell_press_style.md` | Cell, Neuron, Immunity | Graphical abstracts, eTOC, Highlights |
-| `medical_journal_styles.md` | NEJM, Lancet, JAMA, BMJ | Structured abstracts, evidence language |
-| `ml_conference_style.md` | NeurIPS, ICML, ICLR, CVPR | Contribution bullets, ablations |
-| `cs_conference_style.md` | ACL, EMNLP, CHI, SIGKDD | Field-specific conventions |
-| `reviewer_expectations.md` | All venues | What reviewers look for, rebuttal tips |
-
-### Writing Examples
-
-Concrete examples are available in `assets/examples/`:
-- `nature_abstract_examples.md`: Flowing paragraph abstracts for high-impact journals
-- `neurips_introduction_example.md`: ML conference intro with contribution bullets
-- `cell_summary_example.md`: Cell Press Summary, Highlights, eTOC format
-- `medical_structured_abstract.md`: NEJM, Lancet, JAMA structured format
-
-### Workflow: Adapting to a Venue
-
-1. **Identify target venue** and load the appropriate style guide
-2. **Review writing conventions**: Tone, voice, abstract format, structure
-3. **Check examples** for section-specific guidance
-4. **Review expectations**: What do reviewers at this venue prioritize?
-5. **Apply formatting**: Use LaTeX template from `assets/`
+The query helper reports only assets that exist in this skill and includes source/currency notes.
----
+### Copy and customize a scaffold
-## Resources
-
-### Bundled Resources
-
-**Writing Style Guides** (in `references/`):
-- `venue_writing_styles.md`: Master style overview and comparison
-- `nature_science_style.md`: Nature/Science writing conventions
-- `cell_press_style.md`: Cell Press journal style
-- `medical_journal_styles.md`: Medical journal writing guide
-- `ml_conference_style.md`: ML conference writing conventions
-- `cs_conference_style.md`: CS conference writing guide
-- `reviewer_expectations.md`: What reviewers look for by venue
-
-**Formatting Requirements** (in `references/`):
-- `journals_formatting.md`: Comprehensive journal formatting requirements
-- `conferences_formatting.md`: Conference paper specifications
-- `posters_guidelines.md`: Research poster design and sizing
-- `grants_requirements.md`: Grant proposal requirements by agency
-
-**Writing Examples** (in `assets/examples/`):
-- `nature_abstract_examples.md`: High-impact journal abstract examples
-- `neurips_introduction_example.md`: ML conference introduction format
-- `cell_summary_example.md`: Cell Press Summary/Highlights/eTOC
-- `medical_structured_abstract.md`: NEJM/Lancet/JAMA abstract format
-
-**Templates** (in `assets/`):
-- `journals/`: Journal article LaTeX templates
-- `posters/`: Research poster templates
-- `grants/`: Grant proposal templates
-
-**Scripts** (in `scripts/`):
-- `query_template.py`: Search and retrieve templates
-- `customize_template.py`: Customize with author info
-- `validate_format.py`: Check compliance with requirements
-
-### External Resources
-
-**Journal Author Guidelines**:
-- Nature: https://www.nature.com/nature/for-authors
-- Science: https://www.science.org/content/page/instructions-authors
-- PLOS: https://plos.org/resources/for-authors/
-- Cell Press: https://www.cell.com/author-guidelines
-
-**Conference Formatting**:
-- NeurIPS: https://neurips.cc/Conferences/2024/CallForPapers
-- ICML: https://icml.cc/Conferences/2024/StyleAuthorInstructions
-- CVPR: https://cvpr.thecvf.com/Conferences/2024/AuthorGuidelines
-
-**Grant Resources**:
-- NSF PAPPG: https://www.nsf.gov/publications/pub_summ.jsp?ods_key=pappg
-- NIH Forms: https://grants.nih.gov/grants/how-to-apply-application-guide.html
-- DOE Funding: https://science.osti.gov/grants
-
-## Example Usage
-
-### Example 1: Nature Article Submission
-
-```markdown
-User: "I need to prepare a manuscript for Nature"
-
-Response:
-1. Load Nature formatting requirements (references/journals_formatting.md)
-2. Retrieve Nature template (assets/journals/nature_article.tex)
-3. Key requirements:
- - Length: ~3000 words, ~5 pages
- - Format: Single column, 12pt font
- - Citations: Numbered superscript (Nature style)
- - Figures: 300+ dpi, RGB color
-4. Customize template with your title, authors, affiliations
-5. Compile and validate against requirements
+```bash
+python scripts/customize_template.py \
+ --template nature_article.tex \
+ --title "Your Paper Title" \
+ --authors "First Author, Second Author" \
+ --affiliations "Institution Name" \
+ --output my_paper.tex
```
-### Example 2: NeurIPS Conference Paper
+Review every replacement and compile before adding substantial content. User-provided text may need LaTeX escaping.
-```markdown
-User: "What are the formatting requirements for NeurIPS?"
+### Inspect a PDF
-Response:
-From references/conferences_formatting.md:
-- Page limit: 8 pages main text + unlimited references/appendix
-- Format: Two-column, 10pt font
-- Template: neurips_2024.sty (official style file)
-- Anonymization: Required for initial submission
-- Citations: Numbered (brackets)
-- Figures: High resolution, colorblind-safe recommended
-```
+Use a verified preset:
-### Example 3: NSF Proposal
-
-```markdown
-User: "Help me format an NSF proposal"
-
-Response:
-NSF requirements (from references/grants_requirements.md):
-- Project Description: 15 pages maximum
-- Project Summary: 1 page (Overview, Intellectual Merit, Broader Impacts)
-- Budget Justification: 3-5 pages
-- Biographical Sketch: 3 pages per senior personnel
-- Font: Minimum 10pt, Times Roman or similar
-- Margins: 1 inch all sides
-Template: assets/grants/nsf_proposal_template.tex
+```bash
+python scripts/validate_format.py \
+ --file paper.pdf \
+ --venue icml-2026 \
+ --content-pages 8 \
+ --check page-count,fonts
```
-### Example 4: Conference Poster
-
-```markdown
-User: "I need to create a poster for ISMB"
+Or provide an explicit limit and source:
-Response:
-ISMB poster specifications:
-- Size: Typically A0 portrait (33.1 × 46.8 inches)
-- Recommended template: beamerposter or tikzposter
-- Font sizes: Title 60-85pt, Headers 36-48pt, Body 24-32pt
-- Include: QR code for paper/supplementary materials
-Available templates:
-- assets/posters/beamerposter_academic.tex
+```bash
+python scripts/validate_format.py \
+ --file proposal.pdf \
+ --max-pages 15 \
+ --content-pages 15 \
+ --source-url "https://www.nsf.gov/policies/pappg" \
+ --check page-count,fonts \
+ --report validation.txt
```
-## Updates and Maintenance
-
-**Template Currency**:
-- Templates updated annually or when venues release new guidelines
-- Last updated: 2024
-- Check official venue sites for most current requirements
-
-**Reporting Issues**:
-- Template compilation errors
-- Outdated formatting requirements
-- Missing venue templates
-- Incorrect specifications
-
-## Summary
+`--content-pages` must be counted according to the official rule. The script does not infer where references or appendices begin.
-The venue-templates skill provides comprehensive access to:
+## Final Compliance Checklist
-1. **50+ publication venue templates** across disciplines
-2. **Detailed formatting requirements** for journals, conferences, posters, grants
-3. **Helper scripts** for template discovery, customization, and validation
-4. **Integration** with other scientific writing skills
-5. **Best practices** for successful academic submissions
+- [ ] Exact venue, year/cycle, track, article type, and stage identified
+- [ ] Official source URL recorded with date checked
+- [ ] Official template or form used where required
+- [ ] Page-limit scope understood, including excluded sections
+- [ ] Required statements, checklists, and disclosures present
+- [ ] Blind-review files and PDF metadata checked for identity leaks
+- [ ] Figures and tables are legible and accessible
+- [ ] References, appendices, and supplements follow current rules
+- [ ] PDF and source package compile cleanly
+- [ ] Submission portal preview reviewed before final submission
-Use this skill whenever you need venue-specific formatting guidance or templates for academic publishing.
+## Maintenance
+This skill was reviewed on 2026-07-20. Annual conference snapshots are labeled with their year. When updating:
+1. replace year-specific claims only after checking official sources;
+2. avoid adding links to assets that are not bundled;
+3. keep generic guidance separate from official requirements;
+4. update helper presets and examples together; and
+5. increment `metadata.version`.
diff --git a/skills/venue-templates/assets/grants/nih_specific_aims.tex b/skills/venue-templates/assets/grants/nih_specific_aims.tex
index be46fa9a..67faf49f 100644
--- a/skills/venue-templates/assets/grants/nih_specific_aims.tex
+++ b/skills/venue-templates/assets/grants/nih_specific_aims.tex
@@ -1,7 +1,9 @@
% NIH Specific Aims Page Template
-% THE MOST CRITICAL PAGE OF YOUR NIH PROPOSAL
-% 1 page maximum - strictly enforced
-% Last updated: 2024
+% Writing scaffold; not an NIH-issued format page
+% Reviewed: 2026-07-20
+% Specific Aims is generally limited to one page.
+% Recheck the NOFO and current application guide before use:
+% https://grants.nih.gov/grants-process/write-application/how-to-apply-application-guide
\documentclass[11pt,letterpaper]{article}
@@ -208,8 +210,8 @@ To translate findings from Aims 1-2, we will \textbf{[approach]} to determine \t
% ====================
% DISEASE BURDEN APPROACH:
-% "Alzheimer's disease (AD) affects 6.7 million Americans and will cost $345 billion in 2023,
-% yet no disease-modifying therapies exist."
+% "[Condition] affects [current, cited population estimate] and causes
+% [current, cited burden], yet [specific unmet need remains]."
% MECHANISTIC GAP APPROACH:
% "Despite decades of research, the molecular mechanisms driving metastasis remain poorly understood,
diff --git a/skills/venue-templates/assets/grants/nsf_proposal_template.tex b/skills/venue-templates/assets/grants/nsf_proposal_template.tex
index 83d45a3a..96a924fa 100644
--- a/skills/venue-templates/assets/grants/nsf_proposal_template.tex
+++ b/skills/venue-templates/assets/grants/nsf_proposal_template.tex
@@ -1,13 +1,17 @@
% NSF Research Proposal Template
-% For NSF Standard Grant Proposals
-% Last updated: 2024
-% Based on NSF PAPPG (Proposal & Award Policies & Procedures Guide)
+% Planning scaffold for common NSF research-proposal narrative components
+% Reviewed: 2026-07-20
+% Based on NSF PAPPG 24-1, current on the review date with later supplements.
+% Recheck https://www.nsf.gov/policies/pappg and the solicitation.
+% This combined file is not an NSF-issued upload package. Submit components
+% separately through Research.gov or Grants.gov as instructed.
\documentclass[11pt,letterpaper]{article}
% Required formatting
\usepackage[margin=1in]{geometry} % 1 inch margins required
-\usepackage{times} % Times Roman font (11pt minimum)
+% Default Computer Modern at 11pt is permitted by the reviewed PAPPG.
+% Times New Roman at 11pt or larger is also permitted.
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amssymb}
@@ -24,6 +28,7 @@
\fancyhf{}
\rhead{\thepage}
\renewcommand{\headrulewidth}{0pt}
+\setlength{\headheight}{14pt}
\begin{document}
@@ -219,9 +224,9 @@ Author, F.F., et al. (2021). Another article. \textit{Nature}, \textit{590}, 234
\newpage
% ====================
-% BUDGET JUSTIFICATION (3-5 pages typical)
+% BUDGET JUSTIFICATION
% Note: Budget is submitted separately in NSF's systems
-% This justifies the budget requests
+% Follow the current PAPPG and solicitation for content and length.
% ====================
\section*{Budget Justification}
@@ -325,19 +330,21 @@ Identify who is responsible for data management implementation.
% ADDITIONAL DOCUMENTS (submitted separately in NSF system)
% ====================
-% 1. BIOGRAPHICAL SKETCH (3 pages per person)
-% - Use NSF-approved format (SciENcv or NSF template)
-% - Professional preparation
-% - Appointments
-% - Products (up to 5 most relevant, up to 5 other significant)
-% - Synergistic activities
+% 1. BIOGRAPHICAL SKETCH
+% - Generate the required compliant PDF in SciENcv
+% - The obsolete three-page cap no longer applies
+% - Do not place Synergistic Activities inside the biosketch
% 2. CURRENT AND PENDING SUPPORT
-% - All current and pending support for all senior personnel
-% - Use NSF format
+% - Generate and certify in SciENcv for each senior/key person
+% - Disclose all proposals, active projects, and required in-kind support
% - Check for overlap with proposed project
-% 3. FACILITIES, EQUIPMENT, AND OTHER RESOURCES
+% 3. SYNERGISTIC ACTIVITIES
+% - Separate document for each senior/key person
+% - Up to one page and up to five distinct examples
+
+% 4. FACILITIES, EQUIPMENT, AND OTHER RESOURCES
% - Describe available facilities and equipment
% - Computational resources
% - Laboratory space
@@ -353,10 +360,11 @@ Identify who is responsible for data management implementation.
% ☐ Project Summary: 1 page, includes Overview, Intellectual Merit, Broader Impacts
% ☐ Project Description: 15 pages maximum
% ☐ References Cited: No page limit, consistent formatting
-% ☐ Biographical Sketches: 3 pages per person, NSF-approved format
-% ☐ Budget Justification: Detailed and reasonable
-% ☐ Data Management Plan: 2 pages maximum
-% ☐ Current & Pending: Complete and accurate
+% ☐ Biographical Sketches: generated and certified in SciENcv
+% ☐ Synergistic Activities: separate one-page document per senior/key person
+% ☐ Budget Justification: follows current PAPPG and solicitation
+% ☐ Data Management and Sharing Plan: 2 pages maximum
+% ☐ Current & Pending: generated, complete, and certified in SciENcv
% ☐ Facilities: Adequate resources described
% ☐ Broader Impacts: Substantive and integrated throughout
% ☐ All required sections included
@@ -365,11 +373,12 @@ Identify who is responsible for data management implementation.
% SUBMISSION NOTES
% ====================
-% 1. Submit through Research.gov or Grants.gov
-% 2. Follow your institution's internal deadlines (usually 3-5 days before NSF deadline)
-% 3. Obtain institutional approval before submission
-% 4. Ensure all senior personnel have NSF IDs
-% 5. Budget prepared in NSF's system (separate from this document)
-% 6. Check program-specific requirements (may differ from standard grant)
-% 7. Contact Program Officer for guidance (encouraged but not required)
+% 1. Recheck the current PAPPG, supplements, and solicitation before use
+% 2. Submit required components separately through Research.gov or Grants.gov
+% 3. Follow your institution's internal deadlines
+% 4. Obtain institutional approval before submission
+% 5. Ensure all senior/key personnel can complete required portal certifications
+% 6. Prepare the budget in NSF's system, separate from this document
+% 7. Apply program-specific requirements when they differ from the PAPPG
+% 8. Contact the Program Officer only as permitted and appropriate
diff --git a/skills/venue-templates/assets/journals/nature_article.tex b/skills/venue-templates/assets/journals/nature_article.tex
index 713b4060..700ddd9e 100644
--- a/skills/venue-templates/assets/journals/nature_article.tex
+++ b/skills/venue-templates/assets/journals/nature_article.tex
@@ -1,6 +1,9 @@
% Nature Journal Article Template
% For submission to Nature family journals
-% Last updated: 2024
+% Reviewed: 2026-07-20
+% Generic writing scaffold, not an official Nature template.
+% Check the exact journal, article type, and submission stage at:
+% https://www.nature.com/nature/for-authors/initial-submission
\documentclass[12pt]{article}
diff --git a/skills/venue-templates/assets/journals/neurips_article.tex b/skills/venue-templates/assets/journals/neurips_article.tex
index 8098961c..9ed17920 100644
--- a/skills/venue-templates/assets/journals/neurips_article.tex
+++ b/skills/venue-templates/assets/journals/neurips_article.tex
@@ -1,12 +1,13 @@
% NeurIPS Conference Paper Template
% For submission to Neural Information Processing Systems (NeurIPS)
-% Last updated: 2024
-% Note: Use the official neurips_2024.sty file from the conference website
+% Reviewed: 2026-07-20
+% Note: Download the complete official NeurIPS 2026 package from:
+% https://neurips.cc/Conferences/2026/CallForPapers
\documentclass{article}
-% Required packages (neurips_2024.sty provides most formatting)
-\usepackage{neurips_2024} % Official NeurIPS style file (download from conference site)
+% Required package from the official NeurIPS 2026 author kit
+\usepackage{neurips_2026}
% Recommended packages
\usepackage{amsmath}
@@ -20,6 +21,7 @@
\usepackage{booktabs} % For better tables
\usepackage{multirow}
\usepackage{microtype} % Improved typography
+\usepackage{xcolor} % Required by the NeurIPS Paper Checklist
% Theorems, lemmas, etc.
\newtheorem{theorem}{Theorem}
@@ -181,15 +183,15 @@ Present your main experimental results.
\begin{table}[t]
\centering
-\caption{Performance comparison on benchmark datasets. Bold indicates best performance. Results reported as mean ± std over 3 runs.}
+\caption{Performance comparison on benchmark datasets. Bold indicates best performance. Results reported as mean $\pm$ standard deviation over 3 runs.}
\label{tab:main_results}
\begin{tabular}{lcccc}
\toprule
Method & Dataset 1 & Dataset 2 & Dataset 3 & Average \\
\midrule
-Baseline 1 & 85.3 ± 0.5 & 72.1 ± 0.8 & 90.2 ± 0.3 & 82.5 \\
-Baseline 2 & 87.2 ± 0.4 & 74.5 ± 0.6 & 91.1 ± 0.5 & 84.3 \\
-\textbf{Our Method} & \textbf{91.7 ± 0.3} & \textbf{79.8 ± 0.5} & \textbf{94.3 ± 0.2} & \textbf{88.6} \\
+Baseline 1 & $85.3 \pm 0.5$ & $72.1 \pm 0.8$ & $90.2 \pm 0.3$ & 82.5 \\
+Baseline 2 & $87.2 \pm 0.4$ & $74.5 \pm 0.6$ & $91.1 \pm 0.5$ & 84.3 \\
+\textbf{Our Method} & $\mathbf{91.7 \pm 0.3}$ & $\mathbf{79.8 \pm 0.5}$ & $\mathbf{94.3 \pm 0.2}$ & \textbf{88.6} \\
\bottomrule
\end{tabular}
\end{table}
@@ -209,16 +211,19 @@ Discuss your findings, limitations, and broader implications.
Honestly acknowledge limitations of your work.
\subsection{Broader Impacts}
-Discuss potential positive and negative societal impacts (required by NeurIPS).
+Discuss potential positive and negative societal impacts when relevant. NeurIPS 2026
+does not require a separately titled Broader Impacts section; ensure the required
+Paper Checklist points to the relevant discussion.
\section{Conclusion}
\label{sec:conclusion}
Summarize your main contributions and findings. Suggest future research directions.
-% Acknowledgments (add after acceptance, not in submission version)
-\section*{Acknowledgments}
-Thank collaborators, funding sources (with grant numbers), and compute resources. Not included in double-blind submission.
+% The official ack environment hides acknowledgments in submission mode.
+\begin{ack}
+Thank collaborators, funding sources (with grant numbers), and compute resources.
+\end{ack}
% References
\bibliographystyle{plainnat} % or other NeurIPS-compatible style
@@ -267,17 +272,21 @@ Provide links to code repository (anonymized for review, e.g., anonymous GitHub)
\item Data: Available upon request / at [repository]
\end{itemize}
+% Required for NeurIPS 2026. Keep checklist.tex from the official author kit.
+\input{checklist}
+
\end{document}
% Notes for Authors:
-% 1. Main paper: 8 pages maximum (excluding references and appendix)
-% 2. References: unlimited pages
-% 3. Appendix: unlimited pages (reviewed at discretion of reviewers)
-% 4. Use double-blind anonymization for initial submission
-% 5. Include broader impact statement
-% 6. Code submission strongly encouraged (anonymous for review)
-% 7. Use official neurips_2024.sty file (download from NeurIPS website)
-% 8. Font: Times, 10pt (enforced by style file)
-% 9. Figures should be colorblind-friendly
-% 10. Ensure reproducibility: report seeds, hyperparameters, dataset splits
+% 1. Main content: 9 pages maximum, including figures
+% 2. Acknowledgments, references, checklist, and optional technical appendices
+% do not count as content pages
+% 3. Appendices are optional reading for reviewers
+% 4. Omit final and preprint options for the anonymized initial submission
+% 5. Keep the complete required NeurIPS Paper Checklist
+% 6. Anonymize submitted code, data, links, and supplementary material
+% 7. Use the complete official NeurIPS 2026 package; do not rename an old style
+% 8. Do not override formatting enforced by the style file
+% 9. Use accessible, color-independent figures
+% 10. Recheck the Call for Papers and Main Track Handbook before submission
diff --git a/skills/venue-templates/assets/journals/plos_one.tex b/skills/venue-templates/assets/journals/plos_one.tex
index ccae2bb6..7250c73d 100644
--- a/skills/venue-templates/assets/journals/plos_one.tex
+++ b/skills/venue-templates/assets/journals/plos_one.tex
@@ -1,6 +1,9 @@
% PLOS ONE Article Template
% For submission to PLOS ONE and other PLOS journals
-% Last updated: 2024
+% Reviewed: 2026-07-20
+% Drafting scaffold, not the official PLOS LaTeX package.
+% Check https://journals.plos.org/plosone/s/submission-guidelines
+% and the current journal-specific LaTeX package before submission.
\documentclass[10pt,letterpaper]{article}
diff --git a/skills/venue-templates/assets/posters/beamerposter_academic.tex b/skills/venue-templates/assets/posters/beamerposter_academic.tex
index 0f5d99d6..8436cf5c 100644
--- a/skills/venue-templates/assets/posters/beamerposter_academic.tex
+++ b/skills/venue-templates/assets/posters/beamerposter_academic.tex
@@ -1,6 +1,7 @@
% Academic Research Poster Template using beamerposter
% For conference presentations
-% Last updated: 2024
+% Reviewed: 2026-07-20
+% Confirm dimensions, orientation, and export rules with the event.
\documentclass[final]{beamer}
@@ -70,7 +71,7 @@
\hspace{1em}\usebeamerfont{author in head/foot}Contact: [email protected]
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.34\paperwidth,ht=4ex,dp=2ex,center]{title in head/foot}%
- \usebeamerfont{title in head/foot}Conference Name 2024
+ \usebeamerfont{title in head/foot}Conference Name and Year
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.33\paperwidth,ht=4ex,dp=2ex,right]{date in head/foot}%
\usebeamerfont{date in head/foot}University Logo\hspace{1em}
diff --git a/skills/venue-templates/references/cell_press_style.md b/skills/venue-templates/references/cell_press_style.md
index b483639e..ace804e4 100644
--- a/skills/venue-templates/references/cell_press_style.md
+++ b/skills/venue-templates/references/cell_press_style.md
@@ -2,7 +2,9 @@
Comprehensive writing guide for Cell, Neuron, Immunity, Molecular Cell, Developmental Cell, Cell Reports, and other Cell Press journals.
-**Last Updated**: 2024
+**Reviewed**: 2026-07-20
+
+Cell Press requirements differ by journal and article type. Verify each front-matter and STAR Methods element in the current author instructions.
---
@@ -20,15 +22,15 @@ Cell Press journals emphasize **mechanistic depth**, **rigorous experimentation*
## Unique Cell Press Features
-Cell Press has several distinctive elements not found in other journals:
+Cell Press journals may use several distinctive elements not found in other journals:
### 1. Summary (Not Abstract)
Cell uses "Summary" instead of "Abstract" - functionally similar but emphasizes synthesis.
-### 2. Graphical Abstract (REQUIRED)
+### 2. Graphical Abstract
-A visual summary appearing on the table of contents. **This is mandatory for all Cell Press journals.**
+A visual summary for discovery and the table of contents. It is required for some journals and article types; verify the current target-journal instructions.
### 3. eTOC Blurb
@@ -453,12 +455,13 @@ Nature 479, 232–236.
## Pre-Submission Checklist
-### Required Elements
-- [ ] Graphical abstract (square format)
-- [ ] Highlights (3-4 bullets, ≤85 characters each)
-- [ ] eTOC blurb (30-50 words)
-- [ ] Summary (≤150 words)
-- [ ] Key Resources Table
+### Required Elements (verify for the exact journal and article type)
+- [ ] Graphical abstract, if required
+- [ ] Highlights, eTOC blurb, and Summary within the current limits
+- [ ] Key Resources Table and STAR Methods components, if required
+- [ ] Limitations of the Study
+- [ ] Resource Availability and Lead Contact information
+- [ ] Declaration of generative AI and AI-assisted technologies, when applicable
### Content
- [ ] Mechanistic depth throughout
diff --git a/skills/venue-templates/references/conferences_formatting.md b/skills/venue-templates/references/conferences_formatting.md
index 89e2a7d5..fd0db20b 100644
--- a/skills/venue-templates/references/conferences_formatting.md
+++ b/skills/venue-templates/references/conferences_formatting.md
@@ -1,564 +1,175 @@
# Conference Formatting Requirements
-Comprehensive formatting requirements and submission guidelines for major academic conferences across disciplines.
-
-**Last Updated**: 2024
-
----
-
-## Machine Learning & Artificial Intelligence
-
-### NeurIPS (Neural Information Processing Systems)
-
-**Conference Type**: Top-tier machine learning conference
-**Frequency**: Annual (December)
-
-**Formatting Requirements**:
-- **Page Limit**:
- - Main paper: 8 pages (excluding references)
- - References: Unlimited
- - Appendix/Supplementary: Unlimited (optional, reviewed at discretion)
-- **Format**: Two-column
-- **Font**: Times or Times New Roman, 10pt for body text
-- **Line spacing**: Single-spaced
-- **Margins**: 1 inch (2.54 cm) all sides
-- **Column separation**: 0.25 inch (0.635 cm)
-- **Paper size**: US Letter (8.5 × 11 inches)
-- **Anonymization**: **Required** for initial submission (double-blind review)
- - Remove author names, affiliations
- - Anonymize self-citations ("Author et al." → "Anonymous et al.")
- - Remove acknowledgments revealing identity
-- **Citations**: Numbered in square brackets [1], [2-4]
-- **References**: Any consistent style (commonly uses numbered references)
-- **Figures**:
- - High resolution (300+ dpi)
- - Colorblind-friendly palettes recommended
- - Can span both columns if needed
-- **Tables**: Clear, readable at publication size
-- **Equations**: Numbered if referenced
-- **LaTeX Class**: `neurips_2024.sty` (updated annually)
-- **Supplementary Materials**:
- - Code strongly encouraged (GitHub, anonymous repo for review)
- - Additional experiments, proofs
- - Not counted toward page limit
-
-**LaTeX Template**: `assets/journals/neurips_article.tex`
-
-**Submission Notes**:
-- Use official style file (changes yearly)
-- Paper ID on first page (auto-generated during submission)
-- Include "broader impact" statement (varies by year)
-- Reproducibility checklist required
-
-**Website**: https://neurips.cc/
-
----
-
-### ICML (International Conference on Machine Learning)
-
-**Conference Type**: Top-tier machine learning conference
-**Frequency**: Annual (July)
-
-**Formatting Requirements**:
-- **Page Limit**:
- - Main paper: 8 pages (excluding references and appendix)
- - References: Unlimited
- - Appendix: Unlimited (optional)
-- **Format**: Two-column
-- **Font**: Times, 10pt
-- **Line spacing**: Single-spaced
-- **Margins**: 1 inch all sides
-- **Paper size**: US Letter
-- **Anonymization**: **Required** (double-blind)
-- **Citations**: Numbered or author-year (consistent style)
-- **Figures**: High resolution, colorblind-safe recommended
-- **LaTeX Class**: `icml2024.sty` (updated yearly)
-- **Supplementary**: Strongly encouraged (code, data, appendix)
-
-**LaTeX Template**: `assets/journals/icml_article.tex`
-
-**Submission Notes**:
-- Must use official ICML style file
-- Checklist for reproducibility
-- Ethics statement if applicable
-
-**Website**: https://icml.cc/
-
----
-
-### ICLR (International Conference on Learning Representations)
-
-**Conference Type**: Top-tier deep learning conference
-**Frequency**: Annual (April/May)
-
-**Formatting Requirements**:
-- **Page Limit**:
- - Main paper: 8 pages (excluding references, appendix, ethics statement)
- - References: Unlimited
- - Appendix: Unlimited
-- **Format**: Two-column
-- **Font**: Times, 10pt
-- **Anonymization**: **Required** (double-blind)
-- **Citations**: Numbered [1] or author-year
-- **LaTeX Class**: `iclr2024_conference.sty`
-- **Supplementary**: Code and data encouraged (anonymous GitHub)
-- **Open Review**: Reviews and responses are public post-decision
-
-**LaTeX Template**: `assets/journals/iclr_article.tex`
-
-**Unique Features**:
-- OpenReview platform (transparent review process)
-- Author-reviewer discussion during review
-- Camera-ready can exceed 8 pages
-
-**Website**: https://iclr.cc/
-
----
-
-### CVPR (Computer Vision and Pattern Recognition)
-
-**Conference Type**: Top-tier computer vision conference
-**Frequency**: Annual (June)
-
-**Formatting Requirements**:
-- **Page Limit**:
- - Main paper: 8 pages (including figures and tables, excluding references)
- - References: Unlimited (separate section)
-- **Format**: Two-column
-- **Font**: Times Roman, 10pt
-- **Anonymization**: **Required** (double-blind)
- - Blur faces in images if needed
- - Anonymize datasets if they reveal identity
-- **Paper size**: US Letter
-- **Citations**: Numbered [1]
-- **Figures**: High resolution, can be color
-- **LaTeX Template**: CVPR official template (changes yearly)
-- **Supplementary Material**:
- - Video demonstrations encouraged
- - Additional results, code
- - 100 MB limit for all supplementary files
+Current-year conference rules change independently by track. Use this guide to find the authoritative source and to understand the scope of the rule; do not carry a page limit or style file into another year.
-**LaTeX Template**: `assets/journals/cvpr_article.tex`
+**Reviewed:** 2026-07-20
-**Website**: https://cvpr.thecvf.com/
+## How to Use This Guide
----
-
-### AAAI (Association for the Advancement of Artificial Intelligence)
-
-**Conference Type**: Major AI conference
-**Frequency**: Annual (February)
+For every submission, record:
-**Formatting Requirements**:
-- **Page Limit**:
- - Technical papers: 7 pages (excluding references)
- - References: Unlimited
-- **Format**: Two-column
-- **Font**: Times Roman, 10pt
-- **Anonymization**: **Required** (double-blind)
-- **Paper size**: US Letter
-- **Citations**: Various styles accepted (be consistent)
-- **LaTeX Template**: AAAI official style
-- **Supplementary**: Optional appendix
-
-**LaTeX Template**: `assets/journals/aaai_article.tex`
-
-**Website**: https://aaai.org/conference/aaai/
+1. conference year and track;
+2. initial, rebuttal, or camera-ready stage;
+3. official author-instruction URL and date checked;
+4. page-limit scope, including references and appendices;
+5. anonymity and external-link policy; and
+6. exact official template package.
----
+Official instructions and files override every summary below.
-### IJCAI (International Joint Conference on Artificial Intelligence)
+## Verified 2026 ML and Vision Snapshots
-**Conference Type**: Major AI conference
-**Frequency**: Annual
+### NeurIPS 2026 — Main Track
-**Formatting Requirements**:
-- **Page Limit**: 7 pages (excluding references)
-- **Format**: Two-column
-- **Font**: Times, 10pt
-- **Anonymization**: **Required**
-- **LaTeX Template**: IJCAI official style
+**Official sources**
----
+- Call for Papers: https://neurips.cc/Conferences/2026/CallForPapers
+- Main Track Handbook: https://neurips.cc/Conferences/2026/MainTrackHandbook
+- Official formatting package: linked from the Call for Papers
-## Computer Science
+**Initial submission**
-### ACM CHI (Human-Computer Interaction)
+- Up to **9 content pages**, including figures.
+- Additional pages containing acknowledgments, references, the required paper checklist, and optional technical appendices do not count as content pages.
+- Omit both the `final` and `preprint` style options; the official style then anonymizes the submission and adds line numbers.
+- Do not include acknowledgments in the anonymized submission.
+- The **NeurIPS Paper Checklist is required**; omitting it can cause desk rejection.
+- Technical appendices may be included after the references. Reviewers are not required to rely on them.
-**Conference Type**: Premier HCI conference
-**Frequency**: Annual (April/May)
+**Template rule**
-**Formatting Requirements**:
-- **Page Limit**:
- - Papers: 10 pages (excluding references)
- - Late-Breaking Work: 4 pages
-- **Format**: Single-column ACM format
-- **Font**: Depends on ACM template
-- **Anonymization**: **Required** for Papers track
-- **LaTeX Class**: `acmart` with CHI proceedings format
-- **Citations**: ACM style (numbered or author-year)
-- **Figures**: High quality, accessibility considered
-- **Accessibility**: Alt text for figures encouraged
+Use the exact NeurIPS 2026 package. The bundled `assets/journals/neurips_article.tex` is only a wrapper and requires the official `neurips_2026.sty` and checklist files.
-**LaTeX Template**: `assets/journals/chi_article.tex`
+### ICML 2026 — Main Track
-**Website**: https://chi.acm.org/
+**Official sources**
----
+- Author Instructions: https://icml.cc/Conferences/2026/AuthorInstructions
+- Call for Papers: https://icml.cc/Conferences/2026/CallForPapers
+- Official style package: https://media.icml.cc/Conferences/ICML2026/Styles/icml2026.zip
-### SIGKDD (Knowledge Discovery and Data Mining)
+**Initial submission**
-**Conference Type**: Top data mining conference
-**Frequency**: Annual (August)
+- Main body: up to **8 pages**.
+- References and appendices may use additional pages and remain in the same PDF.
+- Submissions must use LaTeX, be anonymized, and follow the official style.
+- The camera-ready version permits one extra main-body page.
+- Material essential to evaluation belongs in the main body; reviewers may decline to read appendices or separate supplements.
-**Formatting Requirements**:
-- **Page Limit**:
- - Research Track: 9 pages (excluding references)
- - Applied Data Science: 9 pages
-- **Format**: Two-column
-- **LaTeX Class**: `acmart` (sigconf format)
-- **Font**: ACM template default
-- **Anonymization**: **Required** (double-blind)
-- **Citations**: ACM numbered style
-- **Supplementary**: Code and data encouraged
+### ICLR 2026
-**LaTeX Template**: `assets/journals/kdd_article.tex`
+**Official source**
-**Website**: https://kdd.org/
+- Author Guide: https://iclr.cc/Conferences/2026/AuthorGuide
----
+**Initial submission**
-### EMNLP (Empirical Methods in Natural Language Processing)
+- Main text: up to **9 pages**.
+- References do not count toward the limit.
+- Appendices may use additional pages, but reviewers are not required to read them.
+- Submissions are double blind; identifying information in the paper or supplement can cause desk rejection.
+- Use the `iclr2026` package linked by the Author Guide.
-**Conference Type**: Top NLP conference
-**Frequency**: Annual (November/December)
+**Later stages**
-**Formatting Requirements**:
-- **Page Limit**:
- - Long papers: 8 pages (+ unlimited references and appendix)
- - Short papers: 4 pages (+ unlimited references)
-- **Format**: Two-column
-- **Font**: Times New Roman, 11pt
-- **Anonymization**: **Required** (double-blind)
- - Do not include author names or affiliations
- - Self-citations should be anonymized
-- **Paper size**: US Letter or A4
-- **Citations**: Named style similar to ACL
-- **LaTeX Template**: ACL/EMNLP official style
-- **Supplementary**: Appendix unlimited, code encouraged
+- The discussion/rebuttal and camera-ready limit increases to **10 main-text pages**.
+- Do not apply that later-stage allowance to the initial submission.
-**LaTeX Template**: `assets/journals/emnlp_article.tex`
+### CVPR 2026
-**Website**: https://www.emnlp.org/
+**Official source**
----
+- Author Guidelines: https://cvpr.thecvf.com/Conferences/2026/AuthorGuidelines
-### ACL (Association for Computational Linguistics)
+**Initial submission**
-**Conference Type**: Premier NLP conference
-**Frequency**: Annual (July)
+- Main paper: up to **8 pages**, including figures and tables.
+- Additional pages may contain cited references only.
+- Use the official CVPR 2026 author kit linked by the Author Guidelines.
+- Papers must be anonymized. Identifying acknowledgments, grant IDs, videos, attached papers, or external links can violate anonymity.
+- External links that expand submitted content or bypass length restrictions are prohibited.
-**Formatting Requirements**:
-- **Page Limit**: 8 pages (long), 4 pages (short), excluding references
-- **Format**: Two-column
-- **Font**: Times, 11pt
-- **Anonymization**: **Required**
-- **LaTeX Template**: ACL official style (acl.sty)
+**Rebuttal**
-**LaTeX Template**: `assets/journals/acl_article.tex`
+- The rebuttal is a one-page PDF using the rebuttal template from the author kit.
+- It must remain anonymous and may not add external material.
----
+## Other Conference Families
-### USENIX Security Symposium
+The following links are discovery starting points, not cached requirements.
-**Conference Type**: Top security conference
-**Frequency**: Annual (August)
+| Venue/family | Official starting point | Template rule |
+|---|---|---|
+| AAAI | https://aaai.org/conference/aaai/ | Use the target year's author kit |
+| IJCAI | https://www.ijcai.org/ | Use the target year's call and style |
+| ACL / ARR | https://aclrollingreview.org/ | Check ARR submission requirements and the committing venue |
+| EMNLP | https://www.emnlp.org/ | Check the current call and ACL style package |
+| ACM CHI | https://chi.acm.org/ | Check the current papers track and ACM workflow |
+| ACM SIGKDD | https://kdd.org/ | Check the exact track; limits differ |
+| ACM SIGIR | https://sigir.org/ | Check the target year's call |
+| USENIX Security | https://www.usenix.org/conference/usenixsecurity | Check the current submission cycle and artifact rules |
+| ISMB | https://www.iscb.org/ismb | Check the proceedings track and journal instructions |
+| RECOMB | https://www.recomb.org/ | Check the target year's Springer/author kit |
+| PSB | https://psb.stanford.edu/ | Check the current author instructions |
+| IEEE conferences | https://conferences.ieeeauthorcenter.ieee.org/ | Use the conference-selected IEEE template |
+| ICRA | https://www.ieee-ras.org/conferences-workshops/fully-sponsored/icra | Check the current author kit and page charges |
-**Formatting Requirements**:
-- **Page Limit**:
- - Papers: No strict limit (typically 15-20 pages including everything)
- - Well-written, concise papers preferred
-- **Format**: Two-column
-- **Font**: Times, 10pt
-- **Anonymization**: **Required** (double-blind)
-- **LaTeX Template**: USENIX official template
-- **Citations**: Numbered
-- **Paper size**: US Letter
+Do not assume that last year's page limit, review model, supplement policy, or class options survived unchanged.
-**LaTeX Template**: `assets/journals/usenix_article.tex`
+## Official Template Workflow
-**Website**: https://www.usenix.org/conference/usenixsecurity
+1. Download the package from the conference's official author page.
+2. Keep all `.sty`, `.cls`, bibliography, and checklist files together.
+3. Compile the sample before editing.
+4. Copy the sample and replace content without changing layout commands.
+5. Preserve submission mode for review; enable camera-ready options only after acceptance.
+6. Re-download the package if the organizers announce a revision.
----
+Avoid unofficial mirrors when an official package exists. Do not rename an old style file to a new year.
-### SIGIR (Information Retrieval)
+## Blind-Review Checklist
-**Conference Type**: Top information retrieval conference
-**Frequency**: Annual (July)
+Check the manuscript, supplement, source archive, PDF metadata, figures, and linked resources.
-**Formatting Requirements**:
-- **Page Limit**:
- - Full papers: 10 pages (excluding references)
- - Short papers: 4 pages (excluding references)
-- **Format**: Single-column ACM format
-- **LaTeX Class**: `acmart` (sigconf)
-- **Anonymization**: **Required**
-- **Citations**: ACM style
+- Remove names, affiliations, emails, acknowledgments, grant numbers, and institution-identifying text when required.
+- Follow the venue's self-citation policy; do not automatically replace every self-citation with “Anonymous.”
+- Remove identifying paths, usernames, comments, Git metadata, document properties, and image metadata.
+- Use only external links permitted by the current policy.
+- Ensure code and data packages are anonymized if submitted for review.
+- Do not disclose the submission's venue status where the conference prohibits it.
-**LaTeX Template**: `assets/journals/sigir_article.tex`
+## Page-Limit Interpretation
----
+“Eight pages” is incomplete without scope. Record whether the limit applies to:
-## Biology & Bioinformatics
+- main text only;
+- figures and tables;
+- acknowledgments;
+- references;
+- appendices;
+- checklists or impact statements; and
+- the combined PDF or a separate supplement.
-### ISMB (Intelligent Systems for Molecular Biology)
+When using `scripts/validate_format.py`, supply `--content-pages` after manually counting according to this scope. Total PDF pages alone cannot establish compliance.
-**Conference Type**: Premier computational biology conference
-**Frequency**: Annual (July)
+## Supplementary Material
-**Formatting Requirements**:
-- **Publication**: Proceedings published in *Bioinformatics* journal
-- **Page Limit**:
- - Typically 7-8 pages including figures and references
-- **Format**: Two-column
-- **Font**: Times, 10pt
-- **Citations**: Numbered (Oxford style similar to Bioinformatics journal)
-- **LaTeX Template**: Oxford Bioinformatics template
-- **Anonymization**: **Not required** (single-blind)
-- **Figures**: High resolution, color acceptable
-- **Supplementary**: Encouraged for additional data/methods
+- Put claims essential to acceptance in the main paper.
+- Treat appendices as optional reading unless the current instructions say otherwise.
+- Apply the same anonymity rules to supplements.
+- Check file count, type, and size limits.
+- Do not use links or supplements to evade the main-paper limit.
+- Confirm whether code/data uploads share the paper deadline.
-**LaTeX Template**: `assets/journals/ismb_article.tex`
-
-**Website**: https://www.iscb.org/ismb
-
----
-
-### RECOMB (Research in Computational Molecular Biology)
-
-**Conference Type**: Top computational biology conference
-**Frequency**: Annual (April/May)
-
-**Formatting Requirements**:
-- **Publication**: Proceedings published as Springer LNCS (Lecture Notes in Computer Science)
-- **Page Limit**:
- - Extended abstracts: 12-15 pages (including references)
-- **Format**: Single-column
-- **Font**: Based on Springer LNCS template
-- **LaTeX Class**: `llncs` (Springer)
-- **Citations**: Numbered or author-year
-- **Anonymization**: **Required** (double-blind)
-- **Supplementary**: Appendix can be submitted
-
-**LaTeX Template**: `assets/journals/recomb_article.tex`
-
-**Website**: https://www.recomb.org/
-
----
-
-### PSB (Pacific Symposium on Biocomputing)
-
-**Conference Type**: Biomedical informatics conference
-**Frequency**: Annual (January)
-
-**Formatting Requirements**:
-- **Page Limit**: 12 pages including figures and references
-- **Format**: Single-column
-- **Font**: Times, 11pt
-- **Margins**: 1 inch all sides
-- **Citations**: Numbered
-- **Anonymization**: **Not required**
-- **Figures**: Embedded in text
-- **LaTeX Template**: PSB official template
-
-**LaTeX Template**: `assets/journals/psb_article.tex`
-
-**Website**: https://psb.stanford.edu/
-
----
-
-## Engineering
-
-### IEEE International Conference on Robotics and Automation (ICRA)
-
-**Formatting Requirements**:
-- **Page Limit**: 8 pages (including figures and references)
-- **Format**: Two-column
-- **Font**: Times, 10pt
-- **LaTeX Class**: IEEEtran
-- **Citations**: IEEE style [1]
-- **Anonymization**: **Required** for initial submission
-- **Video**: Optional video submissions encouraged
-
-**LaTeX Template**: `assets/journals/icra_article.tex`
-
----
-
-### IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS)
-
-**Formatting**: Same as ICRA (IEEE robotics template)
-
----
-
-### International Conference on Computer-Aided Design (ICCAD)
-
-**Formatting Requirements**:
-- **Page Limit**: 8 pages
-- **Format**: Two-column
-- **LaTeX Class**: IEEE template
-- **Citations**: IEEE style
-
----
-
-### Design Automation Conference (DAC)
-
-**Formatting Requirements**:
-- **Page Limit**: 6 pages
-- **Format**: Two-column
-- **Font**: Times, 10pt
-- **LaTeX Class**: ACM or IEEE template (check yearly guidelines)
-
----
-
-## Multidisciplinary
-
-### AAAS Annual Meeting
-
-**Conference Type**: Broad scientific conference
-**Formatting**: Varies by symposium (typically extended abstracts)
-
----
-
-## Quick Reference Table
-
-| Conference | Pages | Format | Blind | Citations | Template |
-|------------|-------|--------|-------|-----------|----------|
-| **NeurIPS** | 8 + refs | Two-col | Double | [1] | `neurips_article.tex` |
-| **ICML** | 8 + refs | Two-col | Double | [1] | `icml_article.tex` |
-| **ICLR** | 8 + refs | Two-col | Double | [1] | `iclr_article.tex` |
-| **CVPR** | 8 + refs | Two-col | Double | [1] | `cvpr_article.tex` |
-| **AAAI** | 7 + refs | Two-col | Double | Various | `aaai_article.tex` |
-| **CHI** | 10 + refs | Single-col | Double | ACM | `chi_article.tex` |
-| **SIGKDD** | 9 + refs | Two-col | Double | ACM [1] | `kdd_article.tex` |
-| **EMNLP** | 8 + refs | Two-col | Double | Named | `emnlp_article.tex` |
-| **ISMB** | 7-8 pages | Two-col | Single | [1] | `ismb_article.tex` |
-| **RECOMB** | 12-15 pages | Single-col | Double | Springer | `recomb_article.tex` |
-
----
-
-## General Conference Submission Guidelines
-
-### Anonymization Best Practices (Double-Blind Review)
-
-**Remove**:
-- Author names, affiliations, emails from title page
-- Acknowledgments section
-- Funding information that reveals identity
-- Any "our previous work" citations that make identity obvious
-
-**Anonymize**:
-- Self-citations: "Smith et al. [5]" → "Anonymous et al. [5]" or "Prior work [5]"
-- Institution-specific details: "our university" → "a large research university"
-- Dataset names if they reveal identity
-
-**Keep Anonymous**:
-- Code repositories (use anonymous GitHub for review)
-- Supplementary materials
-- Any URLs or links
-
-### Supplementary Materials
-
-**Common Inclusions**:
-- Source code (GitHub repository, zip file)
-- Additional experimental results
-- Proofs and derivations
-- Extended related work
-- Dataset descriptions
-- Video demonstrations
-- Interactive demos
-
-**Best Practices**:
-- Keep supplementary well-organized
-- Reference supplementary clearly from main paper
-- Ensure supplementary is anonymized for blind review
-- Check file size limits (typically 50-100 MB)
-
-### Camera-Ready Preparation
+## Camera-Ready Preparation
After acceptance:
-1. **De-anonymize**: Add author names, affiliations
-2. **Add acknowledgments**: Funding, contributions
-3. **Copyright**: Add conference copyright notice
-4. **Formatting**: Follow camera-ready specific guidelines
-5. **Page limit**: May allow 1-2 extra pages (check guidelines)
-6. **PDF/A compliance**: Some conferences require PDF/A format
-
-### Accessibility Considerations
-
-**For All Conferences**:
-- Use colorblind-safe color palettes
-- Ensure sufficient contrast
-- Provide alt text for figures (where supported)
-- Use clear, readable fonts
-- Avoid solely color-based distinctions
-
----
-
-## Common Mistakes to Avoid
-
-1. **Wrong style file**: Using outdated conference style file
-2. **Page limit violation**: Figures/tables pushing over limit
-3. **Font size manipulation**: Changing fonts to fit more content
-4. **Margin adjustments**: Modifying margins to gain space
-5. **De-anonymization**: Accidentally revealing identity in blind review
-6. **Missing references**: Not citing relevant prior work
-7. **Low-quality figures**: Pixelated or illegible figures
-8. **Inconsistent formatting**: Different sections using different styles
-
----
-
-## Getting Official Templates
-
-**Where to Find Official Templates**:
-1. **Conference website**: "Call for Papers" or "Author Instructions"
-2. **GitHub**: Many conferences host templates on GitHub
-3. **Overleaf**: Many official templates available on Overleaf
-4. **CTAN**: LaTeX class files often on CTAN repository
-
-**Template Naming**:
-- Conferences often update templates yearly
-- Use the correct year's template (e.g., `neurips_2024.sty`)
-- Check for "camera-ready" vs. "submission" versions
-
----
-
-## Notes
-
-1. **Annual updates**: Conference requirements change; always check current year's CFP
-2. **Deadline types**:
- - Abstract deadline (often 1 week before paper deadline)
- - Paper deadline (firm, no extensions typically)
- - Supplementary deadline (may be a few days after paper)
-3. **Timezone**: Pay attention to deadline timezone (often AOE - Anywhere on Earth)
-4. **Rebuttal**: Many conferences have author response/rebuttal periods
-5. **Dual submission**: Check conference policy on concurrent submissions
-6. **Poster/Oral**: Acceptance often comes with presentation format
-
-## Conference Tiers (Informal)
-
-**Machine Learning**:
-- **Tier 1**: NeurIPS, ICML, ICLR
-- **Tier 2**: AAAI, IJCAI, UAI
-
-**Computer Vision**:
-- **Tier 1**: CVPR, ICCV, ECCV
-
-**Natural Language Processing**:
-- **Tier 1**: ACL, EMNLP, NAACL
-
-**Bioinformatics**:
-- **Tier 1**: RECOMB, ISMB
-- **Tier 2**: PSB, WABI
-(Tiers are informal and field-dependent; not official rankings)
+1. switch to the official final/camera-ready mode;
+2. add authors and permitted acknowledgments;
+3. apply the camera-ready page allowance, if any;
+4. complete rights, licensing, accessibility, and metadata forms;
+5. include only accepted and permitted supplementary material; and
+6. inspect the publisher or proceedings proof.
+Submission and camera-ready rules are different contracts. Re-verify both.
diff --git a/skills/venue-templates/references/cs_conference_style.md b/skills/venue-templates/references/cs_conference_style.md
index dcafd5cd..621041a4 100644
--- a/skills/venue-templates/references/cs_conference_style.md
+++ b/skills/venue-templates/references/cs_conference_style.md
@@ -2,7 +2,9 @@
Comprehensive writing guide for ACL, EMNLP, NAACL (NLP), CHI, CSCW (HCI), SIGKDD, WWW, SIGIR (data mining/IR), and other major CS conferences.
-**Last Updated**: 2024
+**Reviewed**: 2026-07-20
+
+Page limits and required sections vary by year, track, ARR cycle, and committing venue. Treat numeric limits as writing context until checked against the current instructions.
---
@@ -89,7 +91,7 @@ prior approaches.
## NLP-Specific Requirements
### Datasets
-- Use **standard benchmarks**: GLUE, SQuAD, CoNLL, OntoNotes
+- Use **task-appropriate current evaluations**: established datasets such as SQuAD, CoNLL, or OntoNotes where they fit, plus current strong-model, human, robustness, safety, or multilingual evaluations as appropriate
- Report **dataset statistics**: train/dev/test sizes
- **Data preprocessing**: Document all steps
@@ -112,7 +114,7 @@ Table 3: Human Evaluation Results (100 samples, 3 annotators)
Method | Fluency | Coherence | Factuality | Overall
─────────────────────────────────────────────────────────────
Baseline | 3.8 | 3.2 | 3.5 | 3.5
-GPT-3.5 | 4.2 | 4.0 | 3.7 | 4.0
+Strong Baseline| 4.2 | 4.0 | 3.7 | 4.0
Our Method | 4.4 | 4.3 | 4.1 | 4.3
─────────────────────────────────────────────────────────────
Inter-annotator κ = 0.72. Scale: 1-5 (higher is better).
@@ -122,8 +124,8 @@ Inter-annotator κ = 0.72. Scale: 1-5 (higher is better).
- **ARR (ACL Rolling Review)**: Shared review system across ACL venues
- **Responsible NLP checklist**: Ethics, limitations, risks
-- **Long (8 pages) vs. Short (4 pages)**: Different expectations
-- **Findings papers**: Lower-tier acceptance track
+- **Long vs. short papers**: Different expectations; verify current page-count exclusions for Limitations, ethics material, references, and appendices
+- **Findings papers**: Distinct publication track with its own selection and commitment process
---
@@ -420,7 +422,7 @@ All CS venues increasingly expect:
| **Evaluation** | Benchmarks + human | User studies | Large-scale exp | Datasets |
| **Theory weight** | Moderate | Low | Moderate | Moderate |
| **Industry value** | High | Medium | Very high | High |
-| **Page limit** | 8 long / 4 short | 10 + refs | 9 + refs | 10 + refs |
+| **Typical paper length** | Long/short categories | Venue-defined | Track-defined | Track-defined |
| **Review style** | ARR | Direct | Direct | Direct |
---
diff --git a/skills/venue-templates/references/grants_requirements.md b/skills/venue-templates/references/grants_requirements.md
index f1c7c3af..6e8a0ac0 100644
--- a/skills/venue-templates/references/grants_requirements.md
+++ b/skills/venue-templates/references/grants_requirements.md
@@ -1,787 +1,267 @@
# Grant Proposal Requirements
-Comprehensive requirements and formatting guidelines for major federal and private foundation grant programs.
+Funding requirements are controlled by the current solicitation or notice of funding opportunity (NOFO), the effective agency guide, and the submission portal. A general agency summary never overrides the call.
-**Last Updated**: 2024
+**Reviewed:** 2026-07-20
----
+## Required Order of Authority
-## NSF (National Science Foundation)
+Use sources in this order:
-### Overview
+1. current solicitation, NOFO, or Broad Agency Announcement (BAA);
+2. amendments and agency notices;
+3. effective agency application guide and form set;
+4. submission-portal validation; and
+5. institutional sponsored-research guidance.
-**Agency**: National Science Foundation
-**Typical Award**: $100K-$500K per year, 3-5 years
-**Success Rate**: 20-25% (varies by program)
-**Review Criteria**: Intellectual Merit + Broader Impacts (equally weighted)
+Record the source URLs, versions, and date checked in the proposal workspace.
----
+## NSF
-### NSF Standard Grant Proposal
+### Current policy basis
-**Page Limits (NSF PAPPG - Proposal & Award Policies & Procedures Guide)**:
+- PAPPG landing page: https://www.nsf.gov/policies/pappg
+- Proposal preparation overview: https://www.nsf.gov/funding/preparing-proposal
+- Current PAPPG Chapter II: follow the version marked current on the landing page
+- SciENcv: https://www.ncbi.nlm.nih.gov/sciencv/
-| Component | Page Limit | Font | Spacing |
-|-----------|-----------|------|---------|
-| **Project Summary** | 1 page | Any readable, 10pt+ | Any |
-| **Project Description** | 15 pages | Times Roman 11pt or similar | Single |
-| **References Cited** | No limit | Times Roman 11pt | Single |
-| **Biographical Sketch** | 3 pages per person | Times Roman 11pt | Single |
-| **Budget Justification** | 3-5 pages | Any readable | Any |
-| **Current & Pending Support** | No limit | Times Roman 11pt | Single |
-| **Facilities, Equipment** | 2 pages | Any readable | Any |
-| **Data Management Plan** | 2 pages | Any readable | Any |
+As reviewed on 2026-07-20, **NSF 24-1** remains the current PAPPG for proposals submitted or due on or after 2024-05-20, with later supplemental policy notices listed on the PAPPG landing page. Recheck this status for every deadline.
-**Margins**: 1 inch (2.54 cm) on all sides (strictly enforced)
+### Verified common research-proposal rules
----
+Unless the solicitation modifies them:
-### NSF Project Summary (1 page)
+| Component | Current general rule |
+|---|---|
+| Project Summary | No more than 1 page; include Overview, Intellectual Merit, and Broader Impacts |
+| Project Description | Up to 15 pages for a standard research proposal |
+| References Cited | Separate section; follow PAPPG content rules |
+| Data Management and Sharing Plan | No more than 2 pages |
+| Biographical Sketch | Generated in SciENcv for each senior/key person; no old three-page cap |
+| Current and Pending (Other) Support | Generated and certified in SciENcv |
+| Synergistic Activities | Separate document, up to 1 page and up to 5 examples per senior/key person |
-**Required Sections** (clearly labeled):
+**General formatting**
-1. **Overview** (1-2 paragraphs)
- - Concise description of research activity
- - Objectives and methods
+- Times New Roman or Computer Modern at 11 points or larger under the current general rule.
+- No more than six lines of text in one vertical inch.
+- Margins of at least one inch in every direction.
+- Portal-generated forms and solicitation-specific instructions may control individual sections.
-2. **Intellectual Merit** (1 paragraph)
- - How project advances knowledge
- - Innovation and transformative potential
- - Qualifications of research team
+### Important change from older guidance
-3. **Broader Impacts** (1 paragraph)
- - Benefits to society
- - Broadening participation
- - Dissemination and outreach
+Do not use the obsolete “three-page NSF biosketch with Synergistic Activities inside it” pattern.
-**Format**: Can be full-page text or sectioned
-**Audience**: Non-specialists (broad scientific community)
+Current workflow:
-**Template**: `assets/grants/nsf_project_summary.tex`
+1. prepare and certify the Biographical Sketch in SciENcv;
+2. prepare and certify Current and Pending (Other) Support in SciENcv; and
+3. upload Synergistic Activities as its own one-page document.
----
+### Project Summary
-### NSF Project Description (15 pages)
+Clearly label:
-**Typical Structure**:
+- **Overview** — proposed activity, objectives, and methods;
+- **Intellectual Merit** — potential to advance knowledge; and
+- **Broader Impacts** — potential to benefit society and produce desired societal outcomes.
-1. **Introduction/Background** (2-3 pages)
- - Current state of knowledge
- - Research gap
- - Preliminary work/feasibility
- - Team qualifications
+The summary should be understandable to a broad scientific audience and is not merely the proposal abstract.
-2. **Research Plan** (8-10 pages)
- - Objectives and hypotheses
- - Methods and approach
- - Timeline and milestones
- - Expected outcomes
+### Project Description
-3. **Broader Impacts** (1-2 pages)
- - Educational activities
- - Broadening participation (underrepresented groups)
- - Dissemination (publications, conferences, public outreach)
- - Societal benefits
+A practical drafting structure is:
-4. **Results from Prior NSF Support** (1 page, if applicable)
- - Required if PI has had NSF support in past 5 years
- - Intellectual merit and broader impacts of prior work
- - Publications from prior NSF grants
+1. problem, prior work, and gap;
+2. objectives or hypotheses;
+3. research plan and methods;
+4. expected outcomes, risks, and alternatives;
+5. timeline and team roles;
+6. Intellectual Merit and Broader Impacts; and
+7. Results from Prior NSF Support when required.
-**Key Requirements**:
-- Intellectual Merit and Broader Impacts integrated throughout
-- Figures and tables allowed (count toward page limit)
-- Citations to references (use References Cited section)
+This is writing guidance, not a required section order. Follow the solicitation.
-**Template**: `assets/grants/nsf_proposal_template.tex`
+### Data Management and Sharing Plan
----
+Address applicable plans for:
-### NSF Biographical Sketch (3 pages)
+- data and other research products;
+- standards and metadata;
+- access, sharing, and any justified restrictions;
+- reuse and redistribution;
+- preservation and archiving; and
+- roles and responsibilities.
-**Required Sections**:
-1. **Professional Preparation**: Institutions, degrees, fields
-2. **Appointments**: Current and previous positions
-3. **Products**: Up to 5 most relevant, up to 5 other significant products
- - Can include publications, datasets, software, patents
-4. **Synergistic Activities**: Up to 5 examples of impact beyond research
+Directorate, office, division, or program guidance may add requirements.
-**Format**:
-- NSF template must be used (SciENcv or NSF-approved format)
-- No longer uses "Publications" but "Products"
+### Bundled NSF scaffold
----
+`assets/grants/nsf_proposal_template.tex` is a planning scaffold for common narrative components. It is not an NSF-issued upload package. Split content into the appropriate Research.gov or Grants.gov fields and use SciENcv/common forms where required.
-### NSF Broader Impacts
+## NIH
-**NSF-Recognized Categories** (demonstrate ≥1):
-1. **Advance discovery while promoting teaching/learning**
-2. **Broaden participation** of underrepresented groups
-3. **Disseminate broadly** to enhance scientific/technological understanding
-4. **Benefits to society** (economic, health, environment, national security)
-5. **Develop scientific workforce** and infrastructure
+### Current policy basis
-**Best Practices**:
-- Be specific with measurable outcomes
-- Explain how activities will be assessed
-- Integrate with research (don't treat as "add-on")
-- Budget for broader impacts activities
+- Application Guide: https://grants.nih.gov/grants-process/write-application/how-to-apply-application-guide
+- Attachment formatting: https://grants.nih.gov/grants-process/write-application/how-to-apply-application-guide/format-attachments
+- Page limits: https://grants.nih.gov/grants-process/write-application/how-to-apply-application-guide/page-limits
-**Examples**:
-- K-12 outreach programs
-- Curriculum development
-- Training underrepresented students
-- Public science communication
-- Open-source software development
+Use the form set and instructions applicable to the due date. The NOFO always takes precedence over general page-limit tables.
----
+### Verified common page limits
-### NSF Budget
+As reviewed on 2026-07-20:
-**Typical Categories**:
-- **Senior Personnel**: PI, co-PIs (% effort, salary)
-- **Other Personnel**: Postdocs, graduate students, undergrads
-- **Fringe Benefits**: Institutional rates
-- **Equipment**: Items >$5,000
-- **Travel**: Domestic and foreign
-- **Participant Support**: Workshops, conferences (separate category)
-- **Other Direct Costs**: Materials, publication, subawards
-- **Indirect Costs**: Institutional F&A rate
+| Attachment | General limit unless the NOFO says otherwise |
+|---|---|
+| Specific Aims | 1 page |
+| R01 Research Strategy | 12 pages |
+| R21 Research Strategy | 6 pages; combined mechanisms can differ |
+| Introduction to resubmission/revision | 1 page |
+| Project Summary/Abstract | 30 lines |
+| Project Narrative | 3 sentences for most activity codes |
+| Legacy Biographical Sketch | 5 pages |
+| Biographical Sketch Common Form and Supplement | No hard page limit; length is controlled through SciENcv data entry |
-**Budget Justification**: Explain need for each item
+Not every activity code uses every attachment. Check the NOFO and activity-code instructions.
----
+### Attachment formatting
-### NSF Data Management Plan (2 pages)
+Verify the current guide for:
-**Required Content**:
-- Types of data produced
-- Standards for data format and metadata
-- Policies for access and sharing
-- Policies for re-use and redistribution
-- Plans for archiving and preservation
+- accepted PDF format;
+- paper size and margins;
+- approved fonts and minimum size;
+- file naming;
+- hyperlinks;
+- headers, footers, and page numbers; and
+- whether a format page or common form is mandatory.
-**Acceptable Approaches**:
-- Deposit in domain-specific repository
-- Institutional repository
-- Data available upon request (with restrictions justification)
+Do not compress text or figures to evade a page limit.
----
+### Specific Aims
-### NSF Review Process
+A useful writing pattern is:
-**Review Criteria** (equally weighted):
+1. significance and unresolved gap;
+2. long-term goal and proposal objective;
+3. central hypothesis or guiding premise;
+4. concise aims with approach and expected outcome; and
+5. impact and next-step payoff.
-1. **Intellectual Merit**:
- - What is the potential to advance knowledge?
- - How well-conceived and organized?
- - Qualifications of PI and team?
- - Availability of resources?
+The pattern is not an NIH-mandated outline. Adapt it to the mechanism and science.
-2. **Broader Impacts**:
- - What are the potential benefits to society?
- - How well-suited to achieve broader impacts?
+`assets/grants/nih_specific_aims.tex` is a writing scaffold for the one-page attachment. Confirm the current font, margin, and PDF rules before use.
-**Panel Review**: Proposals reviewed by panel of experts
-**Timeline**: Typically 6 months from deadline to award decision
+### Research Strategy
----
+For R01-style research applications, organize around:
-### NSF LaTeX Templates
+- Significance;
+- Innovation; and
+- Approach.
-- **Full Proposal**: `assets/grants/nsf_proposal_template.tex`
-- **Project Summary**: `assets/grants/nsf_project_summary.tex`
-- **Biographical Sketch**: Use NSF SciENcv or template
+Address rigor, feasibility, analysis, expected outcomes, potential problems, alternatives, milestones, and relevant biological variables where applicable. Mechanism- and NOFO-specific instructions can add or replace requirements.
-**Resources**:
-- NSF PAPPG: https://www.nsf.gov/publications/pub_summ.jsp?ods_key=pappg
-- NSF Fastlane: https://www.fastlane.nsf.gov/
+### Biosketch and common forms
----
+Do not rely on the old assumption that every NIH biosketch is a manually edited five-page PDF. Determine whether the application uses:
-## NIH (National Institutes of Health)
+- a legacy biosketch format page; or
+- the Biographical Sketch Common Form and NIH supplement through SciENcv.
-### Overview
+Use the current forms directory and due-date-specific instructions.
-**Agency**: National Institutes of Health
-**Funding Mechanisms**:
-- **R01**: Research Project Grant (most common)
-- **R21**: Exploratory/Developmental Research Grant
-- **K Awards**: Career Development Awards
-**Success Rate**: 10-20% (varies by institute and mechanism)
+## DOE
----
+### Official starting points
-### NIH R01 Research Grant
+- Office of Science funding opportunities: https://science.osti.gov/grants
+- DOE funding opportunities: https://www.energy.gov/funding-financing
+- SAM.gov: https://sam.gov/content/opportunities
-**Page Limits** (Research Strategy):
+DOE requirements vary substantially by Funding Opportunity Announcement. Extract exact rules for:
-| Component | Page Limit | Font | Spacing |
-|-----------|-----------|------|---------|
-| **Specific Aims** | 1 page | Arial 11pt minimum | Any |
-| **Research Strategy** | 12 pages | Arial 11pt minimum | 0.5 inch margins minimum |
-| - Significance | Part of 12 | | |
-| - Innovation | Part of 12 | | |
-| - Approach | Part of 12 | | |
-| **Bibliography** | No limit | Arial 11pt | |
-| **Biographical Sketch** | 5 pages per person | Arial 11pt | |
+- pre-application or concept paper;
+- project narrative;
+- resumes/biosketches and support disclosures;
+- data management or data-sharing plan;
+- budget files and cost sharing;
+- current/pending support;
+- milestones, deliverables, and technology readiness; and
+- submission system.
-**Margins**: 0.5 inch minimum (all sides)
-**Paper Size**: Letter (8.5 × 11 inches)
+No DOE template is bundled in this skill.
----
+## DARPA
-### NIH Specific Aims Page (1 page)
+### Official starting points
-**THE MOST CRITICAL COMPONENT**
+- Opportunities: https://www.darpa.mil/work-with-us/opportunities
+- SAM.gov: https://sam.gov/content/opportunities
-**Structure** (recommended):
+Every BAA defines its own volumes, page limits, abstract/full-proposal stages, security markings, cost package, and submission channel. Do not apply a generic “20–25 page DARPA proposal” limit.
-1. **Opening paragraph** (2-3 sentences)
- - Hook: Significance of problem
- - Gap: What's not known
+Use the Heilmeier questions as a thinking aid when relevant:
-2. **Long-term goal** (1 sentence)
- - Overarching research vision
+- What are you trying to do?
+- How is it done today, and what are the limits?
+- What is new, and why might it succeed?
+- Who cares, and what difference will success make?
+- What are the risks, cost, schedule, and measurable tests?
-3. **Objective** (1-2 sentences)
- - What this proposal will accomplish
- - Central hypothesis
-
-4. **Rationale** (2-3 sentences)
- - Why you expect success
- - Preliminary data supporting hypothesis
-
-5. **Specific Aims** (3 aims typical)
- - **Aim 1**: [Title]. [1-2 sentence description. Working hypothesis. Expected outcome.]
- - **Aim 2**: [Title]. [1-2 sentence description. Working hypothesis. Expected outcome.]
- - **Aim 3**: [Title]. [1-2 sentence description. Working hypothesis. Expected outcome.]
-
-6. **Payoff paragraph** (2-3 sentences)
- - Impact and significance
- - Innovation
- - Future directions
-
-**Best Practices**:
-- Crystal clear, compelling narrative
-- State hypothesis explicitly
-- Explain expected outcomes
-- Show innovation and impact
-
-**Template**: `assets/grants/nih_specific_aims.tex`
-
----
-
-### NIH Research Strategy (12 pages)
-
-**Required Sections**:
-
-#### 1. Significance (typically 2-3 pages)
-- **Importance**: Critical barrier to progress
-- **Knowledge gap**: What's not known
-- **Impact**: How project advances field
-- **Rigor**: Scientific premise/prior work
-- **References**: Cite key literature
-
-#### 2. Innovation (typically 1-2 pages)
-- **Novelty**: New concepts, approaches, methods
-- **Challenge paradigms**: Shift thinking
-- **Refined/new methodologies**: Technical innovation
-- **Novel applications**: Existing tools in new ways
-
-#### 3. Approach (typically 7-9 pages)
-**For Each Aim**:
-- **Rationale**: Why this aim
-- **Experimental design**: Detailed methods
-- **Expected outcomes**: What results mean
-- **Potential problems & alternatives**: Mitigation strategies
-- **Rigor and reproducibility**: Controls, replication, statistics
-- **Timeline**: When each aim completed
-
-**Additional Approach Content**:
-- Preliminary data (critical for R01)
-- Power analyses for sample sizes
-- Statistical analysis plans
-- Rigor of prior research cited
-
----
-
-### NIH Biographical Sketch (5 pages)
-
-**Sections** (NIH format):
-1. **Personal Statement** (4 sentences explaining why you're suited)
-2. **Positions, Honors, and Scientific Appointments**
-3. **Contributions to Science** (Up to 5 contributions, up to 4 pubs each)
-4. **Research Support** (current and completed grants, overlap checked)
-
-**Format**: Must use NIH template (fillable PDF or format page)
-
----
-
-### NIH Review Criteria
-
-**Scored Criteria** (1-9 scale, 1=best):
-1. **Significance**: Importance, impact
-2. **Investigator(s)**: Qualifications, track record
-3. **Innovation**: Novel concepts, methods
-4. **Approach**: Feasibility, rigor, design
-5. **Environment**: Institutional support, resources
-
-**Additional Considerations** (not scored but noted):
-- Vertebrate animals
-- Biohazards
-- Human subjects protections
-- Inclusion of women, minorities, children
-- Budget appropriateness
-
-**Overall Impact Score**: 1-9 (synthesizes all criteria)
-
----
-
-### NIH R21 (Exploratory Grant)
-
-**Key Differences from R01**:
-- **Research Strategy**: 6 pages (vs. 12 for R01)
-- **Duration**: 2 years maximum
-- **Budget**: $275K total costs over 2 years
-- **Preliminary data**: Not required (exploratory nature)
-- **Purpose**: High-risk, high-reward projects; new directions
-
-**When to Choose R21 vs. R01**:
-- R21: Early-stage, limited preliminary data, high-risk
-- R01: Established line of research, strong preliminary data
-
----
-
-### NIH K Awards (Career Development)
-
-**Mechanisms**:
-- **K01**: Mentored Research Scientist Development Award
-- **K08**: Mentored Clinical Scientist Research Career Development Award
-- **K23**: Mentored Patient-Oriented Research Career Development Award
-- **K99/R00**: Pathway to Independence Award (postdoc to faculty)
-
-**Key Components**:
-- **Career Development Plan**: Training goals, timeline
-- **Research Plan**: 6-12 pages (mechanism-dependent)
-- **Mentor(s)**: Letters of support, mentoring plan
-- **Institutional Commitment**: Environment, resources
-- **Protected Time**: 75% research effort typical
-
----
-
-### NIH Budget
-
-**Modular vs. Detailed**:
-- **Modular**: ≤$250K direct costs per year (25K increments)
-- **Detailed**: >$250K direct costs per year
-
-**Modular Budget**: Only need budget justification for personnel, consortium, equipment >$25K
-
-**Budget Period**: Year-by-year (usually 5 years for R01)
-
----
-
-### NIH LaTeX Templates
-
-- **R01 Full Proposal**: `assets/grants/nih_r01_template.tex`
-- **Specific Aims**: `assets/grants/nih_specific_aims.tex`
-- **Biographical Sketch**: Use NIH fillable PDF or format page
-
-**Resources**:
-- NIH Application Guide: https://grants.nih.gov/grants/how-to-apply-application-guide.html
-- SF424 Forms: https://grants.nih.gov/grants/how-to-apply-application-guide/forms-e/general-forms-e.pdf
-
----
-
-## DOE (Department of Energy)
-
-### Overview
-
-**Agency**: U.S. Department of Energy
-**Offices**:
-- **Office of Science**: Basic research (BES, BER, ASCR, NP, HEP, FES)
-- **ARPA-E**: High-risk, high-reward energy technologies
-- **EERE**: Energy efficiency and renewable energy
-
-**Typical Award**: $200K-$1M per year, 3 years
-**Success Rate**: 10-30% (varies by program)
-
----
-
-### DOE Office of Science Proposal
-
-**Page Limits** (typical, varies by FOA):
-
-| Component | Page Limit | Format |
-|-----------|-----------|--------|
-| **Project Narrative** | 10-20 pages | Times 11pt, 1" margins |
-| **References** | No limit | |
-| **Budget Justification** | 3-5 pages | |
-| **Biographical Sketches** | 2-3 pages each | |
-| **Current & Pending** | No limit | |
-| **Facilities & Resources** | No limit | |
-| **Data Management Plan** | 2 pages | |
-
----
-
-### DOE Project Narrative Structure
-
-**Typical Sections**:
-
-1. **Background and Significance** (2-3 pages)
- - Energy relevance
- - Current state of knowledge
- - Research need
-
-2. **Preliminary Work** (1-2 pages)
- - Team's qualifications
- - Relevant prior results
-
-3. **Research Plan** (10-15 pages)
- - **Objectives**: Clear goals
- - **Technical approach**: Detailed methods
- - **Milestones and deliverables**: Specific, measurable
- - **Timeline**: Gantt chart common
- - **Team and management**: Roles, collaboration
-
-4. **Broader Impacts** (1-2 pages)
- - Workforce development
- - Technology transfer potential
- - Publications and dissemination
-
----
-
-### DOE-Specific Requirements
-
-**Energy Relevance**: Must clearly tie to DOE mission
-- Basic science: Fundamental understanding for energy applications
-- Applied: Energy efficiency, renewable energy, grid, storage
-
-**Technology Readiness Levels (TRLs)**: Often required to specify
-- **TRL 1-3**: Basic research, proof of concept
-- **TRL 4-6**: Component/subsystem validation
-- **TRL 7-9**: System demonstration, deployment
-
-**National Laboratory Collaboration**: Encouraged
-- Include lab scientists as co-PIs or collaborators
-- Letter of collaboration from lab
-
-**Cost Sharing**: Sometimes required (check FOA)
-- Can be in-kind (equipment, time)
-- Must be documented
-
----
-
-### DOE Budget Considerations
-
-**Allowable Costs**:
-- Personnel (salaries, benefits)
-- Equipment
-- Travel (especially to DOE national labs)
-- Materials and supplies
-- Subcontracts
-- Indirect costs (negotiated F&A rate)
-
-**Unallowable**:
-- Construction
-- Entertainment
-- Some indirect costs (depends on institution type)
-
----
-
-### DOE LaTeX Template
-
-**Template**: `assets/grants/doe_proposal_template.tex`
-
-**Resources**:
-- DOE Office of Science Funding: https://science.osti.gov/grants
-- EERE Funding: https://www.energy.gov/eere/funding/eere-funding-opportunities
-
----
-
-## DARPA (Defense Advanced Research Projects Agency)
-
-### Overview
-
-**Agency**: Defense Advanced Research Projects Agency (DoD)
-**Mission**: High-risk, high-reward research for national security
-**Typical Award**: $500K-$5M per year, 2-4 years
-**Success Rate**: 5-15% (highly competitive)
-
----
-
-### DARPA BAA (Broad Agency Announcement) Response
-
-**Page Limits** (typical, varies by BAA):
-
-| Component | Page Limit | Format |
-|-----------|-----------|--------|
-| **Technical and Management Proposal** | 20-25 pages | Times 12pt, 1" margins |
-| **Cost Proposal** | Separate volume | |
-
----
-
-### DARPA Technical Proposal Structure
-
-**Key Sections**:
-
-1. **Executive Summary** (1 page)
- - Vision and impact
- - Technical approach overview
- - Team qualifications
-
-2. **Heilmeier Catechism** (1-2 pages)
- DARPA requires answering these questions:
- - **What are you trying to do?** Articulate objectives without jargon
- - **How is it done today? Limitations?** Current practice and shortcomings
- - **What is new in your approach?** Innovation
- - **Who cares?** Impact if successful
- - **If successful, what difference will it make?** Transformation
- - **What are the risks?** Technical risks and mitigation
- - **How much will it cost?** Budget overview
- - **How long will it take?** Timeline
- - **What are the mid-term and final exams?** Milestones for success
-
-3. **Technical Approach** (10-15 pages)
- - Detailed technical plan
- - Task breakdown
- - Risk mitigation
- - Innovation justification
-
-4. **Management Plan** (2-3 pages)
- - Team organization
- - Key personnel roles
- - Collaboration approach
- - Milestone schedule (Gantt chart)
-
-5. **Capabilities and Experience** (2-3 pages)
- - Team qualifications
- - Relevant facilities and equipment
- - Similar past programs
-
-6. **Transition Plan** (1-2 pages)
- - Path to DoD transition
- - End users identified
- - Technology transfer approach
-
----
-
-### DARPA-Specific Considerations
-
-**Engagement with Program Manager (PM)**:
-- **Strongly encouraged** to contact PM before submission
-- Discuss idea alignment with program goals
-- PM can provide feedback on approach
-
-**Transformative Impact**:
-- Must demonstrate potential for "game-changing" impact
-- Not incremental improvements
-
-**Technical Risk**:
-- High-risk approaches acceptable (even encouraged)
-- Must show mitigation strategies
-
-**National Security Relevance**:
-- Clear connection to defense applications
-- Dual-use (civilian + military) often valuable
-
-**Metrics for Success**:
-- Quantifiable milestones
-- "Go/no-go" decision points
-
----
-
-### DARPA Budget
-
-**Full Cost Accounting**: Detailed justification required
-- **Labor**: Hourly rates, hours per task
-- **Materials**: Itemized
-- **Equipment**: Justification for purchases
-- **Travel**: Specific trips with purpose
-- **Subcontracts**: Detailed subcontract budgets
-- **Indirect Costs**: Negotiated rates
-
-**Cost Realism**: Budget must be realistic for proposed work
-
----
-
-### DARPA LaTeX Template
-
-**Template**: `assets/grants/darpa_baa_response.tex`
-
-**Resources**:
-- DARPA Opportunities: https://www.darpa.mil/work-with-us/opportunities
-- BAA Listings: SAM.gov (formerly FedBizOpps)
-
----
+The BAA controls the actual proposal structure. No DARPA template is bundled.
## Private Foundations
-### Gates Foundation
-
-**Focus Areas**: Global health, poverty alleviation, education
-**Typical Award**: Varies widely ($100K to $10M+)
-
-**Proposal Requirements**:
-- **Letter of Inquiry** (2-3 pages): Initial screening
-- **Full Proposal** (if invited): 10-15 pages
-- **Theory of Change**: How intervention leads to impact
-- **Monitoring & Evaluation**: Metrics, data collection
-
-**Key Emphases**:
-- Scalability and sustainability
-- Impact in low-resource settings
-- Partnerships with local organizations
-- Data-driven decision making
-
----
-
-### Wellcome Trust
-
-**Focus**: Biomedical research, global health
-**Geographic**: UK and international
-**Typical Award**: £100K to £5M
-
-**Proposal Format** (varies by scheme):
-- **Investigator Awards**: Track record and research vision
-- **Project Grants**: Specific research project
-- **Career Development**: Early/mid-career researchers
-
-**Requirements**:
-- Research plan
-- Track record
-- Value for money justification
-- Patient and public involvement
-
----
-
-### Howard Hughes Medical Institute (HHMI)
-
-**Type**: Investigator appointments (not grants)
-**Award**: ~$9M over 7 years (renewable)
-**Focus**: Biomedical research, early-career scientists
-
-**Selection**:
-- Nomination by institution
-- Track record of innovation
-- Research vision for next 5-7 years
-- Scientific leadership potential
-
----
-
-### Chan Zuckerberg Initiative (CZI)
-
-**Focus**: Science, education, justice & opportunity
-**Award Types**:
-- **Imaging**: Advanced imaging technologies
-- **Neurodegeneration Challenge**: AD, ALS, PD, FTD
-- **Single-Cell Biology**: Tools and resources
-
-**Emphasis**:
-- Open science (data sharing, open-source)
-- Collaboration across institutions
-- Technology development
-- Diversity and inclusion
-
----
-
-## Quick Reference Table
-
-| Agency | Typical Award | Duration | Key Criteria | Template |
-|--------|--------------|----------|--------------|----------|
-| **NSF** | $100K-500K/yr | 3-5 yrs | Intellectual Merit + Broader Impacts | `nsf_proposal_template.tex` |
-| **NIH R01** | $250K-500K/yr | 5 yrs | Significance, Innovation, Approach | `nih_r01_template.tex` |
-| **NIH R21** | $275K total | 2 yrs | Exploratory, high-risk | `nih_r21_template.tex` |
-| **DOE** | $200K-1M/yr | 3 yrs | Energy relevance, TRLs | `doe_proposal_template.tex` |
-| **DARPA** | $500K-5M/yr | 2-4 yrs | Transformative, Heilmeier | `darpa_baa_response.tex` |
-
----
-
-## General Best Practices
-
-### Writing Effective Proposals
-
-1. **Start early**: 2-3 months minimum
-2. **Read the call carefully**: Follow requirements exactly
-3. **Know your reviewers**: Write for expert audience
-4. **Tell a story**: Compelling narrative with clear logic
-5. **Be specific**: Concrete objectives, methods, outcomes
-6. **Show feasibility**: Preliminary data, expertise
-7. **Address weaknesses**: Acknowledge and mitigate risks
-
-### Common Mistakes to Avoid
-
-1. **Vague objectives**: "Understand X" → "Determine whether X causes Y"
-2. **Lack of innovation**: Incremental vs. transformative
-3. **Poor broader impacts** (NSF): Generic, unintegrated
-4. **Weak specific aims** (NIH): Most critical page!
-5. **Missing preliminary data**: Show feasibility
-6. **Unrealistic timeline**: Be honest about what's achievable
-7. **Formatting violations**: Auto-rejection possible
-8. **Typos and errors**: Suggests lack of care
-
-### Timeline for Proposal Development
-
-**3 months before deadline**:
-- Identify opportunity
-- Assemble team
-- Outline aims/objectives
-
-**2 months before**:
-- Draft aims/objectives
-- Preliminary budget
-- Contact program officer (if allowed)
-
-**1 month before**:
-- Full first draft
-- Internal review
-- Revise based on feedback
+Foundation programs change frequently. Start from the exact open call and capture:
-**2 weeks before**:
-- Final revisions
-- Proofread carefully
-- Assemble all documents
+- eligibility and geographic restrictions;
+- concept-note or invitation stage;
+- narrative questions and character limits;
+- indirect-cost policy;
+- budget template and currency;
+- required partners or letters;
+- data, open-science, and intellectual-property terms; and
+- portal deadline and timezone.
-**1 week before**:
-- Institutional review/approval
-- Budget finalization
-- Submission system upload
+Do not use remembered award sizes or historical success rates as current facts.
-**2 days before**:
-- Final check
-- Submit (don't wait until deadline!)
+## Proposal Compliance Matrix
----
+Create a matrix before drafting:
-## Resources
+| Requirement | Source and section | Limit/format | Owner | Status |
+|---|---|---|---|---|
+| Project narrative | NOFO §IV | Example: 12 pages | PI | Drafting |
+| Biosketch | Agency guide | SciENcv common form | Each senior/key person | Pending |
+| Budget justification | NOFO §IV | Portal PDF | Administrator | Pending |
+| Data plan | Policy + NOFO | Example: 2 pages | Data lead | Drafting |
-### Grant Writing Guides
-- NSF PAPPG: https://www.nsf.gov/publications/pub_summ.jsp?ods_key=pappg
-- NIH Application Guide: https://grants.nih.gov/grants/how-to-apply-application-guide.html
-- GrantForward (database): https://www.grantforward.com/
-- Pivot (database): https://pivot.proquest.com/
+Use the exact source language rather than paraphrasing ambiguous limits.
-### Institutional Resources
-- Office of Sponsored Research (OSR)
-- Grant writing workshops
-- Internal mock reviews
-- Budget/compliance offices
+## General Proposal Checklist
----
+- [ ] Solicitation/NOFO number and amendment date recorded
+- [ ] Effective agency guide and form set confirmed
+- [ ] Eligibility and registration complete
+- [ ] Every component mapped to a portal field
+- [ ] Page, character, font, margin, and file rules verified
+- [ ] Biosketch/support forms use the required current system
+- [ ] Budget and cost-sharing rules reviewed institutionally
+- [ ] Human/animal subjects, export control, security, and data rules addressed
+- [ ] Required letters and certifications collected
+- [ ] Portal validation and institutional review completed before the deadline
-## Summary
+## Timing
-**Key Takeaways**:
-
-1. **Know the agency**: Different missions, different emphases
-2. **Follow the rules**: Page limits, fonts, margins strictly enforced
-3. **Tell a compelling story**: Clear problem, innovative solution, feasible plan
-4. **Demonstrate impact**: Intellectual merit (NSF/NIH) or mission relevance (DOE/DARPA)
-5. **Show feasibility**: Preliminary data, team expertise, resources
-6. **Budget realistically**: Justify all costs
-7. **Proofread carefully**: Typos undermine credibility
-8. **Submit early**: Technical glitches happen
+Begin compliance mapping before writing. Build in time for:
-**Remember**: Grant writing is a skill developed over time. Seek feedback, revise, and persist!
+- collaborator and subaward documents;
+- SciENcv/common-form certification;
+- institutional budget and compliance review;
+- PDF conversion and portal validation; and
+- correction of errors before the deadline.
+Never use a generic template as evidence that the final package is compliant.
diff --git a/skills/venue-templates/references/journals_formatting.md b/skills/venue-templates/references/journals_formatting.md
index 2b9576b8..f779a592 100644
--- a/skills/venue-templates/references/journals_formatting.md
+++ b/skills/venue-templates/references/journals_formatting.md
@@ -1,508 +1,200 @@
# Journal Formatting Requirements
-Comprehensive formatting requirements and submission guidelines for major scientific journals across disciplines.
+Journal requirements vary by journal, article type, and submission stage. Publisher-wide conventions are useful for discovery but do not replace the target journal's current Guide for Authors.
-**Last Updated**: 2024
+**Reviewed:** 2026-07-20
----
+## Verification Workflow
-## Nature Portfolio
-
-### Nature
-
-**Journal Type**: Top-tier multidisciplinary science journal
-**Publisher**: Nature Publishing Group
-**Impact Factor**: ~64 (varies by year)
-
-**Formatting Requirements**:
-- **Length**: Articles ~3,000 words (excluding Methods, References, Figure Legends)
-- **Structure**: Title, Authors, Affiliations, Abstract (≤200 words), Main text, Methods, References, Acknowledgements, Author Contributions, Competing Interests, Figure Legends
-- **Format**: Single column for submission (final published version is two-column)
-- **Font**: Any standard font (Times, Arial, Helvetica), 12pt
-- **Line spacing**: Double-spaced
-- **Margins**: 2.5 cm (1 inch) all sides
-- **Page numbers**: Required on all pages
-- **Citations**: Numbered sequentially in superscript¹'²'³
-- **References**: Nature style (abbreviated journal names)
- - Format: Author, A. A., Author, B. B. & Author, C. C. Article title. *Journal Abbrev.* **vol**, pages (year).
- - Example: Watson, J. D. & Crick, F. H. C. Molecular structure of nucleic acids. *Nature* **171**, 737–738 (1953).
-- **Figures**:
- - Format: TIFF, EPS, PDF (vector preferred)
- - Resolution: 300-600 dpi for photos, 1000 dpi for line art
- - Color: RGB or CMYK
- - Size: Fit to single column (89 mm) or double column (183 mm)
- - Legends: Provided separately, not embedded in figure
-- **Tables**: Editable format (Word, Excel), not as images
-- **Supplementary Info**: Unlimited, PDF format preferred
-
-**LaTeX Template**: `assets/journals/nature_article.tex`
-
-**Author Guidelines**: https://www.nature.com/nature/for-authors
-
----
-
-### Nature Communications
-
-**Journal Type**: Open-access multidisciplinary journal
-**Publisher**: Nature Publishing Group
-
-**Formatting Requirements**:
-- **Length**: No strict limit (typically 5,000-8,000 words)
-- **Structure**: Same as Nature (Title, Abstract, Main text, Methods, References, etc.)
-- **Format**: Single column
-- **Font**: Times New Roman, Arial, or similar, 12pt
-- **Line spacing**: Double-spaced
-- **Margins**: 2.5 cm all sides
-- **Citations**: Numbered sequentially in superscript
-- **References**: Nature style (same as Nature)
-- **Figures**: Same requirements as Nature
-- **Tables**: Same requirements as Nature
-- **Open Access**: All articles are open access (APC applies)
-
-**LaTeX Template**: `assets/journals/nature_communications.tex`
-
----
-
-### Nature Methods, Nature Biotechnology, Nature Machine Intelligence
-
-**Formatting**: Same as Nature Communications (Nature family journals share similar formatting)
-
-**Discipline-Specific Notes**:
-- **Nature Methods**: Emphasize methodological innovation and validation
-- **Nature Biotechnology**: Focus on biotechnology applications and translation
-- **Nature Machine Intelligence**: AI/ML applications across disciplines
-
----
-
-## Science Family
-
-### Science
-
-**Journal Type**: Top-tier multidisciplinary science journal
-**Publisher**: American Association for the Advancement of Science (AAAS)
-
-**Formatting Requirements**:
-- **Length**:
- - Research Articles: 2,500 words (text only, excluding refs/figs)
- - Reports: 2,500 words maximum
-- **Structure**: Title, Authors, Affiliations, Abstract (≤125 words), Main text, Materials and Methods, References, Acknowledgments, Supplementary Materials
-- **Format**: Single column for submission
-- **Font**: Times New Roman, 12pt
-- **Line spacing**: Double-spaced
-- **Margins**: 1 inch all sides
-- **Citations**: Numbered sequentially in parentheses (1, 2, 3)
-- **References**: Science style (no article titles in main refs, moved to supplementary)
- - Format: A. Author, B. Author, *Journal Abbrev.* **vol**, pages (year).
- - Example: J. D. Watson, F. H. C. Crick, *Nature* **171**, 737 (1953).
-- **Figures**:
- - Format: PDF, EPS, TIFF
- - Resolution: 300 dpi minimum
- - Color: RGB
- - Size: Maximum width 9 cm (single column) or 18.3 cm (double column)
- - Figures count toward page limit
-- **Tables**: Include in main text or as separate files
-- **Supplementary Materials**: Extensive materials allowed
-
-**LaTeX Template**: `assets/journals/science_article.tex`
-
-**Author Guidelines**: https://www.science.org/content/page/instructions-authors
-
----
-
-### Science Advances
-
-**Journal Type**: Open-access multidisciplinary journal
-**Publisher**: AAAS
-
-**Formatting Requirements**:
-- **Length**: No strict word limit (but concise writing encouraged)
-- **Structure**: Similar to Science (more flexible)
-- **Format**: Single column
-- **Font**: Times New Roman, 12pt
-- **Citations**: Numbered in parentheses
-- **References**: Science style
-- **Figures**: Same as Science
-- **Open Access**: All articles open access
-
-**LaTeX Template**: `assets/journals/science_advances.tex`
-
----
-
-## PLOS (Public Library of Science)
-
-### PLOS ONE
-
-**Journal Type**: Open-access multidisciplinary journal
-**Publisher**: Public Library of Science
-
-**Formatting Requirements**:
-- **Length**: No maximum length
-- **Structure**: Title, Authors, Affiliations, Abstract, Introduction, Materials and Methods, Results, Discussion, Conclusions (optional), References, Supporting Information
-- **Format**: Editable file (LaTeX, Word, RTF)
-- **Font**: Times, Arial, or Helvetica, 10-12pt
-- **Line spacing**: Double-spaced
-- **Margins**: 1 inch (2.54 cm) all sides
-- **Page numbers**: Required
-- **Citations**: Vancouver style, numbered in brackets [1], [2], [3]
-- **References**: Vancouver/NLM format
- - Format: Author AA, Author BB, Author CC. Article title. Journal Abbrev. Year;vol(issue):pages. doi:xx.xxxx
- - Example: Watson JD, Crick FHC. Molecular structure of nucleic acids. Nature. 1953;171(4356):737-738.
-- **Figures**:
- - Format: TIFF, EPS, PDF, PNG
- - Resolution: 300-600 dpi
- - Color: RGB
- - Legends: Provided in main text after references
-- **Tables**: Editable format, one per page
-- **Data Availability**: Statement required
-- **Open Access**: All articles open access (APC applies)
-
-**LaTeX Template**: `assets/journals/plos_one.tex`
-
-**Author Guidelines**: https://journals.plos.org/plosone/s/submission-guidelines
-
----
-
-### PLOS Biology, PLOS Computational Biology, etc.
-
-**Formatting**: Similar to PLOS ONE with discipline-specific variations
-
-**Key Differences**:
-- PLOS Biology: More selective, emphasizes broad significance
-- PLOS Comp Bio: Focus on computational methods and models
-
----
-
-## Cell Press
-
-### Cell
-
-**Journal Type**: Top-tier biology journal
-**Publisher**: Cell Press (Elsevier)
-
-**Formatting Requirements**:
-- **Length**:
- - Articles: ~5,000 words (excluding Methods, References)
- - Short Articles: ~2,500 words
-- **Structure**: Summary (≤150 words), Keywords, Introduction, Results, Discussion, Experimental Procedures, Acknowledgments, Author Contributions, Declaration of Interests, References
-- **Format**: Double-spaced
-- **Font**: 12pt
-- **Margins**: 1 inch all sides
-- **Citations**: Author-year format (Smith et al., 2023)
-- **References**: Cell style
- - Format: Author, A.A., and Author, B.B. (Year). Title. *Journal* vol, pages.
- - Example: Watson, J.D., and Crick, F.H. (1953). Molecular structure of nucleic acids. *Nature* 171, 737-738.
-- **Figures**:
- - Format: TIFF, EPS preferred
- - Resolution: 300 dpi photos, 1000 dpi line art
- - Color: RGB or CMYK
- - Multipanel figures common
-- **Tables**: Editable format
-- **eTOC Blurb**: 30-50 word summary required
-- **Graphical Abstract**: Required
-
-**LaTeX Template**: `assets/journals/cell_article.tex`
-
-**Author Guidelines**: https://www.cell.com/cell/authors
-
----
-
-### Neuron, Immunity, Molecular Cell, Developmental Cell
-
-**Formatting**: Similar to Cell with discipline-specific expectations
-
----
+Before formatting:
-## IEEE Transactions
+1. identify the exact journal and article type;
+2. open the journal's official author instructions;
+3. determine whether the initial submission is format-flexible;
+4. distinguish initial-submission rules from revised/final-production rules;
+5. record length, abstract, display-item, data/code, reporting, and disclosure requirements; and
+6. use the official template only when the journal requires or recommends it.
-### IEEE Transactions on [Various Topics]
+Do not apply rules from a flagship journal to every journal in the same publisher family.
-**Journal Type**: Engineering and computer science journals
-**Publisher**: Institute of Electrical and Electronics Engineers
-
-**Formatting Requirements**:
-- **Length**: Varies by transaction (typically 8-12 pages in final format)
-- **Structure**: Abstract, Index Terms, Introduction, [Body sections], Conclusion, Acknowledgment, References, Biographies
-- **Format**: Two-column
-- **Font**: Times New Roman, 10pt
-- **Column spacing**: 0.17 inch (4.23 mm)
-- **Margins**:
- - Top: 19 mm (0.75 in)
- - Bottom: 25 mm (1 in)
- - Side: 17 mm (0.67 in)
-- **Citations**: Numbered in square brackets [1], [2], [3]
-- **References**: IEEE style
- - Format: [1] A. A. Author, "Title of paper," *Journal Abbrev.*, vol. x, no. x, pp. xxx-xxx, Mon. Year.
- - Example: [1] J. D. Watson and F. H. C. Crick, "Molecular structure of nucleic acids," *Nature*, vol. 171, pp. 737-738, Apr. 1953.
-- **Figures**:
- - Format: EPS, PDF (vector), TIFF (raster)
- - Resolution: 600-1200 dpi line art, 300 dpi grayscale/color
- - Color: RGB for online, CMYK for print if needed
- - Position: Top or bottom of column
-- **Tables**: LaTeX table environment, positioned at top/bottom
-- **Equations**: Numbered consecutively
-
-**LaTeX Template**: `assets/journals/ieee_trans.tex`
-
-**Author Guidelines**: https://journals.ieeeauthorcenter.ieee.org/
-
----
-
-### IEEE Access
-
-**Journal Type**: Open-access multidisciplinary engineering journal
-**Publisher**: IEEE
-
-**Formatting**: Similar to IEEE Transactions
-- **Length**: No page limits
-- **Open Access**: All articles open access
-- **Rapid publication**: Faster review than Transactions
-
-**LaTeX Template**: `assets/journals/ieee_access.tex`
-
----
-
-## ACM Publications
-
-### ACM Transactions
-
-**Journal Type**: Computer science transactions
-**Publisher**: Association for Computing Machinery
+## Nature Portfolio
-**Formatting Requirements**:
-- **Length**: No strict limit
-- **Structure**: Abstract, CCS Concepts, Keywords, ACM Reference Format, Introduction, [Body], Conclusion, Acknowledgments, References
-- **Format**: Two-column (final), single-column for submission OK
-- **Font**: Depends on template (usually 9-10pt)
-- **Class**: Use `acmart` LaTeX document class
-- **Citations**: Numbered [1] or author-year depending on venue
-- **References**: ACM style
- - Format: Author. Year. Title. Journal vol, issue (Year), pages. DOI
- - Example: James D. Watson and Francis H. C. Crick. 1953. Molecular structure of nucleic acids. Nature 171, 4356 (1953), 737-738. https://doi.org/10.1038/171737a0
-- **Figures**: EPS, PDF (vector preferred), high-resolution raster
-- **CCS Concepts**: Required (ACM Computing Classification System)
-- **Keywords**: Required
+### Nature
-**LaTeX Template**: `assets/journals/acm_article.tex`
+**Official resources**
-**Author Guidelines**: https://www.acm.org/publications/authors
+- Author hub: https://www.nature.com/nature/for-authors
+- Initial submission: https://www.nature.com/nature/for-authors/initial-submission
+- Formatting guide: https://www.nature.com/nature/for-authors/formatting-guide
----
+Nature states that initial submissions are flexible in format within reason. Authors are encouraged to combine text and figures in one Word file or PDF for review. The formatting guide describes article formats and typical final print lengths; these are not a generic “five-page submission limit.”
-## Springer Journals
+For Articles, the formatting guide describes:
-### General Springer Journals
+- a fully referenced summary paragraph, ideally no more than 200 words;
+- typical final print lengths that differ for physical-science and biological/clinical/social-science papers; and
+- detailed figure, reference, methods, and reporting requirements.
-**Publisher**: Springer Nature
+Use `assets/journals/nature_article.tex` only as a writing scaffold. It is not an official Nature class or a guarantee of compliance.
-**Formatting Requirements**:
-- **Length**: Varies by journal (check specific journal)
-- **Format**: Single column for submission (LaTeX or Word)
-- **Font**: 10-12pt
-- **Line spacing**: Double or 1.5
-- **Citations**: Numbered or author-year (varies by journal)
-- **References**: Springer style (similar to Vancouver or author-year)
- - Numbered: Author AA, Author BB (Year) Title. Journal vol:pages
- - Author-year: Author AA, Author BB (Year) Title. Journal vol:pages
-- **Figures**: TIFF, EPS, PDF; 300+ dpi
-- **Tables**: Editable format
-- **Document Class**: `svjour3` for many Springer journals
+### Other Nature Portfolio journals
-**LaTeX Template**: `assets/journals/springer_article.tex`
+Open the exact journal's **Submission Guidelines**. Some Nature Portfolio journals explicitly accept PDF, Word, or compiled TeX/LaTeX for a format-flexible initial submission, while others provide journal-specific structure and final-format instructions.
-**Author Guidelines**: Varies by specific journal
+Do not assume that Nature, Nature Communications, Scientific Reports, and subject journals share one word limit or template.
----
+## Science Family
-## Elsevier Journals
+**Official starting point**
-### General Elsevier Journals
+- Science author instructions: https://www.science.org/content/page/instructions-authors
-**Publisher**: Elsevier
+Resolve the exact journal and contribution type before applying length, abstract, reference, or supplementary-material rules. Science, Science Advances, and specialist journals have different workflows.
-**Formatting Requirements**:
-- **Length**: Varies widely by journal
-- **Format**: Single column (`preprint`) or two-column typeset (`twocolumn`); also `1p` / `3p` / `5p` layout options
-- **Font**: 10–12pt (set via `\documentclass[12pt]{elsarticle}`)
-- **Line spacing**: Double-spaced for submission (`\usepackage{setspace}\doublespacing`)
-- **Citations**: Numbered or author-year — Elsevier ships three matched bib styles (see below)
-- **References**: Style varies by journal (Harvard, Vancouver, numbered)
- - Check specific journal's "Guide for Authors"
-- **Figures**: TIFF, EPS; 300+ dpi line art / halftone
-- **Tables**: Editable format (`booktabs` recommended)
-- **Document Class**: `elsarticle` LaTeX class (replaces deprecated `elsart`)
+No Science template is bundled in this skill. Use the official instructions and files provided by the target journal.
-**LaTeX Templates** (pick by citation style required by the target journal):
+## PLOS
-| Template file | natbib option | Matching `.bst` | Citation looks like |
-|---|---|---|---|
-| `assets/journals/elsarticle-template-num.tex` | `numbers` | `elsarticle-num.bst` | `[1]`, `[2,3]` |
-| `assets/journals/elsarticle-template-num-names.tex` | `numbers,sort&compress` | `elsarticle-num-names.bst` | `Jones et al. [21]` |
-| `assets/journals/elsarticle-template-harv.tex` | `authoryear` | `elsarticle-harv.bst` | `(Jones, 2023)` / `Jones (2023)` |
+**Official resources**
-All three `.bst` files are bundled alongside the templates in `assets/journals/`.
+- PLOS ONE submission guidelines: https://journals.plos.org/plosone/s/submission-guidelines
+- PLOS journal-specific LaTeX pages are linked from each journal's author resources.
-**Common documentclass options**:
-- `preprint` (default, single column, double spaced — use for submission)
-- `review` (double spaced, large margins, for reviewing)
-- `1p` / `3p` / `5p` (1-, 3-, 5-column typeset layouts — mainly for final camera-ready)
-- `times` (Times-like font)
-- `twocolumn`, `final`, `authoryear`, `number`
+PLOS supplies an official LaTeX package and BibTeX style for LaTeX submissions. Follow the target PLOS journal's package and upload instructions; manuscript and figure-file handling can be specific to the journal and submission stage.
-**Front-matter macros** (specific to elsarticle):
-- `\title{...}` `\author[label]{...}` `\affiliation[label]{...}` `\ead{email}` `\ead[url]{...}`
-- `\cortext[cor1]{Corresponding author}` paired with `\author[...]{... \corref{cor1}}`
-- `\begin{abstract}...\end{abstract}` and `\begin{keyword}...\end{keyword}` inside `\begin{frontmatter}...\end{frontmatter}`
+`assets/journals/plos_one.tex` is a drafting scaffold, not a substitute for the current PLOS package.
-**Author Guidelines**: https://www.elsevier.com/authors (select specific journal — many sub-journals override defaults, especially word limits, abstract structure, and `highlights` / `graphical abstract` requirements)
+## Cell Press
-**Class documentation**: CTAN `elsarticle` package → `elsdoc.pdf` for the full reference.
+**Official starting point**
----
+- Cell author resources: https://www.cell.com/cell/authors
-## BMC Journals
+Check the exact journal and article type for:
-### BMC Biology, BMC Bioinformatics, etc.
+- Summary and Highlights limits;
+- graphical abstract or eTOC requirements;
+- STAR Methods or other methods structure;
+- Resource Availability and Lead Contact sections;
+- Limitations of the Study;
+- data/code availability declarations; and
+- generative-AI or AI-assisted-technology declarations.
-**Publisher**: BioMed Central (Springer Nature)
+No Cell Press LaTeX template is bundled. Use `references/cell_press_style.md` for writing guidance and the official author resources for submission requirements.
-**Formatting Requirements**:
-- **Length**: No maximum length
-- **Structure**: Abstract (structured), Keywords, Background, [Methods/Results/Discussion], Conclusions, Abbreviations, Declarations (Ethics, Consent, Availability, Competing interests, Funding, Authors' contributions, Acknowledgements), References
-- **Format**: Single column
-- **Font**: Arial or Times, 12pt
-- **Line spacing**: Double
-- **Citations**: Vancouver style, numbered in brackets [1]
-- **References**: Vancouver/NLM format
-- **Figures**: TIFF, EPS, PNG; 300+ dpi
-- **Tables**: Editable
-- **Open Access**: All BMC journals are open access
-- **Data Availability**: Statement required
+## IEEE
-**LaTeX Template**: `assets/journals/bmc_article.tex`
+**Official resources**
-**Author Guidelines**: https://www.biomedcentral.com/getpublished
+- IEEE journal templates: https://journals.ieeeauthorcenter.ieee.org/create-your-ieee-journal-article/authoring-tools-and-templates/tools-for-ieee-authors/ieee-article-templates
+- IEEE Template Selector: https://template-selector.ieee.org/
----
+Use the Template Selector to resolve the publication-specific Word or LaTeX package. Page limits, review layout, biographies, open-access declarations, and overlength charges vary by journal.
-## Frontiers Journals
+No IEEE template is bundled in this skill.
-### Frontiers in [Various Topics]
+## ACM
-**Publisher**: Frontiers Media
+**Official resources**
-**Formatting Requirements**:
-- **Length**: Varies by article type (Research Article ~12 pages, Brief Research Report ~4 pages)
-- **Structure**: Abstract, Keywords, Introduction, Materials and Methods, Results, Discussion, Conclusion, Data Availability Statement, Ethics Statement, Author Contributions, Funding, Acknowledgments, Conflict of Interest, References
-- **Format**: Single column
-- **Font**: Times New Roman, 12pt
-- **Line spacing**: Double
-- **Citations**: Numbered (Frontiers style)
-- **References**: Frontiers format
- - Format: Author A., Author B., Author C. (Year). Title. *Journal Abbrev.* vol:pages. doi
- - Example: Watson J. D., Crick F. H. C. (1953). Molecular structure of nucleic acids. *Nature* 171:737-738. doi:10.1038/171737a0
-- **Figures**: TIFF, EPS; 300 dpi minimum
-- **Tables**: Editable
-- **Open Access**: All Frontiers journals are open access
-- **Figure Legends**: Detailed, 350 words max per figure
+- ACM LaTeX preparation: https://authors.acm.org/proceedings/production-information/preparing-your-article-with-latex
+- ACM journals submission process: https://authors.acm.org/journals/submission-process
-**LaTeX Template**: `assets/journals/frontiers_article.tex`
+ACM uses the `acmart` class with publication-specific options and the TAPS production workflow. The review format selected by a conference or journal may differ from the final TAPS output.
-**Author Guidelines**: https://www.frontiersin.org/guidelines/author-guidelines
+No ACM template is bundled. Use the official ACM Master Article Template and the target publication's instructions.
----
+## Elsevier
-## Specialized Journals
+**Official resource**
-### PNAS (Proceedings of the National Academy of Sciences)
+- LaTeX instructions: https://www.elsevier.com/researcher/author/policies-and-guidelines/latex-instructions
-**Formatting Requirements**:
-- **Length**: 6 pages (text, figures, tables combined)
-- **Abstract**: 250 words max
-- **Significance Statement**: 120 words max (required)
-- **Structure**: Abstract, Significance, Main text, Materials and Methods, Acknowledgments, References
-- **Format**: Single column
-- **Citations**: Numbered
-- **References**: PNAS style
-- **LaTeX Class**: `pnas-new`
+Elsevier documents the `elsarticle` class and provides separate CAS single- and double-column templates. The exact journal's Guide for Authors determines word limits, article structure, reference style, highlights, graphical abstracts, and whether PDF-only initial submission is accepted.
-**LaTeX Template**: `assets/journals/pnas_article.tex`
+Bundled examples:
----
+| File | Citation mode | Matching bibliography style |
+|---|---|---|
+| `assets/journals/elsarticle-template-num.tex` | numeric | `elsarticle-num.bst` |
+| `assets/journals/elsarticle-template-num-names.tex` | numeric, sorted/compressed | `elsarticle-num-names.bst` |
+| `assets/journals/elsarticle-template-harv.tex` | author-year | `elsarticle-harv.bst` |
-### Physical Review Letters (PRL)
+These are examples for the `elsarticle` workflow. Compare them with the current class documentation and target journal instructions before submission.
-**Publisher**: American Physical Society
+## Other Publisher and Society Starting Points
-**Formatting Requirements**:
-- **Length**: 4 pages (including figures and references)
-- **Format**: Two-column (REVTeX 4.2)
-- **Abstract**: No more than 600 characters
-- **Citations**: Numbered
-- **References**: APS style
-- **Document Class**: `revtex4-2`
+| Publisher or journal | Official starting point | Key caution |
+|---|---|---|
+| Springer Nature journals | Target journal's “Submission Guidelines” | Template and reference style vary by journal |
+| BMC | https://www.biomedcentral.com/getpublished | Article type and declaration sections vary |
+| Frontiers | https://www.frontiersin.org/guidelines/author-guidelines | Check article-type limits and required statements |
+| PNAS | https://www.pnas.org/author-center | Check article type and current significance-statement rules |
+| APS / PRL | https://journals.aps.org/authors | Use current REVTeX and journal-specific length rules |
+| NEJM | https://www.nejm.org/author-center | Use article-type instructions and reporting guidelines |
+| The Lancet | https://www.thelancet.com/what-we-publish | Use journal and article-type author guidance |
-**LaTeX Template**: `assets/journals/prl_article.tex`
+## What to Extract From Author Instructions
----
+### Manuscript structure
-### New England Journal of Medicine (NEJM)
+- article type and section order;
+- structured or unstructured abstract;
+- word, character, display-item, and reference limits;
+- required methods, limitations, reporting, and availability sections; and
+- title-page and contributor information.
-**Formatting Requirements**:
-- **Length**: Original Articles ~3,000 words
-- **Structure**: Abstract (structured, 250 words), Introduction, Methods, Results, Discussion, References
-- **Format**: Double-spaced
-- **Citations**: Numbered
-- **References**: NEJM style (modified Vancouver)
-- **Figures**: High resolution, professional quality
-- **Word submission preferred** (LaTeX less common)
+### Files and formatting
----
+- accepted initial manuscript format;
+- whether figures are embedded or uploaded separately;
+- official Word/LaTeX package;
+- line numbering, page numbering, and spacing;
+- figure dimensions, color mode, and resolution;
+- editable table requirements; and
+- source archive requirements after acceptance.
-### The Lancet
+### Policy and declarations
-**Formatting Requirements**:
-- **Length**: Articles ~3,000 words
-- **Abstract**: Structured, 300 words
-- **Structure**: Panel (summary box), Introduction, Methods, Results, Discussion, References
-- **Citations**: Numbered
-- **References**: Lancet style (modified Vancouver)
-- **Word preferred** for submission
+- authorship and contributor roles;
+- competing interests and funding;
+- ethics approval, consent, and trial registration;
+- data, code, and materials availability;
+- preprint and related-manuscript policy;
+- reporting guideline/checklist; and
+- use of generative AI or AI-assisted tools.
----
+## Initial Submission Versus Production
-## Quick Reference Table
+Many journals accept a readable, format-flexible initial PDF and impose detailed house style only after revision or acceptance. Formatting a first submission to mimic the published two-column layout may add work without improving compliance.
-| Journal | Max Length | Format | Citations | Template |
-|---------|-----------|--------|-----------|----------|
-| **Nature** | ~3,000 words | Single col | Superscript | `nature_article.tex` |
-| **Science** | 2,500 words | Single col | (1) brackets | `science_article.tex` |
-| **PLOS ONE** | Unlimited | Single col | [1] Vancouver | `plos_one.tex` |
-| **Cell** | ~5,000 words | Double sp | (Author, year) | `cell_article.tex` |
-| **IEEE Trans** | 8-12 pages | Two col | [1] IEEE | `ieee_trans.tex` |
-| **ACM Trans** | Variable | Two col | [1] or author-yr | `acm_article.tex` |
-| **Springer** | Variable | Single col | Numbered/author-yr | `springer_article.tex` |
-| **BMC** | Unlimited | Single col | [1] Vancouver | `bmc_article.tex` |
-| **Frontiers** | ~12 pages | Single col | Numbered | `frontiers_article.tex` |
+Use this order:
----
+1. satisfy the current initial-submission requirements;
+2. preserve editable source and high-quality figures;
+3. wait for journal-specific revision or production instructions; and
+4. reformat only when requested or required.
-## Notes
+## Bundled Asset Inventory
-1. **Always check official guidelines**: Journal requirements change; verify before submission
-2. **Template currency**: These templates are updated regularly but may lag official changes
-3. **Supplementary materials**: Most journals allow extensive supplementary materials
-4. **Preprint policies**: Check journal's preprint policy (most allow arXiv, bioRxiv)
-5. **Open access options**: Many subscription journals offer open access for a fee
-6. **LaTeX vs. Word**: Most journals accept both; LaTeX preferred for math-heavy content
+Only these journal-oriented assets are present:
-## Getting Official Templates
+- `assets/journals/nature_article.tex`
+- `assets/journals/plos_one.tex`
+- `assets/journals/neurips_article.tex`
+- three Elsevier `elsarticle` examples and their `.bst` files
-Many journals provide official LaTeX templates:
-- **Nature**: Download from journal website
-- **IEEE**: IEEEtran class (widely available)
-- **ACM**: acmart class (CTAN)
-- **Elsevier**: elsarticle class (CTAN)
-- **Springer**: svjour3 class (journal website)
+If a template is not in this list, obtain it from the official source. Do not invent a relative asset path.
-Check journal's "For Authors" or "Submit" page for the most current templates.
+## Final Journal Checklist
+- [ ] Exact journal and article type confirmed
+- [ ] Official instructions checked and dated
+- [ ] Initial versus revised/final rules distinguished
+- [ ] Official template used if required
+- [ ] Length and display-item limits checked
+- [ ] Required reporting guideline and checklist included
+- [ ] Ethics, consent, trial registration, and disclosures complete
+- [ ] Data/code/materials statements complete
+- [ ] Figures and tables meet current technical requirements
+- [ ] Source archive and PDF reviewed in the submission portal
diff --git a/skills/venue-templates/references/medical_journal_styles.md b/skills/venue-templates/references/medical_journal_styles.md
index 3285102c..96eba0d3 100644
--- a/skills/venue-templates/references/medical_journal_styles.md
+++ b/skills/venue-templates/references/medical_journal_styles.md
@@ -2,7 +2,9 @@
Comprehensive writing guide for NEJM, Lancet, JAMA, BMJ, Annals of Internal Medicine, and other major medical journals.
-**Last Updated**: 2024
+**Reviewed**: 2026-07-20
+
+Article-type instructions and reporting guidelines change. Verify every numeric limit with the journal's current author center.
---
@@ -197,7 +199,7 @@ treated (NNT=40; 95% CI, 28 to 67)."
- Why this matters clinically
```
-"Type 2 diabetes affects more than 450 million adults worldwide and is
+"Type 2 diabetes affects hundreds of millions of adults worldwide and is
a leading cause of cardiovascular disease, renal failure, and premature
death. Despite advances in glucose-lowering therapies, patients with
diabetes continue to face a two- to four-fold increased risk of
@@ -369,8 +371,7 @@ longer periods.
- **Word limit**: 2,700 words (excluding abstract, references)
- **Abstract**: 250 words, structured
-- **References**: ~40-50 typical
-- **Figures/Tables**: 4-5 combined
+- **References and display items**: Check the current Original Article instructions in the NEJM Author Center; do not rely on cached generic counts
- **Style**: Definitive, authoritative
- **Emphasis**: Major clinical trials, transformative research
@@ -411,7 +412,7 @@ longer periods.
### CONSORT (RCTs)
-**25-item checklist** including:
+**CONSORT 2025 uses a 30-item checklist and flow diagram** covering:
- Trial design, randomization, blinding
- Participant flow (diagram required)
- All outcomes with effect sizes and CIs
@@ -531,5 +532,5 @@ Standard presentation:
- `venue_writing_styles.md` - Master style overview
- `journals_formatting.md` - Technical formatting requirements
- `reviewer_expectations.md` - What medical reviewers seek
-- Reporting guideline resources: consort-statement.org, strobe-statement.org
+- Reporting guideline resources: https://www.consort-spirit.org/ and https://www.strobe-statement.org/
diff --git a/skills/venue-templates/references/ml_conference_style.md b/skills/venue-templates/references/ml_conference_style.md
index 441b7941..49c5310e 100644
--- a/skills/venue-templates/references/ml_conference_style.md
+++ b/skills/venue-templates/references/ml_conference_style.md
@@ -2,7 +2,9 @@
Comprehensive writing guide for NeurIPS, ICML, ICLR, CVPR, ECCV, ICCV, and other major machine learning and computer vision conferences.
-**Last Updated**: 2024
+**Reviewed**: 2026-07-20
+
+Annual format, checklist, and review rules must be checked in the current author kit. See `conferences_formatting.md` for source links and verified 2026 snapshots.
---
@@ -334,7 +336,7 @@ FlashAttention-1 (baseline) | 1.0x | 1.0x
- **Organized by theme**: Not chronological
- **Position your work**: How you differ from each line of work
- **Fair characterization**: Don't misrepresent prior work
-- **Recent citations**: Include 2023-2024 papers
+- **Recent citations**: Include relevant work from the last two to three years as well as foundational papers
### Example Structure
@@ -388,9 +390,9 @@ hold for future hardware generations.
## Reproducibility
-### Reproducibility Checklist (NeurIPS/ICML)
+### Paper and Reproducibility Checklists
-Most ML conferences require a reproducibility checklist covering:
+Many ML conferences use a paper checklist, reproducibility statement, or related disclosures. The exact name and questions vary. Common topics include:
- [ ] Code availability
- [ ] Dataset availability
@@ -459,7 +461,7 @@ Self-contained captions that explain:
### Reference Guidelines
-- **Cite recent work**: 2022-2024 papers expected
+- **Cite recent work**: Cover relevant work from the last two to three years without omitting foundational results
- **Don't over-cite yourself**: Raises bias concerns
- **Cite arxiv appropriately**: Use published version when available
- **Include all relevant prior work**: Missing citations hurt review
@@ -468,33 +470,37 @@ Self-contained captions that explain:
## Venue-Specific Notes
+The limits below are verified 2026 snapshots for initial submissions. Recheck the exact year and track before use.
+
### NeurIPS
-- **8 pages** main + unlimited appendix/references
-- **Broader Impact** section sometimes required
-- **Reproducibility checklist** mandatory
-- OpenReview submission, public reviews
+- **9 content pages**, including figures
+- Acknowledgments, references, the required Paper Checklist, and optional technical appendices do not count as content pages
+- A separately titled Broader Impacts section is not universally required; discuss impacts where relevant and answer the checklist
+- Initial submission uses the anonymous mode of the official style
### ICML
-- **8 pages** main + unlimited appendix/references
+- **8 pages** main body + additional references/appendices in the same PDF
- Strong emphasis on **theory + experiments**
-- Reproducibility statement encouraged
+- Use the official 2026 LaTeX style and anonymized submission mode
### ICLR
-- **8 pages** main (camera-ready can exceed)
+- **9 pages** main text for initial submission; 10 during discussion/rebuttal and camera-ready
- OpenReview with **public reviews and discussion**
- Author response period is interactive
- Strong emphasis on **novelty and insight**
-### CVPR/ICCV/ECCV
+### CVPR
-- **8 pages** main including references
-- **Supplementary video** encouraged
+- **8 pages** including figures and tables, excluding cited-reference-only pages
+- Use the official CVPR 2026 author kit and follow its external-link restrictions
- Heavy emphasis on **visual results**
- Benchmark performance critical
+ICCV and ECCV have independent yearly instructions; do not inherit CVPR's current rules.
+
---
## Common Mistakes
diff --git a/skills/venue-templates/references/nature_science_style.md b/skills/venue-templates/references/nature_science_style.md
index b77fcd83..136456b8 100644
--- a/skills/venue-templates/references/nature_science_style.md
+++ b/skills/venue-templates/references/nature_science_style.md
@@ -2,7 +2,9 @@
Comprehensive writing guide for Nature, Science, and related high-impact multidisciplinary journals (Nature Communications, Science Advances, PNAS).
-**Last Updated**: 2024
+**Reviewed**: 2026-07-20
+
+Writing guidance is descriptive. Check the exact journal, contribution type, and current author instructions before applying numeric limits.
---
@@ -50,9 +52,9 @@ Nature and Science are the world's premier multidisciplinary scientific journals
### Style Requirements
- **Flowing paragraphs** (NOT structured with labeled sections)
-- **150-200 words** for Nature; up to 250 for Nature Communications
+- **Nature Articles**: the summary paragraph is ideally no more than 200 words; other journals and contribution types vary
- **No citations** in abstract
-- **No abbreviations** (or define at first use if essential)
+- **Avoid numbers, abbreviations, acronyms, and measurements unless essential** in a Nature summary paragraph
- **Self-contained**: Understandable without reading the paper
### Abstract Structure (Implicit)
diff --git a/skills/venue-templates/references/posters_guidelines.md b/skills/venue-templates/references/posters_guidelines.md
index ccf4c0f5..8b685cd1 100644
--- a/skills/venue-templates/references/posters_guidelines.md
+++ b/skills/venue-templates/references/posters_guidelines.md
@@ -2,7 +2,9 @@
Comprehensive guidelines for creating effective academic research posters including sizing, layout, typography, and design best practices.
-**Last Updated**: 2024
+**Reviewed**: 2026-07-20
+
+Poster dimensions and upload rules are event-specific. Confirm the current presenter instructions before choosing a size, orientation, or file format.
---
@@ -334,7 +336,7 @@ Use colorblind-friendly color combinations:
- Steeper learning curve
- Can be slow to compile
-**Template**: `assets/posters/tikzposter_research.tex`
+**Bundled template**: None. Start from the current `tikzposter` package documentation or an event-provided template.
**Example Usage**:
```latex
@@ -358,7 +360,7 @@ Use colorblind-friendly color combinations:
- Complex syntax
- Less commonly used
-**Template**: `assets/posters/baposter_conference.tex`
+**Bundled template**: None. Start from the current `baposter` package documentation or an event-provided template.
**Example Usage**:
```latex
@@ -594,8 +596,8 @@ Generate QR codes linking to:
### LaTeX Templates
- `assets/posters/beamerposter_academic.tex`
-- `assets/posters/tikzposter_research.tex`
-- `assets/posters/baposter_conference.tex`
+
+This is the only poster template bundled with the skill. `tikzposter` and `baposter` remain possible external authoring packages, but no local templates are provided for them.
### Online Resources
- Better Posters Blog: https://betterposters.blogspot.com/
diff --git a/skills/venue-templates/references/reviewer_expectations.md b/skills/venue-templates/references/reviewer_expectations.md
index a0da05f5..3594a951 100644
--- a/skills/venue-templates/references/reviewer_expectations.md
+++ b/skills/venue-templates/references/reviewer_expectations.md
@@ -2,7 +2,9 @@
Understanding what reviewers look for at different venues is essential for crafting successful submissions. This guide covers evaluation criteria, common rejection reasons, and how to address reviewer concerns.
-**Last Updated**: 2024
+**Reviewed**: 2026-07-20
+
+Review forms and scoring scales change by cycle. Use the current reviewer guidelines when predicting criteria or preparing a rebuttal.
---
@@ -30,7 +32,7 @@ Reviewers at different venues prioritize different aspects. Understanding these
### Review Process
-1. **Editorial triage**: Most papers rejected without review (Nature: ~92%)
+1. **Editorial triage**: Highly selective journals reject many submissions before external review; do not confuse overall rejection rate with desk-rejection rate
2. **Expert review**: 2-4 reviewers if sent out
3. **Cross-discipline reviewer**: Often includes non-specialist
4. **Quick turnaround**: First decision typically 2-4 weeks
@@ -175,15 +177,18 @@ Reviewers at different venues prioritize different aspects. Understanding these
### Scoring Dimensions
-Typical NeurIPS/ICML scoring:
+Current ML review forms commonly separate dimensions such as:
+
+| Dimension | What's Evaluated |
+|-----------|------------------|
+| **Quality** | Technical correctness, evidence, and rigor |
+| **Clarity** | Organization, explanation, and reproducibility |
+| **Significance** | Importance and likely impact |
+| **Originality** | Novelty relative to prior work |
+| **Overall assessment** | Holistic recommendation under the current rubric |
+| **Confidence** | Reviewer's expertise and certainty |
-| Dimension | Score Range | What's Evaluated |
-|-----------|-------------|------------------|
-| **Soundness** | 1-4 | Technical correctness |
-| **Contribution** | 1-4 | Significance of results |
-| **Presentation** | 1-4 | Clarity and organization |
-| **Overall** | 1-10 | Holistic assessment |
-| **Confidence** | 1-5 | Reviewer expertise |
+Do not cache numeric ranges across years or venues; quote the current review form when a score matters.
### What Gets a Paper Rejected
diff --git a/skills/venue-templates/references/venue_writing_styles.md b/skills/venue-templates/references/venue_writing_styles.md
index ef877d73..7885c473 100644
--- a/skills/venue-templates/references/venue_writing_styles.md
+++ b/skills/venue-templates/references/venue_writing_styles.md
@@ -2,7 +2,9 @@
This guide provides an overview of how writing style varies across publication venues. Understanding these differences is essential for crafting papers that read like authentic publications at each venue.
-**Last Updated**: 2024
+**Reviewed**: 2026-07-20
+
+Writing conventions are descriptive, not submission requirements. Check the exact venue and article type before treating any element as mandatory.
---
@@ -160,7 +162,7 @@ ML abstracts are **dense and numbers-focused**:
### ACL/EMNLP (NLP)
- **Task-focused**: Clear problem definition
-- **Benchmark-heavy**: Standard datasets (GLUE, SQuAD, etc.)
+- **Evaluation-heavy**: Use task-appropriate current benchmarks, strong model baselines, human evaluation, or safety/robustness tests; classic datasets such as GLUE or SQuAD remain relevant only for matching tasks
- **Error analysis valued**: Where does it fail?
- **Human evaluation**: Often expected alongside automatic metrics
- **Ethical considerations**: Bias, fairness, environmental cost
diff --git a/skills/venue-templates/scripts/generate_schematic.py b/skills/venue-templates/scripts/generate_schematic.py
deleted file mode 100644
index 6843e0a1..00000000
--- a/skills/venue-templates/scripts/generate_schematic.py
+++ /dev/null
@@ -1,139 +0,0 @@
-#!/usr/bin/env python3
-"""
-Scientific schematic generation using Nano Banana 2.
-
-Generate any scientific diagram by describing it in natural language.
-Nano Banana 2 handles everything automatically with smart iterative refinement.
-
-Smart iteration: Only regenerates if quality is below threshold for your document type.
-Quality review: Uses Gemini 3.1 Pro Preview for professional scientific evaluation.
-
-Usage:
- # Generate for journal paper (highest quality threshold)
- python generate_schematic.py "CONSORT flowchart" -o flowchart.png --doc-type journal
-
- # Generate for presentation (lower threshold, faster)
- python generate_schematic.py "Transformer architecture" -o transformer.png --doc-type presentation
-
- # Generate for poster
- python generate_schematic.py "MAPK signaling pathway" -o pathway.png --doc-type poster
-"""
-
-import argparse
-import os
-import subprocess
-import sys
-from pathlib import Path
-
-
-def main():
- """Command-line interface."""
- parser = argparse.ArgumentParser(
- description="Generate scientific schematics using AI with smart iterative refinement",
- formatter_class=argparse.RawDescriptionHelpFormatter,
- epilog="""
-How it works:
- Simply describe your diagram in natural language
- Nano Banana 2 generates it automatically with:
- - Smart iteration (only regenerates if quality is below threshold)
- - Quality review by Gemini 3.1 Pro Preview
- - Document-type aware quality thresholds
- - Publication-ready output
-
-Document Types (quality thresholds):
- journal 8.5/10 - Nature, Science, peer-reviewed journals
- conference 8.0/10 - Conference papers
- thesis 8.0/10 - Dissertations, theses
- grant 8.0/10 - Grant proposals
- preprint 7.5/10 - arXiv, bioRxiv, etc.
- report 7.5/10 - Technical reports
- poster 7.0/10 - Academic posters
- presentation 6.5/10 - Slides, talks
- default 7.5/10 - General purpose
-
-Examples:
- # Generate for journal paper (strict quality)
- python generate_schematic.py "CONSORT participant flow" -o flowchart.png --doc-type journal
-
- # Generate for poster (moderate quality)
- python generate_schematic.py "Transformer architecture" -o arch.png --doc-type poster
-
- # Generate for slides (faster, lower threshold)
- python generate_schematic.py "System diagram" -o system.png --doc-type presentation
-
- # Custom max iterations
- python generate_schematic.py "Complex pathway" -o pathway.png --iterations 2
-
- # Verbose output
- python generate_schematic.py "Circuit diagram" -o circuit.png -v
-
-Environment Variables:
- OPENROUTER_API_KEY Required for AI generation
- """
- )
-
- parser.add_argument("prompt",
- help="Description of the diagram to generate")
- parser.add_argument("-o", "--output", required=True,
- help="Output file path")
- parser.add_argument("--doc-type", default="default",
- choices=["journal", "conference", "poster", "presentation",
- "report", "grant", "thesis", "preprint", "default"],
- help="Document type for quality threshold (default: default)")
- parser.add_argument("--iterations", type=int, default=2,
- help="Maximum refinement iterations (default: 2, max: 2)")
- parser.add_argument("--api-key",
- help="OpenRouter API key (or use OPENROUTER_API_KEY env var)")
- parser.add_argument("-v", "--verbose", action="store_true",
- help="Verbose output")
-
- args = parser.parse_args()
-
- # Check for API key
- api_key = args.api_key or os.getenv("OPENROUTER_API_KEY")
- if not api_key:
- print("Error: OPENROUTER_API_KEY environment variable not set")
- print("\nFor AI generation, you need an OpenRouter API key.")
- print("Get one at: https://openrouter.ai/keys")
- print("\nSet it with:")
- print(" export OPENROUTER_API_KEY='your_api_key'")
- print("\nOr use --api-key flag")
- sys.exit(1)
-
- # Find AI generation script
- script_dir = Path(__file__).parent
- ai_script = script_dir / "generate_schematic_ai.py"
-
- if not ai_script.exists():
- print(f"Error: AI generation script not found: {ai_script}")
- sys.exit(1)
-
- # Build command
- cmd = [sys.executable, str(ai_script), args.prompt, "-o", args.output]
-
- if args.doc_type != "default":
- cmd.extend(["--doc-type", args.doc_type])
-
- # Enforce max 2 iterations
- iterations = min(args.iterations, 2)
- if iterations != 2:
- cmd.extend(["--iterations", str(iterations)])
-
- if args.verbose:
- cmd.append("-v")
-
- # Execute — pass API key via environment to avoid exposure in process listings
- try:
- env = os.environ.copy()
- if api_key:
- env["OPENROUTER_API_KEY"] = api_key
- result = subprocess.run(cmd, check=False, env=env)
- sys.exit(result.returncode)
- except Exception as e:
- print(f"Error executing AI generation: {e}")
- sys.exit(1)
-
-
-if __name__ == "__main__":
- main()
-
diff --git a/skills/venue-templates/scripts/generate_schematic_ai.py b/skills/venue-templates/scripts/generate_schematic_ai.py
deleted file mode 100644
index 52170753..00000000
--- a/skills/venue-templates/scripts/generate_schematic_ai.py
+++ /dev/null
@@ -1,817 +0,0 @@
-#!/usr/bin/env python3
-"""
-AI-powered scientific schematic generation using Nano Banana 2.
-
-This script uses a smart iterative refinement approach:
-1. Generate initial image with Nano Banana 2
-2. AI quality review using Gemini 3.1 Pro Preview for scientific critique
-3. Only regenerate if quality is below threshold for document type
-4. Repeat until quality meets standards (max iterations)
-
-Requirements:
- - OPENROUTER_API_KEY environment variable
- - requests library
-
-Usage:
- python generate_schematic_ai.py "Create a flowchart showing CONSORT participant flow" -o flowchart.png
- python generate_schematic_ai.py "Neural network architecture diagram" -o architecture.png --iterations 2
- python generate_schematic_ai.py "Simple block diagram" -o diagram.png --doc-type poster
-"""
-
-import argparse
-import base64
-import json
-import os
-import sys
-import time
-from pathlib import Path
-from typing import Optional, Dict, Any, List, Tuple
-
-try:
- import requests
-except ImportError:
- print("Error: requests library not found. Install with: pip install requests")
- sys.exit(1)
-
-# Try to load .env file from multiple potential locations
-def _load_env_file():
- """Load .env file from current directory or script directory only."""
- try:
- from dotenv import load_dotenv
- except ImportError:
- return False
-
- for candidate in [Path.cwd() / ".env", Path(__file__).resolve().parent / ".env"]:
- if candidate.exists():
- load_dotenv(dotenv_path=candidate, override=False)
- return True
-
- return False
-
-
-class ScientificSchematicGenerator:
- """Generate scientific schematics using AI with smart iterative refinement.
-
- Uses Gemini 3.1 Pro Preview for quality review to determine if regeneration is needed.
- Multiple passes only occur if the generated schematic doesn't meet the
- quality threshold for the target document type.
- """
-
- # Quality thresholds by document type (score out of 10)
- # Higher thresholds for more formal publications
- QUALITY_THRESHOLDS = {
- "journal": 8.5, # Nature, Science, etc. - highest standards
- "conference": 8.0, # Conference papers - high standards
- "poster": 7.0, # Academic posters - good quality
- "presentation": 6.5, # Slides/talks - clear but less formal
- "report": 7.5, # Technical reports - professional
- "grant": 8.0, # Grant proposals - must be compelling
- "thesis": 8.0, # Dissertations - formal academic
- "preprint": 7.5, # arXiv, etc. - good quality
- "default": 7.5, # Default threshold
- }
-
- # Scientific diagram best practices prompt template
- SCIENTIFIC_DIAGRAM_GUIDELINES = """
-Create a high-quality scientific diagram with these requirements:
-
-VISUAL QUALITY:
-- Clean white or light background (no textures or gradients)
-- High contrast for readability and printing
-- Professional, publication-ready appearance
-- Sharp, clear lines and text
-- Adequate spacing between elements to prevent crowding
-
-TYPOGRAPHY:
-- Clear, readable sans-serif fonts (Arial, Helvetica style)
-- Minimum 10pt font size for all labels
-- Consistent font sizes throughout
-- All text horizontal or clearly readable
-- No overlapping text
-
-SCIENTIFIC STANDARDS:
-- Accurate representation of concepts
-- Clear labels for all components
-- Include scale bars, legends, or axes where appropriate
-- Use standard scientific notation and symbols
-- Include units where applicable
-
-ACCESSIBILITY:
-- Colorblind-friendly color palette (use Okabe-Ito colors if using color)
-- High contrast between elements
-- Redundant encoding (shapes + colors, not just colors)
-- Works well in grayscale
-
-LAYOUT:
-- Logical flow (left-to-right or top-to-bottom)
-- Clear visual hierarchy
-- Balanced composition
-- Appropriate use of whitespace
-- No clutter or unnecessary decorative elements
-
-IMPORTANT - NO FIGURE NUMBERS:
-- Do NOT include "Figure 1:", "Fig. 1", or any figure numbering in the image
-- Do NOT add captions or titles like "Figure: ..." at the top or bottom
-- Figure numbers and captions are added separately in the document/LaTeX
-- The diagram should contain only the visual content itself
-"""
-
- def __init__(self, api_key: Optional[str] = None, verbose: bool = False):
- """
- Initialize the generator.
-
- Args:
- api_key: OpenRouter API key (or use OPENROUTER_API_KEY env var)
- verbose: Print detailed progress information
- """
- # Priority: 1) explicit api_key param, 2) environment variable, 3) .env file
- self.api_key = api_key or os.getenv("OPENROUTER_API_KEY")
-
- # If not found in environment, try loading from .env file
- if not self.api_key:
- _load_env_file()
- self.api_key = os.getenv("OPENROUTER_API_KEY")
-
- if not self.api_key:
- raise ValueError(
- "OPENROUTER_API_KEY not found. Please either:\n"
- " 1. Set the OPENROUTER_API_KEY environment variable\n"
- " 2. Add OPENROUTER_API_KEY to your .env file\n"
- " 3. Pass api_key parameter to the constructor\n"
- "Get your API key from: https://openrouter.ai/keys"
- )
-
- self.verbose = verbose
- self._last_error = None # Track last error for better reporting
- self.base_url = "https://openrouter.ai/api/v1"
- # Nano Banana 2 - Google's advanced image generation model
- # https://openrouter.ai/google/gemini-3-pro-image-preview
- self.image_model = "google/gemini-3.1-flash-image-preview"
- # Gemini 3.1 Pro Preview for quality review - excellent vision and reasoning
- self.review_model = "google/gemini-3.1-pro-preview"
-
- def _log(self, message: str):
- """Log message if verbose mode is enabled."""
- if self.verbose:
- print(f"[{time.strftime('%H:%M:%S')}] {message}")
-
- def _make_request(self, model: str, messages: List[Dict[str, Any]],
- modalities: Optional[List[str]] = None) -> Dict[str, Any]:
- """
- Make a request to OpenRouter API.
-
- Args:
- model: Model identifier
- messages: List of message dictionaries
- modalities: Optional list of modalities (e.g., ["image", "text"])
-
- Returns:
- API response as dictionary
- """
- headers = {
- "Authorization": f"Bearer {self.api_key}",
- "Content-Type": "application/json",
- "HTTP-Referer": "https://github.com/scientific-writer",
- "X-Title": "Scientific Schematic Generator"
- }
-
- payload = {
- "model": model,
- "messages": messages
- }
-
- if modalities:
- payload["modalities"] = modalities
-
- self._log(f"Making request to {model}...")
-
- try:
- response = requests.post(
- f"{self.base_url}/chat/completions",
- headers=headers,
- json=payload,
- timeout=120
- )
-
- # Try to get response body even on error
- try:
- response_json = response.json()
- except json.JSONDecodeError:
- response_json = {"raw_text": response.text[:500]}
-
- # Check for HTTP errors but include response body in error message
- if response.status_code != 200:
- error_detail = response_json.get("error", response_json)
- self._log(f"HTTP {response.status_code}: {error_detail}")
- raise RuntimeError(f"API request failed (HTTP {response.status_code}): {error_detail}")
-
- return response_json
- except requests.exceptions.Timeout:
- raise RuntimeError("API request timed out after 120 seconds")
- except requests.exceptions.RequestException as e:
- raise RuntimeError(f"API request failed: {str(e)}")
-
- def _extract_image_from_response(self, response: Dict[str, Any]) -> Optional[bytes]:
- """
- Extract base64-encoded image from API response.
-
- For Nano Banana 2, images are returned in the 'images' field of the message,
- not in the 'content' field.
-
- Args:
- response: API response dictionary
-
- Returns:
- Image bytes or None if not found
- """
- try:
- choices = response.get("choices", [])
- if not choices:
- self._log("No choices in response")
- return None
-
- message = choices[0].get("message", {})
-
- # IMPORTANT: Nano Banana 2 returns images in the 'images' field
- images = message.get("images", [])
- if images and len(images) > 0:
- self._log(f"Found {len(images)} image(s) in 'images' field")
-
- # Get first image
- first_image = images[0]
- if isinstance(first_image, dict):
- # Extract image_url
- if first_image.get("type") == "image_url":
- url = first_image.get("image_url", {})
- if isinstance(url, dict):
- url = url.get("url", "")
-
- if url and url.startswith("data:image"):
- # Extract base64 data after comma
- if "," in url:
- base64_str = url.split(",", 1)[1]
- # Clean whitespace
- base64_str = base64_str.replace('\n', '').replace('\r', '').replace(' ', '')
- self._log(f"Extracted base64 data (length: {len(base64_str)})")
- return base64.b64decode(base64_str)
-
- # Fallback: check content field (for other models or future changes)
- content = message.get("content", "")
-
- if self.verbose:
- self._log(f"Content type: {type(content)}, length: {len(str(content))}")
-
- # Handle string content
- if isinstance(content, str) and "data:image" in content:
- import re
- match = re.search(r'data:image/[^;]+;base64,([A-Za-z0-9+/=\n\r]+)', content, re.DOTALL)
- if match:
- base64_str = match.group(1).replace('\n', '').replace('\r', '').replace(' ', '')
- self._log(f"Found image in content field (length: {len(base64_str)})")
- return base64.b64decode(base64_str)
-
- # Handle list content
- if isinstance(content, list):
- for i, block in enumerate(content):
- if isinstance(block, dict) and block.get("type") == "image_url":
- url = block.get("image_url", {})
- if isinstance(url, dict):
- url = url.get("url", "")
- if url and url.startswith("data:image") and "," in url:
- base64_str = url.split(",", 1)[1].replace('\n', '').replace('\r', '').replace(' ', '')
- self._log(f"Found image in content block {i}")
- return base64.b64decode(base64_str)
-
- self._log("No image data found in response")
- return None
-
- except Exception as e:
- self._log(f"Error extracting image: {str(e)}")
- import traceback
- if self.verbose:
- traceback.print_exc()
- return None
-
- def _image_to_base64(self, image_path: str) -> str:
- """
- Convert image file to base64 data URL.
-
- Args:
- image_path: Path to image file
-
- Returns:
- Base64 data URL string
- """
- with open(image_path, "rb") as f:
- image_data = f.read()
-
- # Determine image type from extension
- ext = Path(image_path).suffix.lower()
- mime_type = {
- ".png": "image/png",
- ".jpg": "image/jpeg",
- ".jpeg": "image/jpeg",
- ".gif": "image/gif",
- ".webp": "image/webp"
- }.get(ext, "image/png")
-
- base64_data = base64.b64encode(image_data).decode("utf-8")
- return f"data:{mime_type};base64,{base64_data}"
-
- def generate_image(self, prompt: str) -> Optional[bytes]:
- """
- Generate an image using Nano Banana 2.
-
- Args:
- prompt: Description of the diagram to generate
-
- Returns:
- Image bytes or None if generation failed
- """
- self._last_error = None # Reset error
-
- messages = [
- {
- "role": "user",
- "content": prompt
- }
- ]
-
- try:
- response = self._make_request(
- model=self.image_model,
- messages=messages,
- modalities=["image", "text"]
- )
-
- # Debug: print response structure if verbose
- if self.verbose:
- self._log(f"Response keys: {response.keys()}")
- if "error" in response:
- self._log(f"API Error: {response['error']}")
- if "choices" in response and response["choices"]:
- msg = response["choices"][0].get("message", {})
- self._log(f"Message keys: {msg.keys()}")
- # Show content preview without printing huge base64 data
- content = msg.get("content", "")
- if isinstance(content, str):
- preview = content[:200] + "..." if len(content) > 200 else content
- self._log(f"Content preview: {preview}")
- elif isinstance(content, list):
- self._log(f"Content is list with {len(content)} items")
- for i, item in enumerate(content[:3]):
- if isinstance(item, dict):
- self._log(f" Item {i}: type={item.get('type')}")
-
- # Check for API errors in response
- if "error" in response:
- error_msg = response["error"]
- if isinstance(error_msg, dict):
- error_msg = error_msg.get("message", str(error_msg))
- self._last_error = f"API Error: {error_msg}"
- print(f"✗ {self._last_error}")
- return None
-
- image_data = self._extract_image_from_response(response)
- if image_data:
- self._log(f"✓ Generated image ({len(image_data)} bytes)")
- else:
- self._last_error = "No image data in API response - model may not support image generation"
- self._log(f"✗ {self._last_error}")
- # Additional debug info when image extraction fails
- if self.verbose and "choices" in response:
- msg = response["choices"][0].get("message", {})
- self._log(f"Full message structure: {json.dumps({k: type(v).__name__ for k, v in msg.items()})}")
-
- return image_data
- except RuntimeError as e:
- self._last_error = str(e)
- self._log(f"✗ Generation failed: {self._last_error}")
- return None
- except Exception as e:
- self._last_error = f"Unexpected error: {str(e)}"
- self._log(f"✗ Generation failed: {self._last_error}")
- import traceback
- if self.verbose:
- traceback.print_exc()
- return None
-
- def review_image(self, image_path: str, original_prompt: str,
- iteration: int, doc_type: str = "default",
- max_iterations: int = 2) -> Tuple[str, float, bool]:
- """
- Review generated image using Gemini 3.1 Pro Preview for quality analysis.
-
- Uses Gemini 3.1 Pro Preview's superior vision and reasoning capabilities to
- evaluate the schematic quality and determine if regeneration is needed.
-
- Args:
- image_path: Path to the generated image
- original_prompt: Original user prompt
- iteration: Current iteration number
- doc_type: Document type (journal, poster, presentation, etc.)
- max_iterations: Maximum iterations allowed
-
- Returns:
- Tuple of (critique text, quality score 0-10, needs_improvement bool)
- """
- # Use Gemini 3.1 Pro Preview for review - excellent vision and analysis
- image_data_url = self._image_to_base64(image_path)
-
- # Get quality threshold for this document type
- threshold = self.QUALITY_THRESHOLDS.get(doc_type.lower(),
- self.QUALITY_THRESHOLDS["default"])
-
- review_prompt = f"""You are an expert reviewer evaluating a scientific diagram for publication quality.
-
-ORIGINAL REQUEST: {original_prompt}
-
-DOCUMENT TYPE: {doc_type} (quality threshold: {threshold}/10)
-ITERATION: {iteration}/{max_iterations}
-
-Carefully evaluate this diagram on these criteria:
-
-1. **Scientific Accuracy** (0-2 points)
- - Correct representation of concepts
- - Proper notation and symbols
- - Accurate relationships shown
-
-2. **Clarity and Readability** (0-2 points)
- - Easy to understand at a glance
- - Clear visual hierarchy
- - No ambiguous elements
-
-3. **Label Quality** (0-2 points)
- - All important elements labeled
- - Labels are readable (appropriate font size)
- - Consistent labeling style
-
-4. **Layout and Composition** (0-2 points)
- - Logical flow (top-to-bottom or left-to-right)
- - Balanced use of space
- - No overlapping elements
-
-5. **Professional Appearance** (0-2 points)
- - Publication-ready quality
- - Clean, crisp lines and shapes
- - Appropriate colors/contrast
-
-RESPOND IN THIS EXACT FORMAT:
-SCORE: [total score 0-10]
-
-STRENGTHS:
-- [strength 1]
-- [strength 2]
-
-ISSUES:
-- [issue 1 if any]
-- [issue 2 if any]
-
-VERDICT: [ACCEPTABLE or NEEDS_IMPROVEMENT]
-
-If score >= {threshold}, the diagram is ACCEPTABLE for {doc_type} publication.
-If score < {threshold}, mark as NEEDS_IMPROVEMENT with specific suggestions."""
-
- messages = [
- {
- "role": "user",
- "content": [
- {
- "type": "text",
- "text": review_prompt
- },
- {
- "type": "image_url",
- "image_url": {
- "url": image_data_url
- }
- }
- ]
- }
- ]
-
- try:
- # Use Gemini 3.1 Pro Preview for high-quality review
- response = self._make_request(
- model=self.review_model,
- messages=messages
- )
-
- # Extract text response
- choices = response.get("choices", [])
- if not choices:
- return "Image generated successfully", 8.0
-
- message = choices[0].get("message", {})
- content = message.get("content", "")
-
- # Check reasoning field (Nano Banana 2 puts analysis here)
- reasoning = message.get("reasoning", "")
- if reasoning and not content:
- content = reasoning
-
- if isinstance(content, list):
- # Extract text from content blocks
- text_parts = []
- for block in content:
- if isinstance(block, dict) and block.get("type") == "text":
- text_parts.append(block.get("text", ""))
- content = "\n".join(text_parts)
-
- # Try to extract score
- score = 7.5 # Default score if extraction fails
- import re
-
- # Look for SCORE: X or SCORE: X/10 format
- score_match = re.search(r'SCORE:\s*(\d+(?:\.\d+)?)', content, re.IGNORECASE)
- if score_match:
- score = float(score_match.group(1))
- else:
- # Fallback: look for any score pattern
- score_match = re.search(r'(?:score|rating|quality)[:\s]+(\d+(?:\.\d+)?)\s*(?:/\s*10)?', content, re.IGNORECASE)
- if score_match:
- score = float(score_match.group(1))
-
- # Determine if improvement is needed based on verdict or score
- needs_improvement = False
- if "NEEDS_IMPROVEMENT" in content.upper():
- needs_improvement = True
- elif score < threshold:
- needs_improvement = True
-
- self._log(f"✓ Review complete (Score: {score}/10, Threshold: {threshold}/10)")
- self._log(f" Verdict: {'Needs improvement' if needs_improvement else 'Acceptable'}")
-
- return (content if content else "Image generated successfully",
- score,
- needs_improvement)
- except Exception as e:
- self._log(f"Review skipped: {str(e)}")
- # Don't fail the whole process if review fails - assume acceptable
- return "Image generated successfully (review skipped)", 7.5, False
-
- def improve_prompt(self, original_prompt: str, critique: str,
- iteration: int) -> str:
- """
- Improve the generation prompt based on critique.
-
- Args:
- original_prompt: Original user prompt
- critique: Review critique from previous iteration
- iteration: Current iteration number
-
- Returns:
- Improved prompt for next generation
- """
- improved_prompt = f"""{self.SCIENTIFIC_DIAGRAM_GUIDELINES}
-
-USER REQUEST: {original_prompt}
-
-ITERATION {iteration}: Based on previous feedback, address these specific improvements:
-{critique}
-
-Generate an improved version that addresses all the critique points while maintaining scientific accuracy and professional quality."""
-
- return improved_prompt
-
- def generate_iterative(self, user_prompt: str, output_path: str,
- iterations: int = 2,
- doc_type: str = "default") -> Dict[str, Any]:
- """
- Generate scientific schematic with smart iterative refinement.
-
- Only regenerates if the quality score is below the threshold for the
- specified document type. This saves API calls and time when the first
- generation is already good enough.
-
- Args:
- user_prompt: User's description of desired diagram
- output_path: Path to save final image
- iterations: Maximum refinement iterations (default: 2, max: 2)
- doc_type: Document type for quality threshold (journal, poster, etc.)
-
- Returns:
- Dictionary with generation results and metadata
- """
- output_path = Path(output_path)
- output_dir = output_path.parent
- output_dir.mkdir(parents=True, exist_ok=True)
-
- base_name = output_path.stem
- extension = output_path.suffix or ".png"
-
- # Get quality threshold for this document type
- threshold = self.QUALITY_THRESHOLDS.get(doc_type.lower(),
- self.QUALITY_THRESHOLDS["default"])
-
- results = {
- "user_prompt": user_prompt,
- "doc_type": doc_type,
- "quality_threshold": threshold,
- "iterations": [],
- "final_image": None,
- "final_score": 0.0,
- "success": False,
- "early_stop": False,
- "early_stop_reason": None
- }
-
- current_prompt = f"""{self.SCIENTIFIC_DIAGRAM_GUIDELINES}
-
-USER REQUEST: {user_prompt}
-
-Generate a publication-quality scientific diagram that meets all the guidelines above."""
-
- print(f"\n{'='*60}")
- print(f"Generating Scientific Schematic")
- print(f"{'='*60}")
- print(f"Description: {user_prompt}")
- print(f"Document Type: {doc_type}")
- print(f"Quality Threshold: {threshold}/10")
- print(f"Max Iterations: {iterations}")
- print(f"Output: {output_path}")
- print(f"{'='*60}\n")
-
- for i in range(1, iterations + 1):
- print(f"\n[Iteration {i}/{iterations}]")
- print("-" * 40)
-
- # Generate image
- print(f"Generating image...")
- image_data = self.generate_image(current_prompt)
-
- if not image_data:
- error_msg = getattr(self, '_last_error', 'Image generation failed - no image data returned')
- print(f"✗ Generation failed: {error_msg}")
- results["iterations"].append({
- "iteration": i,
- "success": False,
- "error": error_msg
- })
- continue
-
- # Save iteration image
- iter_path = output_dir / f"{base_name}_v{i}{extension}"
- with open(iter_path, "wb") as f:
- f.write(image_data)
- print(f"✓ Saved: {iter_path}")
-
- # Review image using Gemini 3.1 Pro Preview
- print(f"Reviewing image with Gemini 3.1 Pro Preview...")
- critique, score, needs_improvement = self.review_image(
- str(iter_path), user_prompt, i, doc_type, iterations
- )
- print(f"✓ Score: {score}/10 (threshold: {threshold}/10)")
-
- # Save iteration results
- iteration_result = {
- "iteration": i,
- "image_path": str(iter_path),
- "prompt": current_prompt,
- "critique": critique,
- "score": score,
- "needs_improvement": needs_improvement,
- "success": True
- }
- results["iterations"].append(iteration_result)
-
- # Check if quality is acceptable - STOP EARLY if so
- if not needs_improvement:
- print(f"\n✓ Quality meets {doc_type} threshold ({score} >= {threshold})")
- print(f" No further iterations needed!")
- results["final_image"] = str(iter_path)
- results["final_score"] = score
- results["success"] = True
- results["early_stop"] = True
- results["early_stop_reason"] = f"Quality score {score} meets threshold {threshold} for {doc_type}"
- break
-
- # If this is the last iteration, we're done regardless
- if i == iterations:
- print(f"\n⚠ Maximum iterations reached")
- results["final_image"] = str(iter_path)
- results["final_score"] = score
- results["success"] = True
- break
-
- # Quality below threshold - improve prompt for next iteration
- print(f"\n⚠ Quality below threshold ({score} < {threshold})")
- print(f"Improving prompt based on feedback...")
- current_prompt = self.improve_prompt(user_prompt, critique, i + 1)
-
- # Copy final version to output path
- if results["success"] and results["final_image"]:
- final_iter_path = Path(results["final_image"])
- if final_iter_path != output_path:
- import shutil
- shutil.copy(final_iter_path, output_path)
- print(f"\n✓ Final image: {output_path}")
-
- # Save review log
- log_path = output_dir / f"{base_name}_review_log.json"
- with open(log_path, "w") as f:
- json.dump(results, f, indent=2)
- print(f"✓ Review log: {log_path}")
-
- print(f"\n{'='*60}")
- print(f"Generation Complete!")
- print(f"Final Score: {results['final_score']}/10")
- if results["early_stop"]:
- print(f"Iterations Used: {len([r for r in results['iterations'] if r.get('success')])}/{iterations} (early stop)")
- print(f"{'='*60}\n")
-
- return results
-
-
-def main():
- """Command-line interface."""
- parser = argparse.ArgumentParser(
- description="Generate scientific schematics using AI with smart iterative refinement",
- formatter_class=argparse.RawDescriptionHelpFormatter,
- epilog="""
-Examples:
- # Generate a flowchart for a journal paper
- python generate_schematic_ai.py "CONSORT participant flow diagram" -o flowchart.png --doc-type journal
-
- # Generate neural network architecture for presentation (lower threshold)
- python generate_schematic_ai.py "Transformer encoder-decoder architecture" -o transformer.png --doc-type presentation
-
- # Generate with custom max iterations for poster
- python generate_schematic_ai.py "Biological signaling pathway" -o pathway.png --iterations 2 --doc-type poster
-
- # Verbose output
- python generate_schematic_ai.py "Circuit diagram" -o circuit.png -v
-
-Document Types (quality thresholds):
- journal 8.5/10 - Nature, Science, peer-reviewed journals
- conference 8.0/10 - Conference papers
- thesis 8.0/10 - Dissertations, theses
- grant 8.0/10 - Grant proposals
- preprint 7.5/10 - arXiv, bioRxiv, etc.
- report 7.5/10 - Technical reports
- poster 7.0/10 - Academic posters
- presentation 6.5/10 - Slides, talks
- default 7.5/10 - General purpose
-
-Note: Multiple iterations only occur if quality is BELOW the threshold.
- If the first generation meets the threshold, no extra API calls are made.
-
-Environment:
- OPENROUTER_API_KEY OpenRouter API key (required)
- """
- )
-
- parser.add_argument("prompt", help="Description of the diagram to generate")
- parser.add_argument("-o", "--output", required=True,
- help="Output image path (e.g., diagram.png)")
- parser.add_argument("--iterations", type=int, default=2,
- help="Maximum refinement iterations (default: 2, max: 2)")
- parser.add_argument("--doc-type", default="default",
- choices=["journal", "conference", "poster", "presentation",
- "report", "grant", "thesis", "preprint", "default"],
- help="Document type for quality threshold (default: default)")
- parser.add_argument("--api-key", help="OpenRouter API key (or set OPENROUTER_API_KEY)")
- parser.add_argument("-v", "--verbose", action="store_true",
- help="Verbose output")
-
- args = parser.parse_args()
-
- # Check for API key
- api_key = args.api_key or os.getenv("OPENROUTER_API_KEY")
- if not api_key:
- print("Error: OPENROUTER_API_KEY environment variable not set")
- print("\nSet it with:")
- print(" export OPENROUTER_API_KEY='your_api_key'")
- print("\nOr provide via --api-key flag")
- sys.exit(1)
-
- # Validate iterations - enforce max of 2
- if args.iterations < 1 or args.iterations > 2:
- print("Error: Iterations must be between 1 and 2")
- sys.exit(1)
-
- try:
- generator = ScientificSchematicGenerator(api_key=api_key, verbose=args.verbose)
- results = generator.generate_iterative(
- user_prompt=args.prompt,
- output_path=args.output,
- iterations=args.iterations,
- doc_type=args.doc_type
- )
-
- if results["success"]:
- print(f"\n✓ Success! Image saved to: {args.output}")
- if results.get("early_stop"):
- print(f" (Completed in {len([r for r in results['iterations'] if r.get('success')])} iteration(s) - quality threshold met)")
- sys.exit(0)
- else:
- print(f"\n✗ Generation failed. Check review log for details.")
- sys.exit(1)
- except Exception as e:
- print(f"\n✗ Error: {str(e)}")
- sys.exit(1)
-
-
-if __name__ == "__main__":
- main()
-
diff --git a/skills/venue-templates/scripts/query_template.py b/skills/venue-templates/scripts/query_template.py
index 95466e94..52863464 100755
--- a/skills/venue-templates/scripts/query_template.py
+++ b/skills/venue-templates/scripts/query_template.py
@@ -1,260 +1,202 @@
#!/usr/bin/env python3
-"""
-Query Template Script
-Search and retrieve venue-specific templates by name, type, or keywords.
+"""List and query the templates actually bundled with venue-templates.
-Usage:
- python query_template.py --venue "Nature" --type "article"
- python query_template.py --keyword "machine learning"
- python query_template.py --list-all
- python query_template.py --venue "NeurIPS" --requirements
+Examples:
+ python scripts/query_template.py --list-all
+ python scripts/query_template.py --venue NeurIPS --requirements
+ python scripts/query_template.py --type grants
+ python scripts/query_template.py --keyword author-year
"""
+from __future__ import annotations
+
import argparse
-import os
import json
from pathlib import Path
-# Template database
+
+CHECKED_DATE = "2026-07-20"
+
TEMPLATES = {
"journals": {
"nature": {
"file": "nature_article.tex",
- "full_name": "Nature",
- "description": "Top-tier multidisciplinary science journal",
- "page_limit": "~3000 words",
- "citation_style": "Superscript numbered",
- "format": "Single column"
+ "full_name": "Nature-oriented article scaffold",
+ "status": "Generic writing scaffold; not an official Nature template.",
+ "source": "https://www.nature.com/nature/for-authors/initial-submission",
+ "requirements": "Initial submissions are format-flexible within reason; check the exact article type.",
},
- "neurips": {
+ "plos-one": {
+ "file": "plos_one.tex",
+ "full_name": "PLOS ONE-oriented article scaffold",
+ "status": "Drafting scaffold; compare with the current official PLOS LaTeX package.",
+ "source": "https://journals.plos.org/plosone/s/submission-guidelines",
+ "requirements": "Follow the current PLOS ONE submission and file-upload instructions.",
+ },
+ "neurips-2026": {
"file": "neurips_article.tex",
- "full_name": "NeurIPS (Neural Information Processing Systems)",
- "description": "Top-tier machine learning conference",
- "page_limit": "8 pages + unlimited refs",
- "citation_style": "Numbered [1]",
- "format": "Two column",
- "anonymization": "Required (double-blind)"
+ "full_name": "NeurIPS 2026 paper wrapper",
+ "status": "Requires the official neurips_2026.sty and checklist files.",
+ "source": "https://neurips.cc/Conferences/2026/CallForPapers",
+ "requirements": (
+ "Main track: 9 content pages; acknowledgments, references, checklist, "
+ "and optional technical appendices do not count. Initial submission is anonymous."
+ ),
+ },
+ "elsevier-numeric": {
+ "file": "elsarticle-template-num.tex",
+ "full_name": "Elsevier elsarticle numeric example",
+ "status": "Bundled example; the journal's Guide for Authors controls.",
+ "source": "https://www.elsevier.com/researcher/author/policies-and-guidelines/latex-instructions",
+ "requirements": "Numeric citations using the bundled elsarticle-num.bst.",
+ },
+ "elsevier-numeric-names": {
+ "file": "elsarticle-template-num-names.tex",
+ "full_name": "Elsevier elsarticle sorted numeric example",
+ "status": "Bundled example; the journal's Guide for Authors controls.",
+ "source": "https://www.elsevier.com/researcher/author/policies-and-guidelines/latex-instructions",
+ "requirements": "Sorted/compressed numeric citations using elsarticle-num-names.bst.",
+ },
+ "elsevier-author-year": {
+ "file": "elsarticle-template-harv.tex",
+ "full_name": "Elsevier elsarticle author-year example",
+ "status": "Bundled example; the journal's Guide for Authors controls.",
+ "source": "https://www.elsevier.com/researcher/author/policies-and-guidelines/latex-instructions",
+ "requirements": "Author-year citations using the bundled elsarticle-harv.bst.",
},
- "plos_one": {
- "file": "plos_one.tex",
- "full_name": "PLOS ONE",
- "description": "Open-access multidisciplinary journal",
- "page_limit": "No limit",
- "citation_style": "Vancouver [1]",
- "format": "Single column"
- }
},
"posters": {
"beamerposter": {
"file": "beamerposter_academic.tex",
- "full_name": "Beamerposter Academic",
- "description": "Classic academic conference poster using beamerposter",
- "size": "A0, customizable",
- "package": "beamerposter"
+ "full_name": "Venue-agnostic beamerposter scaffold",
+ "status": "Set dimensions and orientation from the event's current presenter instructions.",
+ "source": None,
+ "requirements": "A0 portrait by default; customize size before use.",
}
},
"grants": {
"nsf": {
"file": "nsf_proposal_template.tex",
- "full_name": "NSF Standard Grant",
- "description": "National Science Foundation research proposal",
- "page_limit": "15 pages (project description)",
- "key_sections": "Project Summary, Project Description, Broader Impacts"
+ "full_name": "NSF narrative planning scaffold",
+ "status": "Not an NSF-issued upload package; split components in the submission portal.",
+ "source": "https://www.nsf.gov/policies/pappg",
+ "requirements": (
+ "Check the current PAPPG and solicitation. Use SciENcv for required "
+ "senior/key-person forms."
+ ),
},
- "nih_specific_aims": {
+ "nih-specific-aims": {
"file": "nih_specific_aims.tex",
- "full_name": "NIH Specific Aims Page",
- "description": "Most critical page of NIH proposals",
- "page_limit": "1 page (strictly enforced)",
- "key_sections": "Hook, Hypothesis, 3 Aims, Payoff"
- }
- }
+ "full_name": "NIH Specific Aims writing scaffold",
+ "status": "Drafting scaffold; the NOFO and current application guide control.",
+ "source": (
+ "https://grants.nih.gov/grants-process/write-application/"
+ "how-to-apply-application-guide/page-limits"
+ ),
+ "requirements": "Specific Aims is generally limited to one page unless the NOFO says otherwise.",
+ },
+ },
}
-def get_skill_path():
- """Get the path to the venue-templates skill directory."""
- # Assume script is in .claude/skills/venue-templates/scripts/
- script_dir = Path(__file__).parent
- skill_dir = script_dir.parent
- return skill_dir
-def search_templates(venue=None, template_type=None, keyword=None):
- """Search for templates matching criteria."""
+def skill_path() -> Path:
+ return Path(__file__).resolve().parent.parent
+
+
+def template_path(category: str, filename: str) -> Path:
+ return skill_path() / "assets" / category / filename
+
+
+def search_templates(
+ venue: str | None = None,
+ template_type: str | None = None,
+ keyword: str | None = None,
+) -> list[dict]:
results = []
-
- for cat_name, category in TEMPLATES.items():
- # Filter by type if specified
- if template_type and cat_name != template_type and template_type != "all":
+ for category_name, category in TEMPLATES.items():
+ if template_type and template_type != "all" and category_name != template_type:
continue
-
- for temp_id, template in category.items():
- # Filter by venue name
- if venue:
- venue_lower = venue.lower()
- if venue_lower not in temp_id and venue_lower not in template.get("full_name", "").lower():
- continue
-
- # Filter by keyword
- if keyword:
- keyword_lower = keyword.lower()
- search_text = json.dumps(template).lower()
- if keyword_lower not in search_text:
- continue
-
- results.append({
- "id": temp_id,
- "category": cat_name,
- "file": template["file"],
- "full_name": template.get("full_name", temp_id),
- "description": template.get("description", ""),
- "details": template
- })
-
+
+ for template_id, template in category.items():
+ searchable = json.dumps(
+ {"id": template_id, "category": category_name, **template}
+ ).lower()
+ if venue and venue.lower() not in searchable:
+ continue
+ if keyword and keyword.lower() not in searchable:
+ continue
+
+ results.append(
+ {
+ "id": template_id,
+ "category": category_name,
+ **template,
+ }
+ )
return results
-def list_all_templates():
- """List all available templates."""
- print("\n=== AVAILABLE TEMPLATES ===\n")
-
- for cat_name, category in TEMPLATES.items():
- print(f"\n{cat_name.upper()}:")
- for temp_id, template in category.items():
- print(f" • {template.get('full_name', temp_id)}")
- print(f" File: {template['file']}")
- if "description" in template:
- print(f" Description: {template['description']}")
- print()
-def print_template_info(template):
- """Print detailed information about a template."""
- print(f"\n{'='*60}")
- print(f"Template: {template['full_name']}")
- print(f"{'='*60}")
- print(f"Category: {template['category']}")
- print(f"File: {template['file']}")
-
- details = template['details']
-
- print(f"\nDescription: {details.get('description', 'N/A')}")
-
- if 'page_limit' in details:
- print(f"Page Limit: {details['page_limit']}")
- if 'citation_style' in details:
- print(f"Citation Style: {details['citation_style']}")
- if 'format' in details:
- print(f"Format: {details['format']}")
- if 'anonymization' in details:
- print(f"⚠️ Anonymization: {details['anonymization']}")
- if 'size' in details:
- print(f"Poster Size: {details['size']}")
- if 'package' in details:
- print(f"LaTeX Package: {details['package']}")
- if 'key_sections' in details:
- print(f"Key Sections: {details['key_sections']}")
-
- # Print full path to template
- skill_path = get_skill_path()
- template_path = skill_path / "assets" / template['category'] / template['file']
- print(f"\nFull Path: {template_path}")
-
- if template_path.exists():
- print("✓ Template file exists")
+def print_template(template: dict, detailed: bool = True) -> None:
+ path = template_path(template["category"], template["file"])
+ print(f"\n{template['full_name']}")
+ print(f" ID: {template['id']}")
+ print(f" Category: {template['category']}")
+ print(f" File: {path}")
+ print(f" Exists: {'yes' if path.is_file() else 'NO'}")
+ if not detailed:
+ return
+
+ print(f" Status: {template['status']}")
+ print(f" Requirements note: {template['requirements']}")
+ if template["source"]:
+ print(f" Official source: {template['source']}")
+ print(f" Source checked: {CHECKED_DATE}; recheck before submission")
else:
- print("✗ Template file not found")
-
- print()
+ print(" Official source: event-specific presenter instructions required")
-def print_requirements(venue):
- """Print formatting requirements for a venue."""
- results = search_templates(venue=venue)
-
- if not results:
- print(f"No templates found for venue: {venue}")
- return
-
- template = results[0] # Take first match
- details = template['details']
-
- print(f"\n{'='*60}")
- print(f"FORMATTING REQUIREMENTS: {template['full_name']}")
- print(f"{'='*60}\n")
-
- if 'page_limit' in details:
- print(f"📄 Page Limit: {details['page_limit']}")
- if 'format' in details:
- print(f"📐 Format: {details['format']}")
- if 'citation_style' in details:
- print(f"📚 Citation Style: {details['citation_style']}")
- if 'anonymization' in details:
- print(f"🔒 Anonymization: {details['anonymization']}")
- if 'size' in details:
- print(f"📏 Size: {details['size']}")
-
- print(f"\n💡 For detailed requirements, see:")
- skill_path = get_skill_path()
-
- if template['category'] == "journals":
- print(f" {skill_path}/references/journals_formatting.md")
- elif template['category'] == "posters":
- print(f" {skill_path}/references/posters_guidelines.md")
- elif template['category'] == "grants":
- print(f" {skill_path}/references/grants_requirements.md")
-
- print()
-def main():
+def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(
- description="Query venue-specific LaTeX templates",
- formatter_class=argparse.RawDescriptionHelpFormatter,
- epilog="""
-Examples:
- %(prog)s --list-all
- %(prog)s --venue "Nature" --type journals
- %(prog)s --keyword "machine learning"
- %(prog)s --venue "NeurIPS" --requirements
- """
+ description="Query templates actually bundled with venue-templates"
+ )
+ parser.add_argument("--venue", help="Venue or agency name")
+ parser.add_argument(
+ "--type",
+ choices=["journals", "posters", "grants", "all"],
+ dest="template_type",
+ help="Template category",
+ )
+ parser.add_argument("--keyword", help="Search all template metadata")
+ parser.add_argument("--list-all", action="store_true", help="List every template")
+ parser.add_argument(
+ "--requirements",
+ action="store_true",
+ help="Show status, requirement note, and official source",
+ )
+ return parser.parse_args()
+
+
+def main() -> int:
+ args = parse_args()
+ if not any([args.list_all, args.venue, args.template_type, args.keyword]):
+ print("Specify --list-all, --venue, --type, or --keyword.")
+ return 2
+
+ results = search_templates(
+ venue=args.venue,
+ template_type="all" if args.list_all else args.template_type,
+ keyword=args.keyword,
)
-
- parser.add_argument('--venue', type=str, help='Venue name (e.g., "Nature", "NeurIPS")')
- parser.add_argument('--type', type=str, choices=['journals', 'posters', 'grants', 'all'],
- help='Template type')
- parser.add_argument('--keyword', type=str, help='Search keyword')
- parser.add_argument('--list-all', action='store_true', help='List all available templates')
- parser.add_argument('--requirements', action='store_true',
- help='Show formatting requirements for venue')
-
- args = parser.parse_args()
-
- # List all templates
- if args.list_all:
- list_all_templates()
- return
-
- # Show requirements
- if args.requirements:
- if not args.venue:
- print("Error: --requirements requires --venue")
- parser.print_help()
- return
- print_requirements(args.venue)
- return
-
- # Search for templates
- if not any([args.venue, args.type, args.keyword]):
- parser.print_help()
- return
-
- results = search_templates(venue=args.venue, template_type=args.type, keyword=args.keyword)
-
if not results:
- print("No templates found matching your criteria.")
- return
-
- print(f"\nFound {len(results)} template(s):\n")
-
+ print("No bundled templates match the query.")
+ print("Use the venue's official author instructions when no asset is bundled.")
+ return 1
+
+ print(f"Bundled templates: {len(results)}")
for result in results:
- print_template_info(result)
+ print_template(result, detailed=args.requirements or not args.list_all)
+ return 0
-if __name__ == "__main__":
- main()
+if __name__ == "__main__":
+ raise SystemExit(main())
diff --git a/skills/venue-templates/scripts/validate_format.py b/skills/venue-templates/scripts/validate_format.py
index 262ede34..5c8488a3 100755
--- a/skills/venue-templates/scripts/validate_format.py
+++ b/skills/venue-templates/scripts/validate_format.py
@@ -1,255 +1,321 @@
#!/usr/bin/env python3
-"""
-Validate Format Script
-Check if document meets venue-specific formatting requirements.
+"""Inspect a submission PDF using a verified limit or an explicit source.
+
+This tool does not infer where references or appendices begin and cannot prove
+margin or font-size compliance. Supply --content-pages after counting pages
+according to the official venue rule.
-Usage:
- python validate_format.py --file my_paper.pdf --venue "Nature" --check-all
- python validate_format.py --file my_paper.pdf --venue "NeurIPS" --check page-count,margins
- python validate_format.py --file my_paper.pdf --venue "PLOS ONE" --report validation_report.txt
+Examples:
+ python scripts/validate_format.py --file paper.pdf --venue icml-2026 \
+ --content-pages 8
+ python scripts/validate_format.py --file proposal.pdf --max-pages 15 \
+ --content-pages 15 --source-url https://www.nsf.gov/policies/pappg
"""
+from __future__ import annotations
+
import argparse
import subprocess
+from datetime import datetime, timezone
from pathlib import Path
-import re
-
-# Venue requirements database
-VENUE_REQUIREMENTS = {
- "nature": {
- "page_limit": 5, # Approximate for ~3000 words
- "margins": {"top": 2.5, "bottom": 2.5, "left": 2.5, "right": 2.5}, # cm
- "font_size": 12, # pt
- "font_family": "Times",
- "line_spacing": "double"
+
+
+PRESETS = {
+ "neurips-2026": {
+ "max_content_pages": 9,
+ "excluded": "acknowledgments, references, checklist, and optional technical appendices",
+ "source": "https://neurips.cc/Conferences/2026/CallForPapers",
+ "checked": "2026-07-20",
},
- "neurips": {
- "page_limit": 8, # Excluding refs
- "margins": {"top": 2.54, "bottom": 2.54, "left": 2.54, "right": 2.54}, # cm (1 inch)
- "font_size": 10,
- "font_family": "Times",
- "format": "two-column"
+ "icml-2026": {
+ "max_content_pages": 8,
+ "excluded": "references and appendices",
+ "source": "https://icml.cc/Conferences/2026/AuthorInstructions",
+ "checked": "2026-07-20",
},
- "plos_one": {
- "page_limit": None, # No limit
- "margins": {"top": 2.54, "bottom": 2.54, "left": 2.54, "right": 2.54},
- "font_size": 10,
- "font_family": "Arial",
- "line_spacing": "double"
+ "iclr-2026": {
+ "max_content_pages": 9,
+ "excluded": "references and appendices",
+ "source": "https://iclr.cc/Conferences/2026/AuthorGuide",
+ "checked": "2026-07-20",
},
- "nsf": {
- "page_limit": 15, # Project description
- "margins": {"top": 2.54, "bottom": 2.54, "left": 2.54, "right": 2.54}, # 1 inch required
- "font_size": 11, # Minimum
- "font_family": "Times Roman",
- "line_spacing": "single or double"
+ "cvpr-2026": {
+ "max_content_pages": 8,
+ "excluded": "cited references only",
+ "source": "https://cvpr.thecvf.com/Conferences/2026/AuthorGuidelines",
+ "checked": "2026-07-20",
+ },
+ "nsf-standard": {
+ "max_content_pages": 15,
+ "excluded": "all separately uploaded proposal components",
+ "source": "https://www.nsf.gov/policies/pappg",
+ "checked": "2026-07-20",
+ },
+ "nih-r01": {
+ "max_content_pages": 12,
+ "excluded": "all attachments outside the Research Strategy",
+ "source": (
+ "https://grants.nih.gov/grants-process/write-application/"
+ "how-to-apply-application-guide/page-limits"
+ ),
+ "checked": "2026-07-20",
},
- "nih": {
- "page_limit": 12, # Research strategy
- "margins": {"top": 1.27, "bottom": 1.27, "left": 1.27, "right": 1.27}, # 0.5 inch minimum
- "font_size": 11, # Arial 11pt minimum
- "font_family": "Arial",
- "line_spacing": "any"
- }
}
-def get_pdf_info(pdf_path):
- """Extract information from PDF using pdfinfo."""
+
+def run_poppler(command: str, pdf_path: Path) -> subprocess.CompletedProcess[str] | None:
try:
- result = subprocess.run(
- ['pdfinfo', str(pdf_path)],
+ return subprocess.run(
+ [command, str(pdf_path)],
capture_output=True,
text=True,
- check=True
+ check=True,
)
-
- info = {}
- for line in result.stdout.split('\n'):
- if ':' in line:
- key, value = line.split(':', 1)
- info[key.strip()] = value.strip()
-
- return info
except FileNotFoundError:
- print("⚠️ pdfinfo not found. Install poppler-utils for full PDF analysis.")
- print(" macOS: brew install poppler")
- print(" Linux: sudo apt-get install poppler-utils")
return None
- except subprocess.CalledProcessError as e:
- print(f"Error running pdfinfo: {e}")
+ except subprocess.CalledProcessError as error:
+ message = error.stderr.strip() or str(error)
+ raise RuntimeError(f"{command} failed: {message}") from error
+
+
+def pdf_info(pdf_path: Path) -> dict[str, str] | None:
+ result = run_poppler("pdfinfo", pdf_path)
+ if result is None:
+ return None
+
+ info = {}
+ for line in result.stdout.splitlines():
+ if ":" in line:
+ key, value = line.split(":", 1)
+ info[key.strip()] = value.strip()
+ return info
+
+
+def embedded_fonts(pdf_path: Path) -> list[str] | None:
+ result = run_poppler("pdffonts", pdf_path)
+ if result is None:
return None
-def check_page_count(pdf_path, venue_reqs):
- """Check if page count is within limit."""
- pdf_info = get_pdf_info(pdf_path)
-
- if not pdf_info:
- return {"status": "skip", "message": "Could not determine page count"}
-
- pages = int(pdf_info.get('Pages', 0))
- limit = venue_reqs.get('page_limit')
-
- if limit is None:
- return {"status": "pass", "message": f"No page limit. Document has {pages} pages."}
-
- if pages <= limit:
- return {"status": "pass", "message": f"✓ Page count OK: {pages}/{limit} pages"}
- else:
- return {"status": "fail", "message": f"✗ Page count exceeded: {pages}/{limit} pages"}
-
-def check_margins(pdf_path, venue_reqs):
- """Check if margins meet requirements."""
- # Note: This is a simplified check. Full margin analysis requires more sophisticated tools.
- req_margins = venue_reqs.get('margins', {})
-
- if not req_margins:
- return {"status": "skip", "message": "No margin requirements specified"}
-
- # This is a placeholder - accurate margin checking requires parsing PDF content
+ fonts = []
+ for line in result.stdout.splitlines()[2:]:
+ fields = line.split()
+ if fields:
+ fonts.append(fields[0])
+ return sorted(set(fonts))
+
+
+def page_count_result(
+ total_pages: int | None,
+ content_pages: int | None,
+ max_content_pages: int | None,
+ excluded: str | None,
+) -> dict[str, str]:
+ if total_pages is None:
+ return {
+ "status": "skip",
+ "message": "pdfinfo is unavailable; install Poppler to inspect the PDF.",
+ }
+ if max_content_pages is None:
+ return {
+ "status": "info",
+ "message": (
+ f"Total PDF pages: {total_pages}. No limit was supplied; verify the "
+ "official instructions manually."
+ ),
+ }
+ if content_pages is None:
+ exclusion_note = f" Excluded scope: {excluded}." if excluded else ""
+ return {
+ "status": "manual",
+ "message": (
+ f"Total PDF pages: {total_pages}; maximum content pages: "
+ f"{max_content_pages}.{exclusion_note} Re-run with --content-pages "
+ "after counting according to the official rule."
+ ),
+ }
+ if content_pages > total_pages:
+ return {
+ "status": "fail",
+ "message": (
+ f"Reported content pages ({content_pages}) exceed total PDF pages "
+ f"({total_pages})."
+ ),
+ }
+ if content_pages > max_content_pages:
+ return {
+ "status": "fail",
+ "message": (
+ f"Content-page limit exceeded: {content_pages}/{max_content_pages}."
+ ),
+ }
+ return {
+ "status": "pass",
+ "message": (
+ f"Content-page count is within the supplied limit: "
+ f"{content_pages}/{max_content_pages}. Total PDF pages: {total_pages}."
+ ),
+ }
+
+
+def font_result(fonts: list[str] | None) -> dict[str, str]:
+ if fonts is None:
+ return {
+ "status": "skip",
+ "message": "pdffonts is unavailable; install Poppler to list embedded fonts.",
+ }
+ if not fonts:
+ return {
+ "status": "manual",
+ "message": "No embedded fonts were reported; inspect the PDF manually.",
+ }
return {
"status": "info",
- "message": f"ℹ️ Required margins: {req_margins} cm (manual verification recommended)"
+ "message": (
+ "Embedded font names: "
+ + ", ".join(fonts)
+ + ". This does not verify font family or point size compliance."
+ ),
}
-def check_fonts(pdf_path, venue_reqs):
- """Check fonts in PDF."""
- try:
- result = subprocess.run(
- ['pdffonts', str(pdf_path)],
- capture_output=True,
- text=True,
- check=True
+
+def metadata_result(info: dict[str, str] | None) -> dict[str, str]:
+ if info is None:
+ return {
+ "status": "skip",
+ "message": "pdfinfo is unavailable; metadata was not inspected.",
+ }
+ fields = ["Title", "Author", "Creator", "Producer"]
+ values = [f"{field}={info[field]!r}" for field in fields if info.get(field)]
+ if not values:
+ return {"status": "info", "message": "No common identity metadata fields were set."}
+ return {
+ "status": "manual",
+ "message": (
+ "PDF metadata: "
+ + "; ".join(values)
+ + ". Check these fields for blind-review identity leaks."
+ ),
+ }
+
+
+def write_report(
+ report_path: Path,
+ pdf_path: Path,
+ source_url: str | None,
+ checked: str | None,
+ results: dict[str, dict[str, str]],
+) -> None:
+ lines = [
+ "Submission PDF Inspection",
+ "=" * 60,
+ f"Generated: {datetime.now(timezone.utc).isoformat()}",
+ f"File: {pdf_path}",
+ f"Official source: {source_url or 'not supplied'}",
+ f"Preset checked: {checked or 'not applicable'}",
+ "",
+ ]
+ for name, result in results.items():
+ lines.extend(
+ [
+ name.upper(),
+ f"Status: {result['status']}",
+ result["message"],
+ "",
+ ]
)
-
- fonts_found = []
- for line in result.stdout.split('\n')[2:]: # Skip header
- if line.strip():
- parts = line.split()
- if parts:
- fonts_found.append(parts[0])
-
- req_font = venue_reqs.get('font_family', '')
- req_size = venue_reqs.get('font_size')
-
- message = f"ℹ️ Fonts found: {', '.join(set(fonts_found))}\n"
- message += f" Required: {req_font}"
- if req_size:
- message += f" {req_size}pt minimum"
-
- return {"status": "info", "message": message}
-
- except FileNotFoundError:
- return {"status": "skip", "message": "pdffonts not available"}
- except subprocess.CalledProcessError:
- return {"status": "skip", "message": "Could not extract font information"}
-
-def validate_document(pdf_path, venue, checks):
- """Validate document against venue requirements."""
-
- venue_key = venue.lower().replace(" ", "_")
-
- if venue_key not in VENUE_REQUIREMENTS:
- print(f"❌ Unknown venue: {venue}")
- print(f"Available venues: {', '.join(VENUE_REQUIREMENTS.keys())}")
- return
-
- venue_reqs = VENUE_REQUIREMENTS[venue_key]
-
- print(f"\n{'='*60}")
- print(f"VALIDATING: {pdf_path.name}")
- print(f"VENUE: {venue}")
- print(f"{'='*60}\n")
-
- results = {}
-
- # Run requested checks
- if 'page-count' in checks or 'all' in checks:
- results['page-count'] = check_page_count(pdf_path, venue_reqs)
-
- if 'margins' in checks or 'all' in checks:
- results['margins'] = check_margins(pdf_path, venue_reqs)
-
- if 'fonts' in checks or 'all' in checks:
- results['fonts'] = check_fonts(pdf_path, venue_reqs)
-
- # Print results
- for check_name, result in results.items():
- print(f"{check_name.upper()}:")
- print(f" {result['message']}\n")
-
- # Summary
- failures = sum(1 for r in results.values() if r['status'] == 'fail')
- passes = sum(1 for r in results.values() if r['status'] == 'pass')
-
- print(f"{'='*60}")
- if failures == 0:
- print(f"✓ VALIDATION PASSED ({passes} checks)")
- else:
- print(f"✗ VALIDATION FAILED ({failures} issues)")
- print(f"{'='*60}\n")
-
- return results
-
-def generate_report(pdf_path, venue, results, report_path):
- """Generate validation report."""
-
- with open(report_path, 'w') as f:
- f.write(f"Validation Report\n")
- f.write(f"{'='*60}\n\n")
- f.write(f"File: {pdf_path}\n")
- f.write(f"Venue: {venue}\n")
- f.write(f"Date: {Path.ctime(pdf_path)}\n\n")
-
- for check_name, result in results.items():
- f.write(f"{check_name.upper()}:\n")
- f.write(f" Status: {result['status']}\n")
- f.write(f" {result['message']}\n\n")
-
- failures = sum(1 for r in results.values() if r['status'] == 'fail')
- f.write(f"\nSummary: {'PASSED' if failures == 0 else 'FAILED'}\n")
-
- print(f"Report saved to: {report_path}")
-
-def main():
+ report_path.write_text("\n".join(lines), encoding="utf-8")
+
+
+def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(
- description="Validate document formatting for venue requirements",
- formatter_class=argparse.RawDescriptionHelpFormatter,
- epilog="""
-Examples:
- %(prog)s --file my_paper.pdf --venue "Nature" --check-all
- %(prog)s --file my_paper.pdf --venue "NeurIPS" --check page-count,fonts
- %(prog)s --file proposal.pdf --venue "NSF" --report validation.txt
- """
+ description="Inspect page count, fonts, and metadata without claiming full compliance"
+ )
+ parser.add_argument("--file", required=True, help="PDF file to inspect")
+ parser.add_argument("--venue", choices=sorted(PRESETS), help="Verified preset")
+ parser.add_argument("--max-pages", type=int, help="Explicit maximum content pages")
+ parser.add_argument(
+ "--content-pages",
+ type=int,
+ help="Content pages counted manually according to the official rule",
+ )
+ parser.add_argument("--source-url", help="Official source for an explicit limit")
+ parser.add_argument(
+ "--check",
+ default="page-count,fonts,metadata",
+ help="Comma-separated: page-count, fonts, metadata, all",
)
-
- parser.add_argument('--file', type=str, required=True, help='PDF file to validate')
- parser.add_argument('--venue', type=str, required=True, help='Target venue')
- parser.add_argument('--check', type=str, default='all',
- help='Checks to perform: page-count, margins, fonts, all (comma-separated)')
- parser.add_argument('--check-all', action='store_true', help='Perform all checks')
- parser.add_argument('--report', type=str, help='Save report to file')
-
- args = parser.parse_args()
-
- # Check file exists
+ parser.add_argument("--report", help="Write a text report")
+ return parser.parse_args()
+
+
+def main() -> int:
+ args = parse_args()
pdf_path = Path(args.file)
- if not pdf_path.exists():
- print(f"Error: File not found: {pdf_path}")
- return
-
- # Parse checks
- if args.check_all:
- checks = ['all']
- else:
- checks = [c.strip() for c in args.check.split(',')]
-
- # Validate
- results = validate_document(pdf_path, args.venue, checks)
-
- # Generate report if requested
- if args.report and results:
- generate_report(pdf_path, args.venue, results, Path(args.report))
+ if not pdf_path.is_file():
+ print(f"Error: file not found: {pdf_path}")
+ return 2
+ if pdf_path.suffix.lower() != ".pdf":
+ print(f"Error: expected a PDF file: {pdf_path}")
+ return 2
+ if args.max_pages is not None and args.max_pages < 1:
+ print("Error: --max-pages must be positive.")
+ return 2
+ if args.content_pages is not None and args.content_pages < 0:
+ print("Error: --content-pages cannot be negative.")
+ return 2
-if __name__ == "__main__":
- main()
+ preset = PRESETS.get(args.venue, {})
+ max_content_pages = args.max_pages or preset.get("max_content_pages")
+ source_url = args.source_url or preset.get("source")
+ excluded = preset.get("excluded")
+ checked = preset.get("checked")
+
+ if args.max_pages is not None and not source_url:
+ print("Warning: supply --source-url so the explicit limit is auditable.")
+
+ checks = {item.strip() for item in args.check.split(",") if item.strip()}
+ allowed = {"page-count", "fonts", "metadata", "all"}
+ unknown = checks - allowed
+ if unknown:
+ print(f"Error: unknown checks: {', '.join(sorted(unknown))}")
+ return 2
+ if "all" in checks:
+ checks = {"page-count", "fonts", "metadata"}
+
+ try:
+ info = pdf_info(pdf_path)
+ total_pages = int(info["Pages"]) if info and info.get("Pages") else None
+ results = {}
+ if "page-count" in checks:
+ results["page-count"] = page_count_result(
+ total_pages,
+ args.content_pages,
+ max_content_pages,
+ excluded,
+ )
+ if "fonts" in checks:
+ results["fonts"] = font_result(embedded_fonts(pdf_path))
+ if "metadata" in checks:
+ results["metadata"] = metadata_result(info)
+ except (RuntimeError, ValueError) as error:
+ print(f"Error: {error}")
+ return 2
+
+ print(f"File: {pdf_path}")
+ if args.venue:
+ print(f"Preset: {args.venue} (checked {checked})")
+ print(f"Official source: {source_url or 'not supplied'}")
+ for name, result in results.items():
+ print(f"\n{name.upper()} [{result['status']}]")
+ print(result["message"])
+
+ if args.report:
+ report_path = Path(args.report)
+ write_report(report_path, pdf_path, source_url, checked, results)
+ print(f"\nReport saved to: {report_path}")
+ return 1 if any(result["status"] == "fail" for result in results.values()) else 0
+
+
+if __name__ == "__main__":
+ raise SystemExit(main())