Skip to main content

A library for computational algebra using Transformers

Project description

CALT: Computer ALgebra with Transformer

Documentation GitHub Pages

📖 📚 View Full Documentation

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 of deep learning can focus on constructing datasets to train and evaluate the model.

🚀 Quick Start

Installation

pip install calt-x

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 DataPipeline generates training and evaluation sets. The data.yaml gives a 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 implement the training and evalutation through IOPipeline, ModelPipeline, and TrainerPipeline. The config file train.yaml (and associated lexer.yaml) gives full 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/ directory.

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/dev/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 Arawaka 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.

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-1.1.0.tar.gz (94.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-1.1.0-py3-none-any.whl (117.0 kB view details)

Uploaded Python 3

File details

Details for the file calt_x-1.1.0.tar.gz.

File metadata

  • Download URL: calt_x-1.1.0.tar.gz
  • Upload date:
  • Size: 94.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for calt_x-1.1.0.tar.gz
Algorithm Hash digest
SHA256 54940328b3759ce1b0b7bf9c21d386559a7b164d6b949df3a412724bd74649e7
MD5 cb3beca58779b176798fc45939727b1f
BLAKE2b-256 d3148c0666c7058b10c3a712c4a6a3db8880cafbb47e1a49e56f3062b2270e02

See more details on using hashes here.

Provenance

The following attestation bundles were made for calt_x-1.1.0.tar.gz:

Publisher: pypi-release.yml on HiroshiKERA/calt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file calt_x-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: calt_x-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 117.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for calt_x-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c4fb809a48b3bb3541d37c52b4db6ac662c0f3992aea5ed758fc7a1e359b0119
MD5 c40e5b3cba14989090c966f4b60d343e
BLAKE2b-256 632eade5bdce3a094529de80fc2767088ee2a9f6e52398dee69758cda128ed87

See more details on using hashes here.

Provenance

The following attestation bundles were made for calt_x-1.1.0-py3-none-any.whl:

Publisher: pypi-release.yml on HiroshiKERA/calt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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