Engineering LLMs for AI for Science: Workflows, Architecture, and Best Practices
Integrating Large Language Models (LLMs) into AI for Science (AI4S) requires a shift from chat interfaces to executable, auditable scientific workflows. This article explores the engineering path for building research agents, detailing a five-layer capability stack and practical applications in single-cell analysis, genetic variant interpretation, and paper reproduction. It also highlights common engineering pitfalls and provides an actionable sequence for teams to build robust, reliable scientific AI infrastructure.
The Problem Isn’t “Models Can Chat,” But That Scientific Workflows Are Too Long
AI for Science (AI4S) refers to using machine learning and large models to participate in observation, hypothesis generation, computation, experimental design, data analysis, and conclusion review—not just generating professional-looking text. A typical signal in recent industry discussions is that general-purpose large models are being integrated into biomedical research agents, covering single-cell analysis, genetic variant interpretation, and paper reproduction. Removing specific product names, this signal still holds: foundation models are moving from “Q&A interfaces” down to a “research execution layer” equipped with tools, data, and auditing.
Capital enthusiasm explains attention, but not engineering difficulty. What truly pushes teams toward AI4S is the structural difference between scientific tasks and general office tasks:
- Inputs are not tidy documents; they are a mix of tables, images, sequences, spectra, experimental records, and literature.
- Correctness cannot be judged by fluency. A clustering label, a pathogenicity grading, or a runnable analysis script must be traceable back to data and parameters.
- A single conversation cannot solve the problem. Real workflows involve multi-step tool calling: quality control (QC), normalization, batch correction, differential analysis, annotation, visualization, and writing methodology paragraphs.
- The cost of failure is asymmetric. Hallucinating a review outline costs a rework; hallucinating a clinically relevant variant conclusion could directly affect subsequent medical judgments.
Therefore, a more accurate description of this “collective advance” is that model capabilities have just crossed the thresholds for tool calling and long context, while the scientific community has long lacked the personnel to productize analysis workflows. The two sides have finally connected at this specific point in time.
Capability Stack: The Model is Just One Layer
It is more useful to think of a research agent as five layers rather than a single chatbot:
- Knowledge Layer: Literature, protocols, ontologies, and domain vocabularies. It constrains statements like “this gene might be related to this pathway” to citable claims.
- Data Layer: Raw sequencing matrices, clinical phenotypes, and experimental metadata. These must include sample IDs, batches, treatment groups, and units, rather than just a file name.
- Tool Layer: Statistical tests, dimensionality reduction, clustering, enrichment analysis, and variant annotation rules. The model should not rewrite these algorithms; it should select, parameterize, and orchestrate them.
- Orchestration Layer: Breaks down natural language goals into plans, calls tools step-by-step, checks if intermediate results cross boundaries, and rolls back or asks a human for help upon failure.
- Evidence Layer: Saves input versions, random seeds, parameters, software environments, and output charts so that another researcher can reproduce the run.
General-purpose large models are best suited for the orchestration and explanation layers. Numerical computation, statistical significance, and established grading rules should still be handled by deterministic programs. If this division of labor is reversed—asking the model to “report a p-value from memory”—the system becomes unusable.
The illustrative orchestration logic can be straightforward:
Goal = User Task + Data Inventory + Allowed Tool SetLoop:Plan = Model generates next step based on current evidenceIf Plan exceeds tool or data permissions: Reject and explain the gapResult = Execute Tool(Plan.parameters)Record(Plan, Parameters, Result Summary, Data Version)If Result triggers QC failure: Modify Plan or escalate to humanUntil Task is complete or step limit is reachedOutput = Conclusion + Charts + Reproducible Records
There are no mysterious interfaces here. The key lies in permissions, step limits, and logging, not how fancy the prompt is.
Scenario 1: Single-Cell Analysis — Model as Navigator, Not Operator
The conventional path for single-cell transcriptomics is relatively stable in the industry: cell and gene QC, normalization, identifying highly variable genes, dimensionality reduction, clustering, cell type annotation based on known marker genes, differential expression between groups, and pathway or gene set enrichment, followed by plotting publishable figures. The pain point usually isn’t the “lack of algorithms,” but the lengthy workflow, parameter sensitivity, hard-to-explain batch effects, and experience-dependent annotation.
The reasonable responsibilities of a research agent here are:
- Translating user goals into checklists. For example, confirming whether the matrix is raw counts or already normalized to avoid log-transforming standardized data again.
- Providing explainable suggestions for QC thresholds and mandating the display of the proportion of filtered cells. The threshold should be determined by data and distribution, not hardcoded as a universal constant.
- Retrieving marker genes and ontologies during the annotation phase to provide candidate labels and counter-evidence, rather than directly outputting a single cell type.
- Separating “batch” from “biological group.” If the two are completely confounded, it should explicitly state that technical effects cannot be distinguished from biological effects.
What it shouldn’t do is equally clear: use generative text to fill in missing expression values, “explain” low-quality cells as new cell types, or claim to have discovered a drug mechanism without a control design. These create conclusions that cannot be verified.
When evaluating such systems, don’t just look at whether the final UMAP plot is visually appealing. More useful metrics include: whether QC rules were executed, whether marker genes are consistent with labels, the clustering stability of repeated runs on the same data, and the proportion of model annotations overturned by human experts. A higher rate of the latter doesn’t necessarily mean the product is bad, but it indicates that the boundaries of automation must be clearly marked.
Scenario 2: Variant Interpretation — Rules Over Language
Genetic variant interpretation is even less tolerant of “gut feelings” than single-cell analysis. A common framework in clinical and research settings categorizes evidence into supporting pathogenic, supporting benign, and uncertain, which are then synthesized into a final grade. Evidence comes from population frequency, functional assays, familial co-segregation, computational predictions, and prior cases—not from the model’s verbal confidence.
Engineering-wise, three principles should be followed:
- Retrieval before generation. First check frequency, transcripts, existing gradings, and literature, then let the model organize the language. If nothing is found, write “insufficient evidence”; do not fabricate a plausible-sounding story.
- Versioned rules. Grading clauses will be updated. The system must record which version of the rules and annotation libraries was used, otherwise the original conclusion cannot be explained two months later.
- The model does not sign the final medical opinion. It can organize conflicting evidence, point out missing experiments, and draft explanations for genetic counselors; the final grading must still be confirmed by a human, keeping a trace of modifications.
A practical output structure is “Claim–Evidence–Gap”: the claim is the candidate grading, the evidence consists of traceable fields, and the gap is what type of experiment or family information is still missing. This structure is more valuable than a smooth pathophysiological explanation because it keeps the uncertainty on the table.
Scenario 3: Paper Reproduction — Goal is to Run, Not Rewrite
Paper reproduction is the best scenario to test a research agent’s honesty. The input is usually methodology paragraphs, supplementary materials, and data availability statements; the output should not be a more polished paper, but rather: whether the environment can be built, whether data is available, whether key figures are reproduced within tolerance, and which steps were left unclear in the original text.
A reproducible closed loop should at least include:
- Parsing the methodology to extract software categories, key parameters, and statistical models. If something cannot be extracted, list it as “unstated in the original text”; do not use common defaults to pretend the original text said so.
- Executing the analysis in an isolated environment. Dependency versions, random seeds, and hardware differences must be recorded in the run log.
- Pre-agreed comparison metrics. For example, clustering adjusted Rand index, overlap ratio of differential genes, or relative error of chart values. A “looks similar” without a threshold does not count as reproduction.
- Failure is also a result. Missing data, incomplete protocols, or unmet statistical assumptions should form a reproduction report, rather than letting the model switch algorithms to “make a similar chart.”
This also explains why large models are useful: methodology texts vary widely, and traditional rule-based parsing easily misses things; models excel at aligning unstructured descriptions to tool parameters. However, it must accept the constraint to “stop if alignment fails.” Being able to stop is closer to science than being able to continue fabricating.
Why Now: Four Matured Technical Conditions
First, context windows and tool calling allow models to hold multi-step plans rather than just answering single-point questions. The planning length of scientific tasks previously just exceeded the controllable range of pure conversational systems.
Second, the “last mile” of scientific data is being organized into callable interfaces: raw files in object storage, tabular sample metadata, literature retrieval, and workflow engines. Without these interfaces, models can only talk in vain.
Third, evaluation has shifted from language benchmarks to task benchmarks. The community is gradually accepting that writing a correct introduction does not equate to performing a correct differential analysis. Task benchmarks force teams to expose intermediate products.
Fourth, the workforce structure has changed. The speed at which experimental teams generate data outpaces the speed at which dedicated bioinformaticians can digest it. Agents are being used to handle workflow navigation and documentation, leaving expert time for experimental design and anomaly judgment.
Funding and media exposure will amplify this trend, but they are not technical reasons. If you only chase the hype without building the evidence layer, the system will fail during its first real-world reproduction attempt.
Common Engineering Pitfalls
Treating domain fine-tuning as a source of correctness. Continuing to train on papers can increase term density, but it will not automatically enforce statistical prerequisites. Fine-tuning is suitable for unifying output formats and tool-calling habits; algorithms and grading still rely on external tools.
Ignoring data governance. Human genetic data, clinical phenotypes, and unpublished results all have authorization boundaries. The tool permissions of the agent should be minimized by project, sample, and personnel. Identifiable information should not be left in logs. Cross-project “incidental retrieval” is also an overstep in scientific scenarios.
No negative testing. Only demonstrating smooth runs on public datasets will overestimate the system. Cases with injected unit errors, swapped group labels, missing batches, and deleted methodology sections should be intentionally added to see if the system refuses or raises an alarm.
Stuffing prompts with role settings. “You are a senior scientist” does not improve the reliability of a p-value. Effective constraints are schema-based outputs, tool whitelists, mandatory citations, and human sign-off points.
Miscalculating compute and costs. Large model API calls are usually not the most expensive part; raw data transfer, alignment, or clustering are. Architecturally, the model should make decisions while the batch processing engine handles the computation, avoiding stuffing matrices into the context window.
Actionable Build Sequence
For teams preparing to integrate large models into their research workflows, a stable sequence is:
- Select a narrow workflow that already has standard operations and clear failure modes, such as single-cell QC to annotation, or variant evidence table compilation. Do not start with “arbitrary scientific questions.”
- Encapsulate existing scripts and rules into a small number of stable tools, each with an input schema, output schema, and error codes.
- Mandate evidence packages: data versions, parameters, environments, charts, and human confirmations. Runs without an evidence package are considered invalid.
- Build golden sets and adversarial sets. The golden set measures whether the task can be completed; the adversarial set measures when it should stop.
- Write the human-AI division of labor into the interface: the model can draft, but key gradings, external conclusions, and data export must be confirmed by humans.
- Only then consider multimodality and longer autonomous step counts. Autonomy is added after error-rejection capability is proven, not turned on by default.
If using cloud-based object storage, container platforms, workflow scheduling, and log auditing, their role is to keep data and run traces in a manageable environment. When choosing, look at the permission model, data residency, and task repeatability; there is no need to bind scientific conclusions to a specific product marketing pitch.
Conclusion
Large models are entering AI4S because scientific workflows can finally be broken down into “language-understood planning” plus “deterministic tool execution” plus “auditable evidence.” Single-cell analysis tests whether it can navigate parameters, variant interpretation tests whether it can follow rules, and paper reproduction tests whether it can stop when information is missing. If a system passes all three, it qualifies as research infrastructure; if it only passes a conversational demo, it remains just an interface.
For developers, the next step is not to pile on a longer prompt, but to write tool boundaries, data versions, and failure criteria into code. For researchers, the question worth asking is not whether the model “understands biology,” but whether every conclusion can be reproduced by another person, on another machine, according to the records. That is the dividing line where AI4S transitions from a hot topic into a methodology.
