Features • Installation • Tutorials • Community • Citing • License
Overview
fasterAI is a PyTorch-based library that makes neural networks smaller, faster, and more efficient through state-of-the-art compression techniques. The library provides simple but powerful implementations of pruning, knowledge distillation, quantization, and other network optimization methods that can be applied with just a few lines of code.
Why compress your models with fasterai?
- Reduce model size by up to 90% with minimal accuracy loss
- Speed up inference for deployment on edge devices
- Lower energy consumption for more sustainable AI
- Simplify architectures while maintaining performance
Features
1. Sparsification
Make your model sparse by replacing selected weights with zeros using Sparsifier or SparsifyCallback.
| Parameter | Description | Options |
|---|---|---|
sparsity |
Percentage of weights to zero out | 0-100% |
granularity |
Level at which to apply sparsity | 'weight', 'vector', 'kernel', 'filter' |
context |
Scope of sparsification | 'local' (per layer), 'global' (whole model) |
criteria |
Method to select weights | 'magnitude', 'movement', 'gradient', etc. |
schedule |
How sparsity evolves during training | 'one_shot', 'iterative', 'gradual', etc. |
2. Pruning
Remove zero-weight nodes from your network structure using Pruner or PruneCallback.
| Parameter | Description | Options |
|---|---|---|
pruning_ratio |
Percentage of weights to remove | 0-100% |
context |
Scope of sparsification | 'local' (per layer), 'global' (whole model) |
criteria |
Method to select weights | 'magnitude', 'movement', 'gradient', etc. |
schedule |
How sparsity evolves during training | 'one_shot', 'iterative', 'gradual', etc. |
3. Knowledge Distillation
Transfer knowledge from a large teacher to a smaller student using KnowledgeDistillationCallback.
| Parameter | Description | Options |
|---|---|---|
teacher |
Teacher model | Any PyTorch model |
loss |
Distillation loss function | 'SoftTarget', 'Logits', 'Attention', etc. |
activations_student |
Student layers to match | Layer names as strings |
activations_teacher |
Teacher layers to match | Layer names as strings |
weight |
Balancing weight for distillation | 0.0-1.0 |
4. Regularization
Push weights toward zero during training using RegularizeCallback.
| Parameter | Description | Options |
|---|---|---|
criteria |
Regularization criteria | Same as sparsification criteria |
granularity |
Level of regularization | Same as sparsification granularity |
weight |
Regularization strength | Floating point value |
schedule |
How sparsity evolves during training | 'one_shot', 'iterative', 'gradual', etc. |
layer_types |
Layer types to regularize | 'nn.Conv2d', 'nn.Linear', etc. |
5. Quantization
Reduce the precision of weights and activations using Quantizer or QuantizeCallback.
| Parameter | Description | Options |
|---|---|---|
backend |
Target backend | 'x86', 'qnnpack' |
method |
Quantization method | 'static', 'dynamic', 'qat' |
use_per_tensor |
Force per-tensor quantization | True/False |
Quick Start
This is how easy it is to induce Sparsification in your PyTorch model:
from fasterai.sparse.all import *
learn = vision_learner(dls, model)
learn.fit_one_cycle(n_epochs, cbs=SparsifyCallback(sparsity, granularity, context, criteria, schedule))
Installation
pip install git+https://github.com/FasterAI-Labs/fasterai.git
or
pip install fasterai
Tutorials
- Get Started with FasterAI
- Create your own pruning schedule
- Find winning tickets using the Lottery Ticket Hypothesis
- Use Knowledge Distillation to help a student model to reach higher performance
- Sparsify Transformers
- Many more !
Join the community
Join our discord server to meet other FasterAI users and share your projects!
Citing
@software{Hubens,
author = {Nathan Hubens},
title = {fasterai},
year = 2022,
publisher = {Zenodo},
version = {v0.3.0},
doi = {10.5281/zenodo.6469868},
url = {https://doi.org/10.5281/zenodo.6469868}
}
License
Apache-2.0 License.
Metadata
Release files for fasterai 0.4.1
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 | |
|---|---|---|---|---|
| fasterai-0.4.1.tar.gz | 87.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fasterai-0.4.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 184.9 kB
Release files / fasterai-0.4.1.tar.gz
| Download URL | fasterai-0.4.1.tar.gz |
|---|---|
| Size | 87.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bb08ccd89f99d9d9080115dce32d14ed32c09cb05d27ea76451e0f9f209d97fb
|
|
BLAKE2b-256 checksum How to use checksums |
9c23c78829d09c519b02cd8dd8a1684795c3b48be75dfd5930c9498b12819373
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.11
|
Release files / fasterai-0.4.1-py3-none-any.whl
| Download URL | fasterai-0.4.1-py3-none-any.whl |
|---|---|
| Size | 97.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a41cde10056a0cfd46e9d2ed5ffe3b7d60cfd1fff21d2b8f59461902878d7d36
|
|
BLAKE2b-256 checksum How to use checksums |
40a4f4661bb9242b75a0ecf5a4f228a8e7d995e4570da5f35c78e8ffc3d26188
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.11
|
Security for fasterai 0.4.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.