Machine learning discovers new champion codes

Yang-Hui He, Alexander M. Kasprzyk, Q. Le, Dmitrii RiabchenkoarXiv 2025 · DOI

Abstract

Finding optimal error-correcting codes is a computationally intensive task, often classified as NP-hard. This paper presents a novel approach combining transformer-based neural networks with genetic algorithms to navigate the search space for linear codes. By treating generator matrices as sequences, the model predicts minimum Hamming distances with high accuracy, enabling the discovery of over 500 champion codes, including six previously unknown mathematical benchmarks.

Introduction

Error-correcting codes are fundamental to modern data transmission, from satellite communications to local Wi-Fi. The strength of a code is primarily defined by its minimum Hamming distance ($d$), which determines its capacity to correct errors. However, calculating $d$ for a general linear code is an NP-hard problem. Traditional methods like the Brouwer–Zimmermann (BZ) algorithm scale poorly, making the search for "champion codes"—those with the highest known $d$ for a given length and dimension—extremely difficult.

Methodology: The GA-Transformer Hybrid

The researchers proposed a two-stage system to accelerate the discovery of optimal codes. The first component is a predictive model based on a modified GPT-2 transformer. Instead of natural language, the model processes the rows of a code's generator matrix as tokens, performing sequence classification to estimate the minimum Hamming distance.

Mapping a lattice $V$ to a generator matrix and its minimum distance $d$.

The second component is a Genetic Algorithm (GA) that explores the space of generalized toric codes. In this framework, lattice points serve as "genes" that define the code. The transformer acts as a fast heuristic filter, providing a fitness score based on predicted $d$. This allows the GA to focus on high-potential candidates, with the computationally expensive BZ algorithm reserved only for final verification.

Data and Training

To train the transformer, the authors generated large synthetic datasets over finite fields $\mathbb{F}_7$ and $\mathbb{F}_8$. A significant challenge was the uneven distribution of minimum distances; certain $d$ values are far rarer than others. To address this, the team employed rebalancing techniques, including oversampling and downsampling, to create a balanced training set of approximately 550,000 elements for $\mathbb{F}_7$.

Frequency distribution of minimum distances in the generated dataset.

Key Results

The transformer achieved approximately 91.6% accuracy within a $\pm 3$ tolerance on the $\mathbb{F}_7$ test set. This "good enough" prediction was sufficient to guide the Genetic Algorithm effectively. Over the finite field $\mathbb{F}_8$, the hybrid method discovered over 500 champion codes. Most notably, six of these codes surpassed the records in the global database of best-known linear codes. Compared to random search, the GA-ML approach demonstrated a twofold improvement in discovery efficiency.

Discussion and Future Work

While successful, the method faces limitations in mid-range dimensions where data is scarce. Additionally, the initial generation of training data still relies on the slow BZ algorithm. Future research could extend this framework to other code families, such as Reed–Muller or quantum codes, provided they can be mapped to an evolvable parameter space. By treating mathematical structures as a language, this work opens new avenues for applying NLP breakthroughs to coding theory.

Summary updated

BibTeX
@misc{he2025machine,
  author = {Yang-Hui He and Alexander M. Kasprzyk and Q. Le and Dmitrii Riabchenko},
  title = {{Machine learning discovers new champion codes}},
  year = {2025},
  eprint = {2512.13370},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2512.13370},
}
Figure