diff --git a/fastembed/image/image_embedding.py b/fastembed/image/image_embedding.py index e5d9f17..50b6e53 100644 --- a/fastembed/image/image_embedding.py +++ b/fastembed/image/image_embedding.py @@ -1,3 +1,4 @@ +import warnings from typing import Any, Iterable, Optional, Sequence, Type, Union from dataclasses import asdict @@ -57,6 +58,12 @@ class ImageEmbedding(ImageEmbeddingBase): **kwargs: Any, ): super().__init__(model_name, cache_dir, threads, **kwargs) + if not cuda and device_ids: + warnings.warn( + "`device_ids` are only used when `cuda` is set to True. Device ids will be ignored.", + UserWarning, + stacklevel=2, + ) for EMBEDDING_MODEL_TYPE in self.EMBEDDINGS_REGISTRY: supported_models = EMBEDDING_MODEL_TYPE._list_supported_models() if any(model_name.lower() == model.model.lower() for model in supported_models): diff --git a/fastembed/late_interaction/late_interaction_text_embedding.py b/fastembed/late_interaction/late_interaction_text_embedding.py index 8f6aa83..066149f 100644 --- a/fastembed/late_interaction/late_interaction_text_embedding.py +++ b/fastembed/late_interaction/late_interaction_text_embedding.py @@ -1,3 +1,4 @@ +import warnings from typing import Any, Iterable, Optional, Sequence, Type, Union from dataclasses import asdict @@ -60,6 +61,13 @@ class LateInteractionTextEmbedding(LateInteractionTextEmbeddingBase): **kwargs: Any, ): super().__init__(model_name, cache_dir, threads, **kwargs) + if not cuda and device_ids: + warnings.warn( + "`device_ids` are only used when `cuda` is set to True. Device ids will be ignored.", + UserWarning, + stacklevel=2, + ) + for EMBEDDING_MODEL_TYPE in self.EMBEDDINGS_REGISTRY: supported_models = EMBEDDING_MODEL_TYPE._list_supported_models() if any(model_name.lower() == model.model.lower() for model in supported_models): diff --git a/fastembed/late_interaction_multimodal/late_interaction_multimodal_embedding.py b/fastembed/late_interaction_multimodal/late_interaction_multimodal_embedding.py index e7c0beb..4244895 100644 --- a/fastembed/late_interaction_multimodal/late_interaction_multimodal_embedding.py +++ b/fastembed/late_interaction_multimodal/late_interaction_multimodal_embedding.py @@ -1,3 +1,4 @@ +import warnings from typing import Any, Iterable, Optional, Sequence, Type, Union from dataclasses import asdict @@ -63,6 +64,12 @@ class LateInteractionMultimodalEmbedding(LateInteractionMultimodalEmbeddingBase) **kwargs: Any, ): super().__init__(model_name, cache_dir, threads, **kwargs) + if not cuda and device_ids: + warnings.warn( + "`device_ids` are only used when `cuda` is set to True. Device ids will be ignored.", + UserWarning, + stacklevel=2, + ) for EMBEDDING_MODEL_TYPE in self.EMBEDDINGS_REGISTRY: supported_models = EMBEDDING_MODEL_TYPE._list_supported_models() if any(model_name.lower() == model.model.lower() for model in supported_models): diff --git a/fastembed/rerank/cross_encoder/text_cross_encoder.py b/fastembed/rerank/cross_encoder/text_cross_encoder.py index 573053e..f01c8f2 100644 --- a/fastembed/rerank/cross_encoder/text_cross_encoder.py +++ b/fastembed/rerank/cross_encoder/text_cross_encoder.py @@ -1,3 +1,4 @@ +import warnings from typing import Any, Iterable, Optional, Sequence, Type from dataclasses import asdict @@ -56,6 +57,12 @@ class TextCrossEncoder(TextCrossEncoderBase): **kwargs: Any, ): super().__init__(model_name, cache_dir, threads, **kwargs) + if not cuda and device_ids: + warnings.warn( + "`device_ids` are only used when `cuda` is set to True. Device ids will be ignored.", + UserWarning, + stacklevel=2, + ) for CROSS_ENCODER_TYPE in self.CROSS_ENCODER_REGISTRY: supported_models = CROSS_ENCODER_TYPE._list_supported_models() diff --git a/fastembed/sparse/sparse_text_embedding.py b/fastembed/sparse/sparse_text_embedding.py index 1e98f1d..6edd141 100644 --- a/fastembed/sparse/sparse_text_embedding.py +++ b/fastembed/sparse/sparse_text_embedding.py @@ -61,6 +61,13 @@ class SparseTextEmbedding(SparseTextEmbeddingBase): **kwargs: Any, ): super().__init__(model_name, cache_dir, threads, **kwargs) + if not cuda and device_ids: + warnings.warn( + "`device_ids` are only used when `cuda` is set to True. Device ids will be ignored.", + UserWarning, + stacklevel=2, + ) + if model_name == "prithvida/Splade_PP_en_v1": warnings.warn( "The right spelling is prithivida/Splade_PP_en_v1. " diff --git a/fastembed/text/text_embedding.py b/fastembed/text/text_embedding.py index 430d7d3..fb28f32 100644 --- a/fastembed/text/text_embedding.py +++ b/fastembed/text/text_embedding.py @@ -49,6 +49,12 @@ class TextEmbedding(TextEmbeddingBase): **kwargs: Any, ): super().__init__(model_name, cache_dir, threads, **kwargs) + if not cuda and device_ids: + warnings.warn( + "`device_ids` are only used when `cuda` is set to True. Device ids will be ignored.", + UserWarning, + stacklevel=2, + ) if model_name == "nomic-ai/nomic-embed-text-v1.5-Q": warnings.warn( "The model 'nomic-ai/nomic-embed-text-v1.5-Q' has been updated on HuggingFace. "