小编wha*_*gon的帖子

PromptTemplate 如何与 RetrievalQA 交互?

我是 LangChain 的新手,我正在尝试创建一个简单的问答机器人(通过文档)。按照他们网站上的文档和指南,我创建了一个简单的工作机器人,但我很难理解代码的某些部分。

template = """Use the following pieces of context to answer the question at the end. 
If you don't know the answer, just say that you don't know, don't try to make up an answer. 
Use three sentences maximum and keep the answer as concise as possible. 
Always say "thanks for asking!" at the end of the answer. 
{context}
Question: {question}
Helpful Answer:"""

QA_CHAIN_PROMPT = PromptTemplate(input_variables=["context", "question"], template=template)

llm = ChatOpenAI(model_name="gpt-3.5-turbo", temperature=0)
qa = RetrievalQA.from_chain_type(llm,
                                chain_type='stuff',
                                retriever=vectorstore.as_retriever(),
                                chain_type_kwargs={"prompt": …
Run Code Online (Sandbox Code Playgroud)

langchain py-langchain

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

标签 统计

langchain ×1

py-langchain ×1