Neural Isomorphic Fields: A Transformer-based Algebraic Numerical Embedding
Organizations: Department of Computer Engineering Amirkabir University of Technology, Tehran, Iran
Abstract
Neural network models often face challenges when processing very small or very large numbers due to issues such as overflow, underflow, and unstable output variations. To mitigate these problems, we propose using embedding vectors for numbers instead of directly using their raw values. These embeddings aim to retain essential algebraic properties while preventing numerical instabilities. We introduce Neural Isomorphic Fields (NIF), a digit-sequence Transformer autoencoder trained with two learned commutative operators and an antisymmetric neural comparator. At zero loss, the embeddings provably form an ordered integral domain isomorphic to the decimal fractions, whose field of fractions is isomorphic to the rationals. For the trained model, we bound errors of operations, chains and algebraic laws by decoding margins, defects and Lipschitz constants. Trained on up to 25 digits, NIF reaches at least 99.9% exact match on closure, identity, associativity and distributivity and 99.8% on ten-step chains and the order relation. With four channels per decimal place, reconstruction and both operations exceed 99.7% exact match on numbers of up to 200 digits whose parts stay within training lengths, so the dimension grows linearly. In a language model, frozen operators raise exact match on 14-20-digit word problems from 12.0% (operators off) to 39.7%.
Figures & tables
| Method | Encoder input | Structure targeted | Ops. in emb. space | Order | Alg. eval. |
| DICE ( Sundararaman et al., 2020 ) | value | distance, magnitude | – | – | – |
| xVal ( Golkar et al., 2023 ) | normalized value | linear in the value | (implicit) | implicit | – |
| LUNA ( Han et al., 2022 ) | digit string | value and format | – | – | – |
| FoNE ( Zhou et al., 2026 ) | value | periodic (Fourier) features per digit place | – | – | – |
| FPE, BitTokens ( Jin et al., 2024 ; Kreitner et al., 2026 ) | IEEE 754 bits | floating-point format | – | – | – |
| NALU, NAU, NPU ( Trask et al., 2018 ; Madsen and Johansen, 2020 ; Heim et al., 2020 ) | raw scalars | arithmetic units | , powers on scalars | – | – |
| Notation | Short form | Description |
| – | The set of rational numbers | |
| – | The set of real numbers | |
| – | The ring of decimal fractions , Eq. ( 1 ) | |
| – | Decimal fractions with at most digits, Eq. ( 2 ) | |
| – | Maximum number of digits of a represented number | |
| , | – | Units of and field of fractions of , Lemma 3.1 |
| Test | Tested quantity | Target and success criterion |
| Identity | ||
| Invertibility ( ) | ||
| Invertibility ( ) | , with | |
| Closure | ||
| Associative | , | |
| Distributive | , |
| Test | Accuracy | EM | EM, oracle length | |
| Reconstruction | ||||
| Reconstruction | 10000 | 100.00 0.00 | 100.00 0.01 | 100.00 0.01 |
| Addition | ||||
| Identity | 10000 | 100.00 0.00 | 100.00 0.00 | 100.00 0.00 |
| Closure | 10000 | 100.00 0.00 | 100.00 0.01 | 100.00 0.01 |
| Inverse | 10000 | 100.00 0.00 | 100.00 0.01 | 100.00 0.01 |
| Model | |||||||
| Accuracy | Exact Match | Accuracy | Exact Match | Accuracy | Exact Match | ||
| Addition | LUNA ( Han et al., 2022 ) | 99.47 0.31 | 90.45 0.48 | 99.30 0.17 | 91.96 0.42 | 97.04 0.36 | 79.28 0.79 |
| FoNE ( Zhou et al., 2026 ) | 98.97 0.51 | 86.94 0.82 | 98.58 0.68 | 82.97 0.51 | 97.84 0.36 | 73.78 0.99 | |
| xVal ( Golkar et al., 2023 ) | 32.15 1.14 | 13.87 3.14 | 9.00 2.14 | 1.14 0.99 | 0 | 0 | |
| AE-only (NIF arch., only) | 100.00 | 99.97 | 99.99 | 99.95 | 100.00 | 99.99 | |
| NIF (ours) | 100.00 0.00 | 100.00 0.00 | 100.00 0.00 | 100.00 0.00 | 100.00 0.00 | 99.99 0.01 | |
| Training lengths | Longer than in training | |||||
| Input of the model | 4 | 8 | 12 | 14 | 16 | 20 |
| Digit tokens only | 98.5 | 99.0 | 92.5 | 0.0 | 0.0 | 0.0 |
| + one-hot digits, read place by place | 99.0 | 99.0 | 99.0 | 100.0 | 98.5 | 89.0 |
| + FoNE (float64), read place by place | 99.5 | 99.0 | 98.5 | 99.0 | 95.0 | 0.0 |
| + FoNE (exact), read place by place | 98.5 | 99.5 | 98.0 | 98.0 | 95.0 | 88.5 |
| + NIF (ours), read place by place | 99.0 | 99.5 | 99.5 | 99.5 | 98.0 | 92.5 |
| Test set | Problems | Base model | Trained with NIF | Operators off | |
| GSM-Ranges, level 1 | 200 | 59.5 | 55.0 | 55.5 | 0.92 |
| GSM-Ranges, level 2 | 200 | 53.5 | 53.5 | 53.0 | 1.00 |
| GSM-Ranges, level 3 | 200 | 43.0 | 46.5 | 46.0 | 0.92 |
| GSM-Ranges, level 4 | 200 | 39.0 | 44.5 | 45.0 | 0.77 |
| GSM-Ranges, level 5 | 200 | 29.5 | 43.0 | 42.5 | 0.004 |
| GSM-Ranges, level 6 | 200 | 28.0 | 43.0 | 40.5 | 0.001 |
Appendix figures & tables5 assets
Supplementary material from the paper’s appendix.
Appendix
| Item | Value |
| Vocabulary | the 14 tokens of Section 3.1 (digits 0–9, decimal point, , , start) and a padding token (the length head replaces an end token) |
| Encoder | pre-norm Transformer (RMSNorm, SwiGLU) with exponent (place-value) embeddings of the tokens, 4 layers, width 256, 8 heads; attention pooling into slots ( ) with exponent embeddings, 2 slot layers, per-slot RMS norm |
| Embedding | , ( place-value slots, channels per slot) |
| Decoder | 2 layers over the slots, length head (two classifiers: – integer and – fractional digits, as many as the slots hold, so that results of operations fit), 4 Transformer layers (rotary positions) with cross-attention to the slots, width 256, 8 heads; greedy decoding of the predicted skeleton |
| Operator | AC layers; : slot Transformer (1 block, width 192, 6 heads, periodic units in a quarter of the SwiGLU channels) |
| Operator | AC layers aligned with Lemma 3.4 (2 blocks each, width 192, 6 heads, , float32); front end of Section 3.3.3 ; hint heads used only during training |
| Operator | EM | EM, 21–25 digits | Steps | First | Digits | ||
| : staged operator (Section 3.3.3 ) | 99.95 | 100.00 | 3250 | 2500 | 100.00 | 100.00 | 99.96 |
| without hint supervision | 29.39 | 0.00 | 8000 | – | 0.00 | 1.69 | 8.54 |
| without least-squares fit of the counts | 99.98 | 98.18 | 5750 | 5250 | 100.00 | 100.00 | 100.00 |
| random instead of decimal frequencies | 99.98 | 100.00 | 5500 | 3500 | 100.00 | 100.00 | 100.00 |
| without periodic features | 99.88 | 98.18 | 8000 | 6250 | 100.00 | 100.00 | 99.86 |
| soft instead of one-hot digit counts | 99.98 | 100.00 | 3000 | 2250 | 100.00 | 100.00 | 99.98 |
| Variant | Rec. | Cl. | Cl. | Inv. | Inv. | Ass. | Ass. | Distr. | O1 | , |
| NIF (all terms) | 100.00 | 100.00 | 99.98 | 100.00 | 85.22 | 99.98 | 99.94 | 99.92 | 99.44 | 99.87 |
| NIF, seed 0 (reference of the tests) | 99.99 | 99.99 | 99.97 | 99.99 | 84.86 | 99.99 | 99.95 | 99.88 | 99.57 | 100.00 |
| only , , | 99.92 | 99.78 ∗ | 22.47 ∗ | 88.47 ∗ | 0.72 ∗ | 99.61 ∗ | 5.12 ∗ | 11.61 ∗ | 92.71 ∗ | 100.00 |
| without hint supervision | 99.92 | 99.80 ∗ | 10.00 ∗ | 100.00 | 17.44 ∗ | 99.62 ∗ | 3.78 ∗ | 2.37 ∗ | 99.74 | 99.80 |
| without targeted pairs and terms on operator outputs | 100.00 | 100.00 | 99.85 | 99.96 | 27.17 ∗ | 99.88 | 99.70 ∗ | 99.55 ∗ | 86.43 ∗ | 100.00 |
| training numbers only from the sampler (no uniform lengths) | 99.99 | 100.00 | 100.00 | 100.00 | 85.40 ∗ | 99.99 | 99.98 | 99.97 | 99.76 | 100.00 |
| Within the training lengths | Longer part | More than digits | |||||||||
| Rec. | Rec. | Rec. | |||||||||
| 104 | 100 | 91.4 | 98.7 | 93.2 | 73.0 | 78.9 | 34.0 | 25.9 | 23.7 | ||
| 208 | 100 | 100 | 100 | 98.5 | 98.5 | 99.93 | 64.5 | 72.4 | 78.6 | ||
| 312 | 99.94 | 99.69 | 99.94 | 98.3 | 98.3 | 98.1 | 51.9 | 59.5 | 64.0 | ||
| 520 | 100 | 100 | 99.99 | 98.1 | 98.6 | 99.50 | 53.5 | 60.5 | 63.8 | ||
| 832 | 100 | 100 | 100 | 99.26 | 99.30 | 99.86 | 72.0 | 75.5 | 79.8 | ||
| Test | EM (%) | Defect | In bound (%) | Wrong ball (%) | ||
| , closure | 100.00 | 0.73 / 1.10 | 2.88 | 99.8 | 0.0 | 2.52 |
| , closure | 99.98 | 0.83 / 1.08 | 2.80 | 99.9 | 0.0 | 3.94 |
| Associativity of | 100.00 | 1.49 / 2.07 | 2.80 | 42.9 | – | – |
| Distributivity | 99.92 | 1.66 / 2.07 | 2.67 | 1.1 | – | – |
| : closure of / | 94.75 / 99.20 | 1.35 / 2.18 | 1.33 / 1.34 | 47.8 / 12.4 | 0.7 / 0.0 | 2.71 / 10.49 |
| : closure of / | 100.00 / 100.00 | 0.48 / 0.34 | 1.52 / 1.51 | 99.2 / 100.0 | 0.0 / 0.0 | 2.22 / 4.12 |