Harrison/redo docs (#130)

Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com>
This commit is contained in:
Harrison Chase
2022-11-13 20:13:23 -08:00
committed by GitHub
parent f23b3ceb49
commit b1b6b27c5f
35 changed files with 909 additions and 368 deletions

View File

@@ -0,0 +1,142 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "f5d249ee",
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"# Generate Examples\n",
"\n",
"This notebook shows how to use LangChain to generate more examples similar to the ones you already have."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "1685fa2f",
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"from langchain.chains.react.prompt import EXAMPLES\n",
"from langchain.llms.openai import OpenAI\n",
"from langchain.example_generator import generate_example, generate_example_from_dynamic_prompt"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "334ef4f7",
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [
{
"data": {
"text/plain": [
"'Question: What is the elevation range for the area that the eastern sector of the\\nColorado orogeny extends into?\\nThought 1: I need to search Colorado orogeny, find the area that the eastern sector\\nof the Colorado orogeny extends into, then find the elevation range of the\\narea.\\nAction 1: Search[Colorado orogeny]\\nObservation 1: The Colorado orogeny was an episode of mountain building (an orogeny) in\\nColorado and surrounding areas.\\nThought 2: It does not mention the eastern sector. So I need to look up eastern\\nsector.\\nAction 2: Lookup[eastern sector]\\nObservation 2: (Result 1 / 1) The eastern sector extends into the High Plains and is called\\nthe Central Plains orogeny.\\nThought 3: The eastern sector of Colorado orogeny extends into the High Plains. So I\\nneed to search High Plains and find its elevation range.\\nAction 3: Search[High Plains]\\nObservation 3: High Plains refers to one of two distinct land regions\\nThought 4: I need to instead search High Plains (United States).\\nAction 4: Search[High Plains (United States)]\\nObservation 4: The High Plains are a subregion of the Great Plains. From east to west, the\\nHigh Plains rise in elevation from around 1,800 to 7,000 ft (550 to 2,130\\nm).[3]\\nThought 5: High Plains rise in elevation from around 1,800 to 7,000 ft, so the answer\\nis 1,800 to 7,000 ft.\\nAction 5: Finish[1,800 to 7,000 ft]'"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# print initial example for visibility\n",
"EXAMPLES[0]"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "a7bd36bc",
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"new_example = generate_example(EXAMPLES, OpenAI())"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "e1efb008",
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [
{
"data": {
"text/plain": [
"['',\n",
" '',\n",
" 'Question: Which ocean is the worlds smallest?',\n",
" '',\n",
" 'Thought 1: I need to search for oceans and find which one is the worlds smallest.',\n",
" '',\n",
" 'Action 1: Search[oceans]',\n",
" '',\n",
" 'Observation 1: There are five oceans: the Pacific, Atlantic, Indian, Southern, and Arctic.',\n",
" '',\n",
" 'Thought 2: I need to compare the sizes of the oceans and find which one is the smallest.',\n",
" '',\n",
" 'Action 2: Compare[Pacific, Atlantic, Indian, Southern, Arctic]',\n",
" '',\n",
" 'Observation 2: The Arctic is the smallest ocean.']"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"new_example.split('\\n')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1ed01ba2",
"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",
"version": "3.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}