mirror of
https://github.com/hwchase17/langchain
synced 2024-11-06 03:20:49 +00:00
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
This commit is contained in:
parent
ef99b06362
commit
1f7edcd08b
@ -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",
|
||||||
|
Loading…
Reference in New Issue
Block a user