科研 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.

发布者 Codar安全审核通过v0.1.0更新于 2026-11-18

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:

  1. Explore: Run MD with the current provisional MLP to generate candidate structures.
  2. Query: Select from the candidates those most likely to improve the model (high uncertainty, high diversity, or in undersampled regions).
  3. Label: Compute DFT energies, forces, and stresses for the selected structures.
  4. Retrain: Add the new DFT data to the training set and retrain or fine-tune the MLP.
  5. 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:

Common Failure Modes

FailureSymptomLikely CauseDiagnosticFix
Runaway MD during explorationEnergy explosion within first ps; max force > 100 eV/Å; atoms escape simulation boxProvisional MLP explores unphysical configuration; model extrapolates far outside training domainMonitor 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 miscalibrationCommittee deviation is uniformly low; exploration MD appears confident but model fails in validationCommittee members are too similar (same architecture + same data + nearly same seed); overfit to training distributionCompare committee member test MAEs independently; test on deliberately out-of-distribution structuresIncrease 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 phaseDataset grows but model fails for temperatures or phases not yet explored; exploration only samples near-equilibriumExploration MD initialized from a single starting configuration or run at a single temperatureVisualize sampled configuration space with SOAP-PCA or UMAP; check if all config_types are represented in new acquisitionsUse multiple exploration trajectories from diverse starting points: different compositions, temperatures, defect types, surfaces; include AIMD snapshots at high temperature
Duplicate configurations inflate datasetDataset grows but model accuracy does not improve; training is slow and expensive for diminishing returnsFarthest-point sampling not applied; or applied with too coarse a descriptor; trajectory sampled too frequentlyCompute pairwise SOAP distances for new acquisitions; if > 50% of pairs have distance < 0.01, dataset is redundantApply farthest-point sampling or clustering before DFT labeling; increase sampling interval in exploration MD; remove near-duplicates with distance threshold
Inconsistent DFT settings across iterationsSystematic energy discontinuity between early and late iterations; training loss increases after adding new dataENCUT, POTCAR version, ISMEAR, or functional changed mid-campaignHash INCAR + POTCAR settings for every DFT calculation; plot E/atom distribution by iterationRecompute affected structures at the canonical settings; reject calculations with non-matching settings hash; use dataset manager with settings validation (Workflow 5)
Overfitting to queried configurationsModel achieves low loss on training set and actively acquired structures but fails on unseen configurationsDataset dominated by structures from one AL iteration; query strategy too narrowly focusedCompare error on a held-out test set never seen by the AL loop vs. error on the training setMaintain 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 domainMLP stable for bulk dynamics but fails for nucleation, phase transition, or rare defect creationStandard temperature-driven exploration does not access rare events on MD timescalesCheck 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 earlyStopping criterion triggers; subsequent production MD fails; model was overconfidentCommittee uncertainty drops below threshold before true convergence; model memorized training distributionContinue monitoring uncertainty on held-out structures after stopping; check production MD stability for 1+ ns before declaring successTighten 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.json file 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_decomposition constraints 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

  1. 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
  2. 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
  3. 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
  4. 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
  5. 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

示例提示词

我想用主动学习策略迭代构建机器学习原子间势的训练数据集。

所属插件

计算材料学:第一性原理与原子模拟面向计算材料研究:DFT 与第一性原理(VASP、Quantum ESPRESSO、CP2K、AiiDA)、缺陷/表面/声子/弹性常数、机器学习势函数训练与验证、分子动力学与增强采样、晶体性质图神经网络与生成模型。

安装该插件会一并获得同领域的 35 个 Skill / MCP。

同插件的其他科研 Skill

常见问题

主动学习构建机器学习势训练集能做什么?

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 收录的每个版本都会记录内容摘要与权限声明,当前版本已通过安全审核。