ray-embedding 0.10.5__py3-none-any.whl → 0.10.11__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ray-embedding might be problematic. Click here for more details.
- ray_embedding/deploy.py +2 -2
- ray_embedding/embedding_model.py +7 -6
- {ray_embedding-0.10.5.dist-info → ray_embedding-0.10.11.dist-info}/METADATA +1 -1
- ray_embedding-0.10.11.dist-info/RECORD +8 -0
- ray_embedding-0.10.5.dist-info/RECORD +0 -8
- {ray_embedding-0.10.5.dist-info → ray_embedding-0.10.11.dist-info}/WHEEL +0 -0
- {ray_embedding-0.10.5.dist-info → ray_embedding-0.10.11.dist-info}/top_level.txt +0 -0
ray_embedding/deploy.py
CHANGED
|
@@ -16,10 +16,10 @@ def deploy_model(args: Dict[str, Any]) -> Application:
|
|
|
16
16
|
model: str = args.pop("model", "")
|
|
17
17
|
assert model
|
|
18
18
|
|
|
19
|
+
device: Optional[str] = args.pop("device", None)
|
|
19
20
|
backend: Optional[str] = args.pop("backend", "torch")
|
|
20
21
|
matryoshka_dim: Optional[int] = args.pop("matryoshka_dim", None)
|
|
21
22
|
trust_remote_code: Optional[bool] = args.pop("trust_remote_code", False)
|
|
22
|
-
device: Optional[str] = args.pop("device", None)
|
|
23
23
|
model_kwargs: Dict[str, Any] = args.pop("model_kwargs", {})
|
|
24
24
|
if "torch_dtype" in model_kwargs:
|
|
25
25
|
torch_dtype = model_kwargs["torch_dtype"].strip()
|
|
@@ -33,8 +33,8 @@ def deploy_model(args: Dict[str, Any]) -> Application:
|
|
|
33
33
|
raise ValueError(f"Invalid torch_dtype: '{torch_dtype}'")
|
|
34
34
|
|
|
35
35
|
deployment = EmbeddingModel.options(name=deployment_name).bind(model=model,
|
|
36
|
-
backend=backend,
|
|
37
36
|
device=device,
|
|
37
|
+
backend=backend,
|
|
38
38
|
matryoshka_dim=matryoshka_dim,
|
|
39
39
|
trust_remote_code=trust_remote_code,
|
|
40
40
|
model_kwargs=model_kwargs
|
ray_embedding/embedding_model.py
CHANGED
|
@@ -28,23 +28,24 @@ web_api = FastAPI(title=f"Ray Embeddings - OpenAI-compatible API")
|
|
|
28
28
|
)
|
|
29
29
|
@serve.ingress(web_api)
|
|
30
30
|
class EmbeddingModel:
|
|
31
|
-
def __init__(self, model: str,
|
|
31
|
+
def __init__(self, model: str, device: Optional[str] = None, backend: Optional[str] = "torch",
|
|
32
32
|
matryoshka_dim: Optional[int] = None, trust_remote_code: Optional[bool] = False,
|
|
33
33
|
model_kwargs: Dict[str, Any] = None):
|
|
34
34
|
logging.basicConfig(level=logging.INFO)
|
|
35
35
|
self.logger = logging.getLogger(__name__)
|
|
36
36
|
self.model = model
|
|
37
37
|
self.init_device = device
|
|
38
|
+
if self.init_device is None or self.init_device == "auto":
|
|
39
|
+
self.init_device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
40
|
+
self.check_health()
|
|
41
|
+
self.torch_device = torch.device(self.init_device)
|
|
38
42
|
self.backend = backend or "torch"
|
|
39
43
|
self.matryoshka_dim = matryoshka_dim
|
|
40
44
|
self.trust_remote_code = trust_remote_code or False
|
|
41
45
|
self.model_kwargs = model_kwargs or {}
|
|
42
|
-
if self.init_device is None:
|
|
43
|
-
self.torch_device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
|
44
|
-
else:
|
|
45
|
-
self.torch_device = torch.device(self.init_device)
|
|
46
46
|
self.logger.info(f"Initializing embedding model: {self.model}")
|
|
47
|
-
self.embedding_model = SentenceTransformer(self.model,
|
|
47
|
+
self.embedding_model = SentenceTransformer(self.model, device=self.init_device, backend=self.backend,
|
|
48
|
+
trust_remote_code=self.trust_remote_code,
|
|
48
49
|
model_kwargs=self.model_kwargs)
|
|
49
50
|
|
|
50
51
|
self.served_model_name = os.path.basename(self.model)
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
ray_embedding/__init__.py,sha256=OYJT0rVaaGzY613JqgfktsCgroDnBkGOHxR2FE9UtRU,49
|
|
2
|
+
ray_embedding/deploy.py,sha256=ZGxcG4589WcRtaM6H84YJarw0m1XqHNgfOf3PLAhM5M,1995
|
|
3
|
+
ray_embedding/dto.py,sha256=e91ejZbM_NB9WTjF1YnfuV71cajYIh0vOX8oV_g2OwM,595
|
|
4
|
+
ray_embedding/embedding_model.py,sha256=SXRc3PtfJkEIHdLvHFCTSTXo8c_NYaL3-5xkxHr3VD4,4603
|
|
5
|
+
ray_embedding-0.10.11.dist-info/METADATA,sha256=413SNOlhdIf-k8kOpzWoQZ5Z_gCFAbova7NTvulnYb8,1095
|
|
6
|
+
ray_embedding-0.10.11.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
|
|
7
|
+
ray_embedding-0.10.11.dist-info/top_level.txt,sha256=ziCblpJq1YsrryshFqxTRuRMgNuO1_tgvAAkGShATNA,14
|
|
8
|
+
ray_embedding-0.10.11.dist-info/RECORD,,
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
ray_embedding/__init__.py,sha256=OYJT0rVaaGzY613JqgfktsCgroDnBkGOHxR2FE9UtRU,49
|
|
2
|
-
ray_embedding/deploy.py,sha256=GEKJAaV25DOlXd7Pqj7bqASM-FcP0FtFsJlI7u_U6Iw,1995
|
|
3
|
-
ray_embedding/dto.py,sha256=e91ejZbM_NB9WTjF1YnfuV71cajYIh0vOX8oV_g2OwM,595
|
|
4
|
-
ray_embedding/embedding_model.py,sha256=i0sno946g2nbnhhhcD-bZ3WoWJi5qScbm716-i6tI1I,4501
|
|
5
|
-
ray_embedding-0.10.5.dist-info/METADATA,sha256=L77LrGKHM2GYVgpXGVqkRYf5LoSCkbHpar6vkwlxIp4,1094
|
|
6
|
-
ray_embedding-0.10.5.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
|
|
7
|
-
ray_embedding-0.10.5.dist-info/top_level.txt,sha256=ziCblpJq1YsrryshFqxTRuRMgNuO1_tgvAAkGShATNA,14
|
|
8
|
-
ray_embedding-0.10.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|