from_llm() — langchain Function Reference
Architecture documentation for the from_llm() function in base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 062c7fde_383f_ddbc_fa3b_affdcf00ca07["from_llm()"] 1cb458d9_f8c6_d78d_c1e3_79a8b3106c08["BaseRetrievalQA"] 062c7fde_383f_ddbc_fa3b_affdcf00ca07 -->|defined in| 1cb458d9_f8c6_d78d_c1e3_79a8b3106c08 style 062c7fde_383f_ddbc_fa3b_affdcf00ca07 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain/langchain_classic/chains/retrieval_qa/base.py lines 70–101
def from_llm(
cls,
llm: BaseLanguageModel,
prompt: PromptTemplate | None = None,
callbacks: Callbacks = None,
llm_chain_kwargs: dict | None = None,
**kwargs: Any,
) -> BaseRetrievalQA:
"""Initialize from LLM."""
_prompt = prompt or PROMPT_SELECTOR.get_prompt(llm)
llm_chain = LLMChain(
llm=llm,
prompt=_prompt,
callbacks=callbacks,
**(llm_chain_kwargs or {}),
)
document_prompt = PromptTemplate(
input_variables=["page_content"],
template="Context:\n{page_content}",
)
combine_documents_chain = StuffDocumentsChain(
llm_chain=llm_chain,
document_variable_name="context",
document_prompt=document_prompt,
callbacks=callbacks,
)
return cls(
combine_documents_chain=combine_documents_chain,
callbacks=callbacks,
**kwargs,
)
Domain
Subdomains
Source
Frequently Asked Questions
What does from_llm() do?
from_llm() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/chains/retrieval_qa/base.py.
Where is from_llm() defined?
from_llm() is defined in libs/langchain/langchain_classic/chains/retrieval_qa/base.py at line 70.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free