Skip to content

Commit

Permalink
Add ONNX export support for modernbert
Browse files Browse the repository at this point in the history
  • Loading branch information
xenova committed Dec 19, 2024
1 parent d33710d commit 282177a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions optimum/exporters/onnx/model_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ def inputs(self) -> Dict[str, Dict[int, str]]:
return {"input_ids": dynamic_axis, "attention_mask": dynamic_axis}


class ModernBertOnnxConfig(DistilBertOnnxConfig):
pass


class MPNetOnnxConfig(DistilBertOnnxConfig):
DEFAULT_ONNX_OPSET = 12 # For lower opsets, results in: Type 'tensor(int64)' of input parameter (/0/auto_model/encoder/Add_1_output_0) of operator (Min) in node (/0/auto_model/encoder/Min) is invalid.

Expand Down
9 changes: 9 additions & 0 deletions optimum/exporters/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,15 @@ class TasksManager:
"image-classification",
onnx="MobileNetV2OnnxConfig",
),
"modernbert": supported_tasks_mapping(
"feature-extraction",
"fill-mask",
"text-classification",
"multiple-choice",
"token-classification",
"question-answering",
onnx="ModernBertOnnxConfig",
),
"mpnet": supported_tasks_mapping(
"feature-extraction",
"fill-mask",
Expand Down

0 comments on commit 282177a

Please sign in to comment.