Resolved PR comments from Boris
This commit is contained in:
parent
401f7c7ef0
commit
209c1a12e8
3
.gitignore
vendored
3
.gitignore
vendored
@ -128,8 +128,7 @@ dmypy.json
|
|||||||
# Pyre type checker
|
# Pyre type checker
|
||||||
.pyre/
|
.pyre/
|
||||||
|
|
||||||
# helpers
|
# Data
|
||||||
*helpers.py
|
|
||||||
*transactions*.jsonl
|
*transactions*.jsonl
|
||||||
/examples/data/transactions*
|
/examples/data/transactions*
|
||||||
*.DS_Store
|
*.DS_Store
|
||||||
|
@ -41,10 +41,9 @@
|
|||||||
"from sklearn.manifold import TSNE\n",
|
"from sklearn.manifold import TSNE\n",
|
||||||
"import matplotlib\n",
|
"import matplotlib\n",
|
||||||
"import matplotlib.pyplot as plt\n",
|
"import matplotlib.pyplot as plt\n",
|
||||||
|
"import os\n",
|
||||||
"\n",
|
"\n",
|
||||||
"from helpers import OPENAI_API_KEY\n",
|
"openai.api_key = os.getenv(\"OPENAI_API_KEY\")\n",
|
||||||
"\n",
|
|
||||||
"openai.api_key = OPENAI_API_KEY\n",
|
|
||||||
"COMPLETIONS_MODEL = \"text-davinci-002\"\n",
|
"COMPLETIONS_MODEL = \"text-davinci-002\"\n",
|
||||||
"\n",
|
"\n",
|
||||||
"# This path leads to a file with embeddings created in the notebook linked above\n",
|
"# This path leads to a file with embeddings created in the notebook linked above\n",
|
||||||
|
@ -40,10 +40,10 @@
|
|||||||
"import openai\n",
|
"import openai\n",
|
||||||
"import pandas as pd\n",
|
"import pandas as pd\n",
|
||||||
"import numpy as np\n",
|
"import numpy as np\n",
|
||||||
|
"import json\n",
|
||||||
|
"import os\n",
|
||||||
"\n",
|
"\n",
|
||||||
"from helpers import OPENAI_API_KEY\n",
|
"openai.api_key = os.getenv(\"OPENAI_API_KEY\")\n",
|
||||||
"\n",
|
|
||||||
"openai.api_key = OPENAI_API_KEY\n",
|
|
||||||
"COMPLETIONS_MODEL = \"text-davinci-002\""
|
"COMPLETIONS_MODEL = \"text-davinci-002\""
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -183,19 +183,9 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 316,
|
"execution_count": 335,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [],
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"31\n",
|
|
||||||
"8\n",
|
|
||||||
"All good\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
"source": [
|
||||||
"def request_completion(prompt):\n",
|
"def request_completion(prompt):\n",
|
||||||
" \n",
|
" \n",
|
||||||
@ -221,7 +211,9 @@
|
|||||||
" \n",
|
" \n",
|
||||||
" return classification\n",
|
" return classification\n",
|
||||||
"\n",
|
"\n",
|
||||||
"import json\n",
|
"# This function takes your training and validation outputs from the prepare_data function of the Finetuning API, and\n",
|
||||||
|
"# confirms that each have the same number of classes.\n",
|
||||||
|
"# If they do not have the same number of classes the fine-tune will fail and return an error\n",
|
||||||
"\n",
|
"\n",
|
||||||
"def check_finetune_classes(train_file,valid_file):\n",
|
"def check_finetune_classes(train_file,valid_file):\n",
|
||||||
"\n",
|
"\n",
|
||||||
@ -270,18 +262,17 @@
|
|||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"zero_shot_prompt = '''You are a data expert working for the National Library of Scotland. \n",
|
"zero_shot_prompt = '''You are a data expert working for the National Library of Scotland. \n",
|
||||||
" You are analysing all transactions over £25,000 in value and classifying them into one of five categories.\n",
|
"You are analysing all transactions over £25,000 in value and classifying them into one of five categories.\n",
|
||||||
" The five categories are Building Improvement, Literature & Archive, Utility Bills, Professional Services and Software/IT.\n",
|
"The five categories are Building Improvement, Literature & Archive, Utility Bills, Professional Services and Software/IT.\n",
|
||||||
" If you can't tell what it is, say Could not classify\n",
|
"If you can't tell what it is, say Could not classify\n",
|
||||||
" \n",
|
" \n",
|
||||||
" Transaction:\n",
|
"Transaction:\n",
|
||||||
" \n",
|
" \n",
|
||||||
" Supplier: SUPPLIER_NAME\n",
|
"Supplier: SUPPLIER_NAME\n",
|
||||||
" Description: DESCRIPTION_TEXT\n",
|
"Description: DESCRIPTION_TEXT\n",
|
||||||
" Value: TRANSACTION_VALUE\n",
|
"Value: TRANSACTION_VALUE\n",
|
||||||
" \n",
|
" \n",
|
||||||
" \n",
|
"The classification is:'''"
|
||||||
" The classification is:'''"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
1
examples/helpers.py
Normal file
1
examples/helpers.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
OPENAI_API_KEY="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"
|
Loading…
x
Reference in New Issue
Block a user