langchain的使用以及算力的计算

文章目录

提示词

import warnings
warnings.filterwarnings("ignore")
from langchain import PromptTemplate,LLMChain
from llm import ChatGLM

# 简单的问题模板
template = """问题: {question}

答案: """
prompt = PromptTemplate(
        template=template,
    input_variables=['question']
)

# user question
question = "中国的首都是哪里?"
print(prompt)

llm = ChatGLM(model_path="../chatglm2-6B/chatglm2-6b")
llm.load_model()
print("ok")

llm_chain = LLMChain(prompt=prompt,llm=llm)
print(llm_chain.run(question))

# 多个问题链
qs = [
    {'question': "姚明是谁?"},
    {'question': "美国的总统是谁?"},
    {'question': "福州今天的天气如何?"},
    {

猜你喜欢

转载自blog.csdn.net/weixin_32393347/article/details/143191627