generated from aicoe-aiops/project-template
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Francesco Murdaca <[email protected]>
- Loading branch information
Francesco Murdaca
committed
Mar 16, 2022
1 parent
ef29347
commit 079d001
Showing
3 changed files
with
1,635 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Fine Tune Model" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Neural Magic hosts many models, including BERT models sparsified on an English text corpus with a masked language modeling training scheme. These sparse models can then finetune to your dataset like you normally would with a dense model using SparseML and recipes." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# This import will install a sparsification compatible version of transformers for SparseML.\n", | ||
"from sparseml.transformers import question_answering" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Load Dataset" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"#TODO: Load dataset." | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Fine Tune Model" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"question_answering(\n", | ||
" output_dir=\"sparse_quantized_bert-question_answering_squad\",\n", | ||
" model_name_or_path=\"zoo:nlp/masked_language_modeling/bert-base/pytorch/huggingface/wikipedia_bookcorpus/12layer_pruned80_quant-none-vnni\",\n", | ||
" recipe=\"zoo:nlp/masked_language_modeling/bert-base/pytorch/huggingface/wikipedia_bookcorpus/12layer_pruned80_quant-none-vnni?recipe_type=transfer-question_answering\",\n", | ||
" distill_teacher=\"path/to/dense-teacher-trained\",\n", | ||
" dataset_name=\"custom-dataset\",\n", | ||
" do_train=True,\n", | ||
" do_eval=True,\n", | ||
" evaluation_strategy=\"epoch\",\n", | ||
" fp16=True,\n", | ||
" seed=21636,\n", | ||
" per_device_train_batch_size=16,\n", | ||
" per_device_eval_batch_size=24,\n", | ||
" preprocessing_num_workers=6,\n", | ||
" save_strategy=\"epoch\",\n", | ||
" save_total_limit=1\n", | ||
")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Store model in ONNX format for deepsparse engine" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"language_info": { | ||
"name": "python" | ||
}, | ||
"orig_nbformat": 4 | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[[source]] | ||
url = "https://pypi.org/simple" | ||
verify_ssl = true | ||
name = "pypi" | ||
|
||
[packages] | ||
sparsezoo = "*" | ||
sparseml = "*" | ||
torch = "<1.9" | ||
boto3 = "*" | ||
|
||
[dev-packages] | ||
|
||
[requires] | ||
python_version = "3.8" |
Oops, something went wrong.