LLMCheckerChain#

This notebook showcases how to use LLMCheckerChain.

from langchain.chains import LLMCheckerChain
from langchain.llms import OpenAI

llm = OpenAI(temperature=0.7)

text = "What type of mammal lays the biggest eggs?"

checker_chain = LLMCheckerChain(llm=llm, verbose=True)

checker_chain.run(text)
> Entering new LLMCheckerChain chain...


> Entering new SequentialChain chain...
Chain 0:
{'statement': '\nNone. Mammals do not lay eggs.'}

Chain 1:
{'assertions': '\nā€¢ Mammals reproduce using live birth\nā€¢ Mammals do not lay eggs\nā€¢ Animals that lay eggs are not mammals'}

Chain 2:
{'checked_assertions': '\n1. True\n\n2. True\n\n3. False - Mammals are a class of animals that includes animals that lay eggs, such as monotremes (platypus and echidna).'}

Chain 3:
{'revised_statement': ' Monotremes, such as the platypus and echidna, lay the biggest eggs of any mammal.'}


> Finished SequentialChain chain.

> Finished LLMCheckerChain chain.
' Monotremes, such as the platypus and echidna, lay the biggest eggs of any mammal.'