Files
langchain/docs/examples/chains/llm_math.ipynb
Samantha WhitmoreandHarrison Chase a408ed3ea3 Samantha/add conversation chain (#166)
Add MemoryChain and ConversationChain as chains that take a docstore in
addition to the prompt, and use the docstore to stuff context into the
prompt. This can be used to have an ongoing conversation with a chatbot.

Probably needs a bit of refactoring for code quality

Co-authored-by: Harrison Chase <hw.chase.17@gmail.com>
2022-11-23 16:35:38 -08:00

1.9 KiB

LLM Math

This notebook showcases using LLMs and Python REPLs to do complex word math problems.

In [1]:
from langchain import OpenAI, LLMMathChain

llm = OpenAI(temperature=0)
llm_math = LLMMathChain(llm=llm, verbose=True)

llm_math.run("How many of the integers between 0 and 99 inclusive are divisible by 8?")
Out [1]:

> Entering new chain...
How many of the integers between 0 and 99 inclusive are divisible by 8?

```python
count = 0
for i in range(100):
    if i % 8 == 0:
        count += 1
print(count)
```

Answer: 13

> Finished chain.
'Answer: 13\n'
In [ ]: