21cmLSTM: Recurrent Emulator for 21 cm Signal
- The paper introduces 21cmLSTM, a recurrent neural network emulator that predicts the full 21 cm brightness-temperature sequence with sub-mK precision, ensuring unbiased Bayesian posteriors.
- It exploits LSTM’s memory capabilities to capture temporal correlations across adjacent frequency bins, replacing computationally expensive semi-numerical simulators in inference pipelines.
- Benchmark tests show an average mean error of ~0.22% and a per-signal evaluation time of 46 ms, establishing 21cmLSTM as the accuracy benchmark in global-signal emulation.
21cmLSTM is a neural-network emulator for the global, sky-averaged 21 cm cosmology signal that uses long short-term memory recurrent layers to predict the full brightness-temperature sequence as a function of frequency or redshift from a low-dimensional set of astrophysical and cosmological parameters. It was introduced to replace computationally expensive semi-numerical and semi-analytical simulators inside Bayesian inference pipelines that may require – likelihood evaluations, while keeping emulation error well below observational noise so that posterior constraints remain unbiased. In the subsequent literature, 21cmLSTM functions as the principal accuracy benchmark for global-signal emulation and is described as the most accurate emulator in the community, with later work comparing faster alternatives such as 21cmKAN against it rather than against earlier feedforward baselines (Jones et al., 2024, Jones et al., 15 Aug 2025).
1. Scientific object and problem setting
The quantity emulated by 21cmLSTM is the global 21 cm differential brightness temperature, denoted , , , or similar notation depending on the source. This signal traces the thermal and ionization history of the intergalactic medium through the Dark Ages, Cosmic Dawn, and the Epoch of Reionization. In the formulation summarized for 21cmLSTM, a standard expression is
where is the neutral hydrogen fraction, the spin temperature, and the CMB temperature. The emulator does not derive these quantities from first principles; rather, it learns the mapping from model parameters to the simulator-produced signal 0 (Jones et al., 2024).
The methodological motivation is specific to global-signal inference. Semi-analytical and semi-numerical simulators are substantially cheaper than full hydrodynamical calculations, but they remain too slow for repeated evaluation in nested-sampling or MCMC analyses. The central requirement emphasized in the 21cmLSTM work is that emulator error must be much smaller than the observational noise, denoted 1, otherwise Bayesian posteriors become biased. The paper reports that when emulator rms error is 2–3 of 4, posterior constraints are unbiased; 21cmLSTM was designed to satisfy that condition even for optimistic noise levels such as 5 mK (Jones et al., 2024).
This framing also explains the specific appeal of an LSTM. Earlier global 21 cm emulators treated the spectrum more like a static multivariate regression target, whereas 21cmLSTM treats it as a correlated sequence across adjacent redshift or frequency bins. That choice is physically motivated by the smooth, temporally correlated evolution of the absorption trough, heating transition, and reionization shoulder (Jones et al., 2024, Jones et al., 31 Aug 2025).
2. Signal representation and modeled parameter spaces
21cmLSTM maps a compact parameter vector to the full one-dimensional global-signal sequence over a fixed grid. The later comparative work summarizes the input dimensionality as typically 6–7 physical parameters, while the output is the global 21 cm brightness temperature sequence over 8–9 or 0 MHz, with 1. The 21cmGEM dataset uses 2 bins and the ARES dataset 3 bins (Jones et al., 15 Aug 2025).
The primary benchmark dataset in the original 21cmLSTM paper is the public 21cmGEM set. It varies seven parameters:
- 4: star formation efficiency; log-uniform in 5
- 6: minimum circular velocity of star-forming halos; log-uniform in 7 km s8
- 9: X-ray efficiency; log-uniform in 0
- 1: CMB optical depth; uniform in 2
- 3: slope of the X-ray spectral energy distribution; uniform in 4
- 5: low-energy cutoff of the X-ray SED; uniform in 6 keV
- 7: ionizing mean free path; uniform in 8 Mpc
For this dataset, the redshift range is 9 with 0, corresponding to 1–2 MHz, and the physically motivated sampling constraint 3 at 4 is imposed. The split used in the original work is train 5, validation 6, test 7 (Jones et al., 2024).
A second benchmark family uses ARES, a semianalytical model with one-dimensional radiative transfer and no 3D volumes. In the comparative literature, the varied parameters are 8, 9, 0, 1, 2, 3, 4, and 5, with ranges given by the ARES training set; the signal coverage is 6–7, 8, with 9 bins and the condition 0 at 1. The explicit split reported in the 21cmLSTM paper is train 2, validation 3, test 4 (Jones et al., 15 Aug 2025, Jones et al., 2024).
These parameterizations encode the main astrophysical drivers of the global signal. In the 21cmGEM interpretation given by the original paper, 5 and 6 regulate when and how efficiently galaxies form, 7, 8, and 9 regulate the timing and spectrum of X-ray heating, 0 constrains the integrated ionizing history, and 1 affects the morphology and percolation of H II regions during reionization (Jones et al., 2024).
3. Recurrent architecture, sequence modeling, and preprocessing
21cmLSTM is explicitly a recurrent, memory-based architecture. The later summaries characterize it as a network chosen for sequential modeling of 2 across redshift or frequency, using gated memory and backpropagation through time to capture temporal dependencies. In the original implementation, the core architecture consists of two stacked LSTM layers operating in many-to-many mode, followed by a final dense layer with linear activation that produces 3 for each channel. The implementation is in Python with Keras/TensorFlow, and the optimizer is Adam (Jones et al., 15 Aug 2025, Jones et al., 2024).
The LSTM recurrence is described in the later lunar-far-side overview by the standard gate equations
4
5
6
This formulation is central to why 21cmLSTM differs from feedforward emulators: the hidden and cell states propagate information across the full sequence, so adjacent and widely separated bins are not predicted independently (Jones et al., 31 Aug 2025).
The input representation is also sequence-aware. The original paper states that the network input is a three-dimensional array of shape 7, where 8 is the batch size, 9 the sequence length, and 0 the number of physical parameters plus one for the frequency value itself. For the 21cmGEM set, 1; for ARES, 2. Including frequency as a feature is intended to help the network learn the global trend (Jones et al., 2024).
Preprocessing is uniform across the emulator comparisons. Parameters sampled log-uniformly are transformed with 3 before training: 4, 5, and 6 for 21cmGEM; 7, 8, 9, and 0 for ARES. Features and labels are then globally min–max normalized according to
1
The signal labels are flipped to run from high 2 to low 3 during training, i.e. descending redshift and ascending frequency (Jones et al., 2024, Jones et al., 15 Aug 2025).
The training protocol reported in the original paper uses a batch-size schedule rather than learning-rate decay: 4 epochs with batch size 5, then 6 epochs with batch size 7, then 8 epochs with batch size 9. Total training time is reported as 00 hr per trial on one NVIDIA A100 GPU with 01 GB memory usage. Early stopping was not used in that work; the number of epochs was chosen empirically. A later overview notes that standard deep-learning stacks such as TensorFlow/Keras or PyTorch are supported in the public implementation, with validation splits and early stopping available in repository configurations (Jones et al., 2024, Jones et al., 31 Aug 2025).
4. Accuracy, error metrics, and benchmark performance
The principal training objective for 21cmLSTM is mean squared error,
02
For test evaluation, the main metric is a relative rms error across the full frequency range,
03
The paper also notes an alternative relative rms definition,
04
but emphasizes the ratio of rms residual to signal amplitude for stability across diverse signals (Jones et al., 2024).
On the held-out 21cmGEM test set of 05 signals, aggregated over 06 independent training trials, 21cmLSTM achieves:
- average mean relative rms error 07
- average median error 08
- average maximum error 09
These correspond to 10 mK 11 mK in absolute units for the average mean error. The best trial reaches mean 12 (13 mK), median 14 (15 mK), and max 16 (17 mK) (Jones et al., 2024).
The same work reports a single-signal wall-clock evaluation time of 18 ms, averaged across 19 trials on the same hardware used for training, including preprocessing and de-normalization. Relative to earlier feedforward emulators on the same dataset, the reported comparisons are:
- 21cmLSTM: 20 ms, mean error 21, max 22
- 21cmVAE: 23 ms measured in that work, mean error 24, max 25
- globalemu: 26 ms, mean error 27, max 28
- 21cmGEM: 29 ms, mean error 30, max 31
The original paper therefore reports that 21cmLSTM reduces average mean error by 32 and maximum error by 33 relative to 21cmVAE, while remaining practically fast for inference (Jones et al., 2024).
Subsequent comparisons with 21cmKAN sharpen the interpretation of these results. On the 21cmGEM test set, 21cmLSTM remains slightly more accurate than 21cmKAN, with average mean relative rms error 34 versus 35 and average maximum error 36 versus 37. However, 21cmKAN evaluates in 38 ms per signal and trains about 39 faster than 21cmLSTM on the same A100 GPU. This later work therefore positions 21cmLSTM as the accuracy leader and 21cmKAN as the speed leader for low-dimensional global-signal emulation (Jones et al., 15 Aug 2025).
5. Bayesian parameter estimation and pipeline integration
A primary purpose of 21cmLSTM is direct insertion into Bayesian inference pipelines. The original validation uses seven-dimensional nested-sampling analyses with MultiNest, 40 live points, default evidence tolerance and sampling efficiency, and priors matched to the 21cmGEM training ranges. Mock data are drawn from the test set and perturbed with white Gaussian noise at 41 mK, 42 mK, and 43 mK (Jones et al., 2024).
The likelihood used in the comparative papers is Gaussian with diagonal covariance:
44
or, equivalently in matrix form,
45
Here 46 is the observed spectrum, 47 the emulator prediction or the full mean model, and 48 the noise covariance, often taken as diagonal in the validation studies. The posterior is written as
49
This establishes 21cmLSTM as a surrogate forward model rather than a standalone inference engine (Jones et al., 2024, Jones et al., 15 Aug 2025).
The reported posterior behavior is a central result. Across the three adopted noise levels, the posterior 50 rms error on the recovered signals is consistently about three times smaller than 51:
- 52 mK 53 posterior 54 rms 55 mK
- 56 mK 57 posterior 58 rms 59 mK
- 60 mK 61 posterior 62 rms 63 mK
As 64 decreases, the posterior mean residual approaches the emulator rms error, reported as 65 mK in one example. Parameter posteriors are described as unbiased, with especially clear constraints for 66, 67, and 68 at 69 mK and improved constraints for 70 and 71 at 72–73 mK (Jones et al., 2024).
Later work broadens the pipeline context. It states that 21cmLSTM and 21cmKAN can be used with nested samplers such as MultiNest, PolyChord, UltraNest, and Dynesty, and that the emulator provides only the cosmological signal. Foreground and instrument terms must be added in the full likelihood, with nuisance parameters for beam chromaticity, bandpass structure, gain drifts, and related systematics. This is especially relevant for lunar far-side observational concepts such as LuSEE-Night and FarView, which benefit from the Moon’s radio-quiet environment but still require internal instrument modeling (Jones et al., 31 Aug 2025).
6. Comparative position, limitations, and reproducibility
Within the global 21 cm emulator literature, 21cmLSTM occupies a specific niche. It is the memory-based model that explicitly exploits temporal correlations across frequency or redshift bins and, in the cited comparisons, remains the most accurate emulator for the task. The later KAN paper is explicit that 21cmLSTM is the best choice when maximizing emulation accuracy is paramount and training or inference resources are available. By contrast, 21cmKAN is presented as preferable when emulator training would otherwise become the bottleneck, because it maintains similar accuracy while training about 74 faster and predicting about 75 faster (Jones et al., 15 Aug 2025).
Its limitations are correspondingly well defined. Because it is recurrent and trained with backpropagation through time, 21cmLSTM is slower to train and more memory intensive than fully parallel feedforward alternatives. The comparative papers also note a larger trainable-parameter count and heavier memory footprint than KAN, even though exact counts are not provided there. In the original validation, inference tests assume diagonal, frequency-independent Gaussian noise, and they do not include foregrounds, beam chromaticity, or instrument systematics in the likelihood; these omissions are identified as validation assumptions rather than claims about realistic end-to-end analysis (Jones et al., 2024, Jones et al., 15 Aug 2025).
Another limitation is domain specificity. As with all emulators, 21cmLSTM is guaranteed to be accurate only within the parameter domain represented by its training data. The later overview makes this explicit: extrapolation to unseen regimes or substantially different physics can degrade performance, so retraining is recommended when the forward model or parameterization changes. A related point is that emulator fidelity does not remove the need for careful treatment of foreground and instrumental degeneracies; the emulator supplies 76, not a complete observational forward model (Jones et al., 31 Aug 2025).
The software and datasets were released for reproducibility and reuse. The public repository is listed as https://github.com/jdorigojones/21cmLSTM, and the associated Zenodo datasets are given as DOI 10.5281/zenodo.5084113 and DOI 10.5281/zenodo.13840725. The original paper emphasizes that the emulator, code, and datasets are publicly available so that 21cmLSTM can be independently tested, retrained, and applied to other 21 cm model families (Jones et al., 2024).
In that sense, 21cmLSTM is both a specific emulator architecture and a reference point in the methodological evolution of global-signal analysis. It established recurrent sequence modeling as a high-accuracy strategy for 77 emulation, demonstrated that sub-mK average rms error is compatible with practical evaluation times, and provided a benchmark against which newer architectures such as 21cmKAN are now assessed (Jones et al., 2024, Jones et al., 15 Aug 2025).