liveBook · Manning

CrystaLLM

As explained in Domain-Specific Small Language Models

A decoder-only Transformer language model in this section that is trained on CIF text to generate crystal structures.

CrystaLLM is a decoder-only Transformer language model that generates inorganic crystal structures from textual crystallographic information files (CIFs). It replaces conventional chemical representations with CIF symbol sequences, targeting physically plausible structures while reducing reliance on computationally intensive candidate optimization. section 8.4

During training, the model tokenizes CIFs and predicts each next token with a causal language-model objective. Cross-entropy compares predictions with left-shifted targets; tokens include CIF tags, atoms, digits, and punctuation. During inference, autoregressive sampling continues from a starting sequence until termination. Monte Carlo tree search and a graph-based neural network improve structural sampling. section 8.4

Figure 8.3 The CrystaLLM training process (a) and the generation process with MCTS decoding (b)

Use the training-and-inference diagram to connect causal next-token prediction with MCTS-based CIF generation. section 8.4

A practical generation workflow:

  • Create a prompt containing a target composition, such as data_Na2Cl2. section 8.4
  • Sample CIF text with a checkpoint, controlling top-k selection, output count, token length, and device. section 8.4
  • Postprocess and evaluate generated files for space-group consistency, atom-site multiplicity, bond-length reasonableness, and validity. section 8.4 section 8.5
  • Use MCTS decoding when improved sampling quality is preferred over straightforward autoregressive sampling. section 8.4

Generating Na2Cl2 structures

A composition prompt for Na2Cl2 can produce CIF output containing symmetry metadata, lattice dimensions, chemical formulas, and atom-site coordinates. Two generated samples achieved consistent space groups and atom-site multiplicities, reasonable bond lengths, and full validity under the reported evaluator. section 8.4

How Domain-Specific Small Language Models covers it

How deep it goes
Explains tokenization, causal prediction, cross-entropy, sampling, and MCTS, but does not detail Transformer internals or chemical validation theory.
Examples
Uses Na2Cl2 prompts, generated CIF files, validity checks, bond-length scores, and an optional MCTS decoding run.
What it assumes
Assumes familiarity with CIF crystallographic data while teaching tokenization, next-token prediction, prompting, and domain-specific validation.
What you can do after
Apply it via the CrystaLLM scripts to prompt, sample, postprocess, evaluate, and optionally search generated CIF structures.
How it connects
Connects CIF, autoregressive generation, Transformer, cross-entropy loss, Monte Carlo tree search, and graph neural networks.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Domain-Specific Small Language Models. The section links point to the parts of the book it draws on.