Switch to side-by-side view

--- a
+++ b/development/qa-server/compare_similarity.ipynb
@@ -0,0 +1,1945 @@
+{
+  "nbformat": 4,
+  "nbformat_minor": 0,
+  "metadata": {
+    "colab": {
+      "name": "compare_similarity.ipynb",
+      "provenance": [],
+      "collapsed_sections": []
+    },
+    "kernelspec": {
+      "display_name": "Python 3",
+      "name": "python3"
+    },
+    "language_info": {
+      "name": "python"
+    }
+  },
+  "cells": [
+    {
+      "cell_type": "code",
+      "metadata": {
+        "colab": {
+          "base_uri": "https://localhost:8080/"
+        },
+        "id": "An5AysOmAscS",
+        "outputId": "45878ec5-3021-4951-f72e-3e2bbab74eee"
+      },
+      "source": [
+        "!pip install transformers[sentencepiece] spacy rouge"
+      ],
+      "execution_count": null,
+      "outputs": [
+        {
+          "output_type": "stream",
+          "name": "stdout",
+          "text": [
+            "Requirement already satisfied: transformers[sentencepiece] in /usr/local/lib/python3.7/dist-packages (4.10.2)\n",
+            "Requirement already satisfied: spacy in /usr/local/lib/python3.7/dist-packages (2.2.4)\n",
+            "Requirement already satisfied: rouge in /usr/local/lib/python3.7/dist-packages (1.0.1)\n",
+            "Requirement already satisfied: tqdm<5.0.0,>=4.38.0 in /usr/local/lib/python3.7/dist-packages (from spacy) (4.62.0)\n",
+            "Requirement already satisfied: preshed<3.1.0,>=3.0.2 in /usr/local/lib/python3.7/dist-packages (from spacy) (3.0.5)\n",
+            "Requirement already satisfied: requests<3.0.0,>=2.13.0 in /usr/local/lib/python3.7/dist-packages (from spacy) (2.23.0)\n",
+            "Requirement already satisfied: numpy>=1.15.0 in /usr/local/lib/python3.7/dist-packages (from spacy) (1.19.5)\n",
+            "Requirement already satisfied: thinc==7.4.0 in /usr/local/lib/python3.7/dist-packages (from spacy) (7.4.0)\n",
+            "Requirement already satisfied: cymem<2.1.0,>=2.0.2 in /usr/local/lib/python3.7/dist-packages (from spacy) (2.0.5)\n",
+            "Requirement already satisfied: blis<0.5.0,>=0.4.0 in /usr/local/lib/python3.7/dist-packages (from spacy) (0.4.1)\n",
+            "Requirement already satisfied: wasabi<1.1.0,>=0.4.0 in /usr/local/lib/python3.7/dist-packages (from spacy) (0.8.2)\n",
+            "Requirement already satisfied: plac<1.2.0,>=0.9.6 in /usr/local/lib/python3.7/dist-packages (from spacy) (1.1.3)\n",
+            "Requirement already satisfied: srsly<1.1.0,>=1.0.2 in /usr/local/lib/python3.7/dist-packages (from spacy) (1.0.5)\n",
+            "Requirement already satisfied: catalogue<1.1.0,>=0.0.7 in /usr/local/lib/python3.7/dist-packages (from spacy) (1.0.0)\n",
+            "Requirement already satisfied: setuptools in /usr/local/lib/python3.7/dist-packages (from spacy) (57.4.0)\n",
+            "Requirement already satisfied: murmurhash<1.1.0,>=0.28.0 in /usr/local/lib/python3.7/dist-packages (from spacy) (1.0.5)\n",
+            "Requirement already satisfied: importlib-metadata>=0.20 in /usr/local/lib/python3.7/dist-packages (from catalogue<1.1.0,>=0.0.7->spacy) (4.6.4)\n",
+            "Requirement already satisfied: typing-extensions>=3.6.4 in /usr/local/lib/python3.7/dist-packages (from importlib-metadata>=0.20->catalogue<1.1.0,>=0.0.7->spacy) (3.7.4.3)\n",
+            "Requirement already satisfied: zipp>=0.5 in /usr/local/lib/python3.7/dist-packages (from importlib-metadata>=0.20->catalogue<1.1.0,>=0.0.7->spacy) (3.5.0)\n",
+            "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.7/dist-packages (from requests<3.0.0,>=2.13.0->spacy) (2021.5.30)\n",
+            "Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.7/dist-packages (from requests<3.0.0,>=2.13.0->spacy) (3.0.4)\n",
+            "Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.7/dist-packages (from requests<3.0.0,>=2.13.0->spacy) (1.24.3)\n",
+            "Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.7/dist-packages (from requests<3.0.0,>=2.13.0->spacy) (2.10)\n",
+            "Requirement already satisfied: six in /usr/local/lib/python3.7/dist-packages (from rouge) (1.15.0)\n",
+            "Requirement already satisfied: huggingface-hub>=0.0.12 in /usr/local/lib/python3.7/dist-packages (from transformers[sentencepiece]) (0.0.16)\n",
+            "Requirement already satisfied: regex!=2019.12.17 in /usr/local/lib/python3.7/dist-packages (from transformers[sentencepiece]) (2019.12.20)\n",
+            "Requirement already satisfied: pyyaml>=5.1 in /usr/local/lib/python3.7/dist-packages (from transformers[sentencepiece]) (5.4.1)\n",
+            "Requirement already satisfied: packaging in /usr/local/lib/python3.7/dist-packages (from transformers[sentencepiece]) (21.0)\n",
+            "Requirement already satisfied: tokenizers<0.11,>=0.10.1 in /usr/local/lib/python3.7/dist-packages (from transformers[sentencepiece]) (0.10.3)\n",
+            "Requirement already satisfied: filelock in /usr/local/lib/python3.7/dist-packages (from transformers[sentencepiece]) (3.0.12)\n",
+            "Requirement already satisfied: sacremoses in /usr/local/lib/python3.7/dist-packages (from transformers[sentencepiece]) (0.0.45)\n",
+            "Requirement already satisfied: protobuf in /usr/local/lib/python3.7/dist-packages (from transformers[sentencepiece]) (3.17.3)\n",
+            "Requirement already satisfied: sentencepiece==0.1.91 in /usr/local/lib/python3.7/dist-packages (from transformers[sentencepiece]) (0.1.91)\n",
+            "Requirement already satisfied: pyparsing>=2.0.2 in /usr/local/lib/python3.7/dist-packages (from packaging->transformers[sentencepiece]) (2.4.7)\n",
+            "Requirement already satisfied: joblib in /usr/local/lib/python3.7/dist-packages (from sacremoses->transformers[sentencepiece]) (1.0.1)\n",
+            "Requirement already satisfied: click in /usr/local/lib/python3.7/dist-packages (from sacremoses->transformers[sentencepiece]) (7.1.2)\n"
+          ]
+        }
+      ]
+    },
+    {
+      "cell_type": "code",
+      "metadata": {
+        "colab": {
+          "base_uri": "https://localhost:8080/"
+        },
+        "id": "dB_NRWSrUksI",
+        "outputId": "a477b700-1d85-4e8f-b936-f94d999c4779"
+      },
+      "source": [
+        "!python -m spacy download en_core_web_lg"
+      ],
+      "execution_count": null,
+      "outputs": [
+        {
+          "output_type": "stream",
+          "name": "stdout",
+          "text": [
+            "Collecting en_core_web_lg==2.2.5\n",
+            "  Downloading https://github.com/explosion/spacy-models/releases/download/en_core_web_lg-2.2.5/en_core_web_lg-2.2.5.tar.gz (827.9 MB)\n",
+            "\u001b[K     |████████████████████████████████| 827.9 MB 1.4 MB/s \n",
+            "\u001b[?25hRequirement already satisfied: spacy>=2.2.2 in /usr/local/lib/python3.7/dist-packages (from en_core_web_lg==2.2.5) (2.2.4)\n",
+            "Requirement already satisfied: blis<0.5.0,>=0.4.0 in /usr/local/lib/python3.7/dist-packages (from spacy>=2.2.2->en_core_web_lg==2.2.5) (0.4.1)\n",
+            "Requirement already satisfied: cymem<2.1.0,>=2.0.2 in /usr/local/lib/python3.7/dist-packages (from spacy>=2.2.2->en_core_web_lg==2.2.5) (2.0.5)\n",
+            "Requirement already satisfied: murmurhash<1.1.0,>=0.28.0 in /usr/local/lib/python3.7/dist-packages (from spacy>=2.2.2->en_core_web_lg==2.2.5) (1.0.5)\n",
+            "Requirement already satisfied: catalogue<1.1.0,>=0.0.7 in /usr/local/lib/python3.7/dist-packages (from spacy>=2.2.2->en_core_web_lg==2.2.5) (1.0.0)\n",
+            "Requirement already satisfied: requests<3.0.0,>=2.13.0 in /usr/local/lib/python3.7/dist-packages (from spacy>=2.2.2->en_core_web_lg==2.2.5) (2.23.0)\n",
+            "Requirement already satisfied: thinc==7.4.0 in /usr/local/lib/python3.7/dist-packages (from spacy>=2.2.2->en_core_web_lg==2.2.5) (7.4.0)\n",
+            "Requirement already satisfied: plac<1.2.0,>=0.9.6 in /usr/local/lib/python3.7/dist-packages (from spacy>=2.2.2->en_core_web_lg==2.2.5) (1.1.3)\n",
+            "Requirement already satisfied: wasabi<1.1.0,>=0.4.0 in /usr/local/lib/python3.7/dist-packages (from spacy>=2.2.2->en_core_web_lg==2.2.5) (0.8.2)\n",
+            "Requirement already satisfied: tqdm<5.0.0,>=4.38.0 in /usr/local/lib/python3.7/dist-packages (from spacy>=2.2.2->en_core_web_lg==2.2.5) (4.62.0)\n",
+            "Requirement already satisfied: setuptools in /usr/local/lib/python3.7/dist-packages (from spacy>=2.2.2->en_core_web_lg==2.2.5) (57.4.0)\n",
+            "Requirement already satisfied: preshed<3.1.0,>=3.0.2 in /usr/local/lib/python3.7/dist-packages (from spacy>=2.2.2->en_core_web_lg==2.2.5) (3.0.5)\n",
+            "Requirement already satisfied: numpy>=1.15.0 in /usr/local/lib/python3.7/dist-packages (from spacy>=2.2.2->en_core_web_lg==2.2.5) (1.19.5)\n",
+            "Requirement already satisfied: srsly<1.1.0,>=1.0.2 in /usr/local/lib/python3.7/dist-packages (from spacy>=2.2.2->en_core_web_lg==2.2.5) (1.0.5)\n",
+            "Requirement already satisfied: importlib-metadata>=0.20 in /usr/local/lib/python3.7/dist-packages (from catalogue<1.1.0,>=0.0.7->spacy>=2.2.2->en_core_web_lg==2.2.5) (4.6.4)\n",
+            "Requirement already satisfied: zipp>=0.5 in /usr/local/lib/python3.7/dist-packages (from importlib-metadata>=0.20->catalogue<1.1.0,>=0.0.7->spacy>=2.2.2->en_core_web_lg==2.2.5) (3.5.0)\n",
+            "Requirement already satisfied: typing-extensions>=3.6.4 in /usr/local/lib/python3.7/dist-packages (from importlib-metadata>=0.20->catalogue<1.1.0,>=0.0.7->spacy>=2.2.2->en_core_web_lg==2.2.5) (3.7.4.3)\n",
+            "Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.7/dist-packages (from requests<3.0.0,>=2.13.0->spacy>=2.2.2->en_core_web_lg==2.2.5) (2.10)\n",
+            "Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.7/dist-packages (from requests<3.0.0,>=2.13.0->spacy>=2.2.2->en_core_web_lg==2.2.5) (3.0.4)\n",
+            "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.7/dist-packages (from requests<3.0.0,>=2.13.0->spacy>=2.2.2->en_core_web_lg==2.2.5) (2021.5.30)\n",
+            "Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.7/dist-packages (from requests<3.0.0,>=2.13.0->spacy>=2.2.2->en_core_web_lg==2.2.5) (1.24.3)\n",
+            "\u001b[38;5;2m✔ Download and installation successful\u001b[0m\n",
+            "You can now load the model via spacy.load('en_core_web_lg')\n"
+          ]
+        }
+      ]
+    },
+    {
+      "cell_type": "code",
+      "metadata": {
+        "id": "CMUTi3TlA0B6"
+      },
+      "source": [
+        "import torch\n",
+        "import re\n",
+        "import spacy\n",
+        "import pandas as pd\n",
+        "import nltk\n",
+        "import json\n",
+        "import en_core_web_lg\n",
+        "from rouge import Rouge \n",
+        "from nltk.translate.bleu_score import sentence_bleu, SmoothingFunction\n",
+        "from transformers import AutoModelForMaskedLM, AutoModel, AutoTokenizer, pipeline"
+      ],
+      "execution_count": null,
+      "outputs": []
+    },
+    {
+      "cell_type": "code",
+      "metadata": {
+        "colab": {
+          "base_uri": "https://localhost:8080/"
+        },
+        "id": "UmirCkCxUI-_",
+        "outputId": "a66cb8ab-c3f6-465c-a5f8-88aca347fb1b"
+      },
+      "source": [
+        "nlp = en_core_web_lg.load()\n",
+        "nltk.download('punkt')"
+      ],
+      "execution_count": null,
+      "outputs": [
+        {
+          "output_type": "stream",
+          "name": "stdout",
+          "text": [
+            "[nltk_data] Downloading package punkt to /root/nltk_data...\n",
+            "[nltk_data]   Package punkt is already up-to-date!\n"
+          ]
+        },
+        {
+          "output_type": "execute_result",
+          "data": {
+            "text/plain": [
+              "True"
+            ]
+          },
+          "metadata": {},
+          "execution_count": 4
+        }
+      ]
+    },
+    {
+      "cell_type": "code",
+      "metadata": {
+        "colab": {
+          "base_uri": "https://localhost:8080/"
+        },
+        "id": "IFZbbywB_Z3Q",
+        "outputId": "069aa0e1-6cb3-42e5-8a12-dc39e88b2591"
+      },
+      "source": [
+        "%cd drive/MyDrive/"
+      ],
+      "execution_count": null,
+      "outputs": [
+        {
+          "output_type": "stream",
+          "name": "stdout",
+          "text": [
+            "/content/drive/MyDrive\n"
+          ]
+        }
+      ]
+    },
+    {
+      "cell_type": "code",
+      "metadata": {
+        "colab": {
+          "base_uri": "https://localhost:8080/"
+        },
+        "id": "3i3Ecbe54kgy",
+        "outputId": "fd35014d-43c7-4d1e-d0a9-4e7e83cc432a"
+      },
+      "source": [
+        "!ls checkpoint-10000"
+      ],
+      "execution_count": null,
+      "outputs": [
+        {
+          "name": "stdout",
+          "output_type": "stream",
+          "text": [
+            "config.json\t   scheduler.pt\t\t    trainer_state.json\n",
+            "optimizer.pt\t   special_tokens_map.json  training_args.bin\n",
+            "pytorch_model.bin  tokenizer_config.json    vocab.txt\n",
+            "rng_state.pth\t   tokenizer.json\n"
+          ]
+        }
+      ]
+    },
+    {
+      "cell_type": "code",
+      "metadata": {
+        "colab": {
+          "base_uri": "https://localhost:8080/"
+        },
+        "id": "O2EzTL6iJ6vS",
+        "outputId": "0290f140-9fb6-4f0a-b3bf-10fbeb86c1ce"
+      },
+      "source": [
+        "!ls model/bert_med/checkpoint/checkpoint-final"
+      ],
+      "execution_count": null,
+      "outputs": [
+        {
+          "name": "stdout",
+          "output_type": "stream",
+          "text": [
+            "all_results.json   qa.json\t\t    trainer_state.json\n",
+            "config.json\t   special_tokens_map.json  training_args.bin\n",
+            "eval_results.json  tokenizer_config.json    train_results.json\n",
+            "pytorch_model.bin  tokenizer.json\t    vocab.txt\n"
+          ]
+        }
+      ]
+    },
+    {
+      "cell_type": "code",
+      "metadata": {
+        "id": "yAFHb0f1Amgf"
+      },
+      "source": [
+        "question = \"Can you give dosage information acetaminophen for children?\"\n",
+        "\n",
+        "reply = \"\"\"Use acetaminophen exactly as directed on the label, or as prescribed by your doctor. Do not use in larger or smaller amounts or for longer than recommended.\n",
+        "Do not take more of this medication than is recommended. An overdose of acetaminophen can damage your liver or cause death.\n",
+        "Adults and teenagers who weigh at least 110 pounds (50 kilograms): Do not take more than 1000 milligrams (mg) at one time. Do not take more than 4000 mg in 24 hours.\n",
+        "Children younger than 12 years old: Do not take more than 5 doses of acetaminophen in 24 hours. Use only the number of milligrams per dose that is recommended for the child's weight and age. Use exactly as directed on the label.\n",
+        "Avoid also using other medicines that contain acetaminophen, or you could have a fatal overdose.\n",
+        "If you are treating a child, use a pediatric form of acetaminophen. Use only the special dose-measuring dropper or oral syringe that comes with the specific pediatric form you are using. Carefully follow the dosing directions on the medicine label.\n",
+        "Measure liquid medicinewith the dosing syringe provided, or with a special dose-measuring spoon or medicine cup. If you do not have a dose-measuring device, ask your pharmacist for one.\n",
+        "Acetaminophen made for infants is available in two different dose concentrations, and each concentration comes with its own medicine dropper or oral syringe. These dosing devices are not equal between the different concentrations. Using the wrong device may cause you to give your child an overdose of acetaminophen. Never mix and match dosing devices between infant formulations of acetaminophen.\n",
+        "You may need to shake the liquid before each use. Follow the directions on the medicine label.\n",
+        "The chewable tablet must be chewed thoroughly before you swallow it.\n",
+        "Make sure your hands are dry when handling the acetaminophen disintegrating tablet. Place the tablet on your tongue. It will begin to dissolve right away. Do not swallow the tablet whole. Allow it to dissolve in your mouth without chewing.\n",
+        "To use the acetaminophen effervescent granules, dissolve one packet of the granules in at least 4 ounces of water. Stir this mixture and drink all of it right away. To make sure you get the entire dose, add a little more water to the same glass, swirl gently and drink right away.\n",
+        "The oral powder should be placed directly on the tongue and swallowed.\n",
+        "Stop taking acetaminophen and call your doctor if:\n",
+        "you still have a sore throat after 2 days of use;\n",
+        "you still have a fever after 3 days of use;\n",
+        "you still have pain after 7 days of use (or 5 days if treating a child);\n",
+        "you have a skin rash, ongoing headache, nausea, vomiting, or any redness or swelling; or\n",
+        "if your symptoms get worse, or if you have any new symptoms.\n",
+        "This medication can cause unusual results with certain lab tests for glucose (sugar) in the urine. Tell any doctor who treats you that you are using acetaminophen.\n",
+        "Store at room temperature away from heat and moisture.\n",
+        "Detailed Acetaminophen dosage information\n",
+        "What happens if I miss a dose?\n",
+        "Since acetaminophen is taken as needed, you may not be on a dosing schedule. If you are taking the medication regularly, take the missed dose as soon as you remember. Skip the missed dose if it is almost time for your next scheduled dose. Do not take extra medicine to make up the missed dose.\n",
+        "What happens if I overdose?\n",
+        "Seek emergency medical attention or call the Poison Help line at 1-800-222-1222. An overdose of acetaminophen can be fatal.\n",
+        "The first signs of an acetaminophen overdose include loss of appetite, nausea, vomiting, stomach pain, sweating, and confusion or weakness. Later symptoms may include pain in your upper stomach, dark urine, and yellowing of your skin or the whites of your eyes.\"\"\""
+      ],
+      "execution_count": null,
+      "outputs": []
+    },
+    {
+      "cell_type": "code",
+      "metadata": {
+        "id": "gRsgpQZqXJwa"
+      },
+      "source": [
+        "doc = nlp(reply)\n",
+        "labels = [str(sentence) for sentence in list(doc.sents)]\n",
+        "examples = [question]"
+      ],
+      "execution_count": null,
+      "outputs": []
+    },
+    {
+      "cell_type": "markdown",
+      "metadata": {
+        "id": "yHLnUWfFTEaL"
+      },
+      "source": [
+        "# Right answer\n",
+        "\n",
+        "Do not take more than 5 doses of acetaminophen in 24 hours. \n",
+        "\n",
+        "Use only the number of milligrams per dose that is recommended for the child's weight and age. \n",
+        "\n",
+        "Use exactly as directed on the label\n",
+        "\n",
+        "If you are treating a child, use a pediatric form of acetaminophen. \n",
+        "\n",
+        "Use only the special dose-measuring dropper or oral syringe that comes with the specific pediatric form you are using. \n",
+        "\n",
+        "Carefully follow the dosing directions on the medicine label.\n"
+      ]
+    },
+    {
+      "cell_type": "code",
+      "metadata": {
+        "colab": {
+          "base_uri": "https://localhost:8080/"
+        },
+        "id": "mT4UYuBVB3IN",
+        "outputId": "f0dee68e-c811-48dd-caa8-b132e7a39ba9"
+      },
+      "source": [
+        "model_name = './'\n",
+        "model = SentenceSimilarity(model_name)\n",
+        "model.compute_label_embedding(labels)"
+      ],
+      "execution_count": null,
+      "outputs": [
+        {
+          "name": "stderr",
+          "output_type": "stream",
+          "text": [
+            "Some weights of the model checkpoint at ./ were not used when initializing BertModel: ['cls.predictions.bias', 'cls.predictions.decoder.weight', 'cls.predictions.decoder.bias', 'cls.predictions.transform.dense.bias', 'cls.predictions.transform.LayerNorm.bias', 'cls.predictions.transform.LayerNorm.weight', 'cls.predictions.transform.dense.weight']\n",
+            "- This IS expected if you are initializing BertModel from the checkpoint of a model trained on another task or with another architecture (e.g. initializing a BertForSequenceClassification model from a BertForPreTraining model).\n",
+            "- This IS NOT expected if you are initializing BertModel from the checkpoint of a model that you expect to be exactly identical (initializing a BertForSequenceClassification model from a BertForSequenceClassification model).\n",
+            "Some weights of BertModel were not initialized from the model checkpoint at ./ and are newly initialized: ['bert.pooler.dense.weight', 'bert.pooler.dense.bias']\n",
+            "You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.\n"
+          ]
+        }
+      ]
+    },
+    {
+      "cell_type": "code",
+      "metadata": {
+        "colab": {
+          "base_uri": "https://localhost:8080/",
+          "height": 1000
+        },
+        "id": "Pyi1fitpBfRP",
+        "outputId": "df8eba4b-2e2c-4ed3-ddb2-1ef876a421a1"
+      },
+      "source": [
+        "s.reset_index().sort_values(by='Similarity', ascending=False).reset_index().drop('index', axis=1)"
+      ],
+      "execution_count": null,
+      "outputs": [
+        {
+          "data": {
+            "text/html": [
+              "<div>\n",
+              "<style scoped>\n",
+              "    .dataframe tbody tr th:only-of-type {\n",
+              "        vertical-align: middle;\n",
+              "    }\n",
+              "\n",
+              "    .dataframe tbody tr th {\n",
+              "        vertical-align: top;\n",
+              "    }\n",
+              "\n",
+              "    .dataframe thead th {\n",
+              "        text-align: right;\n",
+              "    }\n",
+              "</style>\n",
+              "<table border=\"1\" class=\"dataframe\">\n",
+              "  <thead>\n",
+              "    <tr style=\"text-align: right;\">\n",
+              "      <th></th>\n",
+              "      <th>Sentences</th>\n",
+              "      <th>Similarity</th>\n",
+              "    </tr>\n",
+              "  </thead>\n",
+              "  <tbody>\n",
+              "    <tr>\n",
+              "      <th>0</th>\n",
+              "      <td>If you are treating a child, use a pediatric f...</td>\n",
+              "      <td>0.747708</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>1</th>\n",
+              "      <td>Use acetaminophen exactly as directed on the l...</td>\n",
+              "      <td>0.706305</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>2</th>\n",
+              "      <td>Acetaminophen made for infants is available in...</td>\n",
+              "      <td>0.703297</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>3</th>\n",
+              "      <td>To use the acetaminophen effervescent granules...</td>\n",
+              "      <td>0.696789</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>4</th>\n",
+              "      <td>Using the wrong device may cause you to give y...</td>\n",
+              "      <td>0.681803</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>5</th>\n",
+              "      <td>Detailed Acetaminophen dosage information\\n</td>\n",
+              "      <td>0.675276</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>6</th>\n",
+              "      <td>Stop taking acetaminophen and call your doctor...</td>\n",
+              "      <td>0.671370</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>7</th>\n",
+              "      <td>An overdose of acetaminophen can be fatal.\\n</td>\n",
+              "      <td>0.663842</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>8</th>\n",
+              "      <td>Make sure your hands are dry when handling the...</td>\n",
+              "      <td>0.658170</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>9</th>\n",
+              "      <td>Use only the number of milligrams per dose tha...</td>\n",
+              "      <td>0.656356</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>10</th>\n",
+              "      <td>Avoid also using other medicines that contain ...</td>\n",
+              "      <td>0.655858</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>11</th>\n",
+              "      <td>Use only the special dose-measuring dropper or...</td>\n",
+              "      <td>0.645513</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>12</th>\n",
+              "      <td>Adults and teenagers who weigh at least 110 po...</td>\n",
+              "      <td>0.643877</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>13</th>\n",
+              "      <td>Carefully follow the dosing directions on the ...</td>\n",
+              "      <td>0.632597</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>14</th>\n",
+              "      <td>The first signs of an acetaminophen overdose i...</td>\n",
+              "      <td>0.628694</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>15</th>\n",
+              "      <td>The chewable tablet must be chewed thoroughly ...</td>\n",
+              "      <td>0.627870</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>16</th>\n",
+              "      <td>This medication can cause unusual results with...</td>\n",
+              "      <td>0.626874</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>17</th>\n",
+              "      <td>These dosing devices are not equal between the...</td>\n",
+              "      <td>0.625572</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>18</th>\n",
+              "      <td>You may need to shake the liquid before each use.</td>\n",
+              "      <td>0.619721</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>19</th>\n",
+              "      <td>Use exactly as directed on the label.\\n</td>\n",
+              "      <td>0.618332</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>20</th>\n",
+              "      <td>Children younger than 12 years old: Do not tak...</td>\n",
+              "      <td>0.614384</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>21</th>\n",
+              "      <td>What happens if I miss a dose?\\n</td>\n",
+              "      <td>0.612846</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>22</th>\n",
+              "      <td>you still have a sore throat after 2 days of u...</td>\n",
+              "      <td>0.612801</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>23</th>\n",
+              "      <td>Later symptoms may include pain in your upper ...</td>\n",
+              "      <td>0.610065</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>24</th>\n",
+              "      <td>If you do not have a dose-measuring device, as...</td>\n",
+              "      <td>0.607285</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>25</th>\n",
+              "      <td>The oral powder should be placed directly on t...</td>\n",
+              "      <td>0.607103</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>26</th>\n",
+              "      <td>Do not take more of this medication than is re...</td>\n",
+              "      <td>0.590531</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>27</th>\n",
+              "      <td>If you are taking the medication regularly, ta...</td>\n",
+              "      <td>0.590087</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>28</th>\n",
+              "      <td>What happens if I overdose?\\n</td>\n",
+              "      <td>0.585356</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>29</th>\n",
+              "      <td>To make sure you get the entire dose, add a li...</td>\n",
+              "      <td>0.582035</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>30</th>\n",
+              "      <td>liquid medicinewith the dosing syringe provide...</td>\n",
+              "      <td>0.578874</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>31</th>\n",
+              "      <td>Skip the missed dose if it is almost time for ...</td>\n",
+              "      <td>0.574738</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>32</th>\n",
+              "      <td>you have a skin rash, ongoing headache, nausea...</td>\n",
+              "      <td>0.560847</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>33</th>\n",
+              "      <td>Stir this mixture and drink all of it right away.</td>\n",
+              "      <td>0.543525</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>34</th>\n",
+              "      <td>Tell any doctor who treats you that you are us...</td>\n",
+              "      <td>0.538676</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>35</th>\n",
+              "      <td>Never mix and match dosing devices between inf...</td>\n",
+              "      <td>0.535131</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>36</th>\n",
+              "      <td>Store at room temperature away from heat and m...</td>\n",
+              "      <td>0.527676</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>37</th>\n",
+              "      <td>Since acetaminophen is taken as needed, you ma...</td>\n",
+              "      <td>0.514140</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>38</th>\n",
+              "      <td>Do not take extra medicine to make up the miss...</td>\n",
+              "      <td>0.488963</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>39</th>\n",
+              "      <td>An overdose of acetaminophen can damage your l...</td>\n",
+              "      <td>0.481425</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>40</th>\n",
+              "      <td>Do not take more than 4000 mg in 24 hours.\\n</td>\n",
+              "      <td>0.466167</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>41</th>\n",
+              "      <td>Place the tablet on your tongue.</td>\n",
+              "      <td>0.459324</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>42</th>\n",
+              "      <td>Follow the directions on the medicine label.\\n</td>\n",
+              "      <td>0.455328</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>43</th>\n",
+              "      <td>Do not swallow the tablet whole.</td>\n",
+              "      <td>0.451297</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>44</th>\n",
+              "      <td>Measure</td>\n",
+              "      <td>0.445951</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>45</th>\n",
+              "      <td>It will begin to dissolve right away.</td>\n",
+              "      <td>0.442590</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>46</th>\n",
+              "      <td>Do not use in larger or smaller amounts or for...</td>\n",
+              "      <td>0.442540</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>47</th>\n",
+              "      <td>Allow it to dissolve in your mouth without che...</td>\n",
+              "      <td>0.418114</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>48</th>\n",
+              "      <td>Seek emergency medical attention or call the P...</td>\n",
+              "      <td>0.411709</td>\n",
+              "    </tr>\n",
+              "  </tbody>\n",
+              "</table>\n",
+              "</div>"
+            ],
+            "text/plain": [
+              "                                            Sentences  Similarity\n",
+              "0   If you are treating a child, use a pediatric f...    0.747708\n",
+              "1   Use acetaminophen exactly as directed on the l...    0.706305\n",
+              "2   Acetaminophen made for infants is available in...    0.703297\n",
+              "3   To use the acetaminophen effervescent granules...    0.696789\n",
+              "4   Using the wrong device may cause you to give y...    0.681803\n",
+              "5         Detailed Acetaminophen dosage information\\n    0.675276\n",
+              "6   Stop taking acetaminophen and call your doctor...    0.671370\n",
+              "7        An overdose of acetaminophen can be fatal.\\n    0.663842\n",
+              "8   Make sure your hands are dry when handling the...    0.658170\n",
+              "9   Use only the number of milligrams per dose tha...    0.656356\n",
+              "10  Avoid also using other medicines that contain ...    0.655858\n",
+              "11  Use only the special dose-measuring dropper or...    0.645513\n",
+              "12  Adults and teenagers who weigh at least 110 po...    0.643877\n",
+              "13  Carefully follow the dosing directions on the ...    0.632597\n",
+              "14  The first signs of an acetaminophen overdose i...    0.628694\n",
+              "15  The chewable tablet must be chewed thoroughly ...    0.627870\n",
+              "16  This medication can cause unusual results with...    0.626874\n",
+              "17  These dosing devices are not equal between the...    0.625572\n",
+              "18  You may need to shake the liquid before each use.    0.619721\n",
+              "19            Use exactly as directed on the label.\\n    0.618332\n",
+              "20  Children younger than 12 years old: Do not tak...    0.614384\n",
+              "21                   What happens if I miss a dose?\\n    0.612846\n",
+              "22  you still have a sore throat after 2 days of u...    0.612801\n",
+              "23  Later symptoms may include pain in your upper ...    0.610065\n",
+              "24  If you do not have a dose-measuring device, as...    0.607285\n",
+              "25  The oral powder should be placed directly on t...    0.607103\n",
+              "26  Do not take more of this medication than is re...    0.590531\n",
+              "27  If you are taking the medication regularly, ta...    0.590087\n",
+              "28                      What happens if I overdose?\\n    0.585356\n",
+              "29  To make sure you get the entire dose, add a li...    0.582035\n",
+              "30  liquid medicinewith the dosing syringe provide...    0.578874\n",
+              "31  Skip the missed dose if it is almost time for ...    0.574738\n",
+              "32  you have a skin rash, ongoing headache, nausea...    0.560847\n",
+              "33  Stir this mixture and drink all of it right away.    0.543525\n",
+              "34  Tell any doctor who treats you that you are us...    0.538676\n",
+              "35  Never mix and match dosing devices between inf...    0.535131\n",
+              "36  Store at room temperature away from heat and m...    0.527676\n",
+              "37  Since acetaminophen is taken as needed, you ma...    0.514140\n",
+              "38  Do not take extra medicine to make up the miss...    0.488963\n",
+              "39  An overdose of acetaminophen can damage your l...    0.481425\n",
+              "40       Do not take more than 4000 mg in 24 hours.\\n    0.466167\n",
+              "41                   Place the tablet on your tongue.    0.459324\n",
+              "42     Follow the directions on the medicine label.\\n    0.455328\n",
+              "43                   Do not swallow the tablet whole.    0.451297\n",
+              "44                                            Measure    0.445951\n",
+              "45              It will begin to dissolve right away.    0.442590\n",
+              "46  Do not use in larger or smaller amounts or for...    0.442540\n",
+              "47  Allow it to dissolve in your mouth without che...    0.418114\n",
+              "48  Seek emergency medical attention or call the P...    0.411709"
+            ]
+          },
+          "execution_count": 91,
+          "metadata": {},
+          "output_type": "execute_result"
+        }
+      ]
+    },
+    {
+      "cell_type": "code",
+      "metadata": {
+        "colab": {
+          "base_uri": "https://localhost:8080/",
+          "height": 1000
+        },
+        "id": "bD8wrYu9Cpxe",
+        "outputId": "4c4f464c-19f5-42d5-ef81-664268abfc14"
+      },
+      "source": [
+        "scores = model.similarity(examples[0])\n",
+        "dic = {}\n",
+        "\n",
+        "print(question)\n",
+        "\n",
+        "for i, ex in enumerate(labels):\n",
+        "    dic[ex] = scores[i]\n",
+        "\n",
+        "s = pd.Series(dic, name='Similarity')\n",
+        "s.index.name = 'Sentences'\n",
+        "df_finetune_bert = s.reset_index()\n",
+        "df_finetune_bert.sort_values(by='Similarity', ascending=False, inplace=True)\n",
+        "df_finetune_bert.reset_index(inplace=True)\n",
+        "df_finetune_bert.drop('index', axis=1, inplace=True)\n",
+        "df_finetune_bert"
+      ],
+      "execution_count": null,
+      "outputs": [
+        {
+          "name": "stdout",
+          "output_type": "stream",
+          "text": [
+            "What is the uses of Gemfibrozil?\n"
+          ]
+        },
+        {
+          "data": {
+            "text/html": [
+              "<div>\n",
+              "<style scoped>\n",
+              "    .dataframe tbody tr th:only-of-type {\n",
+              "        vertical-align: middle;\n",
+              "    }\n",
+              "\n",
+              "    .dataframe tbody tr th {\n",
+              "        vertical-align: top;\n",
+              "    }\n",
+              "\n",
+              "    .dataframe thead th {\n",
+              "        text-align: right;\n",
+              "    }\n",
+              "</style>\n",
+              "<table border=\"1\" class=\"dataframe\">\n",
+              "  <thead>\n",
+              "    <tr style=\"text-align: right;\">\n",
+              "      <th></th>\n",
+              "      <th>Sentences</th>\n",
+              "      <th>Similarity</th>\n",
+              "    </tr>\n",
+              "  </thead>\n",
+              "  <tbody>\n",
+              "    <tr>\n",
+              "      <th>0</th>\n",
+              "      <td>If you are treating a child, use a pediatric f...</td>\n",
+              "      <td>0.747708</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>1</th>\n",
+              "      <td>Use acetaminophen exactly as directed on the l...</td>\n",
+              "      <td>0.706305</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>2</th>\n",
+              "      <td>Acetaminophen made for infants is available in...</td>\n",
+              "      <td>0.703297</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>3</th>\n",
+              "      <td>To use the acetaminophen effervescent granules...</td>\n",
+              "      <td>0.696789</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>4</th>\n",
+              "      <td>Using the wrong device may cause you to give y...</td>\n",
+              "      <td>0.681803</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>5</th>\n",
+              "      <td>Detailed Acetaminophen dosage information\\n</td>\n",
+              "      <td>0.675276</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>6</th>\n",
+              "      <td>Stop taking acetaminophen and call your doctor...</td>\n",
+              "      <td>0.671370</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>7</th>\n",
+              "      <td>An overdose of acetaminophen can be fatal.\\n</td>\n",
+              "      <td>0.663842</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>8</th>\n",
+              "      <td>Make sure your hands are dry when handling the...</td>\n",
+              "      <td>0.658170</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>9</th>\n",
+              "      <td>Use only the number of milligrams per dose tha...</td>\n",
+              "      <td>0.656356</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>10</th>\n",
+              "      <td>Avoid also using other medicines that contain ...</td>\n",
+              "      <td>0.655858</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>11</th>\n",
+              "      <td>Use only the special dose-measuring dropper or...</td>\n",
+              "      <td>0.645513</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>12</th>\n",
+              "      <td>Adults and teenagers who weigh at least 110 po...</td>\n",
+              "      <td>0.643877</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>13</th>\n",
+              "      <td>Carefully follow the dosing directions on the ...</td>\n",
+              "      <td>0.632597</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>14</th>\n",
+              "      <td>The first signs of an acetaminophen overdose i...</td>\n",
+              "      <td>0.628694</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>15</th>\n",
+              "      <td>The chewable tablet must be chewed thoroughly ...</td>\n",
+              "      <td>0.627870</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>16</th>\n",
+              "      <td>This medication can cause unusual results with...</td>\n",
+              "      <td>0.626874</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>17</th>\n",
+              "      <td>These dosing devices are not equal between the...</td>\n",
+              "      <td>0.625572</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>18</th>\n",
+              "      <td>You may need to shake the liquid before each use.</td>\n",
+              "      <td>0.619721</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>19</th>\n",
+              "      <td>Use exactly as directed on the label.\\n</td>\n",
+              "      <td>0.618332</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>20</th>\n",
+              "      <td>Children younger than 12 years old: Do not tak...</td>\n",
+              "      <td>0.614384</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>21</th>\n",
+              "      <td>What happens if I miss a dose?\\n</td>\n",
+              "      <td>0.612846</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>22</th>\n",
+              "      <td>you still have a sore throat after 2 days of u...</td>\n",
+              "      <td>0.612801</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>23</th>\n",
+              "      <td>Later symptoms may include pain in your upper ...</td>\n",
+              "      <td>0.610065</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>24</th>\n",
+              "      <td>If you do not have a dose-measuring device, as...</td>\n",
+              "      <td>0.607285</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>25</th>\n",
+              "      <td>The oral powder should be placed directly on t...</td>\n",
+              "      <td>0.607103</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>26</th>\n",
+              "      <td>Do not take more of this medication than is re...</td>\n",
+              "      <td>0.590531</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>27</th>\n",
+              "      <td>If you are taking the medication regularly, ta...</td>\n",
+              "      <td>0.590087</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>28</th>\n",
+              "      <td>What happens if I overdose?\\n</td>\n",
+              "      <td>0.585356</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>29</th>\n",
+              "      <td>To make sure you get the entire dose, add a li...</td>\n",
+              "      <td>0.582035</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>30</th>\n",
+              "      <td>liquid medicinewith the dosing syringe provide...</td>\n",
+              "      <td>0.578874</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>31</th>\n",
+              "      <td>Skip the missed dose if it is almost time for ...</td>\n",
+              "      <td>0.574738</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>32</th>\n",
+              "      <td>you have a skin rash, ongoing headache, nausea...</td>\n",
+              "      <td>0.560847</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>33</th>\n",
+              "      <td>Stir this mixture and drink all of it right away.</td>\n",
+              "      <td>0.543525</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>34</th>\n",
+              "      <td>Tell any doctor who treats you that you are us...</td>\n",
+              "      <td>0.538676</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>35</th>\n",
+              "      <td>Never mix and match dosing devices between inf...</td>\n",
+              "      <td>0.535131</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>36</th>\n",
+              "      <td>Store at room temperature away from heat and m...</td>\n",
+              "      <td>0.527676</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>37</th>\n",
+              "      <td>Since acetaminophen is taken as needed, you ma...</td>\n",
+              "      <td>0.514140</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>38</th>\n",
+              "      <td>Do not take extra medicine to make up the miss...</td>\n",
+              "      <td>0.488963</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>39</th>\n",
+              "      <td>An overdose of acetaminophen can damage your l...</td>\n",
+              "      <td>0.481425</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>40</th>\n",
+              "      <td>Do not take more than 4000 mg in 24 hours.\\n</td>\n",
+              "      <td>0.466167</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>41</th>\n",
+              "      <td>Place the tablet on your tongue.</td>\n",
+              "      <td>0.459324</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>42</th>\n",
+              "      <td>Follow the directions on the medicine label.\\n</td>\n",
+              "      <td>0.455328</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>43</th>\n",
+              "      <td>Do not swallow the tablet whole.</td>\n",
+              "      <td>0.451297</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>44</th>\n",
+              "      <td>Measure</td>\n",
+              "      <td>0.445951</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>45</th>\n",
+              "      <td>It will begin to dissolve right away.</td>\n",
+              "      <td>0.442590</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>46</th>\n",
+              "      <td>Do not use in larger or smaller amounts or for...</td>\n",
+              "      <td>0.442540</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>47</th>\n",
+              "      <td>Allow it to dissolve in your mouth without che...</td>\n",
+              "      <td>0.418114</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>48</th>\n",
+              "      <td>Seek emergency medical attention or call the P...</td>\n",
+              "      <td>0.411709</td>\n",
+              "    </tr>\n",
+              "  </tbody>\n",
+              "</table>\n",
+              "</div>"
+            ],
+            "text/plain": [
+              "                                            Sentences  Similarity\n",
+              "0   If you are treating a child, use a pediatric f...    0.747708\n",
+              "1   Use acetaminophen exactly as directed on the l...    0.706305\n",
+              "2   Acetaminophen made for infants is available in...    0.703297\n",
+              "3   To use the acetaminophen effervescent granules...    0.696789\n",
+              "4   Using the wrong device may cause you to give y...    0.681803\n",
+              "5         Detailed Acetaminophen dosage information\\n    0.675276\n",
+              "6   Stop taking acetaminophen and call your doctor...    0.671370\n",
+              "7        An overdose of acetaminophen can be fatal.\\n    0.663842\n",
+              "8   Make sure your hands are dry when handling the...    0.658170\n",
+              "9   Use only the number of milligrams per dose tha...    0.656356\n",
+              "10  Avoid also using other medicines that contain ...    0.655858\n",
+              "11  Use only the special dose-measuring dropper or...    0.645513\n",
+              "12  Adults and teenagers who weigh at least 110 po...    0.643877\n",
+              "13  Carefully follow the dosing directions on the ...    0.632597\n",
+              "14  The first signs of an acetaminophen overdose i...    0.628694\n",
+              "15  The chewable tablet must be chewed thoroughly ...    0.627870\n",
+              "16  This medication can cause unusual results with...    0.626874\n",
+              "17  These dosing devices are not equal between the...    0.625572\n",
+              "18  You may need to shake the liquid before each use.    0.619721\n",
+              "19            Use exactly as directed on the label.\\n    0.618332\n",
+              "20  Children younger than 12 years old: Do not tak...    0.614384\n",
+              "21                   What happens if I miss a dose?\\n    0.612846\n",
+              "22  you still have a sore throat after 2 days of u...    0.612801\n",
+              "23  Later symptoms may include pain in your upper ...    0.610065\n",
+              "24  If you do not have a dose-measuring device, as...    0.607285\n",
+              "25  The oral powder should be placed directly on t...    0.607103\n",
+              "26  Do not take more of this medication than is re...    0.590531\n",
+              "27  If you are taking the medication regularly, ta...    0.590087\n",
+              "28                      What happens if I overdose?\\n    0.585356\n",
+              "29  To make sure you get the entire dose, add a li...    0.582035\n",
+              "30  liquid medicinewith the dosing syringe provide...    0.578874\n",
+              "31  Skip the missed dose if it is almost time for ...    0.574738\n",
+              "32  you have a skin rash, ongoing headache, nausea...    0.560847\n",
+              "33  Stir this mixture and drink all of it right away.    0.543525\n",
+              "34  Tell any doctor who treats you that you are us...    0.538676\n",
+              "35  Never mix and match dosing devices between inf...    0.535131\n",
+              "36  Store at room temperature away from heat and m...    0.527676\n",
+              "37  Since acetaminophen is taken as needed, you ma...    0.514140\n",
+              "38  Do not take extra medicine to make up the miss...    0.488963\n",
+              "39  An overdose of acetaminophen can damage your l...    0.481425\n",
+              "40       Do not take more than 4000 mg in 24 hours.\\n    0.466167\n",
+              "41                   Place the tablet on your tongue.    0.459324\n",
+              "42     Follow the directions on the medicine label.\\n    0.455328\n",
+              "43                   Do not swallow the tablet whole.    0.451297\n",
+              "44                                            Measure    0.445951\n",
+              "45              It will begin to dissolve right away.    0.442590\n",
+              "46  Do not use in larger or smaller amounts or for...    0.442540\n",
+              "47  Allow it to dissolve in your mouth without che...    0.418114\n",
+              "48  Seek emergency medical attention or call the P...    0.411709"
+            ]
+          },
+          "execution_count": 92,
+          "metadata": {},
+          "output_type": "execute_result"
+        }
+      ]
+    },
+    {
+      "cell_type": "code",
+      "metadata": {
+        "colab": {
+          "base_uri": "https://localhost:8080/"
+        },
+        "id": "hjDAA4hYjIN8",
+        "outputId": "9388c1ac-4c22-49f0-c1c0-5fb8bd184da2"
+      },
+      "source": [
+        "print(df_finetune_bert[df_finetune_bert['Sentences'].str.contains(\"Do not take more than 5 doses of acetaminophen in 24 hours.\")], \n",
+        "      df_finetune_bert[df_finetune_bert['Sentences'].str.contains(\"Use only the number of milligrams per dose that is recommended for the child's weight and age.\")],\n",
+        "      df_finetune_bert[df_finetune_bert['Sentences'].str.contains(\"Use exactly as directed on the label\")],\n",
+        "      df_finetune_bert[df_finetune_bert['Sentences'].str.contains(\"If you are treating a child, use a pediatric form of acetaminophen.\")],\n",
+        "      df_finetune_bert[df_finetune_bert['Sentences'].str.contains(\"Use only the special dose-measuring dropper or oral syringe that comes with the specific pediatric form you are using.\")],\n",
+        "      df_finetune_bert[df_finetune_bert['Sentences'].str.contains(\"Carefully follow the dosing directions on the medicine label.\")],)"
+      ],
+      "execution_count": null,
+      "outputs": [
+        {
+          "name": "stdout",
+          "output_type": "stream",
+          "text": [
+            "                                            Sentences  Similarity\n",
+            "20  Children younger than 12 years old: Do not tak...    0.614384                                            Sentences  Similarity\n",
+            "9  Use only the number of milligrams per dose tha...    0.656356                                   Sentences  Similarity\n",
+            "19  Use exactly as directed on the label.\\n    0.618332                                            Sentences  Similarity\n",
+            "0  If you are treating a child, use a pediatric f...    0.747708                                             Sentences  Similarity\n",
+            "11  Use only the special dose-measuring dropper or...    0.645513                                             Sentences  Similarity\n",
+            "13  Carefully follow the dosing directions on the ...    0.632597\n"
+          ]
+        }
+      ]
+    },
+    {
+      "cell_type": "code",
+      "metadata": {
+        "colab": {
+          "base_uri": "https://localhost:8080/",
+          "height": 1000
+        },
+        "id": "tfPoaRlCJUOp",
+        "outputId": "41d5f96b-94dd-4cf3-964d-d5efe8bda297"
+      },
+      "source": [
+        "model_name_bert = 'bert-large-uncased'\n",
+        "model_bert = SentenceSimilarity(model_name_bert)\n",
+        "model_bert.compute_label_embedding(labels)\n",
+        "\n",
+        "scores = model_bert.similarity(examples[0])\n",
+        "dic = {}\n",
+        "\n",
+        "print(question)\n",
+        "\n",
+        "for i, ex in enumerate(labels):\n",
+        "    dic[ex] = scores[i]\n",
+        "\n",
+        "s = pd.Series(dic, name='Similarity')\n",
+        "s.index.name = 'Sentences'\n",
+        "df_bert = s.reset_index()\n",
+        "df_bert.sort_values(by='Similarity', ascending=False, inplace=True)\n",
+        "df_bert.reset_index(inplace=True)\n",
+        "df_bert.drop('index', axis=1, inplace=True)\n",
+        "df_bert"
+      ],
+      "execution_count": null,
+      "outputs": [
+        {
+          "name": "stderr",
+          "output_type": "stream",
+          "text": [
+            "Some weights of the model checkpoint at bert-large-uncased were not used when initializing BertModel: ['cls.seq_relationship.weight', 'cls.predictions.bias', 'cls.predictions.decoder.weight', 'cls.predictions.transform.dense.bias', 'cls.predictions.transform.LayerNorm.bias', 'cls.predictions.transform.LayerNorm.weight', 'cls.seq_relationship.bias', 'cls.predictions.transform.dense.weight']\n",
+            "- This IS expected if you are initializing BertModel from the checkpoint of a model trained on another task or with another architecture (e.g. initializing a BertForSequenceClassification model from a BertForPreTraining model).\n",
+            "- This IS NOT expected if you are initializing BertModel from the checkpoint of a model that you expect to be exactly identical (initializing a BertForSequenceClassification model from a BertForSequenceClassification model).\n"
+          ]
+        },
+        {
+          "name": "stdout",
+          "output_type": "stream",
+          "text": [
+            "What is the uses of Gemfibrozil?\n"
+          ]
+        },
+        {
+          "data": {
+            "text/html": [
+              "<div>\n",
+              "<style scoped>\n",
+              "    .dataframe tbody tr th:only-of-type {\n",
+              "        vertical-align: middle;\n",
+              "    }\n",
+              "\n",
+              "    .dataframe tbody tr th {\n",
+              "        vertical-align: top;\n",
+              "    }\n",
+              "\n",
+              "    .dataframe thead th {\n",
+              "        text-align: right;\n",
+              "    }\n",
+              "</style>\n",
+              "<table border=\"1\" class=\"dataframe\">\n",
+              "  <thead>\n",
+              "    <tr style=\"text-align: right;\">\n",
+              "      <th></th>\n",
+              "      <th>Sentences</th>\n",
+              "      <th>Similarity</th>\n",
+              "    </tr>\n",
+              "  </thead>\n",
+              "  <tbody>\n",
+              "    <tr>\n",
+              "      <th>0</th>\n",
+              "      <td>Detailed Acetaminophen dosage information\\n</td>\n",
+              "      <td>0.789242</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>1</th>\n",
+              "      <td>Since acetaminophen is taken as needed, you ma...</td>\n",
+              "      <td>0.766882</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>2</th>\n",
+              "      <td>An overdose of acetaminophen can be fatal.\\n</td>\n",
+              "      <td>0.765281</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>3</th>\n",
+              "      <td>Avoid also using other medicines that contain ...</td>\n",
+              "      <td>0.763936</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>4</th>\n",
+              "      <td>If you are treating a child, use a pediatric f...</td>\n",
+              "      <td>0.759143</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>5</th>\n",
+              "      <td>Stop taking acetaminophen and call your doctor...</td>\n",
+              "      <td>0.756515</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>6</th>\n",
+              "      <td>Never mix and match dosing devices between inf...</td>\n",
+              "      <td>0.751906</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>7</th>\n",
+              "      <td>An overdose of acetaminophen can damage your l...</td>\n",
+              "      <td>0.744130</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>8</th>\n",
+              "      <td>Acetaminophen made for infants is available in...</td>\n",
+              "      <td>0.741706</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>9</th>\n",
+              "      <td>This medication can cause unusual results with...</td>\n",
+              "      <td>0.739916</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>10</th>\n",
+              "      <td>Tell any doctor who treats you that you are us...</td>\n",
+              "      <td>0.731940</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>11</th>\n",
+              "      <td>Make sure your hands are dry when handling the...</td>\n",
+              "      <td>0.729707</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>12</th>\n",
+              "      <td>Using the wrong device may cause you to give y...</td>\n",
+              "      <td>0.729371</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>13</th>\n",
+              "      <td>These dosing devices are not equal between the...</td>\n",
+              "      <td>0.717396</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>14</th>\n",
+              "      <td>Children younger than 12 years old: Do not tak...</td>\n",
+              "      <td>0.709048</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>15</th>\n",
+              "      <td>Do not take more of this medication than is re...</td>\n",
+              "      <td>0.702219</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>16</th>\n",
+              "      <td>If you do not have a dose-measuring device, as...</td>\n",
+              "      <td>0.695315</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>17</th>\n",
+              "      <td>The first signs of an acetaminophen overdose i...</td>\n",
+              "      <td>0.689395</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>18</th>\n",
+              "      <td>Do not take more than 4000 mg in 24 hours.\\n</td>\n",
+              "      <td>0.687813</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>19</th>\n",
+              "      <td>Do not use in larger or smaller amounts or for...</td>\n",
+              "      <td>0.687785</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>20</th>\n",
+              "      <td>What happens if I miss a dose?\\n</td>\n",
+              "      <td>0.685977</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>21</th>\n",
+              "      <td>The chewable tablet must be chewed thoroughly ...</td>\n",
+              "      <td>0.685920</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>22</th>\n",
+              "      <td>Use only the number of milligrams per dose tha...</td>\n",
+              "      <td>0.685338</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>23</th>\n",
+              "      <td>Follow the directions on the medicine label.\\n</td>\n",
+              "      <td>0.679554</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>24</th>\n",
+              "      <td>you still have a sore throat after 2 days of u...</td>\n",
+              "      <td>0.677651</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>25</th>\n",
+              "      <td>Carefully follow the dosing directions on the ...</td>\n",
+              "      <td>0.677499</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>26</th>\n",
+              "      <td>What happens if I overdose?\\n</td>\n",
+              "      <td>0.672212</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>27</th>\n",
+              "      <td>Do not take extra medicine to make up the miss...</td>\n",
+              "      <td>0.671241</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>28</th>\n",
+              "      <td>Use only the special dose-measuring dropper or...</td>\n",
+              "      <td>0.670978</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>29</th>\n",
+              "      <td>To use the acetaminophen effervescent granules...</td>\n",
+              "      <td>0.662610</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>30</th>\n",
+              "      <td>Skip the missed dose if it is almost time for ...</td>\n",
+              "      <td>0.661607</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>31</th>\n",
+              "      <td>Use acetaminophen exactly as directed on the l...</td>\n",
+              "      <td>0.660867</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>32</th>\n",
+              "      <td>If you are taking the medication regularly, ta...</td>\n",
+              "      <td>0.659690</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>33</th>\n",
+              "      <td>The oral powder should be placed directly on t...</td>\n",
+              "      <td>0.657789</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>34</th>\n",
+              "      <td>you have a skin rash, ongoing headache, nausea...</td>\n",
+              "      <td>0.650195</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>35</th>\n",
+              "      <td>liquid medicinewith the dosing syringe provide...</td>\n",
+              "      <td>0.646352</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>36</th>\n",
+              "      <td>Later symptoms may include pain in your upper ...</td>\n",
+              "      <td>0.644153</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>37</th>\n",
+              "      <td>Adults and teenagers who weigh at least 110 po...</td>\n",
+              "      <td>0.640857</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>38</th>\n",
+              "      <td>Allow it to dissolve in your mouth without che...</td>\n",
+              "      <td>0.632413</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>39</th>\n",
+              "      <td>You may need to shake the liquid before each use.</td>\n",
+              "      <td>0.626181</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>40</th>\n",
+              "      <td>To make sure you get the entire dose, add a li...</td>\n",
+              "      <td>0.622170</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>41</th>\n",
+              "      <td>Store at room temperature away from heat and m...</td>\n",
+              "      <td>0.619892</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>42</th>\n",
+              "      <td>Do not swallow the tablet whole.</td>\n",
+              "      <td>0.616105</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>43</th>\n",
+              "      <td>Stir this mixture and drink all of it right away.</td>\n",
+              "      <td>0.580591</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>44</th>\n",
+              "      <td>Seek emergency medical attention or call the P...</td>\n",
+              "      <td>0.571924</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>45</th>\n",
+              "      <td>Place the tablet on your tongue.</td>\n",
+              "      <td>0.552882</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>46</th>\n",
+              "      <td>It will begin to dissolve right away.</td>\n",
+              "      <td>0.519208</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>47</th>\n",
+              "      <td>Use exactly as directed on the label.\\n</td>\n",
+              "      <td>0.466816</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>48</th>\n",
+              "      <td>Measure</td>\n",
+              "      <td>0.395664</td>\n",
+              "    </tr>\n",
+              "  </tbody>\n",
+              "</table>\n",
+              "</div>"
+            ],
+            "text/plain": [
+              "                                            Sentences  Similarity\n",
+              "0         Detailed Acetaminophen dosage information\\n    0.789242\n",
+              "1   Since acetaminophen is taken as needed, you ma...    0.766882\n",
+              "2        An overdose of acetaminophen can be fatal.\\n    0.765281\n",
+              "3   Avoid also using other medicines that contain ...    0.763936\n",
+              "4   If you are treating a child, use a pediatric f...    0.759143\n",
+              "5   Stop taking acetaminophen and call your doctor...    0.756515\n",
+              "6   Never mix and match dosing devices between inf...    0.751906\n",
+              "7   An overdose of acetaminophen can damage your l...    0.744130\n",
+              "8   Acetaminophen made for infants is available in...    0.741706\n",
+              "9   This medication can cause unusual results with...    0.739916\n",
+              "10  Tell any doctor who treats you that you are us...    0.731940\n",
+              "11  Make sure your hands are dry when handling the...    0.729707\n",
+              "12  Using the wrong device may cause you to give y...    0.729371\n",
+              "13  These dosing devices are not equal between the...    0.717396\n",
+              "14  Children younger than 12 years old: Do not tak...    0.709048\n",
+              "15  Do not take more of this medication than is re...    0.702219\n",
+              "16  If you do not have a dose-measuring device, as...    0.695315\n",
+              "17  The first signs of an acetaminophen overdose i...    0.689395\n",
+              "18       Do not take more than 4000 mg in 24 hours.\\n    0.687813\n",
+              "19  Do not use in larger or smaller amounts or for...    0.687785\n",
+              "20                   What happens if I miss a dose?\\n    0.685977\n",
+              "21  The chewable tablet must be chewed thoroughly ...    0.685920\n",
+              "22  Use only the number of milligrams per dose tha...    0.685338\n",
+              "23     Follow the directions on the medicine label.\\n    0.679554\n",
+              "24  you still have a sore throat after 2 days of u...    0.677651\n",
+              "25  Carefully follow the dosing directions on the ...    0.677499\n",
+              "26                      What happens if I overdose?\\n    0.672212\n",
+              "27  Do not take extra medicine to make up the miss...    0.671241\n",
+              "28  Use only the special dose-measuring dropper or...    0.670978\n",
+              "29  To use the acetaminophen effervescent granules...    0.662610\n",
+              "30  Skip the missed dose if it is almost time for ...    0.661607\n",
+              "31  Use acetaminophen exactly as directed on the l...    0.660867\n",
+              "32  If you are taking the medication regularly, ta...    0.659690\n",
+              "33  The oral powder should be placed directly on t...    0.657789\n",
+              "34  you have a skin rash, ongoing headache, nausea...    0.650195\n",
+              "35  liquid medicinewith the dosing syringe provide...    0.646352\n",
+              "36  Later symptoms may include pain in your upper ...    0.644153\n",
+              "37  Adults and teenagers who weigh at least 110 po...    0.640857\n",
+              "38  Allow it to dissolve in your mouth without che...    0.632413\n",
+              "39  You may need to shake the liquid before each use.    0.626181\n",
+              "40  To make sure you get the entire dose, add a li...    0.622170\n",
+              "41  Store at room temperature away from heat and m...    0.619892\n",
+              "42                   Do not swallow the tablet whole.    0.616105\n",
+              "43  Stir this mixture and drink all of it right away.    0.580591\n",
+              "44  Seek emergency medical attention or call the P...    0.571924\n",
+              "45                   Place the tablet on your tongue.    0.552882\n",
+              "46              It will begin to dissolve right away.    0.519208\n",
+              "47            Use exactly as directed on the label.\\n    0.466816\n",
+              "48                                            Measure    0.395664"
+            ]
+          },
+          "execution_count": 94,
+          "metadata": {},
+          "output_type": "execute_result"
+        }
+      ]
+    },
+    {
+      "cell_type": "code",
+      "metadata": {
+        "colab": {
+          "base_uri": "https://localhost:8080/"
+        },
+        "id": "h3_NoSK8jUi9",
+        "outputId": "b8bf93e9-c80b-4a82-f6e0-38fb5e05f446"
+      },
+      "source": [
+        "print(df_bert[df_bert['Sentences'].str.contains(\"Do not take more than 5 doses of acetaminophen in 24 hours.\")], \n",
+        "      df_bert[df_bert['Sentences'].str.contains(\"Use only the number of milligrams per dose that is recommended for the child's weight and age.\")],\n",
+        "      df_bert[df_bert['Sentences'].str.contains(\"Use exactly as directed on the label\")],\n",
+        "      df_bert[df_bert['Sentences'].str.contains(\"If you are treating a child, use a pediatric form of acetaminophen.\")],\n",
+        "      df_bert[df_bert['Sentences'].str.contains(\"Use only the special dose-measuring dropper or oral syringe that comes with the specific pediatric form you are using.\")],\n",
+        "      df_bert[df_bert['Sentences'].str.contains(\"Carefully follow the dosing directions on the medicine label.\")],)"
+      ],
+      "execution_count": null,
+      "outputs": [
+        {
+          "name": "stdout",
+          "output_type": "stream",
+          "text": [
+            "                                            Sentences  Similarity\n",
+            "14  Children younger than 12 years old: Do not tak...    0.709048                                             Sentences  Similarity\n",
+            "22  Use only the number of milligrams per dose tha...    0.685338                                   Sentences  Similarity\n",
+            "47  Use exactly as directed on the label.\\n    0.466816                                            Sentences  Similarity\n",
+            "4  If you are treating a child, use a pediatric f...    0.759143                                             Sentences  Similarity\n",
+            "28  Use only the special dose-measuring dropper or...    0.670978                                             Sentences  Similarity\n",
+            "25  Carefully follow the dosing directions on the ...    0.677499\n"
+          ]
+        }
+      ]
+    },
+    {
+      "cell_type": "code",
+      "metadata": {
+        "colab": {
+          "base_uri": "https://localhost:8080/",
+          "height": 1000
+        },
+        "id": "BndVU53GKPS-",
+        "outputId": "c5d92f22-d675-49bc-ae85-c7198888e899"
+      },
+      "source": [
+        "model_name_xlm = 'vicgalle/xlm-roberta-large-xnli-anli'\n",
+        "model_xlm = SentenceSimilarity(model_name_xlm)\n",
+        "model_xlm.compute_label_embedding(labels)\n",
+        "\n",
+        "scores = model_xlm.similarity(examples[0])\n",
+        "dic = {}\n",
+        "\n",
+        "print(question)\n",
+        "\n",
+        "for i, ex in enumerate(labels):\n",
+        "    dic[ex] = scores[i]\n",
+        "\n",
+        "s = pd.Series(dic, name='Similarity')\n",
+        "s.index.name = 'Sentences'\n",
+        "df_xlm = s.reset_index()\n",
+        "df_xlm.sort_values(by='Similarity', ascending=False, inplace=True)\n",
+        "df_xlm"
+      ],
+      "execution_count": null,
+      "outputs": [
+        {
+          "name": "stdout",
+          "output_type": "stream",
+          "text": [
+            "What is the uses of Gemfibrozil?\n"
+          ]
+        },
+        {
+          "data": {
+            "text/html": [
+              "<div>\n",
+              "<style scoped>\n",
+              "    .dataframe tbody tr th:only-of-type {\n",
+              "        vertical-align: middle;\n",
+              "    }\n",
+              "\n",
+              "    .dataframe tbody tr th {\n",
+              "        vertical-align: top;\n",
+              "    }\n",
+              "\n",
+              "    .dataframe thead th {\n",
+              "        text-align: right;\n",
+              "    }\n",
+              "</style>\n",
+              "<table border=\"1\" class=\"dataframe\">\n",
+              "  <thead>\n",
+              "    <tr style=\"text-align: right;\">\n",
+              "      <th></th>\n",
+              "      <th>Sentences</th>\n",
+              "      <th>Similarity</th>\n",
+              "    </tr>\n",
+              "  </thead>\n",
+              "  <tbody>\n",
+              "    <tr>\n",
+              "      <th>38</th>\n",
+              "      <td>Detailed Acetaminophen dosage information\\n</td>\n",
+              "      <td>0.991904</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>19</th>\n",
+              "      <td>Never mix and match dosing devices between inf...</td>\n",
+              "      <td>0.989643</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>14</th>\n",
+              "      <td>liquid medicinewith the dosing syringe provide...</td>\n",
+              "      <td>0.989598</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>45</th>\n",
+              "      <td>Seek emergency medical attention or call the P...</td>\n",
+              "      <td>0.986279</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>42</th>\n",
+              "      <td>Skip the missed dose if it is almost time for ...</td>\n",
+              "      <td>0.986243</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>28</th>\n",
+              "      <td>To use the acetaminophen effervescent granules...</td>\n",
+              "      <td>0.985514</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>22</th>\n",
+              "      <td>The chewable tablet must be chewed thoroughly ...</td>\n",
+              "      <td>0.984686</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>34</th>\n",
+              "      <td>you have a skin rash, ongoing headache, nausea...</td>\n",
+              "      <td>0.984482</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>7</th>\n",
+              "      <td>Use only the number of milligrams per dose tha...</td>\n",
+              "      <td>0.984069</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>30</th>\n",
+              "      <td>To make sure you get the entire dose, add a li...</td>\n",
+              "      <td>0.983659</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>11</th>\n",
+              "      <td>Use only the special dose-measuring dropper or...</td>\n",
+              "      <td>0.982866</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>47</th>\n",
+              "      <td>The first signs of an acetaminophen overdose i...</td>\n",
+              "      <td>0.981202</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>41</th>\n",
+              "      <td>If you are taking the medication regularly, ta...</td>\n",
+              "      <td>0.980014</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>10</th>\n",
+              "      <td>If you are treating a child, use a pediatric f...</td>\n",
+              "      <td>0.978841</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>29</th>\n",
+              "      <td>Stir this mixture and drink all of it right away.</td>\n",
+              "      <td>0.978108</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>4</th>\n",
+              "      <td>Adults and teenagers who weigh at least 110 po...</td>\n",
+              "      <td>0.974876</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>5</th>\n",
+              "      <td>Do not take more than 4000 mg in 24 hours.\\n</td>\n",
+              "      <td>0.974606</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>44</th>\n",
+              "      <td>What happens if I overdose?\\n</td>\n",
+              "      <td>0.974580</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>48</th>\n",
+              "      <td>Later symptoms may include pain in your upper ...</td>\n",
+              "      <td>0.974143</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>20</th>\n",
+              "      <td>You may need to shake the liquid before each use.</td>\n",
+              "      <td>0.971407</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>6</th>\n",
+              "      <td>Children younger than 12 years old: Do not tak...</td>\n",
+              "      <td>0.970931</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>16</th>\n",
+              "      <td>Acetaminophen made for infants is available in...</td>\n",
+              "      <td>0.970326</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>25</th>\n",
+              "      <td>It will begin to dissolve right away.</td>\n",
+              "      <td>0.965610</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>35</th>\n",
+              "      <td>This medication can cause unusual results with...</td>\n",
+              "      <td>0.965369</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>43</th>\n",
+              "      <td>Do not take extra medicine to make up the miss...</td>\n",
+              "      <td>0.965241</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>33</th>\n",
+              "      <td>you still have a sore throat after 2 days of u...</td>\n",
+              "      <td>0.964760</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>3</th>\n",
+              "      <td>An overdose of acetaminophen can damage your l...</td>\n",
+              "      <td>0.962565</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>37</th>\n",
+              "      <td>Store at room temperature away from heat and m...</td>\n",
+              "      <td>0.961480</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>1</th>\n",
+              "      <td>Do not use in larger or smaller amounts or for...</td>\n",
+              "      <td>0.958920</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>12</th>\n",
+              "      <td>Carefully follow the dosing directions on the ...</td>\n",
+              "      <td>0.957755</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>32</th>\n",
+              "      <td>Stop taking acetaminophen and call your doctor...</td>\n",
+              "      <td>0.957628</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>0</th>\n",
+              "      <td>Use acetaminophen exactly as directed on the l...</td>\n",
+              "      <td>0.955922</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>8</th>\n",
+              "      <td>Use exactly as directed on the label.\\n</td>\n",
+              "      <td>0.955541</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>15</th>\n",
+              "      <td>If you do not have a dose-measuring device, as...</td>\n",
+              "      <td>0.952480</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>21</th>\n",
+              "      <td>Follow the directions on the medicine label.\\n</td>\n",
+              "      <td>0.948743</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>9</th>\n",
+              "      <td>Avoid also using other medicines that contain ...</td>\n",
+              "      <td>0.948524</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>24</th>\n",
+              "      <td>Place the tablet on your tongue.</td>\n",
+              "      <td>0.939802</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>31</th>\n",
+              "      <td>The oral powder should be placed directly on t...</td>\n",
+              "      <td>0.935658</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>18</th>\n",
+              "      <td>Using the wrong device may cause you to give y...</td>\n",
+              "      <td>0.933256</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>26</th>\n",
+              "      <td>Do not swallow the tablet whole.</td>\n",
+              "      <td>0.929310</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>39</th>\n",
+              "      <td>What happens if I miss a dose?\\n</td>\n",
+              "      <td>0.925999</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>36</th>\n",
+              "      <td>Tell any doctor who treats you that you are us...</td>\n",
+              "      <td>0.881941</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>17</th>\n",
+              "      <td>These dosing devices are not equal between the...</td>\n",
+              "      <td>0.834642</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>40</th>\n",
+              "      <td>Since acetaminophen is taken as needed, you ma...</td>\n",
+              "      <td>0.793494</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>23</th>\n",
+              "      <td>Make sure your hands are dry when handling the...</td>\n",
+              "      <td>0.784750</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>2</th>\n",
+              "      <td>Do not take more of this medication than is re...</td>\n",
+              "      <td>0.764344</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>46</th>\n",
+              "      <td>An overdose of acetaminophen can be fatal.\\n</td>\n",
+              "      <td>0.699272</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>13</th>\n",
+              "      <td>Measure</td>\n",
+              "      <td>0.637849</td>\n",
+              "    </tr>\n",
+              "    <tr>\n",
+              "      <th>27</th>\n",
+              "      <td>Allow it to dissolve in your mouth without che...</td>\n",
+              "      <td>0.632083</td>\n",
+              "    </tr>\n",
+              "  </tbody>\n",
+              "</table>\n",
+              "</div>"
+            ],
+            "text/plain": [
+              "                                            Sentences  Similarity\n",
+              "38        Detailed Acetaminophen dosage information\\n    0.991904\n",
+              "19  Never mix and match dosing devices between inf...    0.989643\n",
+              "14  liquid medicinewith the dosing syringe provide...    0.989598\n",
+              "45  Seek emergency medical attention or call the P...    0.986279\n",
+              "42  Skip the missed dose if it is almost time for ...    0.986243\n",
+              "28  To use the acetaminophen effervescent granules...    0.985514\n",
+              "22  The chewable tablet must be chewed thoroughly ...    0.984686\n",
+              "34  you have a skin rash, ongoing headache, nausea...    0.984482\n",
+              "7   Use only the number of milligrams per dose tha...    0.984069\n",
+              "30  To make sure you get the entire dose, add a li...    0.983659\n",
+              "11  Use only the special dose-measuring dropper or...    0.982866\n",
+              "47  The first signs of an acetaminophen overdose i...    0.981202\n",
+              "41  If you are taking the medication regularly, ta...    0.980014\n",
+              "10  If you are treating a child, use a pediatric f...    0.978841\n",
+              "29  Stir this mixture and drink all of it right away.    0.978108\n",
+              "4   Adults and teenagers who weigh at least 110 po...    0.974876\n",
+              "5        Do not take more than 4000 mg in 24 hours.\\n    0.974606\n",
+              "44                      What happens if I overdose?\\n    0.974580\n",
+              "48  Later symptoms may include pain in your upper ...    0.974143\n",
+              "20  You may need to shake the liquid before each use.    0.971407\n",
+              "6   Children younger than 12 years old: Do not tak...    0.970931\n",
+              "16  Acetaminophen made for infants is available in...    0.970326\n",
+              "25              It will begin to dissolve right away.    0.965610\n",
+              "35  This medication can cause unusual results with...    0.965369\n",
+              "43  Do not take extra medicine to make up the miss...    0.965241\n",
+              "33  you still have a sore throat after 2 days of u...    0.964760\n",
+              "3   An overdose of acetaminophen can damage your l...    0.962565\n",
+              "37  Store at room temperature away from heat and m...    0.961480\n",
+              "1   Do not use in larger or smaller amounts or for...    0.958920\n",
+              "12  Carefully follow the dosing directions on the ...    0.957755\n",
+              "32  Stop taking acetaminophen and call your doctor...    0.957628\n",
+              "0   Use acetaminophen exactly as directed on the l...    0.955922\n",
+              "8             Use exactly as directed on the label.\\n    0.955541\n",
+              "15  If you do not have a dose-measuring device, as...    0.952480\n",
+              "21     Follow the directions on the medicine label.\\n    0.948743\n",
+              "9   Avoid also using other medicines that contain ...    0.948524\n",
+              "24                   Place the tablet on your tongue.    0.939802\n",
+              "31  The oral powder should be placed directly on t...    0.935658\n",
+              "18  Using the wrong device may cause you to give y...    0.933256\n",
+              "26                   Do not swallow the tablet whole.    0.929310\n",
+              "39                   What happens if I miss a dose?\\n    0.925999\n",
+              "36  Tell any doctor who treats you that you are us...    0.881941\n",
+              "17  These dosing devices are not equal between the...    0.834642\n",
+              "40  Since acetaminophen is taken as needed, you ma...    0.793494\n",
+              "23  Make sure your hands are dry when handling the...    0.784750\n",
+              "2   Do not take more of this medication than is re...    0.764344\n",
+              "46       An overdose of acetaminophen can be fatal.\\n    0.699272\n",
+              "13                                            Measure    0.637849\n",
+              "27  Allow it to dissolve in your mouth without che...    0.632083"
+            ]
+          },
+          "execution_count": 97,
+          "metadata": {},
+          "output_type": "execute_result"
+        }
+      ]
+    },
+    {
+      "cell_type": "code",
+      "metadata": {
+        "colab": {
+          "base_uri": "https://localhost:8080/"
+        },
+        "id": "WiYQwg83gXRR",
+        "outputId": "2404e412-339f-4932-b0b0-5b74d4697d08"
+      },
+      "source": [
+        "print(df_xlm[df_xlm['Sentences'].str.contains(\"Do not take more than 5 doses of acetaminophen in 24 hours.\")], \n",
+        "      df_xlm[df_xlm['Sentences'].str.contains(\"Use only the number of milligrams per dose that is recommended for the child's weight and age.\")],\n",
+        "      df_xlm[df_xlm['Sentences'].str.contains(\"Use exactly as directed on the label\")],\n",
+        "      df_xlm[df_xlm['Sentences'].str.contains(\"If you are treating a child, use a pediatric form of acetaminophen.\")],\n",
+        "      df_xlm[df_xlm['Sentences'].str.contains(\"Use only the special dose-measuring dropper or oral syringe that comes with the specific pediatric form you are using.\")],\n",
+        "      df_xlm[df_xlm['Sentences'].str.contains(\"Carefully follow the dosing directions on the medicine label.\")],)"
+      ],
+      "execution_count": null,
+      "outputs": [
+        {
+          "name": "stdout",
+          "output_type": "stream",
+          "text": [
+            "                                           Sentences  Similarity\n",
+            "6  Children younger than 12 years old: Do not tak...    0.970931                                            Sentences  Similarity\n",
+            "7  Use only the number of milligrams per dose tha...    0.984069                                  Sentences  Similarity\n",
+            "8  Use exactly as directed on the label.\\n    0.955541                                             Sentences  Similarity\n",
+            "10  If you are treating a child, use a pediatric f...    0.978841                                             Sentences  Similarity\n",
+            "11  Use only the special dose-measuring dropper or...    0.982866                                             Sentences  Similarity\n",
+            "12  Carefully follow the dosing directions on the ...    0.957755\n"
+          ]
+        }
+      ]
+    },
+    {
+      "cell_type": "code",
+      "metadata": {
+        "id": "eomecefJ5Hn5"
+      },
+      "source": [
+        ""
+      ],
+      "execution_count": null,
+      "outputs": []
+    }
+  ]
+}
\ No newline at end of file