Flash-ANSR: Fast Amortized Neural Symbolic Regression - Discover symbolic expressions from tabular data using SetTransformer and Transformer architectures
Project description
⚡Flash-ANSR:
Fast Amortized Neural Symbolic Regression
Flash-ANSR is a library for amortized neural symbolic regression: load a pretrained model, call fit(X, y), and recover a symbolic expression for your tabular data, or train your own model. It is built for fast, ready-to-use inference.
Publications
- Saegert & Köthe 2026, Breaking the Simplification Bottleneck in Amortized Neural Symbolic Regression (preprint, under review) https://arxiv.org/abs/2602.08885
Usage
pip install flash-ansr
import torch
import numpy as np
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
# Import flash_ansr
from flash_ansr import (
FlashANSR,
SoftmaxSamplingConfig,
install_model,
get_path,
)
# Select a model from Hugging Face
# https://huggingface.co/models?search=flash-ansr-v23.0
MODEL = "psaegert/flash-ansr-v23.0-120M"
# Download the latest snapshot of the model
# By default, the model is downloaded to the directory `./models/` in the package root
install_model(MODEL)
# Load the model (KV-cache, auto-batching and static decoding are on by default; see "Inference speed")
model = FlashANSR.load(
directory=get_path('models', MODEL),
generation_config=SoftmaxSamplingConfig(choices=1024), # or BeamSearchConfig / MCTSGenerationConfig
length_penalty=0.05, # prefer shorter expressions when scoring candidates (renamed from `parsimony` in v0.5)
).to(device)
# Define data: a small synthetic example, y = 2.5 * sin(x) + x^2 / 3
X = np.linspace(-5, 5, 100).reshape(-1, 1)
y = 2.5 * np.sin(X[:, 0]) + X[:, 0] ** 2 / 3
# Fit the model to the data
model.fit(X, y, verbose=True)
# Show the best expression
print(model.get_expression())
# Predict with the best expression
y_pred = model.predict(X)
Explore more in the Demo Notebook.
Train your own: see the training guide and browse the pretrained model collection on Hugging Face.
Inference speed
Flash-ANSR v0.5 ships several inference-speed improvements, enabled by default and designed to be quality-neutral, so the quickstart above already runs in the fast regime. The speed-relevant settings live on the generation config:
| Setting | Default | What it does |
|---|---|---|
use_cache |
True |
KV-cache decoding |
batch_size |
'auto' |
candidate-budget-adaptive batching (pass an int to override) |
static_decode |
None |
static decoding, auto-enabled for capable models (set True/False to force) |
from flash_ansr import SoftmaxSamplingConfig
config = SoftmaxSamplingConfig(
choices=1024, # number of candidate expressions to sample
use_cache=True, # KV cache (default)
batch_size='auto', # candidate-budget-adaptive chunking (default)
static_decode=None, # auto for capable models (default)
)
Constant refinement runs in parallel; control it via FlashANSR.load(..., refiner_workers=N, persistent_refine_pool=True).
To reproduce v0.4.x inference behavior, opt out of the new defaults:
SoftmaxSamplingConfig(choices=1024, use_cache=False, batch_size=128, static_decode=False)
Breaking change (v0.5): the candidate-selection penalty
parsimonywas renamed tolength_penalty. Replace anyparsimony=arguments withlength_penalty=.
Overview
SRSD/FastSRB ResultsResults on the SRSD/FastSRB benchmark [Matsubara et al. 2022], [Martinek 2025] Left: Validation Numeric Recovery Rate (vNRR) as a function of inference time (log scale). FLASH-ANSR models (shades of blue) scale monotonically with compute, with the 120M model partially surpassing the PySR baseline (red). Baselines NeSymReS [Biggio et al. 2021] and E2E [Kamienny et al. 2022] fail to generalize to the benchmark. Right: Expression Length Ratio (predicted vs ground truth) versus compute. We observe a parsimony inversion: while PySR [Cranmer 2023] increases complexity to minimize error over time, FLASH-ANSR converges toward simpler, more canonical expressions as the sampling budget increases. Shaded regions denote 95% confidence intervals. |
TrainingThe Flash-ANSR training pipeline. Following the established standard encoder-decoder paradigm, our framework integrates SimpliPy (top center) into the loop for synchronous simplification of on-the-fly generated training expressions. |
ArchitectureFlash-ANSR model architecture. The Set Transformer [Lee et al. 2019] encoder ingests a variable-sized set of input-output pairs and produces a fixed-size latent representation via Induced Set Attention Blocks (ISAB) and Set Attention Blocks (SAB). The Transformer decoder [Vaswani et al. 2017], [Xiong et al. 2020] autoregressively generates a symbolic expression token-by-token, attending to the encoded dataset at each step. |
Related projects
- SimpliPy: the expression simplification engine integrated into the Flash-ANSR training loop.
- srbf: the companion symbolic-regression evaluation and benchmarking framework (engine, model adapters, benchmarks, metrics), developed alongside Flash-ANSR.
Citation
@misc{saegert2026breakingsimplificationbottleneckamortized,
title = {Breaking the Simplification Bottleneck in Amortized Neural Symbolic Regression},
author = {Paul Saegert and Ullrich Köthe},
year = {2026},
eprint = {2602.08885},
archivePrefix = {arXiv},
primaryClass = {cs.LG},
url = {https://arxiv.org/abs/2602.08885},
}
% Optionally
@mastersthesis{flash-ansr2024-thesis,
author = {Paul Saegert},
title = {Flash Amortized Neural Symbolic Regression},
school = {Heidelberg University},
year = {2025},
url = {https://github.com/psaegert/flash-ansr-thesis}
}
@software{flash-ansr2024,
author = {Paul Saegert},
title = {Flash Amortized Neural Symbolic Regression},
year = {2024},
publisher = {GitHub},
version = {0.5.0},
url = {https://github.com/psaegert/flash-ansr}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flash_ansr-0.6.1.tar.gz.
File metadata
- Download URL: flash_ansr-0.6.1.tar.gz
- Upload date:
- Size: 173.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b320fba332e6f8dabd1396e25e8d588f92dd29be55696518b718d3bb748c54f2
|
|
| MD5 |
4b3073aa07904e01b6862cdd4b95be30
|
|
| BLAKE2b-256 |
20224ecbbef52c0cfc6527caf0c9f95f9487c70c2652989b6a5615655bfb3a60
|
Provenance
The following attestation bundles were made for flash_ansr-0.6.1.tar.gz:
Publisher:
publish.yaml on psaegert/flash-ansr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flash_ansr-0.6.1.tar.gz -
Subject digest:
b320fba332e6f8dabd1396e25e8d588f92dd29be55696518b718d3bb748c54f2 - Sigstore transparency entry: 1986000120
- Sigstore integration time:
-
Permalink:
psaegert/flash-ansr@9c4b74ceacfabaf3f9c29c894a63b3b012262b32 -
Branch / Tag:
refs/tags/v0.6.1 - Owner: https://github.com/psaegert
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@9c4b74ceacfabaf3f9c29c894a63b3b012262b32 -
Trigger Event:
release
-
Statement type:
File details
Details for the file flash_ansr-0.6.1-py3-none-any.whl.
File metadata
- Download URL: flash_ansr-0.6.1-py3-none-any.whl
- Upload date:
- Size: 170.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b5522ae173b989975f027e2c7ec67133f90f3fe87795402e337497f1439e9312
|
|
| MD5 |
595382b49dc079fbf7191a1faa6c6f93
|
|
| BLAKE2b-256 |
2f4f2d5147e0bd4ab8ea96e612c836e54ef0b13de9a42f6d624f4bbfbfe4212b
|
Provenance
The following attestation bundles were made for flash_ansr-0.6.1-py3-none-any.whl:
Publisher:
publish.yaml on psaegert/flash-ansr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flash_ansr-0.6.1-py3-none-any.whl -
Subject digest:
b5522ae173b989975f027e2c7ec67133f90f3fe87795402e337497f1439e9312 - Sigstore transparency entry: 1986000253
- Sigstore integration time:
-
Permalink:
psaegert/flash-ansr@9c4b74ceacfabaf3f9c29c894a63b3b012262b32 -
Branch / Tag:
refs/tags/v0.6.1 - Owner: https://github.com/psaegert
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@9c4b74ceacfabaf3f9c29c894a63b3b012262b32 -
Trigger Event:
release
-
Statement type: