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

Commit 2f1c91c

Browse files
committed
fix nlp sparse transfer ONNX export commands
1 parent d756278 commit 2f1c91c

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/content/get-started/transfer-a-sparsified-model/nlp-text-classification.mdx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ index: 1000
88

99
# Transfer a Sparsified Model for Text Classification
1010

11-
This page walks through an example of fine-tuning a pre-sparsified model onto a new dataset for sentiment analysis.
11+
This page walks through an example of fine-tuning a pre-sparsified model onto a new dataset for sentiment analysis.
1212

13-
For NLP tasks, model distillation from a dense teacher to a sparse student model is helpful to achieve higher sparsity and accuracy.
13+
For NLP tasks, model distillation from a dense teacher to a sparse student model is helpful to achieve higher sparsity and accuracy.
1414
We will follow two steps using SparseML:
1515
1. Fine-tune a dense teacher model (BERT) onto a new dataset (SST2)
1616
2. Transfer learn a pre-sparsified model (DistilBERT) from the SparseZoo onto SST2, distilling from the dense teacher model trained in step 1
@@ -47,14 +47,14 @@ $ sparseml.transformers.text_classification \
4747
--save_strategy epoch --save_total_limit 1
4848
```
4949

50-
The SparseML train script is a wrapper around a [HuggingFace script](https://huggingface.co/docs/transformers/run_scripts), and
50+
The SparseML train script is a wrapper around a [HuggingFace script](https://huggingface.co/docs/transformers/run_scripts), and
5151
usage for most arguments follows the HuggingFace. The most important arguments for SparseML are:
52-
- `model_name_or_path`: specifies starting model. It can be a SparseZoo stub, HF model identifier, or a local directory
52+
- `model_name_or_path`: specifies starting model. It can be a SparseZoo stub, HF model identifier, or a local directory
5353
with `model.pt`, `tokenizer.json` and `config.json`
5454
- `recipe`: recipe containing the training hyperparamters (SparseZoo stub or a local file)
5555
- `task_name`: specifies the sentiment analysis task. If not provided, also specifies the dataset, pipelines, and eval metrics.
5656

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

6060
Run the following to see the full list of options:
@@ -87,7 +87,7 @@ $ sparseml.transformers.text_classification \
8787
--save_strategy epoch --save_total_limit 1
8888
```
8989

90-
Usage is the same as above. The `--distill_teacher` argument instructs SparseML to perform model distillation from the
90+
Usage is the same as above. The `--distill_teacher` argument instructs SparseML to perform model distillation from the
9191
teacher saved at `models/teacher`.
9292

9393
There are many additional command line arguments that can be passed to tweak your fine-tuning process. Run the following to see the full list of options:
@@ -99,12 +99,12 @@ $ sparseml.transformers.text_classification -h
9999

100100
With the sparsified model successfully trained, it is time to export it for inference.
101101
The `sparseml.transformers.export_onnx` command is used to export the training graph to a performant inference one.
102-
After the command completes, a `model.onnx` file is created in `models/sparsified` folder.
102+
After the command completes, a `model.onnx` file is created in `models/deployment` folder.
103103
It is now ready for deployment with the DeepSparse Engine.
104104

105105
```bash
106106
$ sparseml.transformers.export_onnx \
107-
--model_path models/sparse_quantized \
107+
--model_path models/sparsified \
108108
--task 'text-classification' --finetuning_task sst2 \
109109
--sequence_length 128
110110
```

0 commit comments

Comments
 (0)