Skip to main content

SLM: Research-Grade TPU-Native Language Model Framework

Package name: build-slm  |  Import name: slm  |  Author: Niranjan Kumar K.  |  Version: 1.0.1  |  License: Apache-2.0

An advanced, scalable, research-grade language model training and inference framework optimized exclusively for Google Colab TPU accelerators using JAX and XLA, featuring a 100% pure-Python CPU reference implementation.

See the user guide, the Google Colab TPU guide, the benchmark report, and the automated test report.


Highlights

  • TPU-Native JAX/XLA Engine: High-throughput training on Google Colab TPU (v2-8, v3-8, v4-8) with bfloat16 mixed precision and float32 master weights.
  • Advanced Architecture: Causal multi-head attention, vectorized RoPE, numerically stable RMSNorm in float32, SwiGLU feed-forward networks, and pre-normalization.
  • Sequence Packing: Static-shape sequence multi-packing with 2D block-diagonal causal masks and padding-aware loss masks.
  • Multi-Device TPU Scaling: Automatic topology inspection, JAX device mesh, and NamedSharding across TPU cores.
  • Dedicated Instruction Tuning: SFT pipeline supporting QA, Alpaca-style instruction-response, multi-turn, reasoning, and math datasets with assistant-only loss masking.
  • Inference Optimization: Stateful KV-caching for O(1) decoding, greedy search, temperature, top-k, nucleus top-p, and repetition penalties.
  • Data Quality Intelligence: Multi-stage cleaning, unicode NFKC, mojibake repair, HTML/boilerplate stripping, SimHash deduplication, 10-domain classification, and zero-leakage disjoint splitting.
  • Comprehensive Evaluation: Top-1, Top-5, Top-10 token accuracy, word accuracy, perplexity, Expected Calibration Error (ECE), and long-context position-bucket evaluation.
  • Safe Migration & Recovery: Atomic checkpoint saving with SHA-256 parameter checksums and backward-compatible v4-to-v5 .kni migration.

Installation

# Base install (pure Python stdlib — no external dependencies)
pip install build-slm

# With TPU acceleration (Google Colab TPU)
pip install "build-slm[tpu]"

# With GPU acceleration (CUDA)
pip install "build-slm[gpu]"

# With CPU-only JAX
pip install "build-slm[cpu]"

Quick Start

from slm import *

# Initialize model (backend="auto" uses TPU if present, falls back to CPU)
model = slm(
    vocab_size=512,
    context_length=128,
    d_model=64,
    heads=4,
    layers=2,
    ff_dim=128,
    learning_rate=3e-4,
    weight_decay=0.01,
)

# Train on a folder of documents
report = model.train(
    "folder_path",
    epochs=3,
    batch_size=4,
    gradient_accumulation_steps=2,
    checkpoint_path="models/my_model.kni",
    use_advanced_cleaning=True,
)

# Fast KV-cached text generation
output = model.predict("The research showed that", max_tokens=80, temperature=0.7, top_p=0.9)
print(output)

Use model.save("models/name") and model.load("models/name") to store or restore a model. The only accepted model extension is .kni; it is added automatically when omitted.

Metadata

Release files for build-slm 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for build-slm 1.0.1
File Size Uploaded Provenance Actions
build_slm-1.0.1.tar.gz 55.1 kB Without provenance Details for build_slm-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for build-slm 1.0.1
File Interpreter ABI Platform Actions
build_slm-1.0.1-py3-none-any.whl Python 3 none any Details for build_slm-1.0.1-py3-none-any.whl

Total release size: 117.3 kB

Release files / build_slm-1.0.1.tar.gz

Download URL build_slm-1.0.1.tar.gz
Size 55.1 kB
Tags Source
SHA-256 checksum
How to use checksums
e9203dc05ea46374a76d80e0016b6e386ca1fa42928989aa97d92e36aa662d6b
BLAKE2b-256 checksum
How to use checksums
2a932f880da1703ca074ba51872e4e0996851fa33b7d2ae8ccae1459cdec17e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / build_slm-1.0.1-py3-none-any.whl

Download URL build_slm-1.0.1-py3-none-any.whl
Size 62.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
36ddcb2f09a87421cecb83959dade1f79558cd9def5aa32a6dd4dbbdc2e65365
BLAKE2b-256 checksum
How to use checksums
ef2757e34cd21524290bf6475ed4e3971869e9c21be824e86af12e99c2f83fba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Security for build-slm 1.0.1

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page