CLI entry points¶
The package provides command-line tools as Python modules rather than installed console scripts. Run them from a repository clone.
Each CLI module documents a representative Usage: command. Use argparse --help for the complete set of available options.
Load and generate¶
Load a pretrained model from the Hub or a local checkpoint and generate CIFs from explicit formulas or a parquet file of prompts.
_load_and_generate
¶
Load a released CrystaLLM-pi model and generate CIF structures.
Prompts can come from a parquet dataset or reduced formulas. Formula mode can search over Z values and either stop at the first valid structure or select the highest-scoring candidate. Generation uses every visible GPU.
--scoring_mode supports LOGP and None. LOGP requires --target_valid_cifs to be greater
than zero.
Usage
Training¶
Training is configuration-driven. A JSONC file provides the base configuration and command-line flags override individual values.
_train
¶
Train or finetune a CrystaLLM-pi model, conditionally or unconditionally.
Conditional runs require condition_columns and an activate_conditionality model family.
Unconditional runs use plain GPT-2. Under torchrun, rank 0 handles logging and checkpoint writes.
Usage
Dataset preparation¶
Prepare datasets through the preprocessing pipeline.
mattergen
¶
Download MatterGen's Alex-MP-20 or MP-20 as a symmetrised CIF parquet.
Source: https://github.com/microsoft/mattergen (data-release/).
Alex-MP-20 keeps its train/val splits. MP-20 also keeps its test split.
Usage
lemat
¶
chili
¶
Download stratified CHILI-100K as a symmetrised CIF parquet.
Source: https://github.com/UlrikFriisJensen/CHILI.
Uses the splits from c-bone/chili100k_strat.
Test: 500 seen, 500 structurally novel and 500 compositionally novel structures.
Validation: 1,500 seen structures. Novelty is measured against LeMaterial (Alex-MP-20 is in LeMaterial).
Split construction: https://github.com/C-Bone-UCL/CrystaLLM-pi-paper/blob/main/notebooks/X_XRD_chili100k.ipynb
crystallm
¶
Extract and symmetrise CIFs from tarballs into a parquet dataset.
The CIF tarballs are converted to the parquet layout expected by the package. Split labels are derived from the tarball filenames after removing their extensions, so filenames determine the resulting split names.
From original repo: https://github.com/lantunes/CrystaLLM/blob/main/ARTIFACTS.md
Usage
deduplicate
¶
Deduplicate CIF data to one entry per formula and space group.
For each (formula, space group) pair, the entry with the smallest volume per formula unit is
retained. Rows with "N/A", zero, or negative values in the selected property columns can be
removed before deduplication.
Usage
cleaning
¶
Clean and normalise CIF data before training.
The pipeline orders disordered structures, normalises property columns, and adds the atomic-properties block expected by the tokenizer. The resulting property scale must match the normalised representation used during model training.
Usage
calculate_theor_xrd
¶
Simulate powder XRD patterns from CIF structures and build XRD condition vectors.
The output uses the condition representation the XRD-conditioned models consume.
Usage
save_dataset_to_hf
¶
Convert a DataFrame into a Hugging Face dataset with train, validation, and test splits.
Splitting is material-based, so all rows for one material remain in the same split. --test_size 0.2
--valid_size 0.2 therefore produces 60/20/20 proportions, while setting both values to zero places
all rows in the training split.
With --save_hub, the dataset is pushed to the Hub as private. Change its visibility in the dataset's settings on Hugging Face if needed.
Usage
save_model_to_hf
¶
Upload a loadable CrystaLLM-pi checkpoint to the Hugging Face Hub.
The upload includes the checkpoint, configuration, and tokenizer files required by
load-and-generate, so the repository can be passed directly as --hf_model_path.
Usage
save_tokenizer_to_hf
¶
Save a custom CIF tokenizer locally and optionally upload it to the Hugging Face Hub.
The vocabulary and space-group files are written in the layout expected by
CustomCIFTokenizer.from_pretrained.
Usage
Generation and scoring¶
The generation CLIs are documented on the Generation page alongside the functions that define each stage of the pipeline.
The evaluation CLIs are documented on the Metrics and analysis page alongside the quantities they report.