Skip to main content

CALT: Computer ALgebra with Transformer

Documentation

CALT is available as the Python package calt-x. For practical examples and project templates built with CALT, see calt-codebase.

Overview

CALT is a simple Python library for learning arithmetic and symbolic computation with a Transformer model (a deep neural model to realize sequence-to-sequence functions).

It offers a basic Transformer model and training pipeline, and non-experts in deep learning can focus on constructing datasets to train and evaluate the model.

Quick Start

Installation

We recommend installing CALT in a dedicated conda environment.

conda create -n calt-env python=3.11
conda activate calt-env
conda install -c conda-forge calt-x

Alternatively, install it from PyPI with pip:

pip install calt-x

CALT supports Python >=3.11 (tested in CI on 3.11–3.14).

Optional: If you use features that depend on SageMath, install SageMath in the same conda environment:

conda install -c conda-forge sage

You can check the available versions with:

conda search calt-x --channel conda-forge

The conda-forge feedstock is available here: conda-forge/calt-x-feedstock.

Instance Generation

For minimal usage, users only need to implement an instance generator for their own task. For example:

def int_sum_generator(seed, N=5, lb=-10, ub=10):
    random.seed(seed)

    # get N random integers from [lb, ub]
    problem = [random.randint(lb, ub) for _ in range(N)]
    answer = sum(problem)

    return problem, answer

Feeding the generator to DatasetPipeline generates training and evaluation sets. The data.yaml configuration file provides full control over the generation process.

cfg = OmegaConf.load("configs/data.yaml")
pipeline = DatasetPipeline.from_config(
    cfg.dataset,
    instance_generator=int_sum_generator
)
pipeline.run()

Training Script

Then, a short script handles training and evaluation through IOPipeline, ModelPipeline, and TrainerPipeline. The train.yaml configuration file and the associated lexer.yaml file provide control over the training setup.

cfg = OmegaConf.load("configs/train.yaml")

io_pipeline = IOPipeline.from_config(cfg.data)
io_dict = io_pipeline.build()

model = ModelPipeline.from_io_dict(cfg.model, io_dict).build()
trainer_pipeline = TrainerPipeline.from_io_dict(cfg.train, model, io_dict).build()

trainer_pipeline.train()
trainer_pipeline.save_model()
trainer_pipeline.evaluate_and_save_generation()

Examples

See examples/ for minimal examples. For practical experiments and project templates built with CALT, see calt-codebase.

For users without a local GPU

If you do not have a local GPU, you can still try CALT in two ways:

  1. Run the demo on Google Colab

    Use the demo notebook from your browser: https://colab.research.google.com/github/HiroshiKERA/calt/blob/main/examples/demos/minimal_demo.ipynb

  2. Use remote jobs on Kaggle

    Submit and monitor training jobs from your local terminal using calt remote .... See the remote job documentation: https://hiroshikera.github.io/calt/remote/

Citation

If you use CALT in your project, please cite our paper:

@misc{kera2025calt,
  title={CALT: A Library for Computer Algebra with Transformer},
  author={Hiroshi Kera and Shun Arakawa and Yuta Sato},
  year={2025},
  archivePrefix={arXiv},
  eprint={2506.08600}
}

Note: The current arXiv preprint is based on the previous version of CALT. The update will come soon.

Metadata

Release files for calt-x 1.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for calt-x 1.6.0
File Size Uploaded Provenance Actions
calt_x-1.6.0.tar.gz 140.1 kB With provenance Details for calt_x-1.6.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for calt-x 1.6.0
File Interpreter ABI Platform Actions
calt_x-1.6.0-py3-none-any.whl Python 3 none any Details for calt_x-1.6.0-py3-none-any.whl

Total release size: 315.3 kB

Release files / calt_x-1.6.0.tar.gz

Download URL calt_x-1.6.0.tar.gz
Size 140.1 kB
Tags Source
SHA-256 checksum
How to use checksums
fd59bba32a6063adb8e8c2b9439a4e40500204e15183bdfcc5163fb5c1690189
BLAKE2b-256 checksum
How to use checksums
575533ce9aa5afe8a3ebf7b2dbee0a0d5b7fb5af419a0ecb503d88499d97264b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Release files / calt_x-1.6.0-py3-none-any.whl

Download URL calt_x-1.6.0-py3-none-any.whl
Size 175.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e21138fd2de29e894afdd9fb8bab461a58e19029b6c23f8f47b177615628765f
BLAKE2b-256 checksum
How to use checksums
fac033f214897e3aca818cba2e9d41bfc9e4f37afa7ef1f640b67550161b5d40
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Security for calt-x 1.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for calt_x-1.6.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page