科研 Skill
主动学习构建机器学习势训练集
active-learning-mlp
Runs active-learning workflows for ML interatomic potentials: uncertainty-guided MD exploration, DFT oracle labeling, query strategy. Use when expanding an MLP training set.
SKILL.md
Active Learning for ML Interatomic Potentials
Description
This skill covers the systematic active learning workflow for iteratively building ML interatomic potential training datasets: initial dataset construction, uncertainty-guided exploration MD, DFT oracle labeling, query strategy, dataset versioning, retraining cadence, and stopping criteria. Active learning is the primary method for constructing compact, non-redundant MLP training datasets that generalize across the thermodynamic conditions and structural environments targeted for production MD. Invoke this skill when building a new MLP training dataset from scratch, when a trained MLP fails in MD outside its training distribution, or when designing a data generation campaign for a new chemical system.
Domain Context
An MLP trained on a finite DFT dataset is accurate only within the distribution of configurations that dataset samples. The critical challenge is that the target distribution — all configurations visited during production MD — is unknown before the potential exists. Active learning resolves this circularity by iterating:
- Explore: Run MD with the current provisional MLP to generate candidate structures.
- Query: Select from the candidates those most likely to improve the model (high uncertainty, high diversity, or in undersampled regions).
- Label: Compute DFT energies, forces, and stresses for the selected structures.
- Retrain: Add the new DFT data to the training set and retrain or fine-tune the MLP.
- Evaluate: Test whether the model has reached the target accuracy and stability.
The loop continues until a stopping criterion is met: typically when the fraction of exploration MD frames with high uncertainty falls below a threshold, indicating that the MLP has learned the accessible configuration space.
Why not random sampling? DFT calculations are expensive (minutes to hours each). Random structures are overwhelmingly drawn from high-energy, irrelevant regions of configuration space. Active learning focuses the DFT budget on structures that are both physically accessible (from MD) and maximally informative (high model uncertainty).
The committee model approach is the dominant practical uncertainty estimator for neural network potentials. Train N models (typically 4–8) with identical architecture but different random seeds or data subsets. Frames where the N models disagree strongly (high force standard deviation) are likely extrapolation candidates — structures where the model is uncertain because it has seen few similar configurations during training.
A key risk: An MLP that is overconfident — one whose uncertainty estimates are well-calibrated on the training distribution but systematically low for a new class of structures — will fail silently. The committee disagreement is only meaningful if the committee members have genuinely diverse representations; identical architectures trained on the same data with different seeds produce limited diversity. Uncertainty quantification does not prove the model is correct; it only identifies structures where the current models disagree.
When to Use This Skill
- Building a system-specific MLP from scratch for a new composition, phase, or temperature range.
- Extending an existing MLP to new conditions (higher temperature, new phase, surface, defect, interface) where the model is known to be extrapolating.
- Generating training datasets for fine-tuning a universal potential (MACE-MP-0) on a specific system.
- Detecting and recovering from MLP failure during production MD (runaway trajectory diagnosis and repair).
- Designing a DFT data collection campaign with a fixed oracle budget (e.g., N DFT calculations per week on a shared HPC cluster).
When Not to Use This Skill
- When a validated universal potential already covers the system — benchmark first; if accuracy is sufficient, active learning is unnecessary overhead.
- When the target configuration space is fully enumerable — for a simple bulk crystal with one equilibrium structure and small thermal displacements, a well-chosen set of rattled structures plus volumetrically strained configurations may be sufficient without an iterative loop.
- When DFT oracle cost is negligible — for systems where DFT calculations are extremely cheap (< 1 minute each), generating a large random dataset and training once is often more practical than a complex AL pipeline.
- For systems requiring excited-state or non-adiabatic dynamics — active learning on Born-Oppenheimer surfaces does not cover conical intersections or photochemical pathways.
Core Concepts
- Committee model: N independently trained MLP instances (same architecture, different random seeds or different data subsets) used jointly for uncertainty estimation. The force disagreement across committee members at a given structure is used as the uncertainty proxy.
- Model deviation (σ_F): The standard deviation of per-atom force predictions across committee members, typically taken as the per-atom maximum or mean. Threshold-based selection: frames with σ_F > σ_high are labeled "extrapolation" (do not use for MD, always send to DFT); frames with σ_low < σ_F < σ_high are "interpolation with uncertainty" (candidates for DFT labeling); frames with σ_F < σ_low are "well-converged" (keep in MD, do not relabel).
- Extrapolation grade (γ̃): In Gaussian process and FLARE-based approaches, a Bayesian measure of how far a new structure departs from the training set in the kernel feature space. Equivalent in spirit to committee model deviation but with principled calibration.
- Query budget: The number of DFT oracle calls per active learning iteration. Constrained by HPC allocation and wall-time. Typical: 50–500 new DFT structures per iteration. [EXPERT REVIEW NEEDED]
- Redundancy filtering: Even among high-uncertainty frames, many may be structurally similar. Selecting all of them wastes the DFT budget. Diversity-based filtering (farthest-point sampling in descriptor space, clustering) selects a non-redundant subset.
- Descriptor for diversity: A fast-to-compute structural fingerprint used to measure pairwise structure similarity. Common choices: SOAP (Smooth Overlap of Atomic Positions) descriptor via DScribe, per-atom ACE descriptors, or MACE latent features. The descriptor space must be computed consistently across all candidate frames.
- Dataset versioning: Each iteration of the active learning loop produces a new dataset version. Versions must be tracked with checksums, metadata (DFT settings, iteration number, added structure count), and provenance (which MD run generated each structure). DVC (Data Version Control) or a custom JSON manifest are common solutions.
- Retraining from scratch vs. fine-tuning: Retraining from scratch on the full updated dataset is the safest option (no artifacts from previous iterations). Fine-tuning on only the new data is faster but risks catastrophic forgetting. For MACE, full retraining with consistent hyperparameters and a fixed random seed is recommended for reproducibility. [EXPERT REVIEW NEEDED]
- Stopping criterion: Common choices: (1) fraction of exploration frames with σ_F > σ_high falls below 1%; (2) MLP validation error on a held-out test set stops improving between iterations; (3) DFT budget is exhausted. Criterion (2) is the most physically meaningful but requires maintaining an independent test set that was not influenced by the active learning queries.
- Oracle consistency: All DFT labels across all iterations must be computed at identical settings: same code, same functional, same ENCUT (VASP) / ecutwfc (QE), same POTCAR version, same smearing. Mixing settings introduces systematic energy offsets that corrupt the training signal.
Key Workflows
Full steps for each part are in references/key-workflows/; open the one you need:
- Workflow 1: Initial dataset construction —
references/key-workflows/01-workflow-1-initial-dataset-construction.md: The first training set must be physically reasonable and cover the target composition and a wide range of energetically accessible structures. It does not need to be large — 200–1000 structures is typical for a starting point. - Workflow 2: Committee model training and force uncertainty estimation —
references/key-workflows/02-workflow-2-committee-model-training-and-force-un.md - Workflow 3: Query strategy — uncertainty filtering and diversity selection —
references/key-workflows/03-workflow-3-query-strategy-uncertainty-filtering.md: Selecting which uncertain frames to send to DFT. High uncertainty alone is insufficient — many high-uncertainty frames may be redundant copies of the same environment. - Workflow 4: DFT oracle — labeling pipeline and consistency checks —
references/key-workflows/04-workflow-4-dft-oracle-labeling-pipeline-and-cons.md - Workflow 5: Dataset versioning, retraining, and the full iteration loop —
references/key-workflows/05-workflow-5-dataset-versioning-retraining-and-the.md - Workflow 6: Validation before production MD deployment —
references/key-workflows/06-workflow-6-validation-before-production-md-deplo.md
Common Failure Modes
| Failure | Symptom | Likely Cause | Diagnostic | Fix |
|---|---|---|---|---|
| Runaway MD during exploration | Energy explosion within first ps; max force > 100 eV/Å; atoms escape simulation box | Provisional MLP explores unphysical configuration; model extrapolates far outside training domain | Monitor max force every 10 steps during exploration; halt trajectory if max force exceeds threshold (e.g., 50 eV/Å) | Set force cap in exploration MD; send the last valid frame before divergence to DFT rather than discarding; add minimum-image distance check to detect unphysical atom separations |
| Uncertainty miscalibration | Committee deviation is uniformly low; exploration MD appears confident but model fails in validation | Committee members are too similar (same architecture + same data + nearly same seed); overfit to training distribution | Compare committee member test MAEs independently; test on deliberately out-of-distribution structures | Increase committee diversity: use different random seeds with larger separation, different data subsets (jackknife), or different architectures; calibrate thresholds on a held-out validation set not used in training |
| Biased exploration — stuck in one phase | Dataset grows but model fails for temperatures or phases not yet explored; exploration only samples near-equilibrium | Exploration MD initialized from a single starting configuration or run at a single temperature | Visualize sampled configuration space with SOAP-PCA or UMAP; check if all config_types are represented in new acquisitions | Use multiple exploration trajectories from diverse starting points: different compositions, temperatures, defect types, surfaces; include AIMD snapshots at high temperature |
| Duplicate configurations inflate dataset | Dataset grows but model accuracy does not improve; training is slow and expensive for diminishing returns | Farthest-point sampling not applied; or applied with too coarse a descriptor; trajectory sampled too frequently | Compute pairwise SOAP distances for new acquisitions; if > 50% of pairs have distance < 0.01, dataset is redundant | Apply farthest-point sampling or clustering before DFT labeling; increase sampling interval in exploration MD; remove near-duplicates with distance threshold |
| Inconsistent DFT settings across iterations | Systematic energy discontinuity between early and late iterations; training loss increases after adding new data | ENCUT, POTCAR version, ISMEAR, or functional changed mid-campaign | Hash INCAR + POTCAR settings for every DFT calculation; plot E/atom distribution by iteration | Recompute affected structures at the canonical settings; reject calculations with non-matching settings hash; use dataset manager with settings validation (Workflow 5) |
| Overfitting to queried configurations | Model achieves low loss on training set and actively acquired structures but fails on unseen configurations | Dataset dominated by structures from one AL iteration; query strategy too narrowly focused | Compare error on a held-out test set never seen by the AL loop vs. error on the training set | Maintain a clean held-out test set from Iteration 0 (never include in AL queries); ensure all config_types are represented in each iteration's acquisitions |
| Missing rare events in training domain | MLP stable for bulk dynamics but fails for nucleation, phase transition, or rare defect creation | Standard temperature-driven exploration does not access rare events on MD timescales | Check validation error on structures from specialized calculations (TS searches, NEB, defect configurations) | Supplement exploration with targeted structure generation: rattled transition-state geometries, NEB images, short-range compressed configurations for fracture |
| False confidence — model stops querying too early | Stopping criterion triggers; subsequent production MD fails; model was overconfident | Committee uncertainty drops below threshold before true convergence; model memorized training distribution | Continue monitoring uncertainty on held-out structures after stopping; check production MD stability for 1+ ns before declaring success | Tighten stopping criterion; require both uncertainty convergence AND validation MAE plateau for ≥ 3 iterations; run production MD on a modest system first before committing to large-scale deployment |
Best Practices
- Freeze DFT settings at Iteration 0 and never change them. Create a canonical
dft_settings.jsonfile at the start of the campaign and validate every new DFT batch against its hash before adding it to the training set. A single ENCUT change or POTCAR version change mid-campaign can corrupt the entire dataset. - Maintain a clean held-out test set from Iteration 0. These structures are labeled with DFT but never shown to the model and never targeted by the query strategy. They provide an unbiased accuracy estimate throughout the campaign. Never add held-out structures to the training set.
- Monitor max force during exploration MD. Set a hard force cap (e.g., 30–50 eV/Å) that halts the trajectory and logs the divergence point. The last frame before divergence contains information about the failure mode — send it for DFT labeling rather than discarding.
- Use at least 4 committee members for meaningful uncertainty estimates. Two members provide a binary agreement/disagreement signal, not a calibrated uncertainty. Four to eight gives a more reliable estimate of the force standard deviation.
- Calibrate uncertainty thresholds on a validation set, not by intuition. The optimal σ_low and σ_query values depend on the system, architecture, and training set size. Compute the fraction of training-distribution structures with σ_F > σ_query; if it is > 20%, the threshold is too low. [EXPERT REVIEW NEEDED]
- Diversify exploration temperatures and conditions. Run exploration MD at multiple temperatures spanning the target application range. For solids, also include slightly above-melt structures to probe the disordered limit. For surfaces, include adsorbed and clean configurations separately.
- Version every dataset update with full provenance. Record: iteration number, DFT settings hash, list of new structure file names, committee model checksum used for the query, and timestamp. Without this, tracking down dataset bugs becomes intractable.
- Document and report the active learning protocol in publications. Specify the committee size, uncertainty thresholds, query strategy, total DFT count per iteration, number of iterations, and convergence criterion. This is the minimum needed for reproducibility of MLP papers.
Integration with Other Skills
- mace-training: The committee training and dataset preparation workflows here extend that skill's single-model training. The extxyz format, DFT conversion routines, and hyperparameter choices transfer directly; this skill adds the iteration and uncertainty layer.
- mlp-validation: Workflow 6 (pre-deployment validation) is a prerequisite to that skill's full validation suite. After the AL loop converges, formal validation (RDF, phonons, elastic constants, long MD stability) should be performed before production deployment.
- mlp-to-lammps: Exploration MD in the AL loop runs the provisional MACE models in LAMMPS or ASE. The LAMMPS compilation requirements and
no_domain_decompositionconstraints described there apply to every exploration run. - uncertainty-mlp: Committee deviation is the simplest uncertainty estimator. That skill covers more principled alternatives (deep ensembles, conformal prediction, last-layer Bayesian approaches) that may be warranted when committee diversity is insufficient.
- dft-dataset-generation: Covers the broader dataset design problem: which structures to include beyond what AL generates (defects, surfaces, NEB images, AIRSS structures). AL is one strategy within that skill's framework.
- dft-convergence: The DFT oracle settings frozen in Workflow 4 must be established using that skill's convergence protocol before the AL campaign begins. Any change discovered during the campaign (e.g., ENCUT too low for a new species) requires recomputing affected structures.
- vasp-workflow: Workflow 4 uses VASP as the DFT oracle. ISIF=2, PREC=Accurate, and tight EDIFF settings from that skill are required for accurate force and stress labels.
- quantum-espresso: When QE is the oracle, the same consistency requirements apply. Forces in QE output are in Ry/bohr and must be converted via ASE before adding to the extxyz dataset.
- lammps-workflow: Exploration MD uses LAMMPS with MACE pair style. The input script mechanics and timestep selection from that skill apply to every exploration trajectory.
- md-equilibration: Exploration trajectories should start from properly equilibrated structures to avoid sampling the transient equilibration phase. The protocol and diagnostics from that skill apply to each new starting configuration.
- reproducibility-workflow: The dataset versioning, DFT settings hashing, and provenance tracking described in Workflow 5 are a specialization of the general reproducibility framework covered there.
Key References
- Zhang, L., et al. (2019). Active learning of uniformly accurate interatomic potentials for materials simulation. Physical Review Materials, 3(2), 023804. https://doi.org/10.1103/PhysRevMaterials.3.023804
- Vandermause, J., et al. (2020). On-the-fly active learning of interpretable Bayesian force fields for atomistic simulations. npj Computational Materials, 6(1), 20. https://doi.org/10.1038/s41524-020-0283-z
- Schran, C., et al. (2020). Committee neural network potentials control generalization errors and enable active learning. Journal of Chemical Physics, 153(10), 104105. https://doi.org/10.1063/5.0016004
- Smith, J. S., et al. (2018). Less is more: Sampling chemical space with active learning. Journal of Chemical Physics, 148(24), 241733. https://doi.org/10.1063/1.5023802
- Imbalzano, G., et al. (2021). Uncertainty estimation for molecular dynamics and sampling. Journal of Chemical Physics, 154(7), 074102. https://doi.org/10.1063/5.0036522
示例提示词
我想用主动学习策略迭代构建机器学习原子间势的训练数据集。
所属插件
安装该插件会一并获得同领域的 35 个 Skill / MCP。
同插件的其他科研 Skill
- AiiDA计算工作流管理Covers AiiDA, a provenance-first Python workflow engine for computational materials science: calculation input generation, remote submission. Use when orchestrating reproducible DFT/MD campaigns.
- ASE原子模拟环境Covers the Atomic Simulation Environment (ASE) as an atomistic workflow hub: Atoms objects, calculators, optimizers, trajectories. Use when scripting or converting structures across DFT/MD codes.
- 粗粒化分子动力学模拟Covers coarse-grained molecular dynamics: mapping atomistic structures to CG beads, parameterizing Martini/IBI/force-matching force fields. Use when atomistic timescales are too short.
- CP2K第一性原理分子动力学Covers end-to-end DFT, AIMD, and atomistic workflows with CP2K using the Gaussian-and-plane-waves method: input construction, convergence testing. Use for CP2K-based simulations.
- 扩散模型生成晶体结构Covers de novo crystal structure generation with score-based diffusion and flow-matching models (MatterGen, DiffCSP, CDVAE). Use when generating candidate structures, not analyzing existing ones.
- 晶体图神经网络性质预测Covers graph neural networks for crystal and periodic-material property prediction: crystal graph construction, periodic neighbor finding. Use when building GNN property predictors for crystals.
- 平面波DFT收敛性测试Covers systematic convergence testing for plane-wave DFT: cutoff energy, k-point mesh density, smearing. Use before trusting DFT energies, forces, or derived properties as converged.
- 机器学习势DFT数据集生成Covers generating DFT-labeled datasets for training ML interatomic potentials: configuration-space coverage. Use when building an MLP training dataset from scratch.
- 点缺陷第一性原理计算Covers first-principles point-defect modeling: vacancy/interstitial/antisite/substitutional construction, charge-state calculations. Use for defect thermodynamics studies.
- 第一性原理声子谱计算Covers lattice dynamics from first principles: phonon dispersion, phonon DOS. Use when computing vibrational or thermodynamic properties from DFT.
- 表面模型DFT计算Covers surface slab model construction and DFT calculation: Miller-index generation, termination selection, slab/vacuum convergence. Use for surface science and catalysis DFT studies.
- 弹性常数计算工作流Computes single-crystal and polycrystalline elastic constants from DFT or MD stress-strain data and checks mechanical stability. Use when deriving stiffness tensors or bulk/shear modulus.
- 增强采样自由能计算Covers enhanced sampling methods for atomistic MD (metadynamics, umbrella sampling. Use for rare-event or slow-transition sampling.
- 状态方程拟合Covers equation-of-state fitting from DFT/ML-potential energy-volume data: Birch-Murnaghan, Vinet, and Murnaghan forms. Use when fitting an EOS to compression data.
- 机器学习势微调迁移训练Covers fine-tuning pretrained universal ML interatomic potentials on system-specific DFT data. Use when adapting a universal MLP to a new system.
- 分子动力学自由能计算Covers quantitative free-energy calculations from MD: alchemical FEP/TI/BAR/MBAR, umbrella-sampling PMF. Use when computing thermodynamic free energies from simulation.
- GROMACS分子动力学工作流Covers end-to-end MD simulations with GROMACS: topology/.mdp construction, energy minimization, NVT/NPT equilibration. Use for GROMACS-based biomolecular or materials MD.
- 高通量DFT自动化筛选Covers automated large-scale DFT screening: workflow graphs with atomate2/jobflow/AiiDA, input-set standardization, custodian error handling. Use for high-throughput DFT screening campaigns.
- LAMMPS分子动力学工作流Covers end-to-end MD simulations with LAMMPS: input script anatomy, force-field deployment, ensemble control, equilibration. Use for LAMMPS-based classical molecular dynamics.
- MACE机器学习势训练Covers training MACE machine-learned interatomic potentials: extxyz dataset preparation, isolated-atom energies, train/val/test splitting. Use for MACE-specific MLP training workflows.
- MatGL图神经网络框架Covers building, applying, validating, and fine-tuning MatGL graph-neural-network models for property prediction and interatomic potentials. Use for pretrained GNN workflows via MatGL.
- 分子动力学轨迹后处理分析Covers quantitative post-processing of atomistic MD trajectories: loading LAMMPS/GROMACS/ASE trajectories and computing RDF, coordination numbers. Use for structural MD trajectory analysis.
- 分子动力学平衡过程设计Covers bringing an atomistic simulation from its initial configuration to a representative equilibrium state before production statistics: ensemble. Use before collecting production MD data.
- 分子动力学力场选型验证Covers selection, validation, and deployment of classical interatomic force fields for MD: physical basis and transferability limits of EAM, MEAM, Tersoff. Use when choosing a force field.
常见问题
主动学习构建机器学习势训练集能做什么?
Runs active-learning workflows for ML interatomic potentials: uncertainty-guided MD exploration, DFT oracle labeling, query strategy. Use when expanding an MLP training set。
如何安装主动学习构建机器学习势训练集?
在科搭 Codar 左侧点击「插件」,在「组件」页签搜索「主动学习构建机器学习势训练集」并安装;在 Claude Code 或 Codex 中可以发送本页的安装提示词,或下载 Skill 包后解压到 ~/.claude/skills 或 ~/.codex/skills。
主动学习构建机器学习势训练集需要哪些权限?
该科研 Skill没有声明额外权限;执行具体操作时仍由 Agent 按自身规则请求确认。
主动学习构建机器学习势训练集经过官方审核吗?
是。SpeedSkills 收录的每个版本都会记录内容摘要与权限声明,当前版本已通过安全审核。