@ -19,32 +19,14 @@
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
"from langchain.prompts import PromptTemplate\n",
"from langchain.prompts import PromptTemplate, FewShotPromptTemplate \n",
"from langchain.prompts.example_selector.ngram_overlap import NGramOverlapExampleSelector\n",
"from langchain.prompts.example_selector.ngram_overlap import NGramOverlapExampleSelector\n",
"from langchain.prompts import FewShotPromptTemplate, PromptTemplate\n",
"\n",
"\n",
"example_prompt = PromptTemplate(\n",
"example_prompt = PromptTemplate(\n",
" input_variables=[\"input\", \"output\"],\n",
" input_variables=[\"input\", \"output\"],\n",
" template=\"Input: {input}\\nOutput: {output}\",\n",
" template=\"Input: {input}\\nOutput: {output}\",\n",
")\n",
")\n",
"\n",
"\n",
"# Examples of a pretend task of creating antonyms.\n",
"examples = [\n",
" {\"input\": \"happy\", \"output\": \"sad\"},\n",
" {\"input\": \"tall\", \"output\": \"short\"},\n",
" {\"input\": \"energetic\", \"output\": \"lethargic\"},\n",
" {\"input\": \"sunny\", \"output\": \"gloomy\"},\n",
" {\"input\": \"windy\", \"output\": \"calm\"},\n",
"]"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "4f318f4b",
"metadata": {},
"outputs": [],
"source": [
"# Examples of a fictional translation task.\n",
"# Examples of a fictional translation task.\n",
"examples = [\n",
"examples = [\n",
" {\"input\": \"See Spot run.\", \"output\": \"Ver correr a Spot.\"},\n",
" {\"input\": \"See Spot run.\", \"output\": \"Ver correr a Spot.\"},\n",
@ -60,10 +42,6 @@
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
"example_prompt = PromptTemplate(\n",
" input_variables=[\"input\", \"output\"],\n",
" template=\"Input: {input}\\nOutput: {output}\",\n",
")\n",
"example_selector = NGramOverlapExampleSelector(\n",
"example_selector = NGramOverlapExampleSelector(\n",
" # The examples it has available to choose from.\n",
" # The examples it has available to choose from.\n",
" examples=examples,\n",
" examples=examples,\n",