Home/Model Training/PocketFlow
PocketFlow logo

PocketFlow

Enrichment pending
Tencent/PocketFlow

An Automatic Model Compression (AutoMC) framework for developing smaller and faster AI applications.

GraphCanon updated today · GitHub synced today

2.9k
Stars
490
Forks
75
Open issues
141
Watchers
3y
Last push
Python OtherCreated Oct 31, 2018

Trust & integrity

Full report
Maintenance
Dormant (1198d since push)
As of today · Source: github_public_v1
Provenance
Not a fork · Organization account
As of today · Source: github_public_v1
Security (OSV)
No lockfile
As of today · Source: none

Public GitHub metadata and optional OSV dependency scans. Signals, not a guarantee. Trust methodology.

Overview

An Automatic Model Compression (AutoMC) framework for developing smaller and faster AI applications.

Capability facts

Languages
python

Source: github.language · Jul 11, 2026

Categories

Tags

README

PocketFlow

PocketFlow is an open-source framework for compressing and accelerating deep learning models with minimal human effort. Deep learning is widely used in various areas, such as computer vision, speech recognition, and natural language translation. However, deep learning models are often computational expensive, which limits further applications on mobile devices with limited computational resources.

PocketFlow aims at providing an easy-to-use toolkit for developers to improve the inference efficiency with little or no performance degradation. Developers only needs to specify the desired compression and/or acceleration ratios and then PocketFlow will automatically choose proper hyper-parameters to generate a highly efficient compressed model for deployment.

PocketFlow was originally developed by researchers and engineers working on machine learning team within Tencent AI Lab for the purposes of compacting deep neural networks with industrial applications.

For full documentation, please refer to PocketFlow's GitHub Pages. To start with, you may be interested in the installation guide and the tutorial on how to train a compressed model and deploy it on mobile devices.

For general discussions about PocketFlow development and directions please refer to PocketFlow Google Group. If you need a general help, please direct to Stack Overflow. You can report issues, bug reports, and feature requests on GitHub Issue Page.

News: we have created a QQ group (ID: 827277965) for technical discussions. Welcome to join us!

Framework

The proposed framework mainly consists of two categories of algorithm components, i.e. learners and hyper-parameter optimizers, as depicted in the figure below. Given an uncompressed original model, the learner module generates a candidate compressed model using some randomly chosen hyper-parameter combination. The candidate model's accuracy and computation efficiency is then evaluated and used by hyper-parameter optimizer module as the feedback signal to determine the next hyper-parameter combination to be explored by the learner module. After a few iterations, the best one of all the candidate models is output as the final compressed model.

Learners

A learner refers to some model compression algorithm augmented with several training techniques as shown in the figure above. Below is a list of model compression algorithms supported in PocketFlow:

NameDescription
ChannelPrunedLearnerchannel pruning with LASSO-based channel selection (He et al., 2017)
DisChnPrunedLearnerdiscrimination-aware channel pruning (Zhuang et al., 2018)
WeightSparseLearnerweight sparsification with dynamic pruning schedule (Zhu & Gupta, 2017)
UniformQuantLearnerweight quantization with uniform reconstruction levels (Jacob et al., 2018)
UniformQuantTFLearnerweight quantization with uniform reconstruction levels and TensorFlow APIs
NonUniformQuantLearnerweight quantization with non-uniform reconstruction levels (Han et al., 2016)

All the above model compression algorithms can trained with fast fine-tuning, which is to directly derive a compressed model from the original one by applying either pruning masks or quantization functions. The resulting model can be fine-tuned with a few iterations to recover the accuracy to some extent. Alternatively, the compressed model can be re-trained with the full training data, which leads to higher accuracy but usually takes longer to complete.

To further reduce the compressed model's performance degradation, we adopt network distillation to augment its training process with an