Skip to main content

Language Modelling Tasks as Objects (LaMoTO) provides a framework for language model training (masked and causal, pretraining and finetuning) where the tasks, not just the models, are classes themselves.

Project description

LaMoTO: Language Modelling Tasks as Objects

Language Modelling Tasks as Objects (LaMoTO) provides a framework for language model training (masked and causal, pretraining and finetuning) where the tasks, not just the models, are classes themselves. It abstracts over the HuggingFace transformers.Trainer with one goal: reduce the entire model training process to a single method call task.train(hyperparameters).

Usage

Let's say you want to train a RoBERTa-base model for dependency parsing (for which, by the way, there is no HuggingFace class). This is how you would do that in LaMoTO, supported by the magic of ArchIt:

from archit.instantiation.basemodels import RobertaBaseModel
from archit.instantiation.heads import DependencyParsingHeadConfig, BaseModelExtendedConfig
from lamoto.tasks import DP
from lamoto.training.auxiliary.hyperparameters import getDefaultHyperparameters

# Define task hyperparameters.
hp = getDefaultHyperparameters()
hp.model_config_or_checkpoint = "roberta-base"
hp.archit_basemodel_class = RobertaBaseModel
hp.archit_head_config = DependencyParsingHeadConfig(
    head_dropout=0.33,
    extended_model_config=BaseModelExtendedConfig(
        layer_pooling=1
    )
)

# Instantiate language modelling task as object, and train model.
task = DP()
task.train(hyperparameters=hp)

Features

  • Train models on >15 pre-training/fine-tuning tasks. See a list by importing from lamoto.tasks.
    • Model architectures come from ArchIt, which means that as long as you have a BaseModel wrapper for your language model backbone, you can train it on any task, regardless of whether you wrote code defining the backbone-with-head architecture required for that task.
    • Custom (i.e. given) architectures are also supported.
  • Evaluate models with a superset of the metrics in HuggingFace's evaluate, with custom inference procedures (see e.g. strided pseudo-perplexity or bits-per-character).
  • Augment datasets before training or evaluating by somehow perturbing them.
  • Supports TkTkT tokenisers.
  • Weights-and-Biases integration.

Installation

If you don't want to edit the source code yourself, run

pip install "lamoto[github] @ git+https://github.com/bauwenst/LaMoTO"

and if you do, instead run

git clone https://github.com/bauwenst/LaMoTO
cd LaMoTO
pip install -e .[github]

To be able to use the Weights-and-Biases integration, make sure you first run wandb login in a command-line terminal on the system you want to run on.

Alternative packages

There exist other libraries that abstract across training tasks in an effort to avoid heavily dedicated training scripts. I'm aware of the following packages (although I'm not sure how extensible they are):

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

lamoto-2026.3.1.tar.gz (106.2 kB view details)

Uploaded Source

Built Distribution

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

lamoto-2026.3.1-py3-none-any.whl (128.9 kB view details)

Uploaded Python 3

File details

Details for the file lamoto-2026.3.1.tar.gz.

File metadata

  • Download URL: lamoto-2026.3.1.tar.gz
  • Upload date:
  • Size: 106.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.5 cpython/3.13.12 HTTPX/0.28.1

File hashes

Hashes for lamoto-2026.3.1.tar.gz
Algorithm Hash digest
SHA256 a8bd642f3636c14eeae17d3fd8ce19c8d96f25b28d12237a46640c2998896bdb
MD5 366c2ef1badfebc0c9eacb95fa2979e4
BLAKE2b-256 5f52c0898e82c4ff658ba37daa18fb62c6fd07dc2eca720c15c4a4ce18a78ff9

See more details on using hashes here.

File details

Details for the file lamoto-2026.3.1-py3-none-any.whl.

File metadata

  • Download URL: lamoto-2026.3.1-py3-none-any.whl
  • Upload date:
  • Size: 128.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.5 cpython/3.13.12 HTTPX/0.28.1

File hashes

Hashes for lamoto-2026.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d367d3f50a8b5dec4e93cd5e5c84079e876c0c5e0145afcee44776858e649124
MD5 98e5d5a6ac92048ba2ecca9475735aef
BLAKE2b-256 785ebbe2a73f19f49e1ce46249372e0e048bba958f3981ff6fbf15d9c823ad65

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