mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-24 07:35:18 +00:00
huggingface: handle image-text-to-text pipeline task (#31611)
**Description:** Allows for HuggingFacePipeline to handle image-text-to-text pipeline
This commit is contained in:
parent
50f998a138
commit
cecfec5efa
@ -23,6 +23,7 @@ DEFAULT_TASK = "text-generation"
|
|||||||
VALID_TASKS = (
|
VALID_TASKS = (
|
||||||
"text2text-generation",
|
"text2text-generation",
|
||||||
"text-generation",
|
"text-generation",
|
||||||
|
"image-text-to-text",
|
||||||
"summarization",
|
"summarization",
|
||||||
"translation",
|
"translation",
|
||||||
)
|
)
|
||||||
@ -38,8 +39,8 @@ class HuggingFacePipeline(BaseLLM):
|
|||||||
|
|
||||||
To use, you should have the ``transformers`` python package installed.
|
To use, you should have the ``transformers`` python package installed.
|
||||||
|
|
||||||
Only supports `text-generation`, `text2text-generation`, `summarization` and
|
Only supports `text-generation`, `text2text-generation`, `image-text-to-text`,
|
||||||
`translation` for now.
|
`summarization` and `translation` for now.
|
||||||
|
|
||||||
Example using from_model_id:
|
Example using from_model_id:
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
@ -327,6 +328,8 @@ class HuggingFacePipeline(BaseLLM):
|
|||||||
text = response["generated_text"]
|
text = response["generated_text"]
|
||||||
elif self.pipeline.task == "text2text-generation":
|
elif self.pipeline.task == "text2text-generation":
|
||||||
text = response["generated_text"]
|
text = response["generated_text"]
|
||||||
|
elif self.pipeline.task == "image-text-to-text":
|
||||||
|
text = response["generated_text"]
|
||||||
elif self.pipeline.task == "summarization":
|
elif self.pipeline.task == "summarization":
|
||||||
text = response["summary_text"]
|
text = response["summary_text"]
|
||||||
elif self.pipeline.task in "translation":
|
elif self.pipeline.task in "translation":
|
||||||
|
Loading…
Reference in New Issue
Block a user