Получение StopIteration при использовании HuggingFaceEndpoint с LangChain и flan-t5-largePython

Программы на Python
Ответить
Anonymous
 Получение StopIteration при использовании HuggingFaceEndpoint с LangChain и flan-t5-large

Сообщение Anonymous »

Я пытаюсь использовать интеграцию langchain_huggingface.HuggingFaceEndpoint для вызова модели «google/flan-t5-large» из Hugging Face в конвейере LangChain. Вот мой код:

Код: Выделить всё

from langchain.prompts import PromptTemplate
from langchain_huggingface import HuggingFaceEndpoint
from langchain_core.runnables import RunnableSequence
import os

# Set your API token
os.environ['HUGGINGFACEHUB_API_TOKEN'] = 'hf_***************'

# Initialize the updated Hugging Face model
flan_t5 = HuggingFaceEndpoint(
repo_id="google/flan-t5-large",
temperature=1e-10,
task="text2text-generation"
)

# Define the prompt template
template = "Translate the following to French:\n\n{question}"
prompt = PromptTemplate(template=template, input_variables=["question"])

# Create the RunnableSequence chain
chain = prompt | flan_t5

# Run the chain with input
question = "Hello"
response = chain.invoke({"question": question})

print("Output:", response)
Однако я получаю следующую ошибку:

Код: Выделить всё

/usr/local/lib/python3.11/dist-packages/huggingface_hub/inference/_providers/__init__.py in get_provider_helper(provider, task, model)
189             raise ValueError("Specifying a model is required when provider is 'auto'")
190         provider_mapping = _fetch_inference_provider_mapping(model)
--> 191         provider = next(iter(provider_mapping)).provider
StopIteration
Что я пробовал:
  • Проверил, что мой токен Hugging Face действителен.
  • Проверил, что «google/flan-t5-large» существует и поддерживает генерацию text2text.
  • Проверил другие идентификаторы репозитория (например, google/flan-t5-xl), но столкнулся с та же проблема.
Вопрос:
  • Почему я получаю эту ошибку StopIteration и как ее исправить?
  • Что-то не так с тем, как я инициализирую HuggingFaceEndpoint или с тем, как определяется поставщик?


Подробнее здесь: https://stackoverflow.com/questions/797 ... nd-flan-t5
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Python»