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.2.tar.gz (65.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.2-py3-none-any.whl (62.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bantam_cli-0.1.2.tar.gz
  • Upload date:
  • Size: 65.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.2.tar.gz
Algorithm Hash digest
SHA256 bcaa1e633fa558926a3017c2b0047e76090c64a016544a6b7e50cd4b1702ea5d
MD5 887998a2f909bec2f0067ed34a1e236c
BLAKE2b-256 3f0397956a4ae5202548b6b71b5a6ee10bed919600503987103b01f9067a9d31

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bantam_cli-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 62.9 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 412a42bf257cab0b78eaab2266e7199e3f76c1ced50db27261fb694767aca6ed
MD5 3c08ee44e5ac38adf0b3e2bf301be96f
BLAKE2b-256 b27b52a5af8dd215baf52b56ccb2060de3517c9abd46c81134bc647b764147b2

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