Skip to main content

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= 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.

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.

https://wandb.ai/site/

Demos and Tutorials

Simple demonstrations for data generation and training are available as Jupyter Notebook files. You can find them in the notebooks directory

Open in Colab

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

calt_x-0.1.0.post6.tar.gz (32.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

calt_x-0.1.0.post6-py3-none-any.whl (37.3 kB view details)

Uploaded Python 3

File details

Details for the file calt_x-0.1.0.post6.tar.gz.

File metadata

  • Download URL: calt_x-0.1.0.post6.tar.gz
  • Upload date:
  • Size: 32.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for calt_x-0.1.0.post6.tar.gz
Algorithm Hash digest
SHA256 03bdfbea15c34fe35f8b726996966d8fac3b6d296fd4662b2e2b8ab12533fbaf
MD5 be0fba1d54ce406cd30065559b305333
BLAKE2b-256 09096a1d73cf4c7785c198a3c0cd1dcf26a67a373784084c934eb3a0d2b1fe9d

See more details on using hashes here.

File details

Details for the file calt_x-0.1.0.post6-py3-none-any.whl.

File metadata

  • Download URL: calt_x-0.1.0.post6-py3-none-any.whl
  • Upload date:
  • Size: 37.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for calt_x-0.1.0.post6-py3-none-any.whl
Algorithm Hash digest
SHA256 733accca77e57b722fd5ccc02c213119755c91475c881f67c6b3220a3497fc0e
MD5 454640b7dbec0e1a71a1ddc1e752eeef
BLAKE2b-256 fe8c3479489e87fcb9c508dcbf6f6e292df2f2346e59eeb56d03c0f5ce3712b4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page