argilla-io / distilabel

Distilabel is a framework for synthetic data and AI feedback for engineers who need fast, reliable and scalable pipelines based on verified research papers.
https://distilabel.argilla.io
Apache License 2.0
1.4k stars 95 forks source link

ModuleNotFoundError: No module named 'distilabel.llm' #599

Closed KaifAhmad1 closed 4 months ago

KaifAhmad1 commented 4 months ago
!pip install -q -U distilabel "farm-haystack[preprocessing]"
!pip install -q -U "distilabel[hf-inference-endpoints, argilla]"

import os
from typing import Dict

from distilabel.llm import InferenceEndpointsLLM
from distilabel.pipeline import Pipeline, pipeline
from distilabel.tasks import TextGenerationTask, SelfInstructTask, Prompt

from datasets import Dataset
from haystack.nodes import PDFToTextConverter, PreProcessor
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /usr/local/lib/python3.10/dist-packages/IPython/core/interactiveshell.py:3553 in run_code        │
│                                                                                                  │
│   3550 │   │   │   │   elif async_ :                                                             │
│   3551 │   │   │   │   │   await eval(code_obj, self.user_global_ns, self.user_ns)               │
│   3552 │   │   │   │   else:                                                                     │
│ ❱ 3553 │   │   │   │   │   exec(code_obj, self.user_global_ns, self.user_ns)                     │
│   3554 │   │   │   finally:                                                                      │
│   3555 │   │   │   │   # Reset our crash handler in place                                        │
│   3556 │   │   │   │   sys.excepthook = old_excepthook                                           │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │         async_ = False                                                                       │ │
│ │       code_obj = <code object <cell line: 4> at 0x7b215423b9f0, file                         │ │
│ │                  "<ipython-input-3-ed9b6e2e422f>", line 1>                                   │ │
│ │          etype = <class 'ModuleNotFoundError'>                                               │ │
│ │ old_excepthook = <bound method IPKernelApp.excepthook of <__main__.ColabKernelApp object at  │ │
│ │                  0x7b216ef49600>>                                                            │ │
│ │        outflag = True                                                                        │ │
│ │         result = <ExecutionResult object at 7b2155807130, execution_count=3                  │ │
│ │                  error_before_exec=None error_in_exec=No module named 'distilabel.llm'       │ │
│ │                  info=<ExecutionInfo object at 7b2155807bb0, raw_cell="import os             │ │
│ │                  from typing import Dict                                                     │ │
│ │                                                                                              │ │
│ │                  from distilabel.." store_history=True silent=False shell_futures=True       │ │
│ │                  cell_id=None> result=None>                                                  │ │
│ │           self = <google.colab._shell.Shell object at 0x7b2166b0b7f0>                        │ │
│ │             tb = <traceback object at 0x7b2154193ec0>                                        │ │
│ │          value = ModuleNotFoundError("No module named 'distilabel.llm'")                     │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ in <cell line: 4>:4                                                                              │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │        Dict = typing.Dict                                                                    │ │
│ │        exit = <IPython.core.autocall.ZMQExitAutocall object at 0x7b2166b0bd90>               │ │
│ │ get_ipython = <bound method InteractiveShell.get_ipython of <google.colab._shell.Shell       │ │
│ │               object at 0x7b2166b0b7f0>>                                                     │ │
│ │          In = [                                                                              │ │
│ │               │   '',                                                                        │ │
│ │               │   'get_ipython().system(\'pip install -q -U distilabel                       │ │
│ │               "farm-haystack[preprocessing]'+91,                                             │ │
│ │               │   'import os\nfrom typing import Dict\n\nfrom distilabel.llm import          │ │
│ │               InferenceEndpoints'+218,                                                       │ │
│ │               │   'import os\nfrom typing import Dict\n\nfrom distilabel.llm import          │ │
│ │               InferenceEndpoints'+218                                                        │ │
│ │               ]                                                                              │ │
│ │          os = <module 'os' from '/usr/lib/python3.10/os.py'>                                 │ │
│ │         Out = {}                                                                             │ │
│ │        quit = <IPython.core.autocall.ZMQExitAutocall object at 0x7b2166b0bd90>               │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
ModuleNotFoundError: No module named 'distilabel.llm'
plaguss commented 4 months ago

Hi @KaifAhmad1 it seems like you are trying to run code from distilabel<1.0.0 but you have installed a version >=1.0.0 (currently we have distilabel.llms module). Could you check?

alvarobartt commented 4 months ago

Also @KaifAhmad1 if you are willing to upgrade to v1.0.0 or higher, we're happy to support the transition from distilabel v0.6.0 or lower to v1.0.0 😄

KaifAhmad1 commented 4 months ago

Hey, @plaguss Here is the version of distillable distilabel Version: 1.0.3

I have tried this script but getting same error

!pip install -q -U distilabel<1.0.0 "farm-haystack[preprocessing]"
!pip install -q -U "distilabel[hf-inference-endpoints, argilla]"
plaguss commented 4 months ago

Apparently the second command is overwriting the version of distilabel, try with the following:

!pip install -q -U "distilabel[hf-inference-endpoints, argilla]<1.0.0"
KaifAhmad1 commented 4 months ago

@plaguss Now Getting this exception!

!pip install -q -U distilabel<1.0.0 "farm-haystack[preprocessing]"
!pip install -q -U "distilabel[hf-inference-endpoints, argilla]<1.0.0"

import os
from typing import Dict

from distilabel.llm import InferenceEndpointsLLM
from distilabel.pipeline import Pipeline, pipeline
from distilabel.tasks import TextGenerationTask, SelfInstructTask, Prompt

from datasets import Dataset
from haystack.nodes import PDFToTextConverter, PreProcessor
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /usr/local/lib/python3.10/dist-packages/IPython/core/interactiveshell.py:3553 in run_code        │
│                                                                                                  │
│   3550 │   │   │   │   elif async_ :                                                             │
│   3551 │   │   │   │   │   await eval(code_obj, self.user_global_ns, self.user_ns)               │
│   3552 │   │   │   │   else:                                                                     │
│ ❱ 3553 │   │   │   │   │   exec(code_obj, self.user_global_ns, self.user_ns)                     │
│   3554 │   │   │   finally:                                                                      │
│   3555 │   │   │   │   # Reset our crash handler in place                                        │
│   3556 │   │   │   │   sys.excepthook = old_excepthook                                           │
│ in <cell line: 4>:4                                                                              │
│                                                                                                  │
│ /usr/local/lib/python3.10/dist-packages/distilabel/llm/__init__.py:18 in <module>                │
│                                                                                                  │
│   15 from distilabel.llm.anyscale import AnyscaleLLM                                             │
│   16 from distilabel.llm.base import LLM, LLMPool, ProcessLLM                                    │
│   17 from distilabel.llm.google.vertexai import VertexAIEndpointLLM, VertexAILLM                 │
│ ❱ 18 from distilabel.llm.huggingface.inference_endpoints import InferenceEndpointsLLM            │
│   19 from distilabel.llm.huggingface.transformers import TransformersLLM                         │
│   20 from distilabel.llm.llama_cpp import LlamaCppLLM                                            │
│   21 from distilabel.llm.mistralai import MistralAILLM                                           │
│                                                                                                  │
│ /usr/local/lib/python3.10/dist-packages/distilabel/llm/huggingface/inference_endpoints.py:38 in  │
│ <module>                                                                                         │
│                                                                                                  │
│    35 │   │   InferenceTimeoutError,                                                             │
│    36 │   │   get_inference_endpoint,                                                            │
│    37 │   )                                                                                      │
│ ❱  38 │   from huggingface_hub.inference._text_generation import TextGenerationError             │
│    39 │                                                                                          │
│    40 │   _INFERENCE_ENDPOINTS_API_RETRY_ON_EXCEPTIONS = (                                       │
│    41 │   │   InferenceTimeoutError,                                                             │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
ModuleNotFoundError: No module named 'huggingface_hub.inference._text_generation'
plaguss commented 4 months ago

That error is not related to distilabel directly but with the dependencies' versions, you should check the dependencies corresponding to that version. The following ones should work:

!pip install huggingface_hub==0.19.0 --upgrade
!pip install transformers==4.34.1 --upgrade

But as @alvarobartt mentioned we are happy to help you with the transition to use the newer version 🙂

KaifAhmad1 commented 4 months ago

Yeah @plaguss @alvarobartt Please! share the documentation toward transition!

plaguss commented 4 months ago

Here is an example of the new API, and the Learn section should guide you through the new components of the library. Closing this issue for now. If you find a specific problem with your pipeline open a new one without a problem