LLMCheckerChain Class — langchain Architecture
Architecture documentation for the LLMCheckerChain class in base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 5aa56bcf_82c4_0170_f600_dbc266dbf61b["LLMCheckerChain"] f3cef70e_11b0_61c9_7ec0_7308f4b45056["Chain"] 5aa56bcf_82c4_0170_f600_dbc266dbf61b -->|extends| f3cef70e_11b0_61c9_7ec0_7308f4b45056 a0a672f2_fe43_2701_45f8_1b60a2179f97["base.py"] 5aa56bcf_82c4_0170_f600_dbc266dbf61b -->|defined in| a0a672f2_fe43_2701_45f8_1b60a2179f97 f272a350_2fd9_70c0_9de4_c963a07940fa["_raise_deprecation()"] 5aa56bcf_82c4_0170_f600_dbc266dbf61b -->|method| f272a350_2fd9_70c0_9de4_c963a07940fa cbea931f_01c5_0277_221a_83340cfd87db["input_keys()"] 5aa56bcf_82c4_0170_f600_dbc266dbf61b -->|method| cbea931f_01c5_0277_221a_83340cfd87db 4c43974a_92e4_3b83_be05_9f17f4be391d["output_keys()"] 5aa56bcf_82c4_0170_f600_dbc266dbf61b -->|method| 4c43974a_92e4_3b83_be05_9f17f4be391d f81221be_a2ac_a3e7_7819_30fb88a7c9bc["_call()"] 5aa56bcf_82c4_0170_f600_dbc266dbf61b -->|method| f81221be_a2ac_a3e7_7819_30fb88a7c9bc d0efdd08_c13a_b40f_e1fb_986721a195b7["_chain_type()"] 5aa56bcf_82c4_0170_f600_dbc266dbf61b -->|method| d0efdd08_c13a_b40f_e1fb_986721a195b7 62540c68_956e_907e_7735_12e71501527a["from_llm()"] 5aa56bcf_82c4_0170_f600_dbc266dbf61b -->|method| 62540c68_956e_907e_7735_12e71501527a
Relationship Graph
Source Code
libs/langchain/langchain_classic/chains/llm_checker/base.py lines 75–199
class LLMCheckerChain(Chain):
"""Chain for question-answering with self-verification.
Example:
```python
from langchain_openai import OpenAI
from langchain_classic.chains import LLMCheckerChain
model = OpenAI(temperature=0.7)
checker_chain = LLMCheckerChain.from_llm(model)
```
"""
question_to_checked_assertions_chain: SequentialChain
llm: BaseLanguageModel | None = None
"""[Deprecated] LLM wrapper to use."""
create_draft_answer_prompt: PromptTemplate = CREATE_DRAFT_ANSWER_PROMPT
"""[Deprecated]"""
list_assertions_prompt: PromptTemplate = LIST_ASSERTIONS_PROMPT
"""[Deprecated]"""
check_assertions_prompt: PromptTemplate = CHECK_ASSERTIONS_PROMPT
"""[Deprecated]"""
revised_answer_prompt: PromptTemplate = REVISED_ANSWER_PROMPT
"""[Deprecated] Prompt to use when questioning the documents."""
input_key: str = "query"
output_key: str = "result"
model_config = ConfigDict(
arbitrary_types_allowed=True,
extra="forbid",
)
@model_validator(mode="before")
@classmethod
def _raise_deprecation(cls, values: dict) -> Any:
if "llm" in values:
warnings.warn(
"Directly instantiating an LLMCheckerChain with an llm is deprecated. "
"Please instantiate with question_to_checked_assertions_chain "
"or using the from_llm class method.",
stacklevel=5,
)
if (
"question_to_checked_assertions_chain" not in values
and values["llm"] is not None
):
question_to_checked_assertions_chain = (
_load_question_to_checked_assertions_chain(
values["llm"],
values.get(
"create_draft_answer_prompt",
CREATE_DRAFT_ANSWER_PROMPT,
),
values.get("list_assertions_prompt", LIST_ASSERTIONS_PROMPT),
values.get("check_assertions_prompt", CHECK_ASSERTIONS_PROMPT),
values.get("revised_answer_prompt", REVISED_ANSWER_PROMPT),
)
)
values["question_to_checked_assertions_chain"] = (
question_to_checked_assertions_chain
)
return values
@property
def input_keys(self) -> list[str]:
"""Return the singular input key."""
return [self.input_key]
@property
def output_keys(self) -> list[str]:
"""Return the singular output key."""
return [self.output_key]
def _call(
self,
inputs: dict[str, Any],
run_manager: CallbackManagerForChainRun | None = None,
) -> dict[str, str]:
_run_manager = run_manager or CallbackManagerForChainRun.get_noop_manager()
question = inputs[self.input_key]
Extends
Source
Frequently Asked Questions
What is the LLMCheckerChain class?
LLMCheckerChain is a class in the langchain codebase, defined in libs/langchain/langchain_classic/chains/llm_checker/base.py.
Where is LLMCheckerChain defined?
LLMCheckerChain is defined in libs/langchain/langchain_classic/chains/llm_checker/base.py at line 75.
What does LLMCheckerChain extend?
LLMCheckerChain extends Chain.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free