Files
langchain/docs/examples/chains/llm_chain.ipynb
T
2022-11-22 06:16:26 -08:00

2.0 KiB

LLM Chain

This notebook showcases a simple LLM chain.

In [1]:
from langchain import PromptTemplate, OpenAI, LLMChain

template = """Question: {question}

Answer: Let's think step by step."""
prompt = PromptTemplate(template=template, input_variables=["question"])
llm_chain = LLMChain(prompt=prompt, llm=OpenAI(temperature=0), verbose=True)

question = "What NFL team won the Super Bowl in the year Justin Beiber was born?"

llm_chain.run(question)
Out [1]:

> Entering new chain...
Prompt after formatting:
Question: What NFL team won the Super Bowl in the year Justin Beiber was born?

Answer: Let's think step by step.

> Finished chain.
' The year Justin Beiber was born was 1994. In 1994, the Dallas Cowboys won the Super Bowl.'
In [ ]: