科研 Skill
贝叶斯优化材料发现
bayesian-optimization
Covers Bayesian optimization for materials and chemistry design: surrogate models, acquisition functions, batch/constrained BO. Use when planning sample-efficient experiments or simulations.
SKILL.md
Bayesian Optimization for Materials and Chemistry
Description
This skill covers Bayesian optimization (BO) for materials discovery and chemistry design: surrogate model construction, acquisition function selection and optimization, batch and constrained BO, multi-objective Pareto-front search, multi-fidelity optimization, and integration with high-throughput DFT, experimental workflows, and active learning loops. It uses BoTorch and Ax as the primary frameworks. Invoke this skill when sequentially selecting experiments or calculations to optimize an expensive objective — band gap, formation energy, synthesis yield, reaction rate, or any property accessible via DFT, simulation, or laboratory measurement — especially when the budget is small (tens to low hundreds of evaluations) and uncertainty-guided exploration matters.
Domain Context
Bayesian optimization is a sequential decision-making strategy for optimizing an expensive black-box function f(x) using as few evaluations as possible. It maintains a probabilistic surrogate model p(f | data) — typically a Gaussian process — and selects the next evaluation point by maximizing an acquisition function α(x) that balances exploration (high uncertainty) and exploitation (high predicted value). After each evaluation, the surrogate is updated and the process repeats.
Why BO for materials: Materials property spaces are high-dimensional, discontinuous, combinatorially large, and expensive to evaluate. A DFT calculation costs minutes to days; a synthesis-and-characterization cycle costs weeks. Random or grid search wastes budget on obviously poor candidates. BO uses all past evaluations to build a model of the objective landscape and targets the most promising regions. In practice, BO routinely outperforms random search on materials benchmarks at budgets of 20–200 evaluations, though the advantage shrinks as budget grows. [EXPERT REVIEW NEEDED: the relative advantage of BO over random search is problem-specific and sometimes smaller than reported in clean benchmarks; noisy experimental settings often reduce the margin]
The surrogate–acquisition loop:
- Fit a surrogate model to all evaluated (x, f(x)) pairs.
- Optimize the acquisition function over the search space to find x_next.
- Evaluate f(x_next) (DFT, experiment, simulation).
- Add (x_next, f(x_next)) to the dataset. Go to 1.
The surrogate provides calibrated uncertainty; the acquisition function converts predicted mean and uncertainty into a score for each candidate; the optimizer (L-BFGS-B for continuous, enumeration for discrete) finds the highest-scoring candidate. The bottleneck is usually step 3 (the expensive evaluation), not steps 1–2.
Exploration vs. exploitation: Acquisition functions parameterize the trade-off. Expected Improvement (EI) tends toward exploitation near the current best; Upper Confidence Bound (UCB) adds κ × σ(x) as an explicit exploration bonus; Thompson Sampling (TS) explores by sampling from the posterior and optimizing the sample. No single strategy dominates across all problem types. [EXPERT REVIEW NEEDED: the optimal exploration-exploitation balance depends on the noise level, budget, and objective landscape topology; there is no universally best acquisition function]
Search space design: The search space is the most consequential design choice. A too-narrow space excludes the optimum; a too-wide space dilutes budget in irrelevant regions; a poorly featurized space makes the surrogate useless. For materials, search spaces include:
- Continuous: alloy compositions (x in [0,1]^N with Σx_i=1), synthesis temperatures, dopant concentrations, DFT parameters.
- Discrete/Categorical: element choices, crystal structure prototypes, functional groups, ligands.
- Structural: crystal geometries described by unit cell parameters + Wyckoff positions; requires a representation that maps structure → fixed-length descriptor before the GP.
- Mixed: categorical element selection + continuous composition + discrete stoichiometry. BoTorch handles mixed spaces via
ParameterConstraintand one-hot encoding of categoricals.
Regret: Cumulative regret measures total suboptimality over the budget. Simple regret is the gap between the best found and the true optimum at the final iteration. These are meaningful only relative to a baseline (random search, grid search, or expert heuristic). Always report a baseline alongside BO results.
Stopping criteria: BO should stop when: (a) the acquisition value of the best unexplored candidate is below a meaningful threshold, (b) the surrogate posterior has converged (low uncertainty everywhere in the feasible region), or (c) the budget is exhausted. In practice, budget exhaustion is the usual stopping condition. Do not stop early based on subjective "convergence" without a quantitative criterion.
When to Use This Skill
- Optimizing a materials property with a small evaluation budget (< ~500 evaluations) where each evaluation is expensive (DFT, experiment, or simulation).
- Sequentially selecting the next structure, composition, or synthesis condition to evaluate — especially when uncertainty guidance matters.
- Multi-objective optimization where multiple properties must be simultaneously optimized and a Pareto front is the goal.
- Multi-fidelity optimization where cheap low-quality evaluations (screening DFT, rapid experiment) can inform where to spend high-fidelity budget.
- Constrained optimization where the search space has physical, chemical, or experimental feasibility constraints.
- Benchmarking BO against random or heuristic search on a retrospective materials dataset.
When Not to Use This Skill
- Very large budgets (> ~1000 evaluations): BO overhead per step grows; simpler methods (neural network surrogates, evolutionary algorithms, grid search) become competitive or superior.
- When the objective is cheap to evaluate: If a single evaluation costs < 1 second, random or grid search with thousands of samples outperforms BO on most problems.
- When the surrogate is fundamentally mis-specified: A GP with the wrong kernel or descriptor will give overconfident or uninformative uncertainty. BO with a bad surrogate can be worse than random search.
- When the search space is not well-defined: BO requires an explicit parameterization of the search space before starting. If candidate generation is the bottleneck, address that first.
- When constraints are so tight that most of the space is infeasible: Constrained BO degrades when the feasible fraction is < ~1%. Use constraint-aware initialization (rejection sampling, feasibility surrogates) or problem reformulation.
- When the objective is deterministic and smooth and the space is low-dimensional (< 5): Classic gradient-based optimization or quasi-Newton methods may be faster and more reliable.
Core Concepts
Full steps for each part are in references/core-concepts/; open the one you need:
- Acquisition Functions —
references/core-concepts/01-acquisition-functions.md: Expected Improvement (EI): - Batch Bayesian Optimization —
references/core-concepts/02-batch-bayesian-optimization.md: When evaluations can be parallelized (multiple DFT jobs simultaneously, multiple synthesis runs in parallel), select a batch of q points jointly. The joint acquisition is: - Multi-Objective Bayesian Optimization —
references/core-concepts/03-multi-objective-bayesian-optimization.md: When optimizing multiple objectives simultaneously (e.g., maximizing band gap and minimizing formation energy), the result is a Pareto front — the set of non-dominated solutions where no objective can be improved without worsening another. - Multi-Fidelity Optimization —
references/core-concepts/04-multi-fidelity-optimization.md: Different levels of fidelity correspond to different approximation qualities: screening DFT (cheap, noisy) vs. converged DFT (expensive, accurate); rapid experiment vs. full characterization. Multi-fidelity BO allocates budget across fidel… - Constrained Bayesian Optimization —
references/core-concepts/05-constrained-bayesian-optimization.md: Constraints are of two types: - Noisy Objectives —
references/core-concepts/06-noisy-objectives.md: When f(x) is observed with noise (experimental measurement error, DFT with loose convergence, stochastic simulation), the GP noise variance must be modeled explicitly:
Key Workflows
Full steps for each part are in references/key-workflows/; open the one you need:
- Workflow 1: Single-Objective BO with BoTorch (Continuous Space) —
references/key-workflows/01-workflow-1-single-objective-bo-with-botorch-cont.md - Workflow 2: Batch BO for Parallel HT-DFT Campaigns —
references/key-workflows/02-workflow-2-batch-bo-for-parallel-ht-dft-campaign.md: When DFT jobs run in parallel, select a batch of q candidates per iteration instead of one. - Workflow 3: Multi-Objective BO with qEHVI (Pareto Front) —
references/key-workflows/03-workflow-3-multi-objective-bo-with-qehvi-pareto.md - Workflow 4: Constrained BO with Feasibility Surrogate —
references/key-workflows/04-workflow-4-constrained-bo-with-feasibility-surro.md - Workflow 5: Multi-Fidelity BO (Screening DFT → Converged DFT) —
references/key-workflows/05-workflow-5-multi-fidelity-bo-screening-dft-conve.md - Workflow 6: BO over Discrete/Categorical Space (Element Selection) —
references/key-workflows/06-workflow-6-bo-over-discrete-categorical-space-el.md - Workflow 7: BO Baseline Comparison and Stopping Analysis —
references/key-workflows/07-workflow-7-bo-baseline-comparison-and-stopping-a.md
Common Failure Modes
| Failure Mode | Symptoms | Likely Cause | Diagnostic | Fix |
|---|---|---|---|---|
| Overconfident surrogate | BO selects candidates in the same region repeatedly; GP posterior variance collapses far from data | Kernel length scale too short; feature space collapses in high dimensions | Plot GP posterior variance over the search space; check calibration on held-out points | Recalibrate GP; try ARD kernel; reduce feature dimensionality; add jitter to diagonal |
| Bad search-space definition | BO finds candidates outside the physically meaningful range; many infeasible evaluations | Bounds set too wide; composition constraints not enforced; categorical choices include impossible elements | Enumerate a sample of candidates and manually inspect feasibility; compute feasibility fraction | Tighten bounds; add linear constraints; use feasibility surrogate; validate search space before submitting |
| Acquisition over-optimization | BO selects the same point or a tight cluster every iteration | Acquisition function has a narrow global maximum; numerical precision issues in L-BFGS-B | Check diversity of selected candidates; increase num_restarts and raw_samples; use multi-start | Increase num_restarts (≥20); use Sobol-based initialization for L-BFGS-B; switch to TS |
| Data leakage | BO benchmark appears much better than random; inflated gains | Test points in initial design; train/test split applied after BO; dataset not deduplicated | Check if initial design or BO selections appear in the test set | Deduplicate; create test split before any BO; use held-out structures never seen during optimization |
| Invalid candidates | DFT calculation fails or returns nonsensical energy for BO-selected candidate | BO ignores physical validity; selected composition is charge-unbalanced or mechanically unstable | Check failure rate of DFT jobs selected by BO vs random; inspect selected compositions | Add known-constraint enforcement; add feasibility surrogate trained on DFT success/failure outcomes |
| Optimizing noisy artifacts | BO converges to a candidate with an anomalously low (or high) DFT energy that is a numerical artifact | Noisy DFT convergence; custodian applied many corrections; basis set incompleteness | Compare single-point energies of "best" candidates at higher ENCUT and tighter EDIFF | Flag high-uncertainty DFT outputs; rerun suspicious best candidates at high-accuracy tier |
| Ignoring constraints | Selected candidates violate composition, stability, or experimental limits | Constraints were not encoded in the search space or acquisition | Check constraint satisfaction rate; plot selected candidates against feasibility boundary | Use ConstrainedExpectedImprovement; encode constraints as linear parameter constraints in BoTorch |
| Reporting only best-found without baseline | Claimed improvement over random is not statistically supported | Only the BO result is reported; no comparison to random search or heuristic | Re-run random search with same budget and n_seeds ≥ 20; compute p-value | Always include random search baseline; report mean ± std over seeds; use Mann-Whitney U test |
| Surrogate not re-fit after each batch | GP becomes stale; uncertainty not updated; acquisition degrades | Re-fitting skipped for speed; model hyperparameters not optimized each iteration | Check if GP hyperparameters change between iterations; compare predictions to held-out data | Re-fit GP after every completed batch; use fit_gpytorch_mll with optimizer each iteration |
| Wrong reference point in multi-objective BO | Hypervolume metric is dominated by one objective; Pareto front metrics inconsistent | Reference point chosen inside the feasible region or not updated as new data arrives | Verify reference point is below all observed objective values; plot dominated region | Set reference point ≤ worst feasible observation per objective; update conservatively if observations improve |
Best Practices
Search space design:
- Define bounds, constraints, and feasibility checks before the first iteration. A search space that must be changed mid-campaign invalidates comparisons across iterations.
- For compositional spaces, always enforce the simplex constraint (Σx_i = 1) explicitly, not post-hoc. BoTorch's
LinearConstrainthandles this natively. - For element-selection problems, use Ax's
ChoiceParameterwith appropriate one-hot or ordinal encoding; do not arbitrarily impose ordinal order on categorical choices. - Start with the minimum number of features needed (3–10). Adding more features increases the curse of dimensionality without necessarily improving the surrogate.
Surrogate fitting and calibration:
- Always check GP calibration on a held-out subset before trusting the uncertainty for acquisition. A coverage probability plot (fraction of test points inside predicted 90% interval vs. 90%) is the minimum calibration check.
- Re-fit GP hyperparameters (length scales, output scale, noise) after every batch. Stale hyperparameters lead to poor uncertainty estimates.
- For objectives with known noise levels (DFT convergence error, experimental uncertainty), use
FixedNoiseGPwith per-observation noise rather than estimating noise from data.
Acquisition function selection:
- Use
qLogNoisyExpectedImprovement(qLogNEI) as the default for single-objective BO with noise. It is numerically more stable than qEI and handles the noisy best-so-far correctly. - For multi-objective problems, use
qLogExpectedHypervolumeImprovementwithsequential=Truefor batches; joint optimization is only needed for very small batches. - For pure exploration (building a training dataset without a specific target), use posterior variance maximization or Thompson Sampling rather than EI.
- For noisy, low-budget settings where calibration is uncertain, consider Thompson Sampling as a robust fallback.
Initialization:
- Use Sobol sequences (quasi-random) rather than uniform random for the initial design; they cover the space more uniformly with the same number of points.
- Initial design size: at least max(5, 2×D) points for a D-dimensional space. For multi-objective problems: at least max(10, 4×D).
- Never use a biased initialization (e.g., only known-good compositions) without explicitly accounting for it in the surrogate and baseline comparison.
Baselines and reporting:
- Always run ≥ 10 random search seeds with the same budget and report mean ± std. BO that does not consistently beat random search is not doing useful work.
- Report: search space definition, initial design size, surrogate type and kernel, acquisition function, batch size, total evaluations, and how the best candidate was selected (not just identified by BO but independently validated).
- For materials discovery claims, validate the BO-identified optimum with a higher-accuracy DFT calculation (high-accuracy tier) or synthesis experiment before publishing.
Multi-fidelity:
- Establish the correlation between fidelities empirically on a calibration set before committing to a multi-fidelity protocol. If low-fidelity predictions are uncorrelated with high-fidelity (ρ < 0.3), multi-fidelity BO provides no benefit. [EXPERT REVIEW NEEDED]
- Track total cost (not total evaluations) as the x-axis in multi-fidelity convergence plots.
Integration with Other Skills
Surrogate and modeling:
- Gaussian Process Materials — the GP surrogate at the heart of BO is built and calibrated using the GP skill. Kernel selection, descriptor choice, length scale fitting, and uncertainty calibration all follow that skill's protocols. BoTorch uses GPyTorch-based GPs that are directly compatible.
- Surrogate Validation — before trusting BO acquisition decisions, the surrogate must pass cross-validation, calibration, and generalization checks defined in the surrogate validation skill. A BO loop built on an uncalibrated surrogate is unreliable. [FORWARD REFERENCE — skill may be in progress]
- Small-Data ML — BO operates in the small-data regime (tens to hundreds of evaluations); this skill covers regularization, cross-validation, and model selection strategies that apply both inside the surrogate and when comparing surrogate families. [FORWARD REFERENCE — skill not yet created]
Data and featurization:
- Materials Featurization — descriptors (Magpie, SOAP, MBTR, graph features) that map structures or compositions to fixed-length vectors are required before a GP or neural surrogate can operate over the chemical space. The featurization skill provides the descriptor pipelines used in Workflows 1–5.
- Materials Databases Access — the initial candidate pool for BO screening is often drawn from Materials Project, AFLOW, or OQMD. Compatibility checking and structure deduplication from the databases skill are required before building the search space.
- Scientific Visualization — Pareto front plots, acquisition function landscape visualization, GP posterior plots, and BO convergence curves are the standard outputs of BO campaigns; this skill provides the plotting conventions and multi-panel figure standards.
- Reproducibility Workflow — BO campaigns involve many coupled objects: the dataset, the surrogate checkpoint, the acquisition log, the evaluation oracle (DFT inputs and outputs), and the final candidate. All must be versioned and archived together for the campaign to be reproducible.
Evaluation oracle:
- High-Throughput DFT — in materials BO, the evaluation oracle is usually HT-DFT. The batch selection from BO maps directly to job submission in atomate2/FireWorks. The HT-DFT skill provides job orchestration; this skill provides the acquisition logic that determines what to submit next.
- DFT Convergence — the DFT convergence tier used for BO evaluations must be documented. Mixing convergence tiers (screening vs. high-accuracy) within the BO dataset corrupts the surrogate.
Active learning:
- Active Learning MLP — BO is a special case of active learning where the query criterion is an acquisition function targeting a single optimum or Pareto front, rather than uncertainty reduction across the full space. This skill and the active-learning-mlp skill share the surrogate → acquisition → oracle → update loop structure.
Key References
- Shahriari, B., Swersky, K., Wang, Z., Adams, R. P. & de Freitas, N. (2016). "Taking the human out of the loop: A review of Bayesian optimization." Proceedings of the IEEE 104, 148–175. Comprehensive review of acquisition functions, theoretical guarantees, and applications.
- Balandat, M., Karrer, B., Jiang, D. R., Daulton, S., Letham, B., Wilson, A. G. & Bakshy, E. (2020). "BoTorch: A framework for efficient Monte-Carlo Bayesian optimization." Advances in Neural Information Processing Systems 33. The primary BoTorch reference; cite when using BoTorch.
- Daulton, S., Balandat, M. & Bakshy, E. (2020). "Differentiable expected hypervolume improvement for parallel multi-objective Bayesian optimization." Advances in Neural Information Processing Systems 33. qEHVI reference for multi-objective BO.
- Hernández-Lobato, J. M., Hoffman, M. W. & Ghahramani, Z. (2014). "Predictive entropy search for efficient global optimization of black-box functions." Advances in Neural Information Processing Systems 27. Entropy Search acquisition function.
- Snoek, J., Larochelle, H. & Adams, R. P. (2012). "Practical Bayesian optimization of machine learning algorithms." Advances in Neural Information Processing Systems 25. Foundational practical BO paper with GP-based acquisition and hyperparameter optimization.
- Griffiths, R.-R. & Hernández-Lobato, J. M. (2020). "Constrained Bayesian optimization for automatic chemical design using variational autoencoders." Chemical Science 11, 577–586. Constrained BO with learned latent spaces for molecular design.
- Häse, F., Roch, L. M. & Aspuru-Guzik, A. (2019). "Phoenics: A Bayesian optimizer for chemistry." ACS Central Science 5, 1231–1241. BO applied to chemistry optimization campaigns; covers periodic and categorical spaces.
- Forrester, A. I. J., Sóbester, A. & Keane, A. J. (2008). Engineering Design via Surrogate Modelling: A Practical Guide. Wiley. Textbook-level reference for surrogate-assisted optimization including multi-fidelity methods.
[EXPERT REVIEW NEEDED: The optimal correlation threshold (ρ < 0.3) for deciding when multi-fidelity BO is not beneficial is a practical rule of thumb; verify against recent multi-fidelity BO benchmarks. Confirm whether qLogNEI is always preferred over qNEI in BoTorch 0.10+ or whether there are regression cases. Review whether the Mann-Whitney U test is the most appropriate statistical test for comparing BO vs. random search regret distributions, as these may not be independent across seeds.]
示例提示词
帮我用贝叶斯优化设计多目标实验方案来加速新合金成分筛选。
所属插件
安装该插件会一并获得同领域的 42 个 Skill / MCP。
同插件的其他科研 Skill
- CALPHAD热力学计算工作流Covers CALPHAD computational thermodynamics: database selection, equilibrium/metastable calculations, binary/ternary phase diagrams. Use when predicting phase stability or solidification paths.
- 材料第一性原理与分子动力学模拟Routes first-principles and classical materials simulation (DFT, MD, ML potentials) to the right specialized workflow. Use as an entry point for any simulation-based materials task.
- 蠕变力学建模与验证Selects, calibrates, and validates creep deformation and rupture models under sustained thermomechanical load, covering rate prediction. Use when assessing long-term high-temperature components.
- 晶体塑性有限元建模Covers crystal plasticity and CPFE modeling of metals: slip systems for FCC/BCC/HCP, Schmid factors. Use when simulating texture- and orientation-dependent plastic deformation.
- 衍射结构表征Covers diffraction-based structure characterization (XRD, neutron, SAED): space group determination, Rietveld refinement, phase identification. Use for any diffraction-pattern analysis technique.
- EBSD织构分析Analyzes EBSD orientation maps for grain size, misorientation, phase, and texture, with pole figures and twin-boundary identification. Use for electron backscatter diffraction workflows.
- 电化学性能测试分析Covers electrochemical characterization: cyclic voltammetry, battery cycling analysis, EIS. Use for electrochemistry-specific data analysis distinct from general materials characterization.
- 金属疲劳寿命评估Builds, calibrates, and validates fatigue assessments for metals and components: stress-life, strain-life, multiaxial critical-plane. Use when predicting fatigue life or crack growth.
- 多物理场有限元建模Covers finite element modeling for coupled materials, mechanics, and transport problems: weak-form construction, boundary conditions, mesh choice. Use for multiphysics FEM simulations.
- 连续尺度有限元力学建模Covers continuum-scale mechanical, thermal, and multiphysics simulation with Abaqus/COMSOL conventions, mesh generation. Use for macroscale FEM consuming measured or computed material properties.
- 断裂力学评估与建模Selects, constructs, and validates fracture-mechanics assessments: LEFM checks, elastic-plastic fracture mechanics. Use when assessing cracked materials or components.
- 高斯过程材料回归建模Covers Gaussian process regression for materials and chemistry datasets: descriptor selection, kernel design. Use when a probabilistic surrogate model with uncertainty is needed.
- 自驱动实验室闭环材料发现Covers combinatorial synthesis, robotic experimentation. Use for autonomous or robotics-driven experimental campaigns, a less standardized domain.
- 材料数据库可复现访问Covers reproducible API access to materials databases (Materials Project, AFLOW, OQMD, NOMAD, COD, ICSD-style sources): authentication. Use when programmatically querying these databases.
- 材料数据库跨库查询Covers querying public materials databases beyond Materials Project: AFLOW, OQMD, NOMAD, JARVIS. Use when pulling or comparing data from these live, API-integrated resources.
- 材料数据标准与互操作Covers data interoperability standards for materials science: CIF crystal files, the OPTIMADE query API. Use when structuring or exchanging materials data between tools.
- 材料结构特征化Covers converting structures, compositions, and trajectories into ML feature vectors: Magpie-style elemental statistics. Use when building inputs for materials ML models.
- 材料科学图表绘制规范Covers publication-quality figure conventions for materials science plots: phase diagrams, pole figures, stress-strain curves. Use when the deliverable is a figure, not just an analysis result.
- 材料信息学性质预测Covers ML for materials property prediction and generative design: descriptor-based models, crystal GNNs (CGCNN/MEGNet-class). Use for materials informatics distinct from interatomic potentials.
- 材料生命周期评估Covers life-cycle assessment for materials and manufacturing routes: goal/scope definition, functional units, inventory construction. Use for environmental-impact studies of materials.
- 材料科学文献检索Covers formulating literature search queries for materials science questions and synthesizing/citing results responsibly. Requires a web search tool; it cannot substitute for one.
- 工程材料选型设计Selects engineering materials via material indices and Ashby charts, ranking candidates by performance per cost or mass. Use when picking a material class for a design constraint.
- 材料统计方法与实验设计Covers statistics shared across materials characterization and simulation: design of experiments. Use for cross-cutting statistical treatment of materials data.
- 材料结构与成分核心分析Covers core structure and composition analysis: reading/writing crystal structures, composition handling, symmetry analysis, phase diagrams. Use as a general-purpose structure-analysis toolkit.
常见问题
贝叶斯优化材料发现能做什么?
Covers Bayesian optimization for materials and chemistry design: surrogate models, acquisition functions, batch/constrained BO. Use when planning sample-efficient experiments or simulations。
如何安装贝叶斯优化材料发现?
在科搭 Codar 左侧点击「插件」,在「组件」页签搜索「贝叶斯优化材料发现」并安装;在 Claude Code 或 Codex 中可以发送本页的安装提示词,或下载 Skill 包后解压到 ~/.claude/skills 或 ~/.codex/skills。
贝叶斯优化材料发现需要哪些权限?
该科研 Skill没有声明额外权限;执行具体操作时仍由 Agent 按自身规则请求确认。
贝叶斯优化材料发现经过官方审核吗?
是。SpeedSkills 收录的每个版本都会记录内容摘要与权限声明,当前版本已通过安全审核。