mirror of
https://github.com/deepset-ai/haystack.git
synced 2026-01-08 04:56:45 +00:00
initial import (#8361)
This commit is contained in:
parent
57027c56fe
commit
fbac1d8b04
@ -12,7 +12,7 @@ from haystack import ComponentError, DeserializationError, Document, component,
|
||||
from haystack.lazy_imports import LazyImport
|
||||
from haystack.utils.device import ComponentDevice
|
||||
|
||||
with LazyImport(message="Run 'pip install transformers[torch]'") as transformers_import:
|
||||
with LazyImport(message="Run 'pip install \"transformers[torch]\"'") as transformers_import:
|
||||
from transformers import AutoModelForTokenClassification, AutoTokenizer, pipeline
|
||||
from transformers import Pipeline as HfPipeline
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ from haystack.utils import (
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
with LazyImport(message="Run 'pip install transformers[torch]'") as torch_and_transformers_import:
|
||||
with LazyImport(message="Run 'pip install \"transformers[torch]\"'") as torch_and_transformers_import:
|
||||
from huggingface_hub import model_info
|
||||
from transformers import PreTrainedTokenizer, PreTrainedTokenizerFast, StoppingCriteriaList, pipeline
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
SUPPORTED_TASKS = ["text-generation", "text2text-generation"]
|
||||
|
||||
with LazyImport(message="Run 'pip install transformers[torch]'") as transformers_import:
|
||||
with LazyImport(message="Run 'pip install \"transformers[torch]\"'") as transformers_import:
|
||||
from transformers import StoppingCriteriaList, pipeline
|
||||
|
||||
from haystack.utils.hf import ( # pylint: disable=ungrouped-imports
|
||||
|
||||
@ -14,7 +14,7 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
with LazyImport(
|
||||
message="PyTorch must be installed to use torch.device or use GPU support in HuggingFace transformers. "
|
||||
"Run 'pip install transformers[torch]'"
|
||||
"Run 'pip install \"transformers[torch]\"'"
|
||||
) as torch_import:
|
||||
import torch
|
||||
|
||||
|
||||
@ -13,7 +13,7 @@ from haystack.lazy_imports import LazyImport
|
||||
from haystack.utils.auth import Secret
|
||||
from haystack.utils.device import ComponentDevice
|
||||
|
||||
with LazyImport(message="Run 'pip install transformers[torch]'") as torch_import:
|
||||
with LazyImport(message="Run 'pip install \"transformers[torch]\"'") as torch_import:
|
||||
import torch
|
||||
|
||||
with LazyImport(message="Run 'pip install \"huggingface_hub>=0.23.0\"'") as huggingface_hub_import:
|
||||
@ -270,7 +270,7 @@ def check_generation_params(kwargs: Optional[Dict[str, Any]], additional_accepte
|
||||
)
|
||||
|
||||
|
||||
with LazyImport(message="Run 'pip install transformers[torch]'") as transformers_import:
|
||||
with LazyImport(message="Run 'pip install \"transformers[torch]\"'") as transformers_import:
|
||||
from transformers import PreTrainedTokenizer, PreTrainedTokenizerFast, StoppingCriteria, TextStreamer
|
||||
|
||||
torch_import.check()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user