  Solar flares are explosions on the Sun. They happen when energy stored in
magnetic fields around solar active regions (ARs) is suddenly released. In this
paper, we present a transformer-based framework, named SolarFlareNet, for
predicting whether an AR would produce a gamma-class flare within the next 24
to 72 hours. We consider three gamma classes, namely the >=M5.0 class, the >=M
class and the >=C class, and build three transformers separately, each
corresponding to a gamma class. Each transformer is used to make predictions of
its corresponding gamma-class flares. The crux of our approach is to model data
samples in an AR as time series and to use transformers to capture the temporal
dynamics of the data samples. Each data sample consists of magnetic parameters
taken from Space-weather HMI Active Region Patches (SHARP) and related data
products. We survey flare events that occurred from May 2010 to December 2022
using the Geostationary Operational Environmental Satellite X-ray flare
catalogs provided by the National Centers for Environmental Information (NCEI),
and build a database of flares with identified ARs in the NCEI flare catalogs.
This flare database is used to construct labels of the data samples suitable
for machine learning. We further extend the deterministic approach to a
calibration-based probabilistic forecasting method. The SolarFlareNet system is
fully operational and is capable of making near real-time predictions of solar
flares on the Web.
