Skip to main content

Bantam language model core

Project description

Bantam

Bantam is a configurable decoder-only transformer packaged with a CLI for tokenizer training, pre-training, SFT, and chat inference. It runs on pure PyTorch (torch>=2.1) and uses the scaled-dot-product/FlashAttention stack for grouped-query attention, sliding windows, and sink tokens without custom kernels.

Key Features

  • Flex-attention based GQA with optional sliding windows and sink tokens.
  • Per-layer overrides let you mix head counts, windows, sinks, and MoE routing per block via layer_configs.
  • SwiGLU dense blocks or Switch/Top-k MoE with router/aux loss controls.
  • Rotary embeddings with linear, NTK, and YaRN-style scaling.
  • Regex-aware BPE trainer (bantam-cli trainbpe) that isolates punctuation, chunks long numbers, and optionally prefills 0–N.
  • Unified CLI for model init, pre-training, SFT (full or LoRA), resume, and chat streaming.

Installation

python3 -m pip install bantam

Optional extras (examples):

# Latest from Git
python3 -m pip install git+https://github.com/theo-bntm/bantam.git

# Editable install for development
git clone https://github.com/theo-bntm/bantam.git
cd bantam
python3 -m pip install -e .

CLI Quick Start

bantam-cli --help          # list commands
python -m bantam --help    # same entry point via module

# Train a tokenizer from JSONL
bantam-cli trainbpe --input data/pretrain.jsonl --out tokenizers/run1

# Generate starter templates (model + training)
bantam-cli define --out configs/templates/pretrain_pair.yaml

# Initialise a model directory from split configs
bantam-cli init --mconf configs/models/pretrain_small.yaml --config configs/training/pretrain_small.yaml --out models/bantam-init

# Launch pre-training run
bantam-cli pretrain --mconf configs/models/pretrain_small.yaml --config configs/training/pretrain_small.yaml

# Resume a checkpointed run
bantam-cli continue-pretrain --mconf configs/models/pretrain_small.yaml --config configs/training/pretrain_small.yaml --model models/run1/checkpoints/step_20000

# Supervised fine-tuning (LoRA or full)
bantam-cli sft --config configs/training/sft_small.yaml --model models/bantam-init

# Chat with a trained checkpoint
bantam-cli chat --model models/run1/best --format chat

Model configs live under configs/models/ with a bantam_config block. Training/SFT configs live under configs/training/ with training_args, optional sft_args, and a run seed. Relative paths resolve against the YAML file location.

Example per-layer tweak:

bantam_config:
  hidden_size: 1024
  num_hidden_layers: 12
  num_attention_heads: 16
  num_key_value_heads: 4
  layer_configs:
    - { window: 2048, num_attention_sinks: 2 }
    - { expert_type: switch, num_experts: 8, moe_capacity_factor: 1.0 }

More Info

Report issues or ideas via GitHub. Enjoy experimenting with Bantam!

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

bantam_cli-0.1.0.tar.gz (62.2 kB view details)

Uploaded Source

Built Distribution

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

bantam_cli-0.1.0-py3-none-any.whl (59.5 kB view details)

Uploaded Python 3

File details

Details for the file bantam_cli-0.1.0.tar.gz.

File metadata

  • Download URL: bantam_cli-0.1.0.tar.gz
  • Upload date:
  • Size: 62.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for bantam_cli-0.1.0.tar.gz
Algorithm Hash digest
SHA256 072d253644ccfdb4952c0a798b9b3f6f17235bf723a305edb166e31a2c727d43
MD5 c8621f240043caa78eea5f3949e625ba
BLAKE2b-256 6bdc44b366fa84e0137b9e8e19efe568576aa8002e83d1c0bae828ebc3bfd0b5

See more details on using hashes here.

File details

Details for the file bantam_cli-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: bantam_cli-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 59.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for bantam_cli-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 50cd89aea9ba573f1b4aac6ad220a43efcfd72e0a0d73ef782491b95d224db49
MD5 c10bcca348e4759cc3bb696e2941e8fa
BLAKE2b-256 827104ecb5510690380820c15ec5dc4876669e3d1ed79235a879544b6029ac6d

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