Giter Site home page Giter Site logo

bertos's Introduction

BERTOS

BERTOS: transformer language model for oxidation state prediction

Citation: Fu, Nihang, Jeffrey Hu, Ying Feng, Gregory Morrison, Hans‐Conrad zur Loye, and Jianjun Hu. "Composition Based Oxidation State Prediction of Materials Using Deep Learning Language Models." Advanced Science (2023): 2301011. Link

Nihang Fu, Jeffrey Hu, Ying Feng, Jianjun Hu*

Machine Learning and Evolution Laboratory
Department of computer science and Engineering
University of South Carolina

Table of Contents

Installations

  1. Set up virtual environment
conda create -n bertos
conda activate bertos
  1. PyTorch and transformers for computers with Nvidia GPU.
conda install pytorch==1.8.0 torchvision==0.9.0 torchaudio==0.8.0 cudatoolkit=11.1 -c pytorch -c conda-forge
conda install -c conda-forge transformers

If you only has CPU on your computer, try this:

pip install transformers[torch]

If you are using Mac M1 chip computer, following this tutorial or this one to install pytorch and transformers.

  1. Other packagess
pip install -r requirements.txt

Datasets

Our training process is carried out on our BERTOS datasets. After extracting the data under datasets folder, you will get the following four folders ICSD, ICSD_CN, ICSD_CN_oxide, and ICSD_oxide.

Usage

A Quick Run

Quickly run the script to train a BERTOS using the OS-ICSD-CN training set and save the model into the ./model_icsdcn folder.

bash train_BERTOS.sh

Training

The command to to train a BERTOS model.

python train_BERTOS.py  --config_name $CONFIG_NAME$  --dataset_name $DATASET_LOADER$   --max_length $MAX_LENGTH$  --per_device_train_batch_size $BATCH_ SIZE$  --learning_rate $LEARNING_RATE$  --num_train_epochs $EPOCHS$    --output_dir $MODEL_OUTPUT_DIRECTORY$

We use ICSD_CN dataset as an example:

python train_BERTOS.py  --config_name ./random_config   --dataset_name materials_icsd_cn.py   --max_length 100  --per_device_train_batch_size 256  --learning_rate 1e-3  --num_train_epochs 500    --output_dir ./model_icsdcn

If you want to change the dataset, you can use different dataset file to replace $DATASET_LOADER$, like materials_icsd.py, materials_icsdcn.py, materials_icsdcno.py, and materials_icsdo.py. And you can also follow the intructions of huggingface to build you own custom dataset.

Predict

Run getOS.py file to get predicted oxidation states for a input formula or input formulas.csv file containing multiple formulas.
Using your model:

python getOS.py --i SrTiO3 --model_name_or_path ./model_icsdcn
python getOS.py --f formulas.csv --model_name_or_path ./model_icsdcn

Using pretrained model:

python getOS.py --i SrTiO3 --model_name_or_path ./trained_models/ICSD_CN
python getOS.py --f formulas.csv --model_name_or_path ./trained_models/ICSD_CN

Pretrained Models

Our trained models can be downloaded from figshare BERTOS models, and you can use it as a test or prediction model.

Performance

Performance Removing OS, the datasets under datasets folder correspond to the datasets in the figure.

Acknowledgement

We use the transformer model as implmented in Huggingface.

@article{wolf2019huggingface,  
  title={Huggingface's transformers: State-of-the-art natural language processing},  
  author={Wolf, Thomas and Debut, Lysandre and Sanh, Victor and Chaumond, Julien and Delangue, Clement and Moi, Anthony and Cistac, Pierric and Rault, Tim and Louf, R{\'e}mi and Funtowicz, Morgan and others},  
  journal={arXiv preprint arXiv:1910.03771},  
  year={2019}  
}

Cite our work

Fu, Nihang, Jeffrey Hu, Ying Feng, Gregory Morrison, Hans‐Conrad zur Loye, and Jianjun Hu. "Composition Based Oxidation State Prediction of Materials Using Deep Learning Language Models." Advanced Science (2023): 2301011. [PDF](https://arxiv.org/pdf/2211.15895)

Contact

If you have any problem using BERTOS, feel free to contact via [email protected].

bertos's People

Contributors

usccolumbia avatar funihang avatar

Stargazers

 avatar Yuzuchan avatar Jeffrey Hu avatar Pepe Marquez  avatar Anthony Onwuli avatar J. George avatar BPY avatar Aron Walsh avatar  avatar  avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.