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=[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.post7.tar.gz (29.0 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.post7-py3-none-any.whl (36.0 kB view details)

Uploaded Python 3

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

Hashes for calt_x-0.1.0.post7.tar.gz
Algorithm Hash digest
SHA256 bee06c51ec8ccb81fb4e57650c134d33032034a27ad783b67909aa57939df620
MD5 0f64b5f24b7f8a2d8b23a2a7c1c0d2fd
BLAKE2b-256 cafde50b5999c4058f999c5f4b10e9cb09b733b5b69a3a5f45ebef4c6cc3fa5b

See more details on using hashes here.

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

Hashes for calt_x-0.1.0.post7-py3-none-any.whl
Algorithm Hash digest
SHA256 d2eb94177d0332a90da25f20b1259df5878ee79028094e3ae157cc66502f3472
MD5 b5185ac94c71c9e5d3c2e6e904125582
BLAKE2b-256 65216c40263771ca72800df1f313d114b8a97830877977703e85726802a515ec

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