ray-embedding 0.9.10__py3-none-any.whl → 0.10.0__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.

@@ -69,7 +69,32 @@ class EmbeddingModel:
69
69
  assert request.model == self.served_model_name, (
70
70
  f"Model '{request.model}' is not supported. Use '{self.served_model_name}' instead."
71
71
  )
72
- return await self.__create_embeddings_batch(request)
72
+
73
+ if isinstance(request.input, str):
74
+ request.input = [request.input]
75
+
76
+ truncate_dim = request.dimensions or self.matryoshka_dim
77
+
78
+ # Compute embeddings and convert to a PyTorch tensor on the GPU
79
+ embeddings = self.embedding_model.encode(
80
+ request.input, convert_to_tensor=True, normalize_embeddings=True
81
+ ).to(self.torch_device)
82
+
83
+ if truncate_dim is not None:
84
+ # Truncate and re-normalize the embeddings
85
+ embeddings = embeddings[:, :truncate_dim]
86
+ embeddings = embeddings / torch.norm(embeddings, dim=1, keepdim=True)
87
+
88
+ # Move all embeddings to CPU at once before conversion
89
+ embeddings = embeddings.cpu().tolist()
90
+
91
+ # Convert embeddings to list format for response
92
+ response_data = [
93
+ {"index": idx, "embedding": emb}
94
+ for idx, emb in enumerate(embeddings)
95
+ ]
96
+ return EmbeddingResponse(object="list", data=response_data, model=request.model)
97
+
73
98
  except Exception as e:
74
99
  self.logger.error(e)
75
100
  raise HTTPException(status_code=500, detail=str(e))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ray-embedding
3
- Version: 0.9.10
3
+ Version: 0.10.0
4
4
  Summary: Deploy SentenceTransformers embedding models to a ray cluster
5
5
  Author: Crispin Almodovar
6
6
  Author-email:
@@ -0,0 +1,8 @@
1
+ ray_embedding/__init__.py,sha256=OYJT0rVaaGzY613JqgfktsCgroDnBkGOHxR2FE9UtRU,49
2
+ ray_embedding/deploy.py,sha256=oqOhMxS5UyZ4oGhfpL7kqvrxLO8QW41sF_FHbNSJe-w,1858
3
+ ray_embedding/dto.py,sha256=e91ejZbM_NB9WTjF1YnfuV71cajYIh0vOX8oV_g2OwM,595
4
+ ray_embedding/embedding_model.py,sha256=cyGH7CZRCAV50T51aTAxTSRCU0haCV_mX42tyhmFa6U,7007
5
+ ray_embedding-0.10.0.dist-info/METADATA,sha256=8uU8yj2bnbxZPlL1WEaU0V6ioi0We6rcUUzTGd62yTk,605
6
+ ray_embedding-0.10.0.dist-info/WHEEL,sha256=GHB6lJx2juba1wDgXDNlMTyM13ckjBMKf-OnwgKOCtA,91
7
+ ray_embedding-0.10.0.dist-info/top_level.txt,sha256=ziCblpJq1YsrryshFqxTRuRMgNuO1_tgvAAkGShATNA,14
8
+ ray_embedding-0.10.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (79.0.1)
2
+ Generator: setuptools (80.3.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,8 +0,0 @@
1
- ray_embedding/__init__.py,sha256=OYJT0rVaaGzY613JqgfktsCgroDnBkGOHxR2FE9UtRU,49
2
- ray_embedding/deploy.py,sha256=oqOhMxS5UyZ4oGhfpL7kqvrxLO8QW41sF_FHbNSJe-w,1858
3
- ray_embedding/dto.py,sha256=e91ejZbM_NB9WTjF1YnfuV71cajYIh0vOX8oV_g2OwM,595
4
- ray_embedding/embedding_model.py,sha256=DyhFO0kQnyoFq_VGJQYDEZKuvtwqhuXr83Vu23yb4ds,5966
5
- ray_embedding-0.9.10.dist-info/METADATA,sha256=aDU4KlY1_-mtJ80tPb9FGGAnB9o2VSjQtsUR3Xt60_k,605
6
- ray_embedding-0.9.10.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
7
- ray_embedding-0.9.10.dist-info/top_level.txt,sha256=ziCblpJq1YsrryshFqxTRuRMgNuO1_tgvAAkGShATNA,14
8
- ray_embedding-0.9.10.dist-info/RECORD,,