Repository: xorbitsai/inference

Issue:
BUG: Unable to list or load embedding models
### Describe the bug
When attempting to list models as like in https://inference.readthedocs.io/en/latest/models/builtin/index.html#embedding-models
using: 
`xinference registrations`
No embedding models are listed, just models of type "LLM" 

The embedding models are also not listed in the GUI.

When trying to launch an embedding model using:
`xinference launch --model-name bge-base-en --model-type embedding`

The following error occurs:
```
$ xinference launch --model-name bge-base-en   --model-type embedding
Traceback (most recent call last):
  File "/home/v2/miniconda3/envs/inference/bin/xinference", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/home/v2/miniconda3/envs/inference/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/v2/miniconda3/envs/inference/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/home/v2/miniconda3/envs/inference/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/v2/miniconda3/envs/inference/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/v2/miniconda3/envs/inference/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/v2/miniconda3/envs/inference/lib/python3.11/site-packages/xinference/deploy/cmdline.py", line 413, in model_launch
    model_uid = client.launch_model(
                ^^^^^^^^^^^^^^^^^^^^
  File "/home/v2/miniconda3/envs/inference/lib/python3.11/site-packages/xinference/client.py", line 816, in launch_model
    raise RuntimeError(
RuntimeError: Failed to launch model, detail: EmbeddingModel.__init__() got an unexpected keyword argument 'trust_remote_code'
```

 
### To Reproduce
To help us to reproduce this bug, please provide information below:

```
conda create -n inference python=3.11.4
conda activate inference
pip install "xinference[all]"
xinference -H 0.0.0.0
xinference launch --model-name bge-base-en --model-type embedding
```

### Expected behavior

1 - Models of type "EMBEDDING" be listed when running: xinference registrations and also via GUI
2 - The embedding models listed in the webpage start properly without the error.

### Additional context
Add any other context about the problem here.



Discussion:
I've reproduced this issue and will fix it soon.

Resolving patch:
diff --git a/xinference/core/supervisor.py b/xinference/core/supervisor.py
--- a/xinference/core/supervisor.py
+++ b/xinference/core/supervisor.py
@@ -101,6 +101,10 @@ async def _choose_worker(self) -> xo.ActorRefType["WorkerActor"]:
 
     @log_sync(logger=logger)
     def list_model_registrations(self, model_type: str) -> List[Dict[str, Any]]:
+        def sort_helper(item):
+            assert isinstance(item["model_name"], str)
+            return item.get("model_name").lower()
+
         if model_type == "LLM":
             from ..model.llm import BUILTIN_LLM_FAMILIES, get_user_defined_llm_families
 
@@ -116,12 +120,17 @@ def list_model_registrations(self, model_type: str) -> List[Dict[str, Any]]:
                 ]
             )
 
-            def sort_helper(item):
-                assert isinstance(item["model_name"], str)
-                return item.get("model_name").lower()
-
             ret.sort(key=sort_helper)
 
+            return ret
+        elif model_type == "embedding":
+            from ..model.embedding import BUILTIN_EMBEDDING_MODELS
+
+            ret = [
+                {"model_name": model_name, "is_builtin": True}
+                for model_name in BUILTIN_EMBEDDING_MODELS
+            ]
+            ret.sort(key=sort_helper)
             return ret
         else:
             raise ValueError(f"Unsupported model type: {model_type}")
@@ -138,6 +147,13 @@ def get_model_registration(
                     return f
 
             raise ValueError(f"Model {model_name} not found")
+        if model_type == "embedding":
+            from ..model.embedding import BUILTIN_EMBEDDING_MODELS
+
+            for f in BUILTIN_EMBEDDING_MODELS.values():
+                if f.model_name == model_name:
+                    return f
+            raise ValueError(f"Model {model_name} not found")
         else:
             raise ValueError(f"Unsupported model type: {model_type}")
 
diff --git a/xinference/deploy/cmdline.py b/xinference/deploy/cmdline.py
--- a/xinference/deploy/cmdline.py
+++ b/xinference/deploy/cmdline.py
@@ -307,22 +307,44 @@ def list_model_registrations(
     registrations = client.list_model_registrations(model_type=model_type)
 
     table = []
-    for registration in registrations:
-        model_name = registration["model_name"]
-        model_family = client.get_model_registration(model_type, model_name)
-        table.append(
-            [
-                model_type,
-                model_family["model_name"],
-                model_family["model_lang"],
-                model_family["model_ability"],
-                registration["is_builtin"],
-            ]
+    if model_type == "LLM":
+        for registration in registrations:
+            model_name = registration["model_name"]
+            model_family = client.get_model_registration(model_type, model_name)
+            table.append(
+                [
+                    model_type,
+                    model_family["model_name"],
+                    model_family["model_lang"],
+                    model_family["model_ability"],
+                    registration["is_builtin"],
+                ]
+            )
+        print(
+            tabulate(
+                table, headers=["Type", "Name", "Language", "Ability", "Is-built-in"]
+            ),
+            file=sys.stderr,
+        )
+    elif model_type == "embedding":
+        for registration in registrations:
+            model_name = registration["model_name"]
+            model_family = client.get_model_registration(model_type, model_name)
+            table.append(
+                [
+                    model_type,
+                    model_family["model_name"],
+                    model_family["language"],
+                    model_family["dimensions"],
+                    registration["is_builtin"],
+                ]
+            )
+        print(
+            tabulate(
+                table, headers=["Type", "Name", "Language", "Dimensions", "Is-built-in"]
+            ),
+            file=sys.stderr,
         )
-    print(
-        tabulate(table, headers=["Type", "Name", "Language", "Ability", "Is-built-in"]),
-        file=sys.stderr,
-    )
 
 
 @cli.command(
diff --git a/xinference/model/core.py b/xinference/model/core.py
--- a/xinference/model/core.py
+++ b/xinference/model/core.py
@@ -48,6 +48,8 @@ def create_model_instance(
             **kwargs,
         )
     elif model_type == "embedding":
+        # embedding model doesn't accept trust_remote_code
+        kwargs.pop("trust_remote_code", None)
         return create_embedding_model_instance(model_uid, model_name, **kwargs)
     else:
         raise ValueError(f"Unsupported model type: {model_type}.")


Test patch: