Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@brockmanmatt
Created August 6, 2020 07:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save brockmanmatt/f2af760dc2ab3934a2316a95c6202cf8 to your computer and use it in GitHub Desktop.
Save brockmanmatt/f2af760dc2ab3934a2316a95c6202cf8 to your computer and use it in GitHub Desktop.
Analogies.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "Analogies.ipynb",
"provenance": [],
"collapsed_sections": [],
"authorship_tag": "ABX9TyN/a9kQjVAYvpsghTukhSEz",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/brockmanmatt/f2af760dc2ab3934a2316a95c6202cf8/analogies.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "code",
"metadata": {
"id": "J7wnsgT2kPut",
"colab_type": "code",
"colab": {
"resources": {
"http://localhost:8080/nbextensions/google.colab/files.js": {
"data": "Ly8gQ29weXJpZ2h0IDIwMTcgR29vZ2xlIExMQwovLwovLyBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKLy8geW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgovLyBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb2YgdGhlIExpY2Vuc2UgYXQKLy8KLy8gICAgICBodHRwOi8vd3d3LmFwYWNoZS5vcmcvbGljZW5zZXMvTElDRU5TRS0yLjAKLy8KLy8gVW5sZXNzIHJlcXVpcmVkIGJ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GIvNjIxMTU2NjAuCiAgICBsZXQgcG9zaXRpb24gPSAwOwogICAgd2hpbGUgKHBvc2l0aW9uIDwgZmlsZURhdGEuYnl0ZUxlbmd0aCkgewogICAgICBjb25zdCBsZW5ndGggPSBNYXRoLm1pbihmaWxlRGF0YS5ieXRlTGVuZ3RoIC0gcG9zaXRpb24sIE1BWF9QQVlMT0FEX1NJWkUpOwogICAgICBjb25zdCBjaHVuayA9IG5ldyBVaW50OEFycmF5KGZpbGVEYXRhLCBwb3NpdGlvbiwgbGVuZ3RoKTsKICAgICAgcG9zaXRpb24gKz0gbGVuZ3RoOwoKICAgICAgY29uc3QgYmFzZTY0ID0gYnRvYShTdHJpbmcuZnJvbUNoYXJDb2RlLmFwcGx5KG51bGwsIGNodW5rKSk7CiAgICAgIHlpZWxkIHsKICAgICAgICByZXNwb25zZTogewogICAgICAgICAgYWN0aW9uOiAnYXBwZW5kJywKICAgICAgICAgIGZpbGU6IGZpbGUubmFtZSwKICAgICAgICAgIGRhdGE6IGJhc2U2NCwKICAgICAgICB9LAogICAgICB9OwogICAgICBwZXJjZW50LnRleHRDb250ZW50ID0KICAgICAgICAgIGAke01hdGgucm91bmQoKHBvc2l0aW9uIC8gZmlsZURhdGEuYnl0ZUxlbmd0aCkgKiAxMDApfSUgZG9uZWA7CiAgICB9CiAgfQoKICAvLyBBbGwgZG9uZS4KICB5aWVsZCB7CiAgICByZXNwb25zZTogewogICAgICBhY3Rpb246ICdjb21wbGV0ZScsCiAgICB9CiAgfTsKfQoKc2NvcGUuZ29vZ2xlID0gc2NvcGUuZ29vZ2xlIHx8IHt9OwpzY29wZS5nb29nbGUuY29sYWIgPSBzY29wZS5nb29nbGUuY29sYWIgfHwge307CnNjb3BlLmdvb2dsZS5jb2xhYi5fZmlsZXMgPSB7CiAgX3VwbG9hZEZpbGVzLAogIF91cGxvYWRGaWxlc0NvbnRpbnVlLAp9Owp9KShzZWxmKTsK",
"ok": true,
"headers": [
[
"content-type",
"application/javascript"
]
],
"status": 200,
"status_text": ""
}
},
"base_uri": "https://localhost:8080/",
"height": 89
},
"outputId": "8a1b5c3f-86ed-4080-9b3e-9f8abaaccb86"
},
"source": [
"from google.colab import files\n",
"uploaded = files.upload()\n",
"print(\"done\")"
],
"execution_count": 1,
"outputs": [
{
"output_type": "display_data",
"data": {
"text/html": [
"\n",
" <input type=\"file\" id=\"files-76d15472-a064-4016-96ed-fb7946939966\" name=\"files[]\" multiple disabled\n",
" style=\"border:none\" />\n",
" <output id=\"result-76d15472-a064-4016-96ed-fb7946939966\">\n",
" Upload widget is only available when the cell has been executed in the\n",
" current browser session. Please rerun this cell to enable.\n",
" </output>\n",
" <script src=\"/nbextensions/google.colab/files.js\"></script> "
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"Saving key.json to key.json\n",
"done\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "WHPHrUnhpKnI",
"colab_type": "text"
},
"source": [
"I'll install the API"
]
},
{
"cell_type": "code",
"metadata": {
"id": "zq0ltp2xn4yt",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 292
},
"outputId": "6438285d-c40b-454a-ee10-9df4441dab95"
},
"source": [
"!pip install openai\n",
"import openai, json, pandas as pd"
],
"execution_count": 2,
"outputs": [
{
"output_type": "stream",
"text": [
"Collecting openai\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/a8/65/c7461f4c87984534683f480ea5742777bc39bbf5721123194c2d0347dc1f/openai-0.2.4.tar.gz (157kB)\n",
"\u001b[K |████████████████████████████████| 163kB 2.7MB/s \n",
"\u001b[?25hRequirement already satisfied: requests>=2.20 in /usr/local/lib/python3.6/dist-packages (from openai) (2.23.0)\n",
"Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.6/dist-packages (from requests>=2.20->openai) (2.10)\n",
"Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.6/dist-packages (from requests>=2.20->openai) (3.0.4)\n",
"Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.6/dist-packages (from requests>=2.20->openai) (1.24.3)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.6/dist-packages (from requests>=2.20->openai) (2020.6.20)\n",
"Building wheels for collected packages: openai\n",
" Building wheel for openai (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
" Created wheel for openai: filename=openai-0.2.4-cp36-none-any.whl size=170709 sha256=ccc21453b511b19483293eec468e3c5f89c1a2cc20ba85bf1066aaf855476230\n",
" Stored in directory: /root/.cache/pip/wheels/74/96/c8/c6e170929c276b836613e1b9985343b501fe455e53d85e7d48\n",
"Successfully built openai\n",
"Installing collected packages: openai\n",
"Successfully installed openai-0.2.4\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "Q2yE0jcnpMEV",
"colab_type": "text"
},
"source": [
"Loading in key.json that I uploaded; I do this so I don't need to worry about accidently leaking creds if I share the colab (which I'm 99% sure is just a json file that won't expose them)"
]
},
{
"cell_type": "code",
"metadata": {
"id": "bwNXXwHen5x9",
"colab_type": "code",
"colab": {}
},
"source": [
"openai.api_key = json.load(open(\"key.json\", \"r\"))[\"key\"]"
],
"execution_count": 3,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "k67w5H0fpTkT",
"colab_type": "text"
},
"source": [
"Default keyword arguments to pass the aPI"
]
},
{
"cell_type": "code",
"metadata": {
"id": "e1EwpqqJkTYh",
"colab_type": "code",
"colab": {}
},
"source": [
"#arguments to send the API\n",
"kwargs = {\n",
"\"engine\":\"davinci\",\n",
"\"temperature\":0,\n",
"\"max_tokens\":50,\n",
"\"stop\":\"\\n\",\n",
"}"
],
"execution_count": 5,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "zZubgPoOpWDH",
"colab_type": "text"
},
"source": [
"Quick wrapper to automatically save prompts and responses sent for later analysis if needed"
]
},
{
"cell_type": "code",
"metadata": {
"id": "sXTDJx0An9Bl",
"colab_type": "code",
"colab": {}
},
"source": [
"import datetime\n",
"def query(prompt, myKwargs = kwargs):\n",
" \"\"\"\n",
" wrapper for the API to save the prompt and the result\n",
" \"\"\"\n",
"\n",
" r = openai.Completion.create(prompt=prompt, **myKwargs)[\"choices\"][0][\"text\"].strip()\n",
" with open(\"{}.json\".format(datetime.datetime.now().strftime(\"%Y%m%d%s\")), \"w\") as fh:\n",
" json.dump({\"prompt\":prompt, \"response\":r}, fh, indent=4)\n",
" return r"
],
"execution_count": 6,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "EdFXafcJpZ3Q",
"colab_type": "text"
},
"source": [
"Test to make sure my query works"
]
},
{
"cell_type": "code",
"metadata": {
"id": "4SlyKgjyopPn",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 35
},
"outputId": "0d7da33f-e09f-4e1b-fa0d-18b442349a37"
},
"source": [
"newKwargs = kwargs.copy()\n",
"newKwargs[\"stop\"] = \"\\n\"\n",
"query(\"q: what is 1+1?\\na:\", newKwargs)"
],
"execution_count": 7,
"outputs": [
{
"output_type": "execute_result",
"data": {
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
},
"text/plain": [
"'2'"
]
},
"metadata": {
"tags": []
},
"execution_count": 7
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "SP31SCu8foFK",
"colab_type": "code",
"colab": {}
},
"source": [
"prompt = \"A duck is to a lake as a dog is to a park\\n\""
],
"execution_count": 8,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "pECOCMczfwOX",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 35
},
"outputId": "cfec0d8e-47ac-491a-b81d-d86e12d5e043"
},
"source": [
"query(prompt + \"A turtle is to a shell as a knight is\")"
],
"execution_count": 9,
"outputs": [
{
"output_type": "execute_result",
"data": {
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
},
"text/plain": [
"'to a horse'"
]
},
"metadata": {
"tags": []
},
"execution_count": 9
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "80aaLxhhf36I",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 35
},
"outputId": "d9d50acd-e5ba-422b-f7fc-064cfa3b4f15"
},
"source": [
"query(prompt + \"A turtle is to a shell as a knife is\")"
],
"execution_count": 10,
"outputs": [
{
"output_type": "execute_result",
"data": {
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
},
"text/plain": [
"'to a box'"
]
},
"metadata": {
"tags": []
},
"execution_count": 10
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "HXyHj3DOf9n2",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 35
},
"outputId": "02492df6-4d4b-4bc3-bd57-77ae18c34680"
},
"source": [
"query(prompt + \"A king is to a man as a queen is\")"
],
"execution_count": 11,
"outputs": [
{
"output_type": "execute_result",
"data": {
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
},
"text/plain": [
"'to a woman'"
]
},
"metadata": {
"tags": []
},
"execution_count": 11
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "iVly2s0hgFE5",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 35
},
"outputId": "4c5c0545-fc7e-43ec-fd7c-80183165b0f7"
},
"source": [
"query(prompt + \"A hand is to an arm as a foot is\")"
],
"execution_count": 12,
"outputs": [
{
"output_type": "execute_result",
"data": {
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
},
"text/plain": [
"'to a leg'"
]
},
"metadata": {
"tags": []
},
"execution_count": 12
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "c9GOiyrigPPy",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 35
},
"outputId": "639200c8-15dd-4302-e93e-ef559b55c4d6"
},
"source": [
"query(prompt + \"A turtle is to a shell as a car is\")"
],
"execution_count": 13,
"outputs": [
{
"output_type": "execute_result",
"data": {
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
},
"text/plain": [
"'to a garage'"
]
},
"metadata": {
"tags": []
},
"execution_count": 13
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "Hc3vn7orgd2-",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 35
},
"outputId": "c265c267-ca53-4970-e6d8-8bb97f816870"
},
"source": [
"query(prompt + \"A train is to tracks as a car is\")"
],
"execution_count": 14,
"outputs": [
{
"output_type": "execute_result",
"data": {
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
},
"text/plain": [
"'to a road'"
]
},
"metadata": {
"tags": []
},
"execution_count": 14
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "NKC3a_CZgrK4",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 35
},
"outputId": "1e3cc422-8fd5-4113-dc14-f3fc4aae3bb0"
},
"source": [
"query(prompt + \"A train is to tracks as a computer is\")"
],
"execution_count": 15,
"outputs": [
{
"output_type": "execute_result",
"data": {
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
},
"text/plain": [
"'to a mouse'"
]
},
"metadata": {
"tags": []
},
"execution_count": 15
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "-9RG3yxDgsiw",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 35
},
"outputId": "150e4e55-05ae-4c3c-96de-393f6b2fa5e6"
},
"source": [
"query(prompt + \"A train is to tracks as a keyboard is\")"
],
"execution_count": 16,
"outputs": [
{
"output_type": "execute_result",
"data": {
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
},
"text/plain": [
"'to a computer'"
]
},
"metadata": {
"tags": []
},
"execution_count": 16
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "IDcEI3OEgu8l",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 35
},
"outputId": "a5d463e6-32bb-4002-cdb5-62aeaf2346cc"
},
"source": [
"query(prompt + \"A train is to tracks as a spaceship is\")"
],
"execution_count": 17,
"outputs": [
{
"output_type": "execute_result",
"data": {
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
},
"text/plain": [
"'to a runway'"
]
},
"metadata": {
"tags": []
},
"execution_count": 17
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "6eZtoyaBgxhR",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 35
},
"outputId": "03e29d73-fb3a-4de6-ac7e-f1e3c650a6c7"
},
"source": [
"query(prompt + \"A train is to tracks as an x-wing is\")"
],
"execution_count": 18,
"outputs": [
{
"output_type": "execute_result",
"data": {
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
},
"text/plain": [
"'to a trench'"
]
},
"metadata": {
"tags": []
},
"execution_count": 18
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "9IEziVYkgzfL",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 35
},
"outputId": "2c628faf-4ce9-4ff6-b86a-5cfcee3e92eb"
},
"source": [
"query(prompt + \"A train is to tracks as a tie fighter is\")"
],
"execution_count": 19,
"outputs": [
{
"output_type": "execute_result",
"data": {
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
},
"text/plain": [
"'to a star destroyer'"
]
},
"metadata": {
"tags": []
},
"execution_count": 19
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "ylRcoYEug4me",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 35
},
"outputId": "12156c6e-9824-4d06-f0f5-7c1db1e25209"
},
"source": [
"query(prompt + \"A train is to tracks as a jedi is\")"
],
"execution_count": 20,
"outputs": [
{
"output_type": "execute_result",
"data": {
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
},
"text/plain": [
"'to a lightsaber'"
]
},
"metadata": {
"tags": []
},
"execution_count": 20
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "TR21WfJOhOUL",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 35
},
"outputId": "cda18ef2-f44f-48f0-b929-ab8a2d81eb28"
},
"source": [
"query(prompt + \"A train is to tracks as a sith is\")"
],
"execution_count": 21,
"outputs": [
{
"output_type": "execute_result",
"data": {
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
},
"text/plain": [
"'to a lightsaber'"
]
},
"metadata": {
"tags": []
},
"execution_count": 21
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "vs4H6XvlhQPC",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 35
},
"outputId": "51f6f742-76ab-4771-f69a-db315a3b9272"
},
"source": [
"query(prompt + \"A train is to tracks as a battleship is\")"
],
"execution_count": 22,
"outputs": [
{
"output_type": "execute_result",
"data": {
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
},
"text/plain": [
"'to a harbor'"
]
},
"metadata": {
"tags": []
},
"execution_count": 22
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "d4OimGw6hSch",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 35
},
"outputId": "c7b8002f-9732-497f-ac17-6b5993544898"
},
"source": [
"query(\"Life is like a box of chocolates, you never know which you're going to get\\nAn x-wing is like\")"
],
"execution_count": 23,
"outputs": [
{
"output_type": "execute_result",
"data": {
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
},
"text/plain": [
"\"a shark, it's got a lot of teeth, and it's really hard to stop\""
]
},
"metadata": {
"tags": []
},
"execution_count": 23
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "vvcbMRoiheI8",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 35
},
"outputId": "37cf1d5f-aea7-4621-85b2-ced622f4afa4"
},
"source": [
"query(\"Life is like a box of chocolates, you never know which you're going to get\\nA tie fighter is like\")"
],
"execution_count": 25,
"outputs": [
{
"output_type": "execute_result",
"data": {
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
},
"text/plain": [
"'a shark, it has to keep moving or it dies'"
]
},
"metadata": {
"tags": []
},
"execution_count": 25
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "QgzL8zl2hg-b",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 35
},
"outputId": "68e364ba-926f-49bf-aec3-ff34558a1fe6"
},
"source": [
"query(\"Life is like a box of chocolates, you never know which you're going to get\\nAn x-wing is like\", myKwargs={\"engine\":\"davinci\", \"temperature\":.25, \"stop\":\"\\n\", \"max_tokens\":50})"
],
"execution_count": 28,
"outputs": [
{
"output_type": "execute_result",
"data": {
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
},
"text/plain": [
"\"a shark, it's got laser beams attached to its head\""
]
},
"metadata": {
"tags": []
},
"execution_count": 28
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "N_Jxa7Yghu11",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 35
},
"outputId": "da3c8fa2-ef68-479e-e2e2-6aa8c6a0015b"
},
"source": [
"query(\"Life is like a box of chocolates, you never know which you're going to get\\nAn x-wing is like\", myKwargs={\"engine\":\"davinci\", \"temperature\":.25, \"stop\":\"\\n\", \"max_tokens\":50})"
],
"execution_count": 29,
"outputs": [
{
"output_type": "execute_result",
"data": {
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
},
"text/plain": [
"\"a y-wing, only it's better\""
]
},
"metadata": {
"tags": []
},
"execution_count": 29
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "eROnUch5h5K0",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 35
},
"outputId": "ded60db7-3795-4487-9a2c-8d899f1efa05"
},
"source": [
"query(\"Life is like a box of chocolates, you never know which you're going to get\\nAn x-wing is like\", myKwargs={\"engine\":\"davinci\", \"temperature\":.5, \"stop\":\"\\n\", \"max_tokens\":50})"
],
"execution_count": 32,
"outputs": [
{
"output_type": "execute_result",
"data": {
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
},
"text/plain": [
"'a miniture TIE fighter, but with x-shaped wings.'"
]
},
"metadata": {
"tags": []
},
"execution_count": 32
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "RVylElfXh6R4",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 35
},
"outputId": "3eaf0864-73e0-4924-b3fc-04d9d097e932"
},
"source": [
"query(\"Life is like a box of chocolates, you never know which you're going to get\\nAn x-wing is like\", myKwargs={\"engine\":\"davinci\", \"temperature\":.5, \"stop\":\"\\n\", \"max_tokens\":50})"
],
"execution_count": 33,
"outputs": [
{
"output_type": "execute_result",
"data": {
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
},
"text/plain": [
"\"a vampire, it's best to shoot it in the face while it's still being developed\""
]
},
"metadata": {
"tags": []
},
"execution_count": 33
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "AxsAv6HGiA19",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 35
},
"outputId": "4db51ac2-3974-412b-9750-3c922e6de0d6"
},
"source": [
"query(\"Life is like a box of chocolates, you never know which you're going to get\\nA tie-fighter is like\", myKwargs={\"engine\":\"davinci\", \"temperature\":.5, \"stop\":\"\\n\", \"max_tokens\":50})"
],
"execution_count": 39,
"outputs": [
{
"output_type": "execute_result",
"data": {
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
},
"text/plain": [
"\"a mosquito. No matter how many you kill, there's always more\""
]
},
"metadata": {
"tags": []
},
"execution_count": 39
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "_ufEs6P0iDJf",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 34
},
"outputId": "af0493e0-76bf-476f-f1f4-313939cc425c"
},
"source": [
"print(\"A tie-fighter is like \" +query(\"Analogies:\\nLife is like a box of chocolates, you never know which you're going to get\\nA tie-fighter is like\", myKwargs={\"engine\":\"davinci\", \"temperature\":.5, \"stop\":\"\\n\", \"max_tokens\":50}))"
],
"execution_count": 43,
"outputs": [
{
"output_type": "stream",
"text": [
"A tie-fighter is like a baby's diaper, it's not made to look pretty, it's made to do it's job.\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "Vf1CAx7HifaH",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 34
},
"outputId": "be5f9e1e-da2a-41e1-9f7e-30ac7f38398d"
},
"source": [
"print(\"A tie-fighter is like \" +query(\"Analogies:\\nLife is like a box of chocolates, you never know which you're going to get\\nA tie-fighter is like\", myKwargs={\"engine\":\"davinci\", \"temperature\":.5, \"stop\":\"\\n\", \"max_tokens\":50}))"
],
"execution_count": 44,
"outputs": [
{
"output_type": "stream",
"text": [
"A tie-fighter is like a shark, it has a front fin and a back fin\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "OBDXp8O6imJ7",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 34
},
"outputId": "de64db2c-4f97-41de-813d-1d180a80d61d"
},
"source": [
"print(\"An x-wing is like \" +query(\"Analogies:\\nLife is like a box of chocolates, you never know which you're going to get\\nAn x-wing is like\", myKwargs={\"engine\":\"davinci\", \"temperature\":.5, \"stop\":\"\\n\", \"max_tokens\":50}))"
],
"execution_count": 46,
"outputs": [
{
"output_type": "stream",
"text": [
"An x-wing is like a swiss army knife, it's a tool for many jobs\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "XxK9pYPPipE0",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 34
},
"outputId": "3d0e3aa4-8e18-4dd2-88ef-15f562c98bf8"
},
"source": [
"print(\"An x-wing is like \" +query(\"Silly Analogies:\\nLife is like a box of chocolates, you never know which you're going to get!\\nAn x-wing is like\", myKwargs={\"engine\":\"davinci\", \"temperature\":1, \"stop\":\"\\n\", \"max_tokens\":50}))"
],
"execution_count": 50,
"outputs": [
{
"output_type": "stream",
"text": [
"An x-wing is like a black hole, it's fierce to encounter!\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "pzZzAbtGi0EX",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 34
},
"outputId": "c4f5bda8-91f4-4909-b35b-756c07f11266"
},
"source": [
"print(\"An x-wing is like \" +query(\"Wise Analogies:\\nLife is like a box of chocolates, you never know which you're going to get!\\nAn x-wing is like\", myKwargs={\"engine\":\"davinci\", \"temperature\":1, \"stop\":\"\\n\", \"max_tokens\":50}))"
],
"execution_count": 53,
"outputs": [
{
"output_type": "stream",
"text": [
"An x-wing is like a puppy, highly efficient, but also a bit annoying.\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "2K7bILFyi1JQ",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 34
},
"outputId": "aab8c367-2b45-4fe1-db86-d3561f5c75db"
},
"source": [
"print(\"An x-wing is like \" +query(\"Wise Analogies:\\nLife is like a box of chocolates, you never know which you're going to get!\\nAn x-wing is like\", myKwargs={\"engine\":\"davinci\", \"temperature\":1, \"stop\":\"\\n\", \"max_tokens\":50}))"
],
"execution_count": 54,
"outputs": [
{
"output_type": "stream",
"text": [
"An x-wing is like a violin solo; No one can follow an x-wing!\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "qFCbZyaKjMhw",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 207
},
"outputId": "9ddd9178-416a-43e9-e05d-3a887a1e5f14"
},
"source": [
"for i in range(10):\n",
" print(\"An x-wing is like \" +query(\"Witty Analogies:\\nLife is like a box of chocolates, you never know which you're going to get!\\nAn x-wing is like\", myKwargs={\"engine\":\"davinci\", \"temperature\":.5, \"stop\":\"\\n\", \"max_tokens\":50}))"
],
"execution_count": 64,
"outputs": [
{
"output_type": "stream",
"text": [
"An x-wing is like a shark. It can be stopped, but it will keep coming back.\n",
"An x-wing is like a bee: it can sting you and it can fly, but it has no balls.\n",
"An x-wing is like a bee, it can sting, but it can't fly.\n",
"An x-wing is like a woman, it can make you feel like a kid again.\n",
"An x-wing is like a mosquito. It's a lot more dangerous than it looks.\n",
"An x-wing is like a really good looking guy with a really small...\n",
"An x-wing is like a bowtie.\n",
"An x-wing is like a shark, it's a fish with a machine gun attached to it.\n",
"An x-wing is like a sewing machine. It's not a very good machine, but if you stick a lightsaber in it, it's amazing.\n",
"An x-wing is like a razor. It's a lot less fun when you can't use it to shave.\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "NH91CQzli4Fc",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 207
},
"outputId": "a894af6f-d074-4ae7-cacc-bfa95ac5ef10"
},
"source": [
"for i in range(10):\n",
" print(\"An x-wing is like \" +query(\"Wise Analogies:\\nLife is like a box of chocolates, you never know which you're going to get!\\nAn x-wing is like\", myKwargs={\"engine\":\"davinci\", \"temperature\":1, \"stop\":\"\\n\", \"max_tokens\":50}))"
],
"execution_count": 62,
"outputs": [
{
"output_type": "stream",
"text": [
"An x-wing is like a large throw pillow.\n",
"An x-wing is like torrential rain, it will screw you up.\n",
"An x-wing is like a liquified moon you mentally carry around in your pocket.\n",
"An x-wing is like a regular Burger, but with missiles!\n",
"An x-wing is like Amazon.com, you never know where to go next!\n",
"An x-wing is like a swiss army knife, it can do many things, but not as well as a purpose built tool!\n",
"An x-wing is like a syringe · Does that make the Millennium Falcon a turkey baster?\n",
"An x-wing is like an addition, sum or difference of two vectors which may be algebraically expressed in either scalar or vector form\n",
"An x-wing is like a swan boat in a tornado.\n",
"An x-wing is like a main battle tank in World War II--two track run, battle-proven, and built to kill people and blow s*** up.\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "OzcfJkYTi5br",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 187
},
"outputId": "699176ec-aeed-4376-8d23-8717e890a110"
},
"source": [
"for i in range(10):\n",
" print(\"A tie fighter is like \" +query(\"Snappy Analogies:\\nLife is like a box of chocolates, you never know which you're going to get!\\nA tie fighter is like\", myKwargs={\"engine\":\"davinci\", \"temperature\":.7, \"stop\":\"\\n\", \"max_tokens\":50}))"
],
"execution_count": 70,
"outputs": [
{
"output_type": "stream",
"text": [
"A tie fighter is like a sandwich, it has a lot of layers but is ultimately quite pointless.\n",
"A tie fighter is like a TIE fighter that got run over by a Tie fighter.\n",
"A tie fighter is like a balloon without a string.\n",
"A tie fighter is like a guillotine, it may look cool but it's going to chop your head off!\n",
"A tie fighter is like a missile with a man in it.\n",
"A tie fighter is like a mosquito. It can be annoying, but is completely harmless.\n",
"A tie fighter is like a very slow, poorly maneuverable X-wing.\n",
"A tie fighter is like a toy spaceship because they are both small and they both have lights.\n",
"A tie fighter is like a coin, it's either heads or tails!\n",
"A tie fighter is like a fork in the garbage disposal.\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "JL8F-KkLjBoM",
"colab_type": "code",
"colab": {}
},
"source": [
""
],
"execution_count": null,
"outputs": []
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment