I am new to LangChain and I'm trying to create a simple Q&A bot (over documents). Following the documentation and guide on their website, I've created a simple working bot, but I'm struggling to understand certain parts of the code.
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": QA_CHAIN_PROMPT})
query = "some query"
print(qa.run(query))
Given the sample code above, I have some questions.
What is the point of having {context} and {question} inside our prompt template, when no arguments are passed inside?
What does
chain_type_kwargs={"prompt": QA_CHAIN_PROMPT}
actually accomplish?If I were to include a new argument inside my prompt (e.g. {name}), where do I go about to actually pass in the value for said argument?