Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.

Commit e29e74e

Browse files
HF typos (#106)
HuggingFace typos. Should be Hugging Face. Multiple places. * Update question-answering.mdx * Update text-classification.mdx * Update question-answering.mdx * Update token-classification.mdx * Update text-classification.mdx * Update sparsify-a-model.mdx * Update supported-integrations.mdx * Update question-answering.mdx Co-authored-by: Robert Shaw <[email protected]>
1 parent bb08a95 commit e29e74e

File tree

5 files changed

+35
-35
lines changed

5 files changed

+35
-35
lines changed

src/content/get-started/sparsify-a-model.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ index: 4000
1111
SparseML enables you to create a sparse model from scratch. The library contains state-of-the-art sparsification algorithms, including pruning, distillation, and quantization techniques.
1212

1313
These algorithms are built on top of sparsification recipes, enabling easy integration into custom ML training pipelines to sparsify most neural networks.
14-
Additionally, SparseML integrates with popular ML repositories like HuggingFace Transformers and Ultralytics YOLO. With these integrations, creating a recipe and passing it to a CLI is all you need to sparsify a model.
14+
Additionally, SparseML integrates with popular ML repositories like Hugging Face Transformers and Ultralytics YOLO. With these integrations, creating a recipe and passing it to a CLI is all you need to sparsify a model.
1515

1616
Aside from sparsification algorithms, SparseML contains generic export pathways for performant deployments.
1717
These export pathways ensure the model saves in the correct format and rewrites the inference graphs for performance, such as quantized operator folding.

src/content/get-started/sparsify-a-model/supported-integrations.mdx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
---
22
title: "Supported Integrations"
3-
metaTitle: "Sparsifying a model for SparseML Integrations"
3+
metaTitle: "Sparsifying a Model for SparseML Integrations"
44
metaDescription: "Sparsify a model with SparseML and recipes for smaller, faster, and cheaper model inferences in deployment"
55
githubURL: "https://github.com/neuralmagic/docs/blob/main/src/content/get-started/sparsify-a-model/supported-integrations.mdx"
66
index: 1000
77
---
88

9-
# Sparsifying a model for SparseML Integrations
9+
# Sparsifying a Model for SparseML Integrations
1010

1111
This page walks through an example of creating a sparsification recipe to prune a dense model from scratch and applying a recipe to a supported integration.
1212

13-
SparseML has pre-made integrations with many popular model repositories, such as with HuggingFace Transformers and Ultralytics YOLOv5.
13+
SparseML has pre-made integrations with many popular model repositories, such as with Hugging Face Transformers and Ultralytics YOLOv5.
1414
For these integrations, a sparsification recipe is all you need, and you can apply state-of-the-art sparsification algorithms, including
1515
pruning, distillation, and quantization, with a single command line call.
1616

@@ -31,17 +31,17 @@ Important hyperparameters that need to be set are the following:
3131
- The layers to prune and their target sparsity levels
3232
- The number of epochs for pruning
3333
- The frequency of pruning
34-
- The length of time to fine tune after pruning
35-
- The the learning rates to (LR) for pruning and finetuning
34+
- The length of time to fine-tune after pruning
35+
- The learning rates to (LR) for pruning and fine-tuning
3636

3737
The proper hyperparameter values will differ for different model architectures, training schemes, and domains, but there is some general intuition for safe starting values.
3838
The following are reasonably default values to start with:
3939
- The final sparsity is set to 80% sparsity applied globally across all layers.
4040
- The running frequency is set to pruning once per epoch (up to a few times per epoch for shorter schedules).
4141
- The number of pruning epochs is set to 1/3 the original training epochs.
42-
- The number of finetuning epochs is set to 1/4 the original epochs.
42+
- The number of fine-tuning epochs is set to 1/4 the original epochs.
4343
- The pruning LR is set to the midrange from the model's training start and final LRs.
44-
- The finetuning LRs cycle from the pruning LR to the final LR is used for training.
44+
- The fine-tuning LRs cycle from the pruning LR to the final LR is used for training.
4545

4646
SparseML conveniently encodes these hyperparameters into a YAML-based **Recipe** file. The rest of the system parses the arguments in the YAML file to set the parameters of the algorithm.
4747

@@ -76,16 +76,16 @@ In this recipe:
7676
- `GlobalMagnitudePruningModifier` applies gradual magnitude pruning globally across all the prunable parameters/weights in a model.
7777
- `GlobalMagnitudePruningModifier` starts at 5% sparsity at epoch 0 and gradually ramps up to 80% sparsity at epoch 30, pruning at the start of each epoch.
7878
- `SetLearningRateModifier` sets the pruning LR to 0.05 (midpoint between the original 0.1 and 0.001 training LRs).
79-
- `LearningRateFunctionModifier` cycles the finetuning LR from the pruning LR to 0.001 with a cosine curve (0.001 was the final original training LR).
80-
- `EpochRangeModifier` expands the training time to continue finetuning for an additional 20 epochs after pruning has ended.
81-
- 30 pruning epochs and 20 finetuning epochs were chosen based on a 90 epoch training schedule -- be sure to adjust based on the number of epochs used for the initial training for your use case.
79+
- `LearningRateFunctionModifier` cycles the fine-tuning LR from the pruning LR to 0.001 with a cosine curve (0.001 was the final original training LR).
80+
- `EpochRangeModifier` expands the training time to continue fine-tuning for an additional 20 epochs after pruning has ended.
81+
- 30 pruning epochs and 20 fine-tuning epochs were chosen based on a 90 epoch training schedule -- be sure to adjust based on the number of epochs used for the initial training for your use case.
8282

8383
## Quantization and Quantization Recipes
8484

8585
A quantization recipe systematically reduces the precision for weights and activations within a neural network, generally from `FP32` to `INT8`. Running a quantized
8686
model increases speed and reduces memory consumption while sacrificing very little in terms of accuracy.
8787

88-
Quantization aware training (QAT) is the standard algorithm. With QAT, fake quantization operators are injected into the graph before quantizable nodes for activations, and weights are wrapped with fake quantization operators.
88+
Quantization-aware training (QAT) is the standard algorithm. With QAT, fake quantization operators are injected into the graph before quantizable nodes for activations, and weights are wrapped with fake quantization operators.
8989
The fake quantization operators interpolate the weights and activations down to INT8 on the forward pass but enable a full update of the weights at FP32 on the backward pass.
9090
The updates to the weights at FP32 throughout the training process allow the model to adapt to the loss of information from quantization on the forward pass.
9191
QAT generally guarantees better recovery for a given model compared with post-training quantization (PTQ), where training is not used.
@@ -124,7 +124,7 @@ Note the `model` is used here as a general placeholder; to determine the name of
124124
## Pruning plus Quantization Recipe
125125

126126
To create a pruning and quantization recipe, the pruning and quantization recipes are merged from the previous sections.
127-
Quantization is added after pruning and finetuning are complete such that the training cycles end with it.
127+
Quantization is added after pruning and fine-tuning are complete such that the training cycles end with it.
128128
This prevents stability issues from lacking precision when pruning and utilizing larger LRs.
129129

130130
Combining the two previous recipes creates the following new recipe.yaml file:

src/content/use-cases/natural-language-processing/question-answering.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
22
title: "Question Answering"
33
metaTitle: "NLP Question Answering"
4-
metaDescription: "Question Answering with HuggingFace Transformers and SparseML to create cheaper and more performant NLP models"
4+
metaDescription: "Question Answering with Hugging Face Transformers and SparseML to create cheaper and more performant NLP models"
55
githubURL: "https://github.com/neuralmagic/docs/blob/main/src/content/use-cases/natural-language-processing/question-answering.mdx"
66
index: 1000
77
---
88

9-
# Question Answering with HuggingFace Transformers and SparseML
9+
# Question Answering with Hugging Face Transformers and SparseML
1010

1111
This page explains how to create and deploy a sparse Transformer for Question Answering.
1212

@@ -19,7 +19,7 @@ This integration enables you to create a sparse model in two ways:
1919
- **Sparse Transfer Learning** - fine-tune a sparse model (or use one of our [sparse pre-trained models](https://sparsezoo.neuralmagic.com/?domain=nlp&sub_domain=question_answering)) on your own private dataset.
2020

2121
Each option is useful in different situations:
22-
- **Sparsification from Scratch** enables you to create a sparse version of any model (even those not in the SparseZoo), but requires hand-tuning the hyperparameters of the Sparsification algorithm.
22+
- **Sparsification from Scratch** enables you to create a sparse version of any model (even those not in the SparseZoo), but requires hand-tuning the hyperparameters of the sparsification algorithm.
2323
- **Sparse Transfer Learning** is the easiest path to creating a sparse model trained on your data. Simply pull a pre-sparsified model and transfer learning recipe from the SparseZoo and fine-tune on your data with a single command.
2424

2525
## Installation Requirements
@@ -53,15 +53,15 @@ sparseml.transformers.question_answering \
5353
--recipe zoo:nlp/question_answering/bert-base/pytorch/huggingface/squad/pruned-aggressive_98
5454
```
5555

56-
The SparseML train script is a wrapper around a [HuggingFace script](https://huggingface.co/docs/transformers/run_scripts),
57-
and usage for most arguments follows the HuggingFace. The most important arguments for SparseML are:
56+
The SparseML train script is a wrapper around a [Hugging Face script](https://huggingface.co/docs/transformers/run_scripts),
57+
and usage for most arguments follows the Hugging Face. The most important arguments for SparseML are:
5858

5959
- `--model_name_or_path` indicates which model to start the pruning process from. It can be a SparseZoo stub, HF model identifier, or a path to a local model.
6060
- `--recipe` points to recipe file containing the sparsification hyperparamters. It can be a SparseZoo stub or a local file. For more on creating a recipe see [here](/user-guide/recipes/creating).
6161
- `--dataset_name` indicates that we should fine tune on the SQuAD dataset.
6262

63-
To utilize a custom dataset, use the `--train_file` and `--validation_file` arguments. To use a dataset from the HuggingFace hub, use `--dataset_name`.
64-
See the [HF Docs](https://huggingface.co/docs/transformers/run_scripts#run-a-script) for more details.
63+
To utilize a custom dataset, use the `--train_file` and `--validation_file` arguments. To use a dataset from the Hugging Face hub, use `--dataset_name`.
64+
See the [Hugging Face Docs](https://huggingface.co/docs/transformers/run_scripts#run-a-script) for more details.
6565

6666
Run the following to see the full list of options:
6767
```bash

src/content/use-cases/natural-language-processing/text-classification.mdx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
22
title: "Text Classification"
33
metaTitle: "NLP Text Classification"
4-
metaDescription: "Text Classification with HuggingFace Transformers and SparseML to create cheaper and more performant NLP models"
4+
metaDescription: "Text Classification with Hugging Face Transformers and SparseML to create cheaper and more performant NLP models"
55
githubURL: "https://github.com/neuralmagic/docs/blob/main/src/content/use-cases/natural-language-processing/text-classification.mdx"
66
index: 2000
77
---
88

9-
# Text Classification with HuggingFace Transformers and SparseML
9+
# Text Classification with Hugging Face Transformers and SparseML
1010

1111
This page explains how to create and deploy a sparse Transformer for Text Classification.
1212

@@ -19,7 +19,7 @@ This integration enables you to create a sparse model in two ways:
1919
- **Sparse Transfer Learning** - fine-tune a sparse model (or use one of our [sparse pre-trained models](https://sparsezoo.neuralmagic.com/?domain=nlp&sub_domain=text_classification)) on your own private dataset.
2020

2121
Each option is useful in different situations:
22-
- **Sparsification from Scratch** enables you to create a sparse version of any model (even those not in the SparseZoo), but requires hand-tuning the hyperparameters of the Sparsification algorithm.
22+
- **Sparsification from Scratch** enables you to create a sparse version of any model (even those not in the SparseZoo), but requires hand-tuning the hyperparameters of the sparsification algorithm.
2323
- **Sparse Transfer Learning** is the easiest path to creating a sparse model trained on your data. Simply pull a pre-sparsified model and transfer learning recipe from the SparseZoo and fine-tune on your data with a single command.
2424

2525
## Installation Requirements
@@ -52,15 +52,15 @@ sparseml.transformers.text_classification \
5252
--recipe zoo:nlp/text_classification/bert-base/pytorch/huggingface/mnli/12layer_pruned90-none
5353
```
5454

55-
The SparseML train script is a wrapper around a [HuggingFace script](https://huggingface.co/docs/transformers/run_scripts), and
56-
usage for most arguments follows the HuggingFace. The most important arguments for SparseML are:
57-
- `model_name_or_path`: specifies starting model. It can be a SparseZoo stub, HF model identifier, or a local directory
55+
The SparseML train script is a wrapper around a [Hugging Face script](https://huggingface.co/docs/transformers/run_scripts), and
56+
usage for most arguments follows the Hugging Face. The most important arguments for SparseML are:
57+
- `model_name_or_path`: specifies starting model. It can be a SparseZoo stub, Hugging Face model identifier, or a local directory
5858
with `model.pt`, `tokenizer.json` and `config.json`
5959
- `recipe`: recipe containing the training hyperparamters (SparseZoo stub or a local file)
6060
- `task_name`: specifies the sentiment analysis task for the MNLI dataset
6161

62-
To utilize a custom dataset, use the `--train_file` and `--validation_file` arguments. To use a dataset from the HuggingFace hub, use `--dataset_name`.
63-
See the [HF Docs](https://huggingface.co/docs/transformers/run_scripts#run-a-script) for more details.
62+
To utilize a custom dataset, use the `--train_file` and `--validation_file` arguments. To use a dataset from the Hugging Face hub, use `--dataset_name`.
63+
See the [Hugging Face Docs](https://huggingface.co/docs/transformers/run_scripts#run-a-script) for more details.
6464

6565
Run the following to see the full list of options:
6666
```bash

src/content/use-cases/natural-language-processing/token-classification.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
22
title: "Token Classification"
33
metaTitle: "NLP Token Classification"
4-
metaDescription: "Token Classification with HuggingFace Transformers and SparseML to create cheaper and more performant NLP models"
4+
metaDescription: "Token Classification with Hugging Face Transformers and SparseML to create cheaper and more performant NLP models"
55
githubURL: "https://github.com/neuralmagic/docs/blob/main/src/content/use-cases/natural-language-processing/text-classification.mdx"
66
index: 3000
77
---
88

9-
# Token Classification with HuggingFace Transformers and SparseML
9+
# Token Classification with Hugging Face Transformers and SparseML
1010

1111
This page explains how to create and deploy a sparse Transformer for Token Classification.
1212

@@ -52,15 +52,15 @@ sparseml.transformers.token_classification \
5252
--recipe zoo:nlp/token_classification/bert-base/pytorch/huggingface/conll2003/12layer_pruned80_quant-none-vnni
5353
```
5454

55-
The SparseML train script is a wrapper around a [HuggingFace script](https://huggingface.co/docs/transformers/run_scripts),
56-
and usage for most arguments follows the HuggingFace. The most important arguments for SparseML are:
55+
The SparseML train script is a wrapper around a [Hugging Face script](https://huggingface.co/docs/transformers/run_scripts),
56+
and usage for most arguments follows the Hugging Face. The most important arguments for SparseML are:
5757

58-
- `--model_name_or_path` indicates which model to start the pruning process from. It can be a SparseZoo stub, HF model identifier, or a path to a local model.
58+
- `--model_name_or_path` indicates which model to start the pruning process from. It can be a SparseZoo stub, Hugging Face model identifier, or a path to a local model.
5959
- `--recipe` points to recipe file containing the sparsification hyperparamters. It can be a SparseZoo stub or a local file. For more on creating a recipe see [here](/user-guide/recipes/creating).
6060
- `--dataset_name` indicates that we should fine tune on the CoNLL-2003 dataset.
6161

62-
To utilize a custom dataset, use the `--train_file` and `--validation_file` arguments. To use a dataset from the HuggingFace hub, use `--dataset_name`.
63-
See the [HF Docs](https://huggingface.co/docs/transformers/run_scripts#run-a-script) for more details.
62+
To utilize a custom dataset, use the `--train_file` and `--validation_file` arguments. To use a dataset from the Hugging Face hub, use `--dataset_name`.
63+
See the [Hugging Face Docs](https://huggingface.co/docs/transformers/run_scripts#run-a-script) for more details.
6464

6565
Run the following to see the full list of options:
6666
```bash

0 commit comments

Comments
 (0)