From 59530534c0aef5d65d2bb197301cefebce1daf39 Mon Sep 17 00:00:00 2001 From: Qiong Wu Date: Thu, 23 Jul 2026 19:46:13 +0800 Subject: [PATCH] recipe(multilingual-e5-small): add CPU fp32/fp16 feature-extraction and sentence-similarity recipes intfloat/multilingual-e5-small is a BertModel sentence embedder. The default build fails at quantize (calibration reader omits token_type_ids); these quant:null float recipes skip that step and build a working float model. L2 PyTorch-vs-ONNX embedding cosine 1.000000, retrieval ranking preserved. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .../cpu/feature-extraction_fp16_config.json | 66 +++++++++++++++++++ .../cpu/feature-extraction_fp32_config.json | 66 +++++++++++++++++++ .../cpu/sentence-similarity_fp16_config.json | 66 +++++++++++++++++++ .../cpu/sentence-similarity_fp32_config.json | 66 +++++++++++++++++++ 4 files changed, 264 insertions(+) create mode 100644 examples/recipes/intfloat_multilingual-e5-small/cpu/cpu/feature-extraction_fp16_config.json create mode 100644 examples/recipes/intfloat_multilingual-e5-small/cpu/cpu/feature-extraction_fp32_config.json create mode 100644 examples/recipes/intfloat_multilingual-e5-small/cpu/cpu/sentence-similarity_fp16_config.json create mode 100644 examples/recipes/intfloat_multilingual-e5-small/cpu/cpu/sentence-similarity_fp32_config.json diff --git a/examples/recipes/intfloat_multilingual-e5-small/cpu/cpu/feature-extraction_fp16_config.json b/examples/recipes/intfloat_multilingual-e5-small/cpu/cpu/feature-extraction_fp16_config.json new file mode 100644 index 000000000..49f99b779 --- /dev/null +++ b/examples/recipes/intfloat_multilingual-e5-small/cpu/cpu/feature-extraction_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, + 250037 + ] + }, + { + "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": "last_hidden_state" + } + ] + }, + "optim": { + "clamp_constant_values": true + }, + "quant": null, + "compile": null, + "loader": { + "task": "feature-extraction", + "model_class": "AutoModel", + "model_type": "bert" + } +} diff --git a/examples/recipes/intfloat_multilingual-e5-small/cpu/cpu/feature-extraction_fp32_config.json b/examples/recipes/intfloat_multilingual-e5-small/cpu/cpu/feature-extraction_fp32_config.json new file mode 100644 index 000000000..49f99b779 --- /dev/null +++ b/examples/recipes/intfloat_multilingual-e5-small/cpu/cpu/feature-extraction_fp32_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, + 250037 + ] + }, + { + "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": "last_hidden_state" + } + ] + }, + "optim": { + "clamp_constant_values": true + }, + "quant": null, + "compile": null, + "loader": { + "task": "feature-extraction", + "model_class": "AutoModel", + "model_type": "bert" + } +} diff --git a/examples/recipes/intfloat_multilingual-e5-small/cpu/cpu/sentence-similarity_fp16_config.json b/examples/recipes/intfloat_multilingual-e5-small/cpu/cpu/sentence-similarity_fp16_config.json new file mode 100644 index 000000000..cda4592eb --- /dev/null +++ b/examples/recipes/intfloat_multilingual-e5-small/cpu/cpu/sentence-similarity_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, + 250037 + ] + }, + { + "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": "last_hidden_state" + } + ] + }, + "optim": { + "clamp_constant_values": true + }, + "quant": null, + "compile": null, + "loader": { + "task": "sentence-similarity", + "model_class": "AutoModel", + "model_type": "bert" + } +} diff --git a/examples/recipes/intfloat_multilingual-e5-small/cpu/cpu/sentence-similarity_fp32_config.json b/examples/recipes/intfloat_multilingual-e5-small/cpu/cpu/sentence-similarity_fp32_config.json new file mode 100644 index 000000000..cda4592eb --- /dev/null +++ b/examples/recipes/intfloat_multilingual-e5-small/cpu/cpu/sentence-similarity_fp32_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, + 250037 + ] + }, + { + "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": "last_hidden_state" + } + ] + }, + "optim": { + "clamp_constant_values": true + }, + "quant": null, + "compile": null, + "loader": { + "task": "sentence-similarity", + "model_class": "AutoModel", + "model_type": "bert" + } +}