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-cli

CLI Quick Start

bantam-cli --help          # list commands

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

# Generate starter configs (model + train + SFT)
bantam-cli define --out configs

# 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 (model config auto-detected)
bantam-cli continue-pretrain --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.1.tar.gz (63.4 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.1-py3-none-any.whl (61.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bantam_cli-0.1.1.tar.gz
  • Upload date:
  • Size: 63.4 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.1.tar.gz
Algorithm Hash digest
SHA256 ba7a3dfaa165871d4ba5ba3a98ccc0ac5602ceef4521cf2826c5771cd9c77c2c
MD5 8e6cdd70b91e830d697de4d2fb025b11
BLAKE2b-256 37368b1e6500c6c5db171a1e4abe958dd23e9f79915b85177b2a08592bf87c23

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bantam_cli-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 61.1 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0138de844c3b18484f4461047263343c33c01142b32322dbdb8362389c51e573
MD5 3be673e4cfe0d65f770a592d873033f3
BLAKE2b-256 67afb4fb82bdc5aed805850005153cc65813772714f3c66a395634f204a0d866

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