load_qa_chain() — langchain Function Reference
Architecture documentation for the load_qa_chain() function in chain.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD bd67ff35_0fda_a8a7_6058_318b3cb7fbe9["load_qa_chain()"] 7bff8b59_614d_4352_11dd_db15fa7a7056["chain.py"] bd67ff35_0fda_a8a7_6058_318b3cb7fbe9 -->|defined in| 7bff8b59_614d_4352_11dd_db15fa7a7056 style bd67ff35_0fda_a8a7_6058_318b3cb7fbe9 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain/langchain_classic/chains/question_answering/chain.py lines 246–284
def load_qa_chain(
llm: BaseLanguageModel,
chain_type: str = "stuff",
verbose: bool | None = None, # noqa: FBT001
callback_manager: BaseCallbackManager | None = None,
**kwargs: Any,
) -> BaseCombineDocumentsChain:
"""Load question answering chain.
Args:
llm: Language Model to use in the chain.
chain_type: Type of document combining chain to use. Should be one of "stuff",
"map_reduce", "map_rerank", and "refine".
verbose: Whether chains should be run in verbose mode or not. Note that this
applies to all chains that make up the final chain.
callback_manager: Callback manager to use for the chain.
**kwargs: Additional keyword arguments.
Returns:
A chain to use for question answering.
"""
loader_mapping: Mapping[str, LoadingCallable] = {
"stuff": _load_stuff_chain,
"map_reduce": _load_map_reduce_chain,
"refine": _load_refine_chain,
"map_rerank": _load_map_rerank_chain,
}
if chain_type not in loader_mapping:
msg = (
f"Got unsupported chain type: {chain_type}. "
f"Should be one of {loader_mapping.keys()}"
)
raise ValueError(msg)
return loader_mapping[chain_type](
llm,
verbose=verbose,
callback_manager=callback_manager,
**kwargs,
)
Domain
Subdomains
Source
Frequently Asked Questions
What does load_qa_chain() do?
load_qa_chain() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/chains/question_answering/chain.py.
Where is load_qa_chain() defined?
load_qa_chain() is defined in libs/langchain/langchain_classic/chains/question_answering/chain.py at line 246.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free