GeomLlama-zmatrix is a fine-tune of Llama-3.1-8B-Instruct that generates
3D molecular conformer geometries directly from a SMILES string, emitting each
structure as a Fenske–Hall Z-matrix (internal coordinates: bond length, bond
angle, dihedral, referenced to previously placed atoms). It is one of two models
from our paper; the companion model, Llama-3.1-8B-GeomLlama-xyz,
emits Cartesian XYZ coordinates instead.
The model was trained jointly ("hybrid") on GEOM-QM9 and GEOM-Drugs, so it
covers both small molecules and larger drug-like molecules with a single set of
weights.
Quick start
The model was trained in the Alpaca instruction format. Reproduce the exact
inference prompt used for the paper's numbers:
python
1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
34model_id ="THGLab/Llama-3.1-8B-GeomLlama-zmatrix"5tok = AutoTokenizer.from_pretrained(model_id)6model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16, device_map="auto")78smiles ="Cc1cccc(CSc2nnnn2-c2ccccc2)c1"9prompt =(10"### Instruction:\n"11"You can generate accurate molecular coordinates from a prompt "12"containing a SMILES string.\n\n"13"### Input:\n"14"Generate a realistic equilibrium geometry for the molecule with the "15f"following SMILES string in Fenske-Hall Z-matrix format: {smiles}\n\n"16"### Response:\n"17)1819inputs = tok(prompt, return_tensors="pt").to(model.device)20out = model.generate(**inputs, max_new_tokens=3072, do_sample=True, temperature=1.0, top_p=0.95)21print(tok.decode(out[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))
Sample many completions per SMILES (each is one candidate conformer) to build a
conformer ensemble. T=1.0, top_p=0.95 and T=1.2, top_p=0.95 are good defaults.
Output format
Each line places one atom. The first token is the element; the remaining tokens
are the internal coordinates relative to earlier atoms:
O 1 # atom 1: reference origin
C 1 1.388 # atom 2: bonded to atom 1 at 1.388 Å
H 2 1.090 1 105.769 # atom 3: bond to 2, angle to 1
C 2 1.547 1 117.304 3 129.0 # atom 4: bond, angle, dihedral
...
Atoms are emitted in an arbitrary order with no atom labels or connectivity
block — the model learns geometry from the SMILES alone. Parse the Z-matrix back
to Cartesian coordinates with a standard NeRF/internal-to-Cartesian routine.
Data: GEOM-QM9 + GEOM-Drugs, Fenske–Hall Z-matrix targets (ori_fh), plus the
Alpaca instruction dataset for
general-instruction rehearsal
Citation
Paper: How Well Can Frontier Large Language Models Generate Structures? High Quality
Prediction of Molecular Geometries with Help from Fine-Tuning —
arXiv:2607.13350. Please cite the paper and the
underlying GEOM dataset (Axelrod & Gómez-Bombarelli, Scientific Data, 2022) if you
use this model.
bibtex
1@misc{cavanagh2026geomllama,
2 title = {How Well Can Frontier Large Language Models Generate Structures?
3 High Quality Prediction of Molecular Geometries with Help from Fine-Tuning},
4 author = {Cavanagh, Joseph M. and Arnold, Jonathan B. and Alteri, Giovanni Battista
5 and Gritsevskiy, Andrew and Head-Gordon, Teresa},
6 year = {2026},
7 eprint = {2607.13350},
8 archivePrefix = {arXiv},
9 url = {https://arxiv.org/abs/2607.13350}
10}