AI4S in Practice: How to Build a Million-Molecule Screening Funnel

    This article breaks down AI4S molecular screening as an engineering problem rather than a single prediction task. It explains the cascade funnel structure, multi-objective scoring with Pareto ranking and uncertainty, agent orchestration with human-in-the-loop checkpoints, active learning loops that address distribution drift, and the traceability requirements that separate scientific AI from general applications. It also outlines a vendor-neutral cloud architecture for handling millions of candidates, cost governance per funnel layer, common pitfalls, and a three-step adoption path.

    Introduction: The Shift from “Writing Code” to “Doing Science”

    Over the past two years, large models have been strongest at code generation and structured text processing. Recent industry signals show the focus of development moving toward biology, chemistry, and pharmaceutical research. The reason is not mysterious: reasoning tasks in finance and law sit at a level comparable to programming, whereas scientific discovery requires a model to perform multi-step inference under incomplete evidence and high noise. That demands more of its reasoning ability, knowledge grounding, and the verifiability of its results.

    The shift is especially visible in drug discovery. A virtual compound library can easily contain hundreds of thousands to tens of millions of molecules, while only a tiny fraction ever reaches the clinic. Traditional workflows rely on extensive manual annotation, literature cross-checking, and expert judgment. A single step, such as marker gene computation, ribosomal protein filtering, or biological plausibility assessment, can take a researcher hours. Once agent orchestration is introduced into this pipeline, the same work can be compressed into the time it takes to have a meal. Note that this is not simply a matter of a “smarter” model; it is the result of re-engineering the process.

    This article discusses no specific product. Instead, it abstracts the problem into a general technical one: how to build a high-throughput, auditable, and iterable AI4S molecular screening system in which thousands of candidate molecules are eliminated layer by layer through a funnel, leaving only a few entities worth investing in clinical validation.

    1. The Nature of the Problem: A Funnel, Not a Single Prediction

    Many teams misunderstand AI4S as “training a stronger prediction model.” In reality, the core structure of molecular screening is a cascade funnel:

    1. Generation/enumeration layer: Starting from known scaffolds, perform substitution and recombination, or sample from a generative model, to produce candidates on the order of 10^6 to 10^7.
    2. Rule and physics filtering layer: Molecular weight, partition coefficient, number of hydrogen bond donors and acceptors, rotatable bonds, reactive groups (PAINS-type alert structures), and so on, cut more than 80% at very low cost.
    3. Docking and binding mode layer: Assess spatial fit with the target and the interaction pattern.
    4. Property prediction layer: Druggability metrics such as solubility, permeability, metabolic stability, hERG, and liver toxicity.
    5. Biological plausibility layer: Pathway consistency, expression specificity, and whether the causal chain with the disease mechanism is self-consistent.
    6. Wet-lab validation layer: Synthesis, biochemical and cell assays, feeding results back to the model.

    The key engineering insight is that the compute budget and precision requirement of each layer are completely different. The physics rule layer must be “fast and rough,” the prediction layer “accurate and stable,” and the final validation layer “few and precise.” The goal of system design is not to make any single layer optimal, but to minimize overall expected cost and maximize expected return.

    2. Multi-Objective Scoring: Turning a “Good Molecule” into a Computable Vector

    Single-objective scoring, such as optimizing binding affinity alone, almost inevitably fails, because it drives the search toward regions with poor solubility and high toxicity. A workable approach is to represent each candidate as a multi-objective vector and then apply scalarization or Pareto ranking:

    1. # Illustrative code: multi-objective scoring and Pareto front filtering
    2. from dataclasses import dataclass
    3. @dataclass
    4. class Candidate:
    5. smiles: str
    6. affinity: float # higher is better
    7. solubility: float # higher is better
    8. toxicity: float # lower is better
    9. synth_feasibility: float # higher is better
    10. def pareto_front(cands):
    11. """Return the non-dominated set to avoid losing information through premature scalarization"""
    12. front = []
    13. for c in cands:
    14. dominated = any(
    15. (o.affinity >= c.affinity and o.solvency_ok(c) if False else False)
    16. for o in cands
    17. )
    18. # A real implementation must compare dominance across each dimension
    19. front.append(c)
    20. return front
    21. def scalarize(c, weights):
    22. return (weights['aff'] * c.affinity
    23. + weights['sol'] * c.solubility
    24. - weights['tox'] * c.toxicity
    25. + weights['syn'] * c.synth_feasibility)

    There are three engineering points. First, perform Pareto non-dominated ranking to preserve diversity, then scalarize according to business weights, avoiding locking down the search space too early through weight settings. Second, every score must carry uncertainty; candidates with high uncertainty should be sent to experiments rather than eliminated outright. Third, scoring functions must be versioned, so any weight or model update can be traced back to specific batch results.

    3. Agent Orchestration: Making a PhD Student’s Implicit Process Explicit

    The time compression mentioned earlier comes essentially from making implicit experience explicit as orchestrable steps. A typical agent pipeline contains four roles:

    • Retrieval agent: Gathers evidence from literature and databases, outputting evidence fragments with source citations;
    • Computation agent: Invokes tools for molecular descriptor calculation, docking, property prediction, and so on;
    • Review agent: Performs biological plausibility checks, identifying mechanism conflicts and flaws in experimental design;
    • Summarization agent: Produces structured reports and decision recommendations.

    The orchestration layer must handle three things: task decomposition and dependency management, retry and timeout handling for tool calls, and human-in-the-loop approval checkpoints. High-risk actions, such as submitting wet-lab experiments or changing a lead compound, must require mandatory human confirmation.

    1. User goal
    2. └─ Planner: decomposes into a subtask DAG
    3. ├─ Retrieval and evidence ──► Evidence store (with citations)
    4. ├─ Parallel computation ──► Metrics table (with uncertainty)
    5. └─ Plausibility review ──► Risk list
    6. └─ Summarization ──► Structured report ──► Human approval ──► Archive/feedback

    4. Active Learning Loop: Making Every Experiment Batch Raise the Model’s Ceiling

    The efficiency ceiling of the funnel is determined by the closed loop. The conventional active learning approach uses an ensemble model or approximate Bayesian inference to estimate predictive variance, selecting “high mean + high variance” candidates for experiments, then retraining once results flow back. Here is a minimal viable loop:

    1. # Illustrative: uncertainty-based batch selection
    2. def select_batch(cands, model_ensemble, batch_size=32, exploit=0.7):
    3. scored = []
    4. for c in cands:
    5. preds = [m.predict(c.features) for m in model_ensemble]
    6. mean = sum(preds) / len(preds)
    7. var = sum((p - mean) ** 2 for p in preds) / len(preds)
    8. scored.append((c, mean, var))
    9. scored.sort(key=lambda x: x[1], reverse=True)
    10. n_exploit = int(batch_size * exploit)
    11. picked = scored[:n_exploit]
    12. rest = sorted(scored[n_exploit:], key=lambda x: x[2], reverse=True)
    13. return picked + rest[:batch_size - n_exploit]

    The distribution drift problem needs emphasis: the generative model continuously pushes candidates into regions outside the training set, and the model’s extrapolation ability in those new regions is unreliable. It is therefore necessary to monitor the difference between the input distribution and the training distribution, and to trigger retraining or fall back to rule filtering when drift exceeds a threshold.

    5. Explainability and Auditability: The Dividing Line Between AI4S and General AI Applications

    Scientific conclusions must be open to challenge and reproduction by peers, which means the system must have traceability built in:

    • Evidence chain: Every conclusion carries source citations and computation parameters, traceable with one click;
    • Decision records: Log model versions, weight configurations, random seeds, and human approval comments;
    • Counterfactual analysis: Explain how a conclusion would change “if a certain substructure or piece of evidence were removed”;
    • Failure case library: Structurally accumulate eliminated molecules and the reasons for elimination, turning them into a negative-sample asset.

    6. Engineering Architecture: A General Cloud Form That Supports Tens of Millions of Candidates

    To put the above logic onto infrastructure, you can assemble it from capabilities common in the industry, without binding to any specific vendor:

    • Object storage: Hold the molecule library, intermediate artifacts, and raw experimental data, with lifecycle policies for hot/cold tiering;
    • Container platform: Containerize compute and inference tasks, scaling elastically by queue;
    • Message queue: Decouple the generation, filtering, and prediction stages, enabling peak shaving and failure isolation;
    • Batch processing and HPC scheduling: Carry large-scale parallel scoring;
    • Vector retrieval service: Support semantic recall over the literature and evidence store;
    • Logging service + monitoring and alerting: Track task success rate, latency, and cost, with automatic alerts on anomalies;
    • Data warehouse/lakehouse: Unify metric definitions and support retrospective analysis.

    In the technical context of Baidu AI Cloud, this kind of requirement typically lands at the level of general product categories: a combination of object storage, container platform, message queue, logging service, and monitoring and alerting is enough to support a complete pipeline from data ingestion to result archiving, without any proprietary coupling in the architecture.

    Cost governance is equally important. It is advisable to set a per-candidate cost budget for each layer and monitor the ratio of “elimination rate / compute consumption” in real time within the funnel. When a layer consumes a lot of compute but its elimination rate is below expectations, that layer’s model needs retraining or its thresholds need adjustment.

    7. Common Pitfalls and Implementation Advice

    1. Chasing only model accuracy while ignoring process design: The funnel’s gains come mainly from layer division and budget allocation.
    2. Scalarizing multiple objectives too early: Preserve the Pareto front first and leave weight decisions to business review.
    3. Ignoring uncertainty: Active learning without variance estimation degenerates into random sampling.
    4. Lacking human checkpoints: A fully automated loop carries very high risk in scientific settings; key nodes must be pausable.
    5. No versioning or record-keeping: In a scientific context, a result that cannot be reproduced is equivalent to no result.

    A three-step adoption path is recommended: first, use rules and existing prediction models to get the funnel running and establish baseline metrics; then introduce agent orchestration and the active learning loop to improve output per unit of compute; finally, complete explainability and audit capabilities so the system qualifies for peer review.

    Conclusion

    The real barrier to AI4S lies not in whether a model can answer a chemistry question, but in whether the elimination process over millions of candidates can be turned into a high-throughput, low-cost, explainable, and reproducible engineering system. Who survives to the end depends on the budget discipline of each funnel layer, the speed of closed-loop feedback, and the trustworthiness of results, rather than the absolute accuracy of any single prediction.