Skip to main content

topologies

A PyTorch toolbox for building, training, comparing and inspecting neural-network architectures — plus a catalog of small reference implementations (GPT, LLaMA, ViT, ResNet, BERT, Mamba, ...).

Early alpha (v0.0.1). The toolbox — training engine, data utilities, tokenizers, model constructor, generation, evaluation, experiments, introspection — is tested. Catalog models in topologies.models / topologies.layers are experimental references: importable, trainable and smoke-tested, but not validated against the papers. APIs may change between releases.

Install

pip install topologies                 # core
pip install "topologies[all]"          # + vision, nlp, tensorboard, visualization, ...

Python 3.10–3.13, PyTorch >=2.2,<2.13.

Quickstart

Train a tiny language model on any text corpus:

from topologies import Trainer, build, data, generate, train_tokenizer
from topologies.nn import TransformerLM

docs = data.read_documents("corpus.txt")
train_docs, val_docs = data.train_val_split(docs, 0.1)
tok = train_tokenizer(train_docs, kind="bpe", vocab_size=2048)
model = build(TransformerLM, "tiny", vocab_size=tok.vocab_size, max_seq=128)

trainer = Trainer(model, data.lm_dataset(train_docs, tok, 128),
                  data.lm_dataset(val_docs, tok, 128),
                  tokenizer=tok, batch_size=32, max_epochs=20, lr=1e-3)
trainer.fit()
trainer.save_pretrained("artifacts/tiny-lm")
print(generate(model, "Once upon a time", tokenizer=tok, max_new_tokens=100, top_k=40))

Compare many configurations with one declaration — the library runs every trial (resumably), then ranks and explains the results:

from topologies import Experiment
from topologies.experiments import LanguageModeling, Variant

exp = Experiment("arch-x-tokenizer",
                 task=LanguageModeling(docs, val_fraction=0.1, block_size=128),
                 axes={"model": [TransformerLM,
                                 Variant("llama-ish", TransformerLM, pos="rope",
                                         norm="rms", activation="swiglu")],
                       "tokenizer": ["char", "bpe:1k", "bpe:4k"]},
                 target_params="1M", train_for="2 epochs", seeds=2)
exp.run().show()

What's inside

  • topologies.nn — composable stacks, presets and parameter budgets
  • Trainer, generate, evaluation, optimization and quantization helpers
  • topologies.data, dataset catalog, tokenizers
  • Experiment — sweeps, leaderboards, pivots, importance analysis
  • topologies.introspection / topologies.visualization — look inside trained models
  • topologies CLI — topologies --help

License

Apache-2.0

Metadata

Release files for topologies 0.0.4

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

Source distribution (sdist)

Source distribution for topologies 0.0.4
File Size Uploaded Provenance Actions
topologies-0.0.4.tar.gz 1.9 MB Without provenance Details for topologies-0.0.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for topologies 0.0.4
File Interpreter ABI Platform Actions
topologies-0.0.4-py3-none-any.whl Python 3 none any Details for topologies-0.0.4-py3-none-any.whl

Total release size: 4.6 MB

Release files / topologies-0.0.4.tar.gz

Download URL topologies-0.0.4.tar.gz
Size 1.9 MB
Tags Source
SHA-256 checksum
How to use checksums
2ffe4795c095dec02ca6c4a2d637ff5ebc45a64612221845072c736affd54a8a
BLAKE2b-256 checksum
How to use checksums
8d222cebb3787535a68f725742172b0b175c30ced7e9b66e409fe428969bdbf5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.4

Release files / topologies-0.0.4-py3-none-any.whl

Download URL topologies-0.0.4-py3-none-any.whl
Size 2.7 MB
Tags Python 3
SHA-256 checksum
How to use checksums
ecffb21f4515e2e4e15f226535cd8f485f7d1f9db36a4e864d6541b167cbd6c0
BLAKE2b-256 checksum
How to use checksums
44144bc9489d2ab8ace14c04c59d4b0ebe6c9c0fa7634b6c1a5432088d8985a6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.4

Security for topologies 0.0.4

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