- Introduction
- Installation
- Forward Property Prediction Model
- Inverse Property Prediction Model
- DiffractGPT Model
- MicroscopyGPT Model
- Notebooks
- HuggingFace
- References
- How to contribute
- Correspondence
- Funding support
Large language models (LLMs), such as ChatGPT, have demonstrated immense potential across various commercial applications; however, their applicability to materials design remains underexplored. In this work, we introduce AtomGPT, a transformer-based model specifically developed for materials design, capable of both atomistic property prediction and structure generation. AtomGPT can be used with both theoretical and experimental data, primarily taking input in .csv format. It has been successfully applied to the computational discovery of new superconductors and semiconductors, as well as to the acceleration of experimental workflows such as X-ray diffraction and microscopy.
First create a conda environment: Install miniforge https://github.com/conda-forge/miniforge
For example:
wget "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh"
Based on your system requirements, you'll get a file something like 'Miniforge3-XYZ'.
bash Miniforge3-$(uname)-$(uname -m).sh
Now, make a conda environment:
conda create --name my_atomgpt python=3.10 -y
conda activate my_atomgpt
git clone https://github.com/atomgptlab/atomgpt.git
cd atomgpt
pip install -e .
Forwards model are used for developing surrogate models for atomic structure to property predictions. It requires text input which can be either the raw POSCAR type files or a text description of the material. After that, we can use Google-T5/ OpenAI GPT2 etc. models with customizing langauage head for accomplishing such a task. The description of a material is generated with ChemNLP/describer function. If you turn convert to False, you can also train on bare POSCAR files.
Both forward and inverse models take a config.json file as an input. Such a config file provides basic training parameters, and an id_prop.csv file path similar to the ALIGNN (https://github.com/usnistgov/alignn) model. See an example here: id_prop.csv.
For training:
python atomgpt/forward_models/forward_models.py --config_name atomgpt/examples/forward_model/config.json
or use atomgpt_forward_train global executable.
For inference:
python atomgpt/forward_models/forward_predict.py --output_dir out --pred_csv atomgpt/examples/forward_model/pred_list_forward.csv
or use atomgpt_forward_predict global executable.
Inverse models are used for generating materials given property and description such as chemical formula. Currently, we use Mistral model, but other models such as Gemma, Lllama etc. can also be easily used. After the structure generation, we can optimize the structure with ALIGNN-FF model (example here and then subject to density functional theory calculations for a few selected candidates using JARVIS-DFT or similar workflow (tutorial for example here. Note that currently, the inversely model training as well as conference requires GPUs.
For training:
python atomgpt/inverse_models/inverse_models.py --config_name atomgpt/examples/inverse_model/config.json
or use atomgpt_inverse_train global executable.
For inference:
python atomgpt/inverse_models/inverse_predict.py --output_dir outputs/checkpoint-2/ --pred_csv "atomgpt/examples/inverse_model/pred_list_inverse.csv"
If you want to use the huggingface model:
python atomgpt/inverse_models/inverse_predict.py --model_name knc6/atomgpt_mistral_tc_supercon --pred_csv "atomgpt/examples/inverse_model/pred_list_inverse.csv"
or if you want infer for just one compound
python atomgpt/inverse_models/inverse_predict.py --model_name knc6/atomgpt_mistral_tc_supercon --formula FeTe --config_path atomgpt/examples/inverse_model/config.json --prop_val 10
Instead of python atomgpt/inverse_models/inverse_predict.py you can also use atomgpt_inverse_predict global executable.
Inverse models are also used for generating materials given spectra/multi value property such as X-ray diffraction and description such as chemical formula.
For training:
python atomgpt/inverse_models/inverse_models.py --config_name atomgpt/examples/inverse_model_multi/config.json
For inference:
python atomgpt/inverse_models/inverse_predict.py --model_name knc6/diffractgpt_mistral_chemical_formula --formula LaB6 --dat_path atomgpt/examples/inverse_model_multi/my_data.dat --config_path atomgpt/examples/inverse_model_multi/config.json
For multiple files/formats
python atomgpt/inverse_models/inverse_predict.py --output_dir outputs_xrd/checkpoint-2 --pred_csv atomgpt/examples/inverse_model_multi/pred_list_inverse.csv --config_path atomgpt/examples/inverse_model_multi/config.json
Example training:
Change dft_2d to c2db or alex_pbe_2d_all if you need larger training set as given here https://atomgptlab.github.io/jarvis-tools/databases/.
Remove max_samples command to train on entire dataset.
python atomgpt/inverse_models/inverse_vision.py --dataset dft_2d --max_samples 10
Using id_prop.csv like format for POSCAR files and corresponding images:
python atomgpt/inverse_models/inverse_vision.py --id_prop_path atomgpt/examples/inverse_model_vision/id_prop.csv
Example inference:
python atomgpt/inverse_models/inverse_vision_predict.py --image_path atomgpt/examples/inverse_model_vision/FeTe.png --formula FeTe
Example to train models from id_prop.csv with POSCAR files and PNG files only
python inverse_models/inverse_vision.py --root_dir examples/inverse_model_vision
More detailed examples/case-studies would be added here soon.
| Notebooks | Google Colab | Descriptions |
|---|---|---|
| Forward Model training | Example of forward model training for exfoliation energy. | |
| Inverse Model training | Example of installing AtomGPT, inverse model training for 5 sample materials, using the trained model for inference, relaxing structures with ALIGNN-FF, generating a database of atomic structures. | |
| HuggingFace AtomGPT model inference | AtomGPT Structure Generation/Inference example with a model hosted on Huggingface. | |
| DiffractGPT inference | Example of predicting crystal structure from X-ray diffraction data. | |
| MicroscopyGPT inference | Example of predicting crystal structure from STEM image data. |
For similar other notebook examples, see JARVIS-Tools-Notebook Collection
- AtomGPT: Atomistic Generative Pretrained Transformer for Forward and Inverse Materials Design
- DiffractGPT: Atomic Structure Determination from X-ray Diffraction Patterns using Generative Pre-trained Transformer
- MicroscopyGPT: Generating Atomic-Structure Captions from Microscopy Images of 2D Materials with Vision-Language Transformers
- ChemNLP: A Natural Language Processing based Library for Materials Chemistry Text Data
- JARVIS-Leaderboard
- NIST-JARVIS Infrastructure
- Unsloth AI
For detailed instructions, please see Contribution instructions
Please report bugs as Github issues (https://github.com/usnistgov/atomgpt/issues) or email to [email protected].
NIST-MGI (https://www.nist.gov/mgi) and CHIPS (https://www.nist.gov/chips)
Note: This project was originally developed under the github.com/usnistgov organization. New updates and developments will be carried out here.
Please see Code of conduct