AI4S in Production: How to Build a Molecular Screening Funnel That Works

    This article explains how to move AI for Science (AI4S) molecular screening from a demo into production. Instead of chasing generation throughput, it refrines the problem around enrichment, cost per validated candidate, and reproducibility, then describes a five-layer decoupled architecture, a multi-stage funnel that narrows 10^9 molecules down to 10^1, agent orchestration with structured outputs and human gates, cost controls for the generate-fast/verify-slow imbalance, common evaluation pitfalls, and a phased rollout plan with wet-lab success as the north star metric.

    1. Reframing the Problem: Not “Compute Faster” but “Screen More Accurately”

    Over the past year, major LLM vendors have visibly shifted R&D focus from code generation toward life sciences, chemistry, and pharmaceutical research. AI4S (AI for Science) and AIDD (AI Driven Drug Discovery) have become high-frequency terms. The reason is not mysterious: the intelligence demand for finance and legal tasks is roughly on par with programming, whereas research tasks impose higher requirements on long-chain reasoning, constraint satisfaction, and result verifiability.

    From an engineering perspective, however, the real bottleneck is not “generation speed.” A virtual library can easily reach 10^6 to 10^9 in scale. If a generative model is treated as a molecule generator, output will instantly exceed the processing capacity of every downstream validation stage. The phrase “who survives to the end” in the title is essentially a question about the screening funnel and the evidence chain: not who floods in the most, but who can be proven effective, synthesizable, and affordable.

    Therefore, the core metrics of an AI4S platform should shift from “throughput” to three quantities:

    • Enrichment: the lift in the proportion of truly active compounds in Top-K relative to a random baseline.
    • Cost per valid candidate: the combined compute and human effort consumed for each compound that enters wet-lab experiments.
    • Reproducibility: the consistency of conclusions produced from the same input at different times and under different configurations.

    2. Reference Architecture: Five Decoupled Layers

    1) Data layer: molecule libraries, protein structures, omics data, and experiment records are unified into object storage, with metadata and version numbers recorded in a database; raw data is immutable, and derived data can be rebuilt.
    2) Compute layer: a container platform hosts stateless compute images, batch queues handle task orchestration, and elastic scaling absorbs peaks.
    3) Intelligence layer: molecular representation models, property prediction models, structure docking and dynamics modules, plus an orchestrating agent.
    4) Evidence layer: logging and monitoring/alerting record the input fingerprint, model version, and random seed for every score.
    5) Interaction layer: dashboards for researchers and an entry point for manual review.

    The value of decoupling: models are replaceable, data is traceable, and compute is portable, avoiding tight coupling of the entire pipeline to any specific tool.

    3. A Multi-Stage Funnel: Compressing 10^9 to 10^1

    A single-stage “one big model does everything” approach is bound to fail in engineering, because the compute-accuracy curves differ drastically across stages. The sensible approach is increasing precision with decreasing sample size:

    • Stage 0 rule filtering: drug-likeness ranges such as molecular weight, partition coefficient, rotatable bonds, and polar surface area; removal of structural alert groups (PAINS-like). Cost is nearly zero, and it typically cuts 60% to 80%.
    • Stage 1 fingerprint similarity and clustering: nearest-neighbor retrieval and diversity clustering using fingerprints or graph representations, ensuring candidates are not redundant copies of the same scaffold.
    • Stage 2 lightweight property prediction: predicting solubility, permeability, metabolic stability, cardiotoxicity risk, and more, with uncertainty outputs.
    • Stage 3 structure-level evaluation: docking scores, plausibility of binding modes, and checks of key residue interactions.
    • Stage 4 high-precision physical computation: methods such as free energy perturbation or thermodynamic integration, opened only to a very small number of candidates.
    • Stage 5 agent-based comprehensive review: integrating the above evidence to make biological plausibility judgments and experiment design suggestions.

    A schematic pipeline skeleton (pseudocode, expressing orchestration logic only):

    1. def screen(library, target, cfg):
    2. cands = rule_filter(library, cfg.lipinski) # Stage 0
    3. cands = cluster_diverse(cands, n=cfg.diversity_n) # Stage 1
    4. cands = predict_props(cands, model=prop_v3) # Stage 2
    5. scored = [(m, dock(m, target)) for m in cands] # Stage 3
    6. top = select_top(scored, k=cfg.k3)
    7. refined = [fep(m, target) for m in top] # Stage 4
    8. return agent_review(refined, evidence=collect()) # Stage 5

    Key point: the output of every stage must carry uncertainty and failure reasons, not just a score. Downstream needs to know “why it was eliminated” to decide whether it is worth retrieving.

    4. Agent Orchestration: Turning “A PhD Student’s Day” into a Reusable Workflow

    What was compressed in the original scenario is highly procedural yet judgment-requiring work such as marker gene computation, ribosomal protein filtering, and biological plausibility assessment. These tasks take 4 to 8 hours, with the main cost in context switching and manual cross-checking rather than compute.

    The right way to agentify them is “narrow responsibility + strong validation”:

    • Each agent handles only one type of judgment, with inputs and outputs constrained by structured schemas; free text is forbidden from being passed directly downstream.
    • Tool calls are whitelisted, and all external computation is initiated through controlled interfaces with fixed parameters and versions.
    • Key conclusions must cite evidence snippets (data source, field, timestamp); without evidence, output “uncertain.”
    • Set human confirmation gates; high-risk conclusions are not allowed to flow automatically.

    A minimal example of structured output:

    1. {
    2. "gene_set": ["GENE_A", "GENE_B"],
    3. "filtered_out": [{"id": "GENE_C", "reason": "ribosomal_protein"}],
    4. "confidence": 0.82,
    5. "evidence": ["dataset:v12/table3", "annotation:2026-05"]
    6. }

    The direct benefit is auditability: any conclusion can be traced to a specific data version and model version, meeting the dual requirements of research and compliance.

    5. Compute and Cost: Don’t Let “A Meal’s Time” Become a Bill Black Hole

    Fast generation and slow verification is the most typical cost-structure imbalance in AI4S. There are four control measures:

    • Tiered quotas: use high-concurrency, low-spec instances for Stage 0/1, and a small number of high-spec instances with queuing for Stage 4, preventing high-precision tasks from seizing all resources.
    • Caching and deduplication: cache intermediate results keyed by the hash of normalized molecules and reuse them across batches; in practice, repeated computation often accounts for a high proportion.
    • Asynchronization: long tasks go through message queues, the frontend is not blocked, and failures are retried automatically with an upper limit.
    • Observability: monitoring and alerting cover queue backlog, single-task latency distribution, and cost per candidate, with automatic degradation to a lower-precision path on anomalies.

    When deployed on the cloud, these capabilities map respectively to general categories such as object storage, container platforms, batch processing and message queues, and logging and monitoring/alerting. General cloud infrastructure from vendors such as Baidu AI Cloud can host this kind of architecture without binding to a specific model.

    6. Evaluation and Pitfalls

    • Data leakage: split training/test sets by time rather than randomly; otherwise high scores from virtual screening are meaningless.
    • Single metric: looking only at score ranking masks calibration problems; report both ranking metrics and calibration curves.
    • Lack of diversity: if Top-K is all the same scaffold, it equals running only one experiment.
    • Not synthesizable: treat synthetic feasibility as an early soft constraint, not a late-stage veto.
    • Conclusion drift: fix random seeds and dependency versions, include them in a regression test set, and run regression before rollout after model upgrades.

    7. Rollout Roadmap

    In the first phase, get Stage 0 to 2 and the evidence layer working, and make reproducibility and cost visibility available first. In the second phase, integrate structure evaluation and agent review, and establish human gates. In the third phase, introduce high-precision physical computation, opened only to the very few candidates that have passed multiple rounds of filtering. Always use “the number and success rate of candidates entering wet-lab experiments” as the sole north star metric; other throughput metrics are only for reference.

    When thousands upon thousands of molecules flood the entrance, victory does not depend on generation capability, but on funnel design, evidence chain completeness, and engineering discipline. These three are the real threshold for AI4S to go from demo to production.