From 776eb4657709f599e6ba3684acbb33805d5765d2 Mon Sep 17 00:00:00 2001 From: Yong Yue Date: Thu, 9 Jul 2026 22:32:37 +0800 Subject: [PATCH] recipe(cross-encoder/ms-marco-MiniLM-L4-v2): add text-classification fp16 and w8a16 recipes Add recipe configurations for cross-encoder/ms-marco-MiniLM-L4-v2 (BertForSequenceClassification, 19.2M params, 4 layers) for text-classification task with fp16 (baseline) and w8a16 (quantized) variants. - fp16: opset 17, seq_len 512, vocab 30522, eval on GLUE MRPC - w8a16: QDQ uint8/uint16, minmax calibration, 59% size reduction (73.2MB -> 29.9MB) - Both recipes include GLUE MRPC eval configuration --- examples/recipes/README.md | 1 + .../text-classification_fp16_config.json | 66 +++++++++++++++ .../text-classification_w8a16_config.json | 83 +++++++++++++++++++ 3 files changed, 150 insertions(+) create mode 100644 examples/recipes/cross-encoder_ms-marco-MiniLM-L4-v2/text-classification_fp16_config.json create mode 100644 examples/recipes/cross-encoder_ms-marco-MiniLM-L4-v2/text-classification_w8a16_config.json diff --git a/examples/recipes/README.md b/examples/recipes/README.md index 1077e4f74..cf8415ae0 100644 --- a/examples/recipes/README.md +++ b/examples/recipes/README.md @@ -38,6 +38,7 @@ Total: **75** (model, task) tuples that pass fp16 eval on all 10 (EP, device) bu | ahotrod/electra_large_discriminator_squad2_512 | question-answering | | apple/mobilevit-small | image-classification | | cardiffnlp/twitter-roberta-base-sentiment-latest | text-classification | +| cross-encoder/ms-marco-MiniLM-L4-v2 | text-classification | | dbmdz/bert-large-cased-finetuned-conll03-english | token-classification | | deepset/bert-large-uncased-whole-word-masking-squad2 | question-answering | | deepset/roberta-base-squad2 | question-answering | diff --git a/examples/recipes/cross-encoder_ms-marco-MiniLM-L4-v2/text-classification_fp16_config.json b/examples/recipes/cross-encoder_ms-marco-MiniLM-L4-v2/text-classification_fp16_config.json new file mode 100644 index 000000000..b8612e5ac --- /dev/null +++ b/examples/recipes/cross-encoder_ms-marco-MiniLM-L4-v2/text-classification_fp16_config.json @@ -0,0 +1,66 @@ +{ + "export": { + "opset_version": 17, + "batch_size": 1, + "export_params": true, + "do_constant_folding": true, + "verbose": false, + "dynamo": false, + "enable_hierarchy_tags": true, + "clean_onnx": false, + "hierarchy_tag_format": "full", + "input_tensors": [ + { + "name": "input_ids", + "dtype": "int32", + "shape": [ + 1, + 512 + ], + "value_range": [ + 0, + 30522 + ] + }, + { + "name": "attention_mask", + "dtype": "int32", + "shape": [ + 1, + 512 + ], + "value_range": [ + 0, + 2 + ] + }, + { + "name": "token_type_ids", + "dtype": "int32", + "shape": [ + 1, + 512 + ], + "value_range": [ + 0, + 2 + ] + } + ], + "output_tensors": [ + { + "name": "logits" + } + ] + }, + "optim": { + "clamp_constant_values": true + }, + "quant": null, + "compile": null, + "loader": { + "task": "text-classification", + "model_class": "AutoModelForSequenceClassification", + "model_type": "bert" + } +} diff --git a/examples/recipes/cross-encoder_ms-marco-MiniLM-L4-v2/text-classification_w8a16_config.json b/examples/recipes/cross-encoder_ms-marco-MiniLM-L4-v2/text-classification_w8a16_config.json new file mode 100644 index 000000000..96a605be5 --- /dev/null +++ b/examples/recipes/cross-encoder_ms-marco-MiniLM-L4-v2/text-classification_w8a16_config.json @@ -0,0 +1,83 @@ +{ + "export": { + "opset_version": 17, + "batch_size": 1, + "export_params": true, + "do_constant_folding": true, + "verbose": false, + "dynamo": false, + "enable_hierarchy_tags": true, + "clean_onnx": false, + "hierarchy_tag_format": "full", + "input_tensors": [ + { + "name": "input_ids", + "dtype": "int32", + "shape": [ + 1, + 512 + ], + "value_range": [ + 0, + 30522 + ] + }, + { + "name": "attention_mask", + "dtype": "int32", + "shape": [ + 1, + 512 + ], + "value_range": [ + 0, + 2 + ] + }, + { + "name": "token_type_ids", + "dtype": "int32", + "shape": [ + 1, + 512 + ], + "value_range": [ + 0, + 2 + ] + } + ], + "output_tensors": [ + { + "name": "logits" + } + ] + }, + "optim": { + "clamp_constant_values": true + }, + "quant": { + "mode": "qdq", + "samples": 10, + "calibration_method": "minmax", + "weight_type": "uint8", + "activation_type": "uint16", + "per_channel": false, + "symmetric": false, + "save_calibration": false, + "distribution": "uniform", + "seed": null, + "calibration_load_path": null, + "calibration_save_path": null, + "op_types_to_quantize": null, + "nodes_to_exclude": null, + "task": "text-classification", + "model_id": "cross-encoder/ms-marco-MiniLM-L4-v2" + }, + "compile": null, + "loader": { + "task": "text-classification", + "model_class": "AutoModelForSequenceClassification", + "model_type": "bert" + } +}