小编Chi*_*ain的帖子

在 python 中使用 Langchain 和 HuggingFaceHub 时无限期等待


from langchain import PromptTemplate, HuggingFaceHub, LLMChain
import os

os.environ['HUGGINGFACEHUB_API_TOKEN'] = 'token'

# initialize HF LLM
flan_t5 = HuggingFaceHub(
    repo_id="google/flan-t5-xl",
    model_kwargs={"temperature": 1e-10}
)

multi_template = """Answer the following questions one at a time.

Questions:
{questions}

Answers:
"""
long_prompt = PromptTemplate(
    template=multi_template,
    input_variables=["questions"]
)

llm_chain = LLMChain(
    prompt=long_prompt,
    llm=flan_t5
)

qs_str = (
    "Which NFL team won the Super Bowl in the 2010 season?\n" +
    "If I am 6 ft 4 inches, how tall am I in centimeters?\n" +
    "Who was the …
Run Code Online (Sandbox Code Playgroud)

python huggingface langchain huggingface-hub

6
推荐指数
1
解决办法
995
查看次数

AttributeError:“模型”对象没有属性“_ctx”:将 gpt4all 与 langchain 一起使用时出错

from langchain import PromptTemplate, LLMChain
from langchain.llms import GPT4All
from langchain.callbacks.base import CallbackManager
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler

local_path = './models/gpt4all-converted.bin'
callback_manager = CallbackManager([StreamingStdOutCallbackHandler()])

template = """Question: {question}

Answer: Let's think step by step.

"""

prompt = PromptTemplate(template=template, input_variables=["question"])
llm = GPT4All(model=local_path,
              callback_manager=callback_manager, verbose=True)
llm_chain = LLMChain(prompt=prompt, llm=llm)

question = "What NFL team won the Super Bowl in the year Justin Bieber was born?"

# question = input("Enter your question: ")

llm_chain.run(question)

Run Code Online (Sandbox Code Playgroud)

尝试在本地使用 gpt4all 测试 langchain 并收到此错误。看起来像是版本的东西。我尝试了很多上网冲浪但没有得到任何结果。

Exception ignored in: <function …
Run Code Online (Sandbox Code Playgroud)

langchain gpt4all pygpt4all

2
推荐指数
1
解决办法
3163
查看次数