-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor!: Sentence Transformers Embedders - new devices mgmt (#7033)
* new device mgmt for Sentence Transformers embedders * reno
- Loading branch information
Showing
5 changed files
with
114 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
releasenotes/notes/sentence-transformers-embedders-new-devices-mgmt-07cb59c6b4a13280.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
upgrade: | ||
- | | ||
Adopt the new framework-agnostic device management in Sentence Transformers Embedders. | ||
Before this change: | ||
```python | ||
from haystack.components.embedders import SentenceTransformersTextEmbedder | ||
embedder = SentenceTransformersTextEmbedder(device="cuda:0") | ||
``` | ||
After this change: | ||
```python | ||
from haystack.utils.device import ComponentDevice, Device | ||
from haystack.components.embedders import SentenceTransformersTextEmbedder | ||
device = ComponentDevice.from_single(Device.gpu(id=0)) | ||
# or | ||
# device = ComponentDevice.from_str("cuda:0") | ||
embedder = SentenceTransformersTextEmbedder(device=device) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters