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 (pretrain format by default)
bantam-cli chat --model models/run1/best
# base model inference
bantam-cli chat --model Theoistic/Bantam-285m
# Conversational chat retaining the last two turns
bantam-cli chat --model Theoistic/Bantam-285m-Instruct --format chat --history-turns 2
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
- Source code & full documentation: https://github.com/theo-bntm/bantam
- Release checklist:
publish.mdinside the repository
Report issues or ideas via GitHub. Enjoy experimenting with Bantam!
LLaMAFactory Integration
You can fine-tune Bantam models with LLaMAFactory once bantam-cli is installed
you need to register the architecture in LLaMA-Factory/src/llamafactory/cli.py
import bantam # lazy imports
import bantam.tokenization_bantam # registers BantamFastTokenizer with AutoTokenizer
import bantam.modeling_bantam # registers config/model with AutoConfig/AutoModel
and add this somewhere in the bottom of LLaMA-Factory/src/llamafactory/data/template.py
register_template(
name="bantam_chat",
format_user=StringFormatter(
slots=["<|USER_START|>{{content}}<|USER_END|><|AGENT_START|>"]
),
format_assistant=StringFormatter(slots=["{{content}}<|AGENT_END|>"]),
format_system=StringFormatter(slots=["<|SYSTEM_START|>{{content}}<|SYSTEM_END|>"]),
format_prefix=EmptyFormatter(slots=[{"bos_token"}]),
stop_words=["<|AGENT_END|>", "<|EOS|>"],
replace_eos=False,
)
- Use
--template bantam_chatin LLaMAFactory for both SFT and preference/DPO runs. - The template leaves user turns in-place but only supervises the assistant span (mirrors Bantam’s
mask_user_queries=truedefault). - Set
include_agent_end=trueandinclude_eos=truein your Bantam SFT config so completions end with<|AGENT_END|><|EOS|>, giving the stop tokens above reliable cut points. - For LoRA vs. full SFT, follow LLaMAFactory’s standard CLI flags—Bantam checkpoints expose all weights so “full” fine-tunes work out of the box.
After training, export the adapter or merged weights from LLaMAFactory and load them with bantam-cli chat --model <path> to validate generations.
Metadata
Release files for bantam-cli 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| bantam_cli-0.1.3.tar.gz | 66.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| bantam_cli-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 130.9 kB
Release files / bantam_cli-0.1.3.tar.gz
| Download URL | bantam_cli-0.1.3.tar.gz |
|---|---|
| Size | 66.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4343dc7ca2c0679c278e80910cddc476959752fe5924dfb19aa42911f0058db6
|
|
BLAKE2b-256 checksum How to use checksums |
0a2d50f0fc9c6f69902eae1abb1b7e832146ace2e87e544c4a951376a0b3f2e8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / bantam_cli-0.1.3-py3-none-any.whl
| Download URL | bantam_cli-0.1.3-py3-none-any.whl |
|---|---|
| Size | 63.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c56a0cb173cf37576829819713274656ff427b7a4d7cbb8b856c7d2076af2046
|
|
BLAKE2b-256 checksum How to use checksums |
60a52a5d7f8d62c0ed2487af324947b71b76adc7d691de9c70e58e6e941480e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for bantam-cli 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.