2022-10-24 21:51:15 +00:00
|
|
|
{
|
|
|
|
"cells": [
|
2022-11-14 04:13:23 +00:00
|
|
|
{
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"id": "e71e720f",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
2023-06-16 18:52:56 +00:00
|
|
|
"# Math chain\n",
|
2022-11-14 04:13:23 +00:00
|
|
|
"\n",
|
|
|
|
"This notebook showcases using LLMs and Python REPLs to do complex word math problems."
|
|
|
|
]
|
|
|
|
},
|
2022-10-24 21:51:15 +00:00
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2023-04-30 18:14:09 +00:00
|
|
|
"execution_count": 4,
|
2022-10-24 21:51:15 +00:00
|
|
|
"id": "44e9ba31",
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
2022-11-03 07:41:07 +00:00
|
|
|
{
|
|
|
|
"name": "stdout",
|
|
|
|
"output_type": "stream",
|
|
|
|
"text": [
|
2022-11-14 04:13:23 +00:00
|
|
|
"\n",
|
|
|
|
"\n",
|
Docs refactor (#480)
Big docs refactor! Motivation is to make it easier for people to find
resources they are looking for. To accomplish this, there are now three
main sections:
- Getting Started: steps for getting started, walking through most core
functionality
- Modules: these are different modules of functionality that langchain
provides. Each part here has a "getting started", "how to", "key
concepts" and "reference" section (except in a few select cases where it
didnt easily fit).
- Use Cases: this is to separate use cases (like summarization, question
answering, evaluation, etc) from the modules, and provide a different
entry point to the code base.
There is also a full reference section, as well as extra resources
(glossary, gallery, etc)
Co-authored-by: Shreya Rajpal <ShreyaR@users.noreply.github.com>
2023-01-02 16:24:09 +00:00
|
|
|
"\u001b[1m> Entering new LLMMathChain chain...\u001b[0m\n",
|
|
|
|
"What is 13 raised to the .3432 power?\u001b[32;1m\u001b[1;3m\n",
|
2023-04-30 18:14:09 +00:00
|
|
|
"```text\n",
|
|
|
|
"13 ** .3432\n",
|
2022-11-03 07:41:07 +00:00
|
|
|
"```\n",
|
2023-04-30 18:14:09 +00:00
|
|
|
"...numexpr.evaluate(\"13 ** .3432\")...\n",
|
2022-11-03 07:41:07 +00:00
|
|
|
"\u001b[0m\n",
|
2023-04-30 18:14:09 +00:00
|
|
|
"Answer: \u001b[33;1m\u001b[1;3m2.4116004626599237\u001b[0m\n",
|
2023-01-13 14:28:51 +00:00
|
|
|
"\u001b[1m> Finished chain.\u001b[0m\n"
|
2022-11-03 07:41:07 +00:00
|
|
|
]
|
|
|
|
},
|
2022-10-24 21:51:15 +00:00
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"text/plain": [
|
2023-04-30 18:14:09 +00:00
|
|
|
"'Answer: 2.4116004626599237'"
|
2022-10-24 21:51:15 +00:00
|
|
|
]
|
|
|
|
},
|
2023-04-30 18:14:09 +00:00
|
|
|
"execution_count": 4,
|
2022-10-24 21:51:15 +00:00
|
|
|
"metadata": {},
|
|
|
|
"output_type": "execute_result"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
2023-09-17 00:22:48 +00:00
|
|
|
"from langchain.llms import OpenAI\nfrom langchain.chains import LLMMathChain\n",
|
2022-10-24 21:51:15 +00:00
|
|
|
"\n",
|
|
|
|
"llm = OpenAI(temperature=0)\n",
|
2023-04-30 18:14:09 +00:00
|
|
|
"llm_math = LLMMathChain.from_llm(llm, verbose=True)\n",
|
2023-01-13 14:28:51 +00:00
|
|
|
"\n",
|
|
|
|
"llm_math.run(\"What is 13 raised to the .3432 power?\")"
|
|
|
|
]
|
|
|
|
},
|
2022-10-24 21:51:15 +00:00
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
2023-04-30 18:14:09 +00:00
|
|
|
"id": "e978bb8e",
|
2022-10-24 21:51:15 +00:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": []
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"metadata": {
|
|
|
|
"kernelspec": {
|
|
|
|
"display_name": "Python 3 (ipykernel)",
|
|
|
|
"language": "python",
|
|
|
|
"name": "python3"
|
|
|
|
},
|
|
|
|
"language_info": {
|
|
|
|
"codemirror_mode": {
|
|
|
|
"name": "ipython",
|
|
|
|
"version": 3
|
|
|
|
},
|
|
|
|
"file_extension": ".py",
|
|
|
|
"mimetype": "text/x-python",
|
|
|
|
"name": "python",
|
|
|
|
"nbconvert_exporter": "python",
|
|
|
|
"pygments_lexer": "ipython3",
|
2023-06-16 18:52:56 +00:00
|
|
|
"version": "3.11.3"
|
2022-10-24 21:51:15 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
"nbformat": 4,
|
|
|
|
"nbformat_minor": 5
|
|
|
|
}
|