Repository: huggingface/optimum

Issue:
`KeyError: 'sentence-transformers'` Unable to export sentence-transformers models
### System Info

```shell
- `optimum` version: 1.12.1.dev0
- `transformers` version: 4.34.0.dev0
- Platform: Linux-5.15.109+-x86_64-with-glibc2.35
- Python version: 3.10.12
- Huggingface_hub version: 0.16.4
- PyTorch version (GPU?): 2.0.1+cu118 (cuda availabe: False)
- Tensorflow version (GPU?): not installed (cuda availabe: NA)
```


### Who can help?

@mht-sharma @fxmarty 

### Information

- [ ] The official example scripts
- [ ] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction (minimal, reproducible, runnable)

Running
```sh
optimum-cli export onnx -m hkunlp/instructor-large test
```

Produces
```
Framework not specified. Using pt to export to ONNX.
Traceback (most recent call last):
  File "/usr/local/bin/optimum-cli", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.10/dist-packages/optimum/commands/optimum_cli.py", line 163, in main
    service.run()
  File "/usr/local/lib/python3.10/dist-packages/optimum/commands/export/onnx.py", line 232, in run
    main_export(
  File "/usr/local/lib/python3.10/dist-packages/optimum/exporters/onnx/__main__.py", line 322, in main_export
    model = TasksManager.get_model_from_task(
  File "/usr/local/lib/python3.10/dist-packages/optimum/exporters/tasks.py", line 1680, in get_model_from_task
    model_class = TasksManager.get_model_class_for_task(
  File "/usr/local/lib/python3.10/dist-packages/optimum/exporters/tasks.py", line 1148, in get_model_class_for_task
    tasks_to_model_loader = TasksManager._LIBRARY_TO_TASKS_TO_MODEL_LOADER_MAP[library]
KeyError: 'sentence-transformers'
```

This was introduced in this [commit](https://github.com/huggingface/optimum/commit/d1e05f3f7a6f3da863b0e8d9275c1c63f78d8c0a).

### Expected behavior

The model should export normally. Reverting to commit 59b7e478031a86809ed5a24e00e5144d35b5f693 does not have this error.


Discussion:

Resolving patch:
diff --git a/optimum/exporters/tasks.py b/optimum/exporters/tasks.py
--- a/optimum/exporters/tasks.py
+++ b/optimum/exporters/tasks.py
@@ -1525,6 +1525,9 @@ def infer_library_from_model(
                 "The library_name could not be automatically inferred. If using the command-line, please provide the argument --library (transformers,diffusers,timm)!"
             )
 
+        if library_name == "sentence-transformers":
+            return "transformers"
+
         return library_name
 
     @classmethod


Test patch:
diff --git a/tests/exporters/exporters_utils.py b/tests/exporters/exporters_utils.py
--- a/tests/exporters/exporters_utils.py
+++ b/tests/exporters/exporters_utils.py
@@ -32,7 +32,17 @@
 PYTORCH_EXPORT_MODELS_TINY = {
     "albert": "hf-internal-testing/tiny-random-AlbertModel",
     "beit": "hf-internal-testing/tiny-random-BeitForImageClassification",
-    "bert": "hf-internal-testing/tiny-random-BertModel",
+    "bert": {
+        "hf-internal-testing/tiny-random-BertModel": [
+            "feature-extraction",
+            "fill-mask",
+            "text-classification",
+            "multiple-choice",
+            "token-classification",
+            "question-answering",
+        ],
+        "nreimers/BERT-Tiny_L-2_H-128_A-2": ["feature-extraction"],
+    },
     "bart": "hf-internal-testing/tiny-random-bart",
     # "big-bird": "hf-internal-testing/tiny-random-BigBirdModel",
     # "bigbird-pegasus": "hf-internal-testing/tiny-random-bigbird_pegasus",