赞
踩
以下的HUGGINGFACEHUB_API_TOKEN 需要自己去huggingface 网站申请 。
from langchain.chains import LLMChain from langchain_core.prompts import ChatPromptTemplate from langchain import hub from langchain_community.llms import HuggingFaceHub from langchain_community.llms import HuggingFaceTextGenInference from langchain_community.chat_models.huggingface import ChatHuggingFace import os os.environ["HUGGINGFACEHUB_API_TOKEN"] = "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" prompt = ChatPromptTemplate.from_template("""{input} """ ) llm = HuggingFaceHub( repo_id="openchat/openchat-3.5-0106", task="text-generation", model_kwargs={"temperature":0.1, "max_length":500} ) chain = LLMChain(llm=llm,prompt=prompt,verbose=True) print(chain.invoke("where is shenzhen"))
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。