Skip to content

HuggingfacePipeline - ValueError: alternative_import must be a fully qualified module path #22510

@ErikTromp

Description

@ErikTromp

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangChain documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

Example Code

from langchain_community.llms.huggingface_pipeline import HuggingFacePipeline
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline

model_id = 'meta-llama/Meta-Llama-3-8B-Instruct'
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id)
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer, max_new_tokens=10)
hf = HuggingFacePipeline(pipeline=pipe)```

### Error Message and Stack Trace (if applicable)

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/e/anaconda3/envs/rag/lib/python3.11/site-packages/langchain_core/_api/deprecation.py", line 182, in warn_if_direct_instance
    emit_warning()
  File "/home/e/anaconda3/envs/rag/lib/python3.11/site-packages/langchain_core/_api/deprecation.py", line 119, in emit_warning
    warn_deprecated(
  File "/home/e/anaconda3/envs/rag/lib/python3.11/site-packages/langchain_core/_api/deprecation.py", line 345, in warn_deprecated
    raise ValueError("alternative_import must be a fully qualified module path")
ValueError: alternative_import must be a fully qualified module path

### Description

Documentation shows how to use HuggingFacePipeline but using that code leads to an error. HF Pipeline can no longer be used.

### System Info

Windows
Langchain 0.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugRelated to a bug, vulnerability, unexpected error with an existing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions