13
13
14
14
######################################################################
15
15
# Introduction
16
- # ============
16
+ # ------------
17
17
#
18
18
# In this tutorial, we will apply the dynamic quantization on a BERT
19
19
# model, closely following the BERT model from the HuggingFace
71
71
72
72
######################################################################
73
73
# Setup
74
- # =====
74
+ # -------
75
75
#
76
76
# Install PyTorch and HuggingFace Transformers
77
- # --------------------------------------------
77
+ # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
78
78
#
79
79
# To start this tutorial, let’s first follow the installation instructions
80
80
# in PyTorch and HuggingFace Github Repo: -
203
203
204
204
######################################################################
205
205
# Fine-tune the BERT model
206
- # ========================
206
+ # --------------------------
207
207
#
208
208
209
209
@@ -476,7 +476,7 @@ def load_and_cache_examples(args, task, tokenizer, evaluate=False):
476
476
477
477
######################################################################
478
478
# Apply the dynamic quantization
479
- # ==============================
479
+ # -------------------------------
480
480
#
481
481
# We call ``torch.quantization.quantize_dynamic`` on the model to apply
482
482
# the dynamic quantization on the HuggingFace BERT model. Specifically,
@@ -626,7 +626,7 @@ def time_model_evaluation(model, configs, tokenizer):
626
626
627
627
######################################################################
628
628
# Conclusion
629
- # ==========
629
+ # ----------
630
630
#
631
631
# In this tutorial, we demonstrated how to demonstrate how to convert a
632
632
# well-known state-of-the-art NLP model like BERT into dynamic quantized
@@ -641,7 +641,7 @@ def time_model_evaluation(model, configs, tokenizer):
641
641
642
642
######################################################################
643
643
# References
644
- # ==========
644
+ # -----------
645
645
#
646
646
# [1] J.Devlin, M. Chang, K. Lee and K. Toutanova, BERT: Pre-training of
647
647
# Deep Bidirectional Transformers for Language Understanding (2018)
@@ -657,5 +657,3 @@ def time_model_evaluation(model, configs, tokenizer):
657
657
######################################################################
658
658
#
659
659
#
660
-
661
-
0 commit comments