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.

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.post5.tar.gz (31.9 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.post5-py3-none-any.whl (37.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: calt_x-0.1.0.post5.tar.gz
  • Upload date:
  • Size: 31.9 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.post5.tar.gz
Algorithm Hash digest
SHA256 c0be8579d7fc4fbfa25b44f1b1e1ac57987c4dcc5f68ab3f6217fded57466488
MD5 38b0b8a4f23c8a4557c97d8578389397
BLAKE2b-256 43a135bd33dfcf1baef0cc1824092f929945c6021fce19f534e20d8dc5cfad5f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: calt_x-0.1.0.post5-py3-none-any.whl
  • Upload date:
  • Size: 37.1 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.post5-py3-none-any.whl
Algorithm Hash digest
SHA256 91956086489b6021c75dd14c0cc6bff6c084a26e0530dc462114fd76951ae7d5
MD5 239f68d5cd16c5a1243c47971156505a
BLAKE2b-256 3337f19b14ece7d59a58d4a0d6bbde6d52f55b4ae4138874ad73b9d2086c9174

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