- The paper introduces NeuRaLaTeX, a library that executes machine learning tasks within the LaTeX compilation process.
- It details a methodology where network architectures, training logic, and evaluations are defined via custom LaTeX commands.
- The authors propose new metrics, WIL and SCOMISCOP, to assess code integration and implementation purity in ML publications.
NeuRaLaTeX Overview
NeuRaLaTeX is presented as a novel deep learning library implemented entirely using the LaTeX typesetting system (2503.24187). The core concept involves defining and executing machine learning workflows directly within a LaTeX document's source code. This includes specifying neural network architectures, loss functions, data loading or generation procedures, training hyperparameters, and experimental setups. The execution of these tasks occurs during the document compilation phase. Upon compiling the .tex file, the LaTeX compiler orchestrates the entire pipeline: generating or loading datasets, performing the training iterations for the specified neural network, evaluating the trained model, and automatically embedding the results, such as figures and tables, into the final compiled document (e.g., a PDF).
Implementation and Workflow
The implementation leverages LaTeX's Turing-complete nature, albeit through unconventional means typically associated with typesetting. Users define model components and training logic using specific LaTeX commands and environments provided by the NeuRaLaTeX library. The library code itself is embedded within the source code of the paper describing it.
The workflow proceeds as follows:
- Definition: Within the
.tex source file, the user specifies the neural network architecture (e.g., number of layers, neurons per layer, activation functions), the loss function (e.g., cross-entropy), and the optimizer details. Data handling is also defined, specifying whether to load data from an external source or generate it synthetically based on defined procedures. Training parameters like learning rate, batch size, and number of epochs are set using dedicated commands.
- Compilation: When the LaTeX compiler (e.g.,
pdflatex, lualatex) processes the document, it encounters the NeuRaLaTeX commands. Instead of just typesetting, these commands trigger computations.
- Execution: The library code, interpreted by the LaTeX compiler, executes the defined machine learning tasks. This includes instantiating the network, preparing the data, iterating through the training loop (forward pass, loss calculation, backpropagation, weight updates), and performing evaluation runs.
- Result Integration: The outputs of the training and evaluation phases, such as loss curves, accuracy metrics, confusion matrices, or visualizations of learned representations, are captured. NeuRaLaTeX then generates the corresponding LaTeX code (e.g.,
tikzpicture for plots, tabular for tables) and inserts it into the appropriate places in the document source stream.
- Output: The final compiled document seamlessly integrates the textual description of the methodology with the computationally generated results derived from executing that methodology.
The paper demonstrates this process by implementing, training, and evaluating a two-layer Multi-Layer Perceptron (MLP) on a synthetic spiral dataset. A 100-point spiral dataset is generated for training, and evaluation is performed on a separately generated spiral dataset. The process, including data generation, training, evaluation, and figure/table generation, is reported to take 48 hours of compilation time for this specific example.
Proposed Metrics
The paper introduces two novel metrics designed to quantify specific aspects of machine learning publications and libraries:
- Written In LaTeX (WIL): This metric measures the proportion of a machine learning library's codebase that is written purely in LaTeX. NeuRaLaTeX achieves a WIL score of 1.0 (or 100%) by definition, as the entire library is claimed to be implemented in LaTeX. This is contrasted with conventional libraries like PyTorch or TensorFlow, which have WIL scores approaching 0.0.
WIL=Total Lines of CodeLines of Code in LaTeX​
- Source Code Of Method in Source Code of Paper (SCOMISCOP): This metric measures the extent to which the source code implementing the method described in a paper is contained within the source code of the paper itself. NeuRaLaTeX also achieves a SCOMISCOP score of 1.0, as the library's implementation is included directly within the paper's
.tex source. This is compared against publications like the original ResNet and Transformer papers, where the implementation code is typically separate from the paper source, resulting in lower SCOMISCOP scores.
SCOMISCOP=Total Lines of Implementation CodeLines of Implementation Code in Paper Source​
The authors claim state-of-the-art performance for NeuRaLaTeX on both the WIL and SCOMISCOP metrics, significantly outperforming existing libraries and prominent research papers according to these specific criteria.
Availability
The paper states that the source code for NeuRaLaTeX, along with documentation and supplementary materials, is available at https://www.neuralatex.com. It is worth noting the publication date (March 31st, 2025) and the website's inclusion of elements like "crypto scams and an invitation to invest," suggesting the project might be presented with satirical intent, potentially as an April Fools' Day piece, despite its technical implementation claims.
Conclusion
NeuRaLaTeX presents a unique approach to integrating machine learning model definition, training, and result reporting directly within the LaTeX document compilation process (2503.24187). Its primary contribution lies in demonstrating the feasibility (albeit with significant computational overhead, exemplified by the 48-hour compilation time for a simple MLP) of performing non-trivial machine learning tasks using only LaTeX. The introduction of the WIL and SCOMISCOP metrics provides a novel, albeit niche, framework for evaluating ML libraries and papers based on their implementation language and code locality, respectively, upon which NeuRaLaTeX claims state-of-the-art performance.