A library for computational algebra using Transformers
Project description
CALT: Computer ALgebra with Transformer
(Note: This project is currently in its initial development phase. The file structure and content are subject to significant changes. Please ensure you are referring to the latest version when using it.)
Overview
calt is a simple Python library for learning arithmetic and symbolic computation with a Transformer model (a deep neural model to realize sequece-to-sequence functions).
It offers a basic Transformer model and training, and non-experts of deep learning (e.g., mathematicians) can focus on constructing datasets to train and evaluate the model. Particularly, users only need to implement an instance generator for their own task.
For example, for the polynomial addition task, the following will work.
class SumProblemGenerator:
# Task - input: F=[f_1, ..., f_s], target: G=[g:= f_1+...+f_s]
def __init__(
self, sampler: PolynomialSampler, max_polynomials: int, min_polynomials: int
):
self.sampler = sampler
self.max_polynomials = max_polynomials
self.min_polynomials = min_polynomials
def __call__(self, seed: int) -> Tuple[List[PolyElement], PolyElement]:
random.seed(seed) # Set random seed
num_polys = random.randint(self.min_polynomials, self.max_polynomials)
F = self.sampler.sample(num_samples=num_polys)
g = sum(F)
return F, g
Then, calt calls this in parallel to efficiently construct a large dataset and then train a Transformer model to learn this computation. For hard problems, the sample generation itself can suggest unexplored problems, and one can study theoretical and algorithmic solutions of them. The following is a small list of such studies from our group.
- "Learning to Compute Gröbner Bases," Kera et al., 2024
- "Computational Algebra with Attention: Transformer Oracles for Border Basis Algorithms," Kera and Pelleriti et al., 2025
- "Geometric Generality of Transformer-Based Gröbner Basis Computation," Kambe et al., 2025
Refer to our paper "CALT: A Library for Computer Algebra with Transformer," Kera et al., 2025 for a comprehensive overview.
Installation
calt-x is available on PyPI. You can install it with:
pip install calt-x
Requirements
- Python ≥ 3.10
Weights & Biases (wandb) Setup
If you are using Weights & Biases (wandb) for the first time to log training progress, you will need to create an account on their website and set up your API key. When you run the training script for the first time, you will be prompted to enter your API key.
Demos and Tutorials
Simple demonstrations for data generation and training are available as Jupyter Notebook files. You can find them in the notebooks directory
Citation
If you use this code in your research, please cite our paper:
@misc{kera2025calt,
title={CALT: A Library for Computer Algebra with Transformer},
author={Hiroshi Kera and Shun Arawaka and Yuta Sato},
year={2025},
archivePrefix={arXiv},
eprint={2506.08600}
}
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 calt_x-0.1.0.post7.tar.gz.
File metadata
- Download URL: calt_x-0.1.0.post7.tar.gz
- Upload date:
- Size: 29.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bee06c51ec8ccb81fb4e57650c134d33032034a27ad783b67909aa57939df620
|
|
| MD5 |
0f64b5f24b7f8a2d8b23a2a7c1c0d2fd
|
|
| BLAKE2b-256 |
cafde50b5999c4058f999c5f4b10e9cb09b733b5b69a3a5f45ebef4c6cc3fa5b
|
File details
Details for the file calt_x-0.1.0.post7-py3-none-any.whl.
File metadata
- Download URL: calt_x-0.1.0.post7-py3-none-any.whl
- Upload date:
- Size: 36.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2eb94177d0332a90da25f20b1259df5878ee79028094e3ae157cc66502f3472
|
|
| MD5 |
b5185ac94c71c9e5d3c2e6e904125582
|
|
| BLAKE2b-256 |
65216c40263771ca72800df1f313d114b8a97830877977703e85726802a515ec
|