Package: pytorch-gleam
A Social Media Natural Language Processing package for PyTorch & PyTorch Lightning.Key Features•About Me•How To Use•ExamplesPyTorch GleamPyTorch Gleam builds uponPyTorch Lightningfor the specific use-case of Natural Language Processing on Social Media, such as Twitter.
PyTorch Gleam strives to make Social Media NLP research easier to understand, use, and extend.
Gleam contains models I use in my research, from fine-tuning a BERT-based model with Lexical, Emotion, and Semantic
information in a Graph Attention Network for stance identification towards COVID-19 misinformation, to
using Information Retrieval systems to identify new types of misinformation on Twitter.About MeMy name isMaxwell Weinzierl, and I am a
Natural Language Processing researcher at the Human Technology Research Institute (HLTRI) at the
University of Texas at Dallas. I am currently working on my PhD, which focuses on COVID-19 and
HPV vaccine misinformation, trust, and more on Social Media platforms such as Twitter. I have built
PyTorch Gleam to enable easy reproducibility for my published research, and for my own quick
iterations on research ideas.How To UseStep 0: InstallSimple installation from PyPIpipinstallpytorch-gleamYou may need to install CUDA drivers and other versions of PyTorch.
SeePyTorchandPyTorch Lightningfor installation help.Step 1: Create ExperimentCreate aconfigsfolder with a YAML experiment file. Gleam utilizes PyTorch Lightning's CLI tools
to configure experiments from YAML files, which enables researchers to clearly look back
and identify both hyper-parameters and model code used in their experiments.
This example is from COVID-19 vaccine misinformation stance identification:pg_examples/covid-stance.yamlseed_everything:0model:class_path:pytorch_gleam.modeling.models.MultiClassFrameLanguageModelinit_args:learning_rate:5e-4pre_model_name:digitalepidemiologylab/covid-twitter-bert-v2label_map:No Stance:0Accept:1Reject:2threshold:class_path:pytorch_gleam.modeling.thresholds.MultiClassThresholdModulemetric:class_path:pytorch_gleam.modeling.metrics.F1PRMultiClassMetricinit_args:mode:macronum_classes:3trainer:max_epochs:10accumulate_grad_batches:4check_val_every_n_epoch:1deterministic:truenum_sanity_val_steps:1checkpoint_callback:falsecallbacks:-class_path:pytorch_gleam.callbacks.FitCheckpointCallbackdata:class_path:pytorch_gleam.data.datasets.MultiClassFrameDataModuleinit_args:batch_size:8max_seq_len:128label_name:misinfolabel_map:No Stance:0Accept:1Reject:2tokenizer_name:digitalepidemiologylab/covid-twitter-bert-v2num_workers:8frame_path:-covid19/misinfo.jsontrain_path:-covid19/stance-train.jsonlval_path:-covid19/stance-dev.jsonltest_path:-covid19/stance-test.jsonlDocumentation on availablemodels,datasets, andcallbackswill be provided soon.Details about how to set up YAML experiment files are provided by
PyTorch Lightning'sdocumentation.Annotations for this example are provided in theVaccineLiesrepository under covid19 as theCoVaxLiescollection:CoVaxLies.
You will need to download the tweet texts from the tweet ids from the Twitter API.Step 2: Run ExperimentCreate amodelsfolder for your savedTensorBoardlogs and model weights.
Determine the GPU ID for the GPU you would like to utilize (multi-gpu supported) and provide the ID in a list, with
a comma at the end if it is a single GPU ID. You can also just specify an integer, such as1, and PyTorch Lightning
will try to find a single free GPU automatically.
Run the following command to start training:gleamfit\--configconfigs/covid-stance.yaml\--trainer.gpus1\--trainer.default_root_dirmodels/covid-stanceYour model will train, withTensorBoardlogging all metrics, and a checkpoint will be saved upon completion.Step 3: Evaluate ExperimentYou can easily evaluate your system on a test collection as follows:gleamtest\--configconfigs/covid-stance.yaml\--trainer.gpus1\--trainer.default_root_dirmodels/covid-stanceExamplesThese are a work-in-progress, as my original research code is a bit messy, but they will be updated soon!COVID-19 Vaccine Misinformation Detection on TwitterCoVaxLies V1 with Graph-Link PredictionCOVID-19 Vaccine Misinformation Stance Identification on TwitterCoVaxLies V2 with Attitude Consistency ScoringCOVID-19 Misinformation Stance Identification on TwitterCOVIDLies with Lexical, Emotion, and Semantic GATs for Stance IdentificationVaccine Misinformation Transfer LearningCOVID-19 to HPV on VaccineLiesHPV to COVID-19 on VaccineLiesVaccine Hesitancy Profiling on TwitterTODO