From 1f7edcd08be1aedc18e10d4e6c8593e715eecb03 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Thu, 12 Oct 2023 08:26:56 +0900 Subject: [PATCH] doc: Fix documentation about n-gram overlap (#11549) Fix the documentation in https://python.langchain.com/docs/modules/model_io/prompts/example_selectors/ngram_overlap. It's currently declaring unrelated variables, for example, `examples` local variable is declared twice and the first one is overwritten immediately. - **Issue:** N/A - **Dependencies:** N/A - **Tag maintainer:** for a quicker response, tag the relevant maintainer (see below), - **Twitter handle:** @dosuken123 --- .../example_selectors/ngram_overlap.ipynb | 24 +------------------ 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/docs/docs/modules/model_io/prompts/example_selectors/ngram_overlap.ipynb b/docs/docs/modules/model_io/prompts/example_selectors/ngram_overlap.ipynb index 9876603a30..0a8cf4aeeb 100644 --- a/docs/docs/modules/model_io/prompts/example_selectors/ngram_overlap.ipynb +++ b/docs/docs/modules/model_io/prompts/example_selectors/ngram_overlap.ipynb @@ -19,32 +19,14 @@ "metadata": {}, "outputs": [], "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 import FewShotPromptTemplate, PromptTemplate\n", "\n", "example_prompt = PromptTemplate(\n", " input_variables=[\"input\", \"output\"],\n", " template=\"Input: {input}\\nOutput: {output}\",\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 = [\n", " {\"input\": \"See Spot run.\", \"output\": \"Ver correr a Spot.\"},\n", @@ -60,10 +42,6 @@ "metadata": {}, "outputs": [], "source": [ - "example_prompt = PromptTemplate(\n", - " input_variables=[\"input\", \"output\"],\n", - " template=\"Input: {input}\\nOutput: {output}\",\n", - ")\n", "example_selector = NGramOverlapExampleSelector(\n", " # The examples it has available to choose from.\n", " examples=examples,\n",