Applies and compares pruning techniques on a BERT model, then exports to ONNX and TFLite for edge deployment.
Techniques compared:
- Unstructured pruning (magnitude-based)
- Structured pruning
- Sparsity analysis and reporting
python -m venv .bert_venv
source .bert_venv/bin/activate
pip install -r requirements.txt
pip install -r requirements-gui.txt # for GUI frontends onlyThe base model (prajjwal1/bert-medium) is downloaded automatically from Hugging Face on first run via the transformers library. No manual download needed.
Run pruning and export:
python BERT-Optimization.pyGenerate reports:
python generate_report.py
python generate_tflite_report.pyGUI frontends:
python bert_gui_streamlit.py # Streamlit
python bert_gui_gradio.py # Gradio
python bert_gui_tkinter.py # Tkinter