Skip to main content

An interactive terminal browser for .safetensors files

Project description

sft

The Swiss army knife for .safetensors files.

PyPI Python CI License

sft demo

sft is a single-binary CLI for inspecting, editing, and diffing .safetensors files — and an interactive terminal browser for poking around large checkpoints. Most commands read the file header only, so multi-gigabyte models open in milliseconds.

It also ships a skill that teaches AI coding agents (Claude Code, Cursor, Codex CLI) when to reach for it and how to parse the output.

Install

uv tool install sft-cli                 # recommended
pip install sft-cli                     # or pip
uv tool install 'sft-cli[torch]'        # + .pt/.pth conversion

🚀 Quick start

sft model.safetensors                   # open the interactive browser
sft info model.safetensors              # one-shot summary
sft info model.safetensors --json       # machine-readable

The bare sft <file> form is a shortcut for sft browse <file>. Inside the browser: ↑↓ to navigate, / to filter, L on a LoRA file for LoRA Mode, D to diff against another file, q to quit.

What it does

Inspect a file without loading it:

sft info  model.safetensors             # size, tensor count, dtypes, metadata
sft ls    model.safetensors             # flat list, sort/filter friendly
sft tree  model.safetensors --depth=2   # hierarchical view
sft stat  model.safetensors             # per-tensor mean/std/min/max/sparsity
sft check model.safetensors             # corruption + NaN/Inf scan

Compare two checkpoints:

sft diff base.safetensors finetuned.safetensors --delta \
    --include='**.self_attn.**'         # cosine, L2, max-abs per tensor

Edit without writing Python:

sft slice  big.safetensors --include='**.weight' -o weights-only.safetensors
sft strip  big.safetensors --exclude='*lora_*'
sft cast   model.safetensors --dtype fp16
sft cat    a.safetensors b.safetensors -o merged.safetensors
sft rename model.safetensors --sub 'model\.' 'backbone.'
sft split  model.safetensors --max-size 4GB
sft convert pytorch_model.bin           # → safetensors

Every write command supports --dry-run and never overwrites the input — outputs default to {stem}.{suffix}.safetensors.

Adapter workflows (PEFT and Kohya):

sft lora info    adapter.safetensors            # rank, alpha, target modules
sft lora svd     adapter.safetensors            # singular-value spectrum
sft lora compat  base.safetensors adapter.safetensors
sft lora extract base.safetensors ft.safetensors --rank 16
sft lora resize  adapter.safetensors --rank auto    # per-pair adaptive rank
sft lora stack   a.safetensors b.safetensors -a 0.7 -b 0.3
sft lora merge   base.safetensors adapter.safetensors
sft lora convert adapter.safetensors --to peft      # Kohya ↔ PEFT

--rank auto picks each pair's output rank from its singular-value spectrum (ceil(stable_rank) + 1), so over-parameterized pairs compress harder than rich ones. auto+N adds a safety margin.

The browser

Press a key, get a result.

Key Action
Navigate
Collapse / expand tree
Tab Switch between tree and table
/ Search / filter
s Cycle sort
Enter Tensor stats popup
m File metadata
c Cast file dtype
L LoRA Mode (per-pair stats, SVD, compress)
D Diff against another file
: Command palette
q Quit

🤖 AI agents

sft skill install                       # auto-detects Claude / Cursor / Codex
sft skill status
sft skill uninstall

The installer symlinks sft's skill into your agent's well-known skills directory (~/.claude/skills/sft, ~/.cursor/skills/sft, etc.), so it stays in sync when you uv tool upgrade sft-cli. Pass --mode copy for a frozen snapshot.

Every command supports --json for clean parsing:

sft info model.safetensors --json | jq '.tensors'
sft lora info adapter.safetensors --json | jq '.rank'
sft stat model.safetensors --json --include='**.q_proj.*'

License

MIT — see LICENSE.

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

sft_cli-0.2.1.tar.gz (214.6 kB view details)

Uploaded Source

Built Distribution

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

sft_cli-0.2.1-py3-none-any.whl (101.8 kB view details)

Uploaded Python 3

File details

Details for the file sft_cli-0.2.1.tar.gz.

File metadata

  • Download URL: sft_cli-0.2.1.tar.gz
  • Upload date:
  • Size: 214.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sft_cli-0.2.1.tar.gz
Algorithm Hash digest
SHA256 bde0d8ac690675c13a5113cc620dbebd9cd463f59baef49038511ab61fc88e47
MD5 804133b6ef9c269f68ad6dcd51c73c96
BLAKE2b-256 5bd9e5e9c282ac849582d4df664b7e74c4d1b066dc5e47142b666c4f055ee10e

See more details on using hashes here.

Provenance

The following attestation bundles were made for sft_cli-0.2.1.tar.gz:

Publisher: publish.yml on matanby/sft-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sft_cli-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: sft_cli-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 101.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sft_cli-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3c70ab6b0a3e2053f598148d4f8f27313339098af754466c084ac8368871059a
MD5 a85b302929913c4e27073c637fdb5663
BLAKE2b-256 b59b7a578ada7b86cb0b497906ddfaeca78880f4fbdf89d01090fb1731b66ace

See more details on using hashes here.

Provenance

The following attestation bundles were made for sft_cli-0.2.1-py3-none-any.whl:

Publisher: publish.yml on matanby/sft-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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