Multimodal LLMs for Chemistry: Designing a Spectra-Reading Assistant
This article explains how multimodal large language models can support chemists in interpreting experimental spectra. It analyzes why spectra reading differs from ordinary image recognition, outlines a five-layer assistant architecture, presents a hypothesis-verification agent workflow, and describes evaluation metrics, production considerations, and common pitfalls.
Introduction: Chemistry Workflows Begin with a Spectrum
In a chemistry laboratory, the identity of a compound is often supported by several spectra:
- Mass spectrometry provides molecular weight and possible molecular formulas.
- Infrared spectroscopy suggests which functional groups are present.
- The details of nuclear magnetic resonance, or NMR, spectra often determine molecular skeletons and spatial configurations.
- Chromatography relates to purity and separation quality.
The usual judgment process is to first determine the molecular formula, then infer the degree of unsaturation, then assign peaks one by one, cross-check them, and finally synthesize candidate structures.
This process has three notable characteristics:
- The raw data produced by instruments comes in diverse formats.
- Interpretation relies heavily on empirical knowledge about “peak-to-structure” relationships.
- The same dataset may correspond to multiple reasonable candidate structures.
For newcomers, learning to interpret an NMR spectrum can require years of training. For experienced chemists, interpretation can become repetitive, time-consuming, and a significant part of daily work.
Large models are now entering chemistry workflows. Pure text models are suitable for summarizing experimental records, retrieving literature, and drafting plans. However, a substantial part of chemical judgment comes from spectra, which makes “multimodal capability plus tool calling” a key requirement. Recently, several AI research teams have published technical documents on multimodal capabilities for scientific scenarios, with chemistry occupying a considerable portion. This reflects a practical driver: spectra have almost never been absent from the screens of chemists.
These technical documents have a notable characteristic: they are not papers and have not undergone peer review, but they often lay out task definitions, data construction, evaluation methods, and failure cases together. Readers can verify the basis of conclusions item by item, which is more useful for engineering teams assessing usability than simply viewing “effect demonstrations.”
This article borrows from their methodology and does not discuss any specific model. Instead, it answers a general question: to make large models truly understand spectra and become assistants to chemists, how should the technical architecture be designed, and what tradeoffs should be made in practice?
Core Challenge: Why Spectra Reading Is Not Ordinary Image Recognition
Many people interpret “looking at images” as conventional object detection or classification. However, the interpretation of chemical spectra goes far beyond that.
- The mapping between spectra and structures is many-to-many. A small molecule may correspond to dozens of NMR signals, and a small superposition error or overlapping peak may allow multiple interpretations for a given signal.
- Spectra are quantifiable data, not just pixels. Peak positions, peak intensities, integral areas, coupling splittings, and spectral shapes all have physical meaning and must be accurately extracted, not judged by an overall impression of the image.
- Context determines the conclusion. Whether the sample is purified, what solvent was used, and what type of NMR spectrum was measured, such as ¹H, ¹³C, or 2D, can significantly change the interpretation.
- Conclusions must be verifiable. Chemical work requires every judgment to be traceable to specific spectral peaks and rules. Models that provide only conclusions without evidence lack persuasiveness in the laboratory.
- The cost of errors is asymmetric. Bringing an incorrect structure into subsequent experiments often wastes more than just time and reagents.
Therefore, “reading spectra” is essentially a controlled reasoning task that requires collaboration between multimodal perception and deterministic chemical computation. The model is responsible for understanding, proposing hypotheses, and organizing judgments. Instrument data processing and chemical computation are responsible for providing factual evidence.
Capability Breakdown: Five Layers a Chemical Assistant Needs
1. Perception layer: turning spectra into structured data
Mainstream multimodal models map images to vectors through visual encoders, then feed them into language models together with text tokens. In the “pixel-to-semantic” alignment paradigm, this is often summarized into three stages: Connect, Pre-train, and Fine-tune. First, large-scale image-text pairs are used for alignment, and then instruction data teach the model to answer questions.
This capability is sufficient for general scenarios, but spectra are extremely sensitive to detail. A peak shift of 0.01 ppm or a small splitting peak may be critical to a judgment, and such information can easily be lost in compressed visual representations. A robust approach is dual-channel input: images are used for overall understanding and layout comprehension, while numerical data exported by instruments, such as peak tables, integrals, and coordinate-axis ranges, are precisely extracted by programs.
Illustrative pseudocode:
def load_spectrum(image_file, raw_data=None):"""Perception layer: recover structured information from the spectrum as much as possible,rather than relying only on pixels.raw_data: peak table, integrals, or raw data exported by the instrument(common formats such as JSON/CSV)"""meta = {"kind": None, "solvent": None, "nucleus": None}if raw_data:meta.update(extract_meta(raw_data)) # Instrument parameters, solvent, number of scans, etc.peaks = extract_peaks(raw_data) # [{"ppm": 7.26, "area": 100.0}, ...]else:# When raw data is unavailable, call OCR to read peak positions, integrals, and coordinate axespeaks = ocr_axes_and_labels(image_file)return {"image": image_file, "peaks": peaks, "meta": meta}def spectrum_context(spec):# Generate a neutral spectral description with units to reduce information loss in the vision encoderreturn {"summary": spec["summary"], # Method, sample, solvent, etc."peaks": spec["peaks"], # Peak position, intensity, integral, splitting if available"source": spec["source"] # raw_data / OCR / image_only}
The priority for numerical input should be: raw data > OCR-extracted data > pure image observation.
2. Knowledge layer: chemical knowledge callable from spectra
Chemical knowledge includes structured parts, such as molecular formulas, functional groups, and the periodic table. It also includes a large amount of empirical content, such as common residual solvent peaks, typical chemical shift ranges, coupling patterns, and practical experience in assigning peaks.
Constructing knowledge into a searchable knowledge base is key to freeing the assistant from “guessing from memory.” The knowledge base can include:
- Historical structure-to-spectrum mapping data from internal samples.
- Analytical methods and SOPs, meaning standard operating procedures, accumulated within the organization.
- Public general chemical rules and reference data.
Knowledge entries can be unified into a “condition-observation-explanation-source” format:
{"rule_id": "R-021","condition": "1H NMR, CDCl3, 400 MHz","observation": "A singlet appears at approximately δ 7.26","explanation": "Residual signal from incompletely deuterated chloroform","source": "Internal reference material list / public reference data"}
Raw data, reference materials, and internal SOPs may involve non-public information. Before integration, permission verification and desensitization must be completed.
3. Reasoning layer: structured prompts and a hypothesis-verification loop
Prompts should clarify the task type, such as determining whether a product matches the target compound, comparing whether two samples are identical, or locating impurity signals. They should also specify the rules to follow: every judgment should indicate the spectral peak position, and when ambiguity exists, candidates should be listed with methods for distinguishing them.
An illustrative prompt skeleton:
[Task] Determine whether the sample meets the structural expectations of target compound T1.[Spectral information] {spectrum_context}[Known background] Reaction system, expected byproducts, purification method[Rules]1. Each judgment must state the spectral peak position or spectrum region used as evidence.2. Do not use data outside the spectral information provided, such as characterization results not given.3. When multiple reasonable explanations exist, list all candidates.4. Provide a confidence level and suggest supplementary experiments that can resolve ambiguity.5. When safety hazards are involved, a clear warning must be provided.[Output] Conclusion + evidence table + candidate structures + confidence level + suggestions
Prompts constrain behavior, while fact verification is handled by tools. A single generation or multi-person review each has blind spots. A common practice is to perform multiple independent generations and then aggregate them: conclusions with high consensus can enter a fast track, while conclusions with significant disagreement can be sent to human review. This is similar to the process of “automated checks plus final human review” in code review.
4. Tool layer: replacing guessing with deterministic computation
A structured reasoning language interleaves Python-style code snippets, tool calls, and natural-language output, forming a loop of “generate code → run → continue reasoning based on results.” This paradigm was published in 2023 and was initially aimed at numerical and symbolic computation. It also illustrates a principle: if something can be calculated accurately by a program, it should not be left to the model to “mentally compute.”
Applied to a chemical assistant, available tools can be divided into four broad categories:
- Data processing: peak extraction, baseline correction, integration, and format conversion.
- Chemoinformatics: molecular formula parsing, unsaturation degree calculation, structure-to-name conversion, and substructure search.
- Spectral simulation and retrieval: mature prediction methods exist for some NMR, infrared, and mass spectrometry data. When conditions are not met, the process can degrade to similarity matching in an annotated sample library, and the result should be clearly marked as “reference-only.”
- Knowledge and literature retrieval: structured retrieval with sources.
It is important to emphasize that tools only provide facts. The final choice of conclusions is still made by the model.
5. Safety and compliance layer: a necessary question beyond papers
Chemical research has a dual-use nature, and some synthetic routes and compounds present safety risks. The assistant should by default refuse requests involving controlled substances or dangerous operations, recognize bypass methods such as “step-by-step decomposition to evade restrictions,” record high-risk requests for audit, and distinguish between “research information” and “executable operational instructions” in answers.
High-confidence false positives and unbounded generation are two types of errors that should least appear in professional scenarios.
Architecture: From Single-Turn Q&A to a Verifiable Agent
Three layers working together form the basic architecture of the assistant:
- Perception layer: ensures input accuracy.
- Knowledge layer: ensures that judgments are evidence-based.
- Reasoning and tool layer: ensures that the process is reviewable.
From an engineering perspective, this can be abstracted into the following flow:
+-------------------------------------------------------------------+| Task entry || Single spectrum / multiple-spectra comparison / reaction || progress tracking / structure verification |+-------------------------+-------------------+-------------------+v v+-----------------+ +---------------------+| Perception layer| | Safety policy || Image + numeric | | Input screening / || dual channel | | output review |+--------+--------+ +----------+----------+| |+-----------+-----------+v+---------------------------------------------------+| Knowledge retrieval: internal sample library / || rule library / SOPs / public reference data |+------------------------+--------------------------+v+---------------------------------------------------+| Reasoning and tool layer (up to N rounds) || Propose hypothesis -> call computation/search || tools -> compare simulated and measured spectra || -> If consistent: output evidence chain; || -> If inconsistent: revise hypothesis |+------------------------+--------------------------+v+---------------------------------------------------+| Output: conclusion + evidence table + confidence || + ambiguity notes + suggested experiments || Full call chain is logged for traceability/audit |+---------------------------------------------------+
The corresponding illustrative “hypothesis-verification” main loop is as follows:
def analyze_spectrum(spec, tools, max_rounds=3):ctx = spectrum_context(spec) # Perception layer outputhypotheses = [] # Maintain candidate structures with evidencefor step in range(max_rounds):hypo = reason(ctx, tools.search_knowledge, hypotheses) # Propose/revise hypothesespredicted = tools.predict_spectrum(hypo) # Simulate or reference matchdiff = compare(ctx, predicted) # Compute differences and match scorehypotheses = update(hypotheses, hypo, diff)if diff.score >= CONFIDENT: # Threshold calibrated from historical samples, not a fixed heuristicbreak# When ambiguity is large or confidence is low, suggest supplementary experiments# rather than forcing a conclusionreport = build_report(hypotheses, ctx, diff)return report
Three points are worth noting:
- When
updateremoves duplicates, it should compare not only standard SMILES but also stereochemical information. - The loop should end early only when confidence is high.
- When confidence is insufficient, the system should return suggestions for supplementary experiments, for example: “A DEPT-135 spectrum is recommended to distinguish primary, secondary, and tertiary carbons” or “A different deuterated solvent is recommended to rule out residual solvent interference,” so that the model clearly knows its boundaries.
Evaluation: How to Determine Whether an Assistant Truly Uses Spectra
Without evaluation, capability upgrades remain at the demonstration level. A practical evaluation system should include at least four parts.
- A fixed test set: jointly annotated by experimental personnel and experts, covering different instruments, solvents, concentrations, molecule types, and data quality levels, such as high signal-to-noise ratio, high noise, and peak overlap.
- Task-specific metrics:
- Peak position and integration extraction error, compared with raw instrument data.
- Functional group identification accuracy, based on expert annotations.
- Candidate structure accuracy, evaluating only structures and conclusions, not whether the wording is fluent.
- Evidence completeness rate, meaning whether each judgment has a spectral peak position or calculation basis.
- Overreach rate, meaning whether information not provided was used.
- Safety violation rate, meaning whether inappropriate content was generated.
- Difficulty stratification: samples with high signal-to-noise ratios and simple structures should be counted separately from samples with high noise or difficult isomer distinction. Averages can hide real weaknesses.
- Expert blind evaluation and double-blind comparison: chemistry experts should compare model outputs with human interpretations in a double-blind setting. The control conditions should not assume a single “best model.” Instead, they should compare three workflows: “human-only,” “model-only,” and “model plus human review,” answering the more practical question: which combination can reduce errors and save time.
Illustrative evaluation code:
def evaluate(report, gold):r = {}# 1) Peak-position extraction error (ppm), computed only when raw data is availableif gold["raw_peaks"]:r["peak_mae"] = mean(abs(p["ppm"] - q["ppm"])for p, q in zip(report["peaks"], gold["raw_peaks"]))# 2) Functional group identification accuracyr["functional_group_acc"] = accuracy(report["groups"], gold["groups"])# 3) Candidate structure accuracy: different representations of the same molecule are considered correctr["top1"] = int(canonical(report["candidates"][0]) == canonical(gold[" smiles".strip()]))r["topk"] = int(canonical(gold["smiles"].strip()) inmap(canonical, report["candidates"][:5]))# 4) Evidence completeness rate: each conclusion should be accompanied by a peak position or calculation basisr["evidence_rate"] = ratio_complete(report["claims"], report["evidence"])# 5) Overreach rate: use of characterization results not present in the inputr["overreach_rate"] = detect_unsupported(report, gold["inputs"])return r
Evaluation results should answer two questions: in which situations the model is reliable, and in which situations human fallback is mandatory. The former determines the scope of automation, while the latter determines workflow design.
Production Architecture: Combining General Cloud Capabilities
Turning a prototype into a service that a team can use typically involves combining several general cloud product capabilities. These are generic categories and do not refer to any vendor-specific interfaces:
- Object storage: archive original spectrum images, raw instrument data, model outputs, and evidence chains as audit records.
- Search services: support semantic retrieval of rule libraries, internal sample libraries, and SOPs.
- Container platforms: deploy inference services, spectral processing tools, and chemical computation tools, making it easier to scale based on queue length.
- Message queues: make time-consuming tasks, such as high-resolution spectrum parsing, asynchronous to avoid blocking on long requests.
- Logging, monitoring, and alerting: record call chains and tool returns, and set alerts for response timeouts, tool failure rates, and sudden changes in confidence distributions.
- Permissions and auditing: knowledge bases should be isolated by project, instrument data should be authorized by laboratory, and sensitive data should be desensitized before entering the reasoning pipeline.
In terms of cost, both visual tokens and multi-round tool calls can easily increase the cost per request. Common strategies include caching the same input, batch processing similar spectra, routing models by task difficulty, and using rule engines to handle simple judgments first. This not only controls cost but also reduces unnecessary model calls.
Common Pitfalls and Recommendations
Inputting only images without numerical data.
Recommendation: preserve the raw instrument data channel and use images only as auxiliary input.Treating simulated values as measured values.
Recommendation: when tools return results, clearly mark them as “computed values” or “reference values,” and reflect this in the evidence table.Ignoring stereochemistry.
Recommendation: include stereochemical information in structure comparison, and require additional evidence for key chiral centers.Overtrusting high confidence.
Recommendation: confidence thresholds should be calibrated from historical samples, and manual sampling review should be retained.Not updating the knowledge base.
Recommendation: incorporate new conclusions, corrected cases, and instrument method changes into versioned updates, ensuring that conclusions can be traced back to a specific version of the rules.
Conclusion: Practical Changes Multimodal LLMs Bring to Chemists
The value of large models reading spectra lies not in replacing the judgment of chemists, but in moving repetitive preliminary screening forward: first provide candidate structures and differences with evidence, allowing experts to spend their time on key judgments.
From a technical route perspective, a reliable chemical assistant needs three things:
- Dual-channel perception of images and numerical data.
- Reasoning that combines knowledge retrieval with deterministic tools.
- Auditable evidence chains and safety constraints.
Rather than pursuing point improvements in isolated cases, it is more important to establish a sustainable evaluation and iteration mechanism so that capability growth can be verified. When a model learns to “read spectra,” what it truly learns is how to make cautious judgments under evidence-based conditions. This is precisely the most fundamental requirement chemistry research places on intelligent assistants.
