# THUDM/SwissArmyTransformer

SwissArmyTransformer is a flexible and powerful library to develop your own Transformer variants.

Repository: https://github.com/THUDM/SwissArmyTransformer
Canonical: https://ross.abutalabs.com/products/swissarmytransformer
Homepage: https://THUDM.github.io/SwissArmyTransformer
Language: Python
License: Apache-2.0
License Family: permissive
Topics: pytorch, transformer, pretrained-models
Last push: 2024-12-26T13:23:58+00:00

## Health v2 (maintenance only)
Score: 23/100 (v2, computed 2026-09-02T17:46:02.011165+00:00)
- activity 0, release rhythm 8, longevity 100
- inputs: {"age_days": 1792, "days_push": 615, "days_rel": null, "gap_med": null, "n_releases_24m": 0}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 1121, forks 99 (observed 2026-08-28T04:03:39.866302+00:00)

## What it is
SwissArmyTransformer (sat) is a PyTorch library for developing custom Transformer model variants where models like BERT, GPT, T5, GLM, and ViT share a common backbone code extended via lightweight mixins. It integrates DeepSpeed ZeRO and model parallelism to support pretraining and finetuning of large models from 100M to 20B parameters.

## Use cases
- develop custom transformer model variants
- finetune large pretrained language models
- add prefix-tuning or p-tuning to existing models
- pretrain large models up to 20B parameters
- build autoregressive text generation with beam search
- add classification heads to pretrained transformers

## When to choose
- you want to experiment with transformer architecture modifications without rewriting backbone code
- you need efficient pretraining or finetuning of large models with deepspeed and model parallelism
- you want to apply parameter-efficient techniques like prefix-tuning across different model families
- you need cached autoregressive inference for generation tasks

## When to avoid
- you need a general-purpose deep learning framework rather than a transformer-specific library
- your models are not transformer-based
- you prefer higher-level abstractions like huggingface transformers for standard finetuning workflows
- you work without gpu resources since the library targets large-scale training

## Facets
- artifact type: library
- maturity: active
- function: llm-training, machine-learning, deep-learning, llm-inference
- domain: deep-learning, large-language-models, machine-learning
- platform: python
- tags: transformer, pytorch, pretrained-models, model-parallelism, deepspeed, finetuning, mixin-architecture, large-models, natural-language-processing, gpu, linux

## Member repositories
- THUDM/SwissArmyTransformer (main) score 23

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:03:39.866302+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T06:40:58.939938+00:00, confidence not recorded.
  - readme: https://github.com/THUDM/SwissArmyTransformer (fetched 2026-08-28T04:03:39.866302+00:00, sha 1e1f12cea0b7)
  - homepage: https://THUDM.github.io/SwissArmyTransformer (fetched 2026-08-29T12:44:47.767523+00:00, sha dbb4343a6440)
  - registry_pypi: https://pypi.org/pypi/swissarmytransformer/json (fetched 2026-08-29T12:44:47.786926+00:00, sha 31c965633e38)
- Data as of 2026-08-30T08:39:29.467469+00:00.
