{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "I8Q51pZ5NI0L"
      },
      "source": [
        "# Build with Gemma and Haystack\n",
        "\n",
        "<img src=\"https://huggingface.co/blog/assets/gemma/Gemma-logo-small.png\" width=\"200\" style=\"display:inline;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n",
        "<img src=\"https://haystack.deepset.ai/images/haystack-ogimage.png\" width=\"430\" style=\"display:inline;\">\n",
        "\n",
        "\n",
        "\n",
        "We will see what we can build with the new [Google Gemma open models](https://blog.google/technology/developers/gemma-open-models/) and the [Haystack LLM framework](https://haystack.deepset.ai/)."
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "1LRwBMJdF_d1"
      },
      "source": [
        "## Installation"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "5ggXrtFs18rs"
      },
      "outputs": [],
      "source": [
        "! pip install haystack-ai \"huggingface_hub>=0.22.0\""
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "Lh60ZvTdGDdh"
      },
      "source": [
        "## Authorization\n",
        "\n",
        "- you need an Hugging Face account\n",
        "- you need to accept Google conditions here: https://huggingface.co/google/gemma-7b-it and wait for the authorization"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 2,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "6lBjYZOC3Ug2",
        "outputId": "1395a3e3-2ce5-48ba-e3cc-148f99a000f8"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Your Hugging Face token··········\n"
          ]
        }
      ],
      "source": [
        "import getpass, os\n",
        "\n",
        "\n",
        "os.environ[\"HF_API_TOKEN\"] = getpass.getpass(\"Your Hugging Face token\")"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "rfW8gRwpGZjc"
      },
      "source": [
        "## Chat with Gemma (travel assistant) 🛩"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "ADndXQaAO2f5"
      },
      "source": [
        "For simplicity, we call the model using the free Hugging Face Inference API with the `HuggingFaceAPIChatGenerator`.\n",
        "\n",
        "(We might also load it in Colab using the `HuggingFaceLocalChatGenerator` in a quantized version)."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 4,
      "metadata": {
        "id": "DDQgIA8v2GAW"
      },
      "outputs": [],
      "source": [
        "from haystack.components.generators.chat import HuggingFaceAPIChatGenerator\n",
        "from haystack.dataclasses import ChatMessage\n",
        "\n",
        "generator = HuggingFaceAPIChatGenerator(\n",
        "    api_type=\"serverless_inference_api\",\n",
        "    api_params={\"model\": \"google/gemma-7b-it\"},\n",
        "    generation_kwargs={\"max_new_tokens\": 350})"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 7,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "De8xaGIR3NCG",
        "outputId": "c7bd23a7-1513-4e51-c8bc-dd96770d1b6f"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Enter your message or Q to exit\n",
            "🧑  can you help me planning a trip?\n",
            "🤖 **Sure, I'd be happy to help you with that. Please provide me with the following information:**\n",
            "\n",
            "* **What you want to do:** What are your interests and what do you want to see and experience on your trip?\n",
            "* **Your budget:** How much you are willing to spend on your trip.\n",
            "* **Your preferred travel dates:** When you would like to travel.\n",
            "* **Your preferred travel style:** Whether you prefer solo travel, group travel, or a guided tour.\n",
            "* **Your preferred location:** Where you would like to go.\n",
            "* **Any specific interests or activities you want to include:** For example, hiking, sightseeing, or exploring the local culture.\n",
            "\n",
            "Once I have this information, I can help you plan a trip that is tailored to your specific interests and budget. I can also provide you with recommendations for accommodations, transportation, and activities.\n",
            "Enter your message or Q to exit\n",
            "🧑 I'm interested in Italy. what can I visit?\n",
            "🤖 Sure, here are some ideas for places you can visit in Italy based on your interests:\n",
            "\n",
            "**For history and culture:**\n",
            "* Rome: The Eternal City, with its ancient ruins, museums, and vibrant culture.\n",
            "* Florence: The \"Cradle of the Renaissance,\" with its stunning architecture, art, and history.\n",
            "* Pompeii: The ancient Roman city preserved by the eruption of Mount Vesuvius in 79 AD.\n",
            "* Cinque Terre: A series of five picturesque villages along the Italian Riviera.\n",
            "* Amalfi Coast: A scenic drive along the coast of the Amalfi Coast, known for its stunning views and charming towns.\n",
            "\n",
            "**For nature and outdoor recreation:**\n",
            "* Mount Vesuvius: An active volcano with a fascinating history.\n",
            "* The Dolomites: A mountain range with breathtaking scenery and a variety of hiking trails.\n",
            "* The Italian Alps: A mountain range with towering peaks and glaciers.\n",
            "* Lake Como: A beautiful lake surrounded by mountains and villages.\n",
            "* The Amalfi Coast: A scenic drive along the coast of the Amalfi Coast, known for its stunning views and charming towns.\n",
            "\n",
            "**For food and wine:**\n",
            "* Tuscany: A region known for its delicious food, wine, and olive oil.\n",
            "* Piedmont: A region known for its truffles, chocolates, and red wine.\n",
            "* Apulia: A region known for its olive oil, cheese, and seafood.\n",
            "* Sicily: A region known for its unique cuisine and vibrant culture.\n",
            "Enter your message or Q to exit\n",
            "🧑 nice. can you provide me with a list of things I should take with me to Italy for the trip?\n",
            "🤖 Sure, here are a few things you should pack for your trip to Italy:\n",
            "\n",
            "* Comfortable walking shoes\n",
            "* Light clothing\n",
            "* Sunscreen\n",
            "* Hat\n",
            "* Sunglasses\n",
            "* Camera\n",
            "* Water bottle\n",
            "* A small amount of cash\n",
            "* Credit card\n",
            "* A few basic Italian phrases\n",
            "* A map of Italy\n",
            "* A guidebook to Italy\n",
            "Enter your message or Q to exit\n",
            "🧑 Q\n"
          ]
        }
      ],
      "source": [
        "messages = []\n",
        "\n",
        "while True:\n",
        "  msg = input(\"Enter your message or Q to exit\\n🧑 \")\n",
        "  if msg==\"Q\":\n",
        "    break\n",
        "  messages.append(ChatMessage.from_user(msg))\n",
        "  response = generator.run(messages=messages)\n",
        "  assistant_resp = response['replies'][0]\n",
        "  print(\"🤖 \"+assistant_resp.text)\n",
        "  messages.append(assistant_resp)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "7XAtaoEiHE6B"
      },
      "source": [
        "## RAG with Gemma (about Rock music) 🎸"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "7Mlv8v0X_qGP"
      },
      "outputs": [],
      "source": [
        "! pip install wikipedia"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "TCeqQB3kHqcz"
      },
      "source": [
        "### Load data from Wikipedia"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 9,
      "metadata": {
        "id": "c_yp6s9aHnhx"
      },
      "outputs": [],
      "source": [
        "favourite_bands=\"\"\"Audioslave\n",
        "Blink-182\n",
        "Dire Straits\n",
        "Evanescence\n",
        "Green Day\n",
        "Muse (band)\n",
        "Nirvana (band)\n",
        "Sum 41\n",
        "The Cure\n",
        "The Smiths\"\"\".split(\"\\n\")"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 17,
      "metadata": {
        "id": "Uu9PclysIP4T"
      },
      "outputs": [],
      "source": [
        "from IPython.display import Image\n",
        "from pprint import pprint\n",
        "import rich\n",
        "import random"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 10,
      "metadata": {
        "id": "cpTwStuJHvxR"
      },
      "outputs": [],
      "source": [
        "import wikipedia\n",
        "from haystack.dataclasses import Document\n",
        "\n",
        "raw_docs=[]\n",
        "\n",
        "for title in favourite_bands:\n",
        "    page = wikipedia.page(title=title, auto_suggest=False)\n",
        "    doc = Document(content=page.content, meta={\"title\": page.title, \"url\":page.url})\n",
        "    raw_docs.append(doc)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "h1fvmgsZH0i8"
      },
      "source": [
        "### Indexing Pipeline"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 11,
      "metadata": {
        "id": "MHVRdvRNHwKT"
      },
      "outputs": [],
      "source": [
        "from haystack import Pipeline\n",
        "from haystack.document_stores.in_memory import InMemoryDocumentStore\n",
        "from haystack.components.preprocessors import DocumentCleaner, DocumentSplitter\n",
        "from haystack.components.writers import DocumentWriter\n",
        "from haystack.document_stores.types import DuplicatePolicy"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 12,
      "metadata": {
        "id": "EoJjHmLjH7Ag"
      },
      "outputs": [],
      "source": [
        "document_store = InMemoryDocumentStore()"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 13,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "fBbmbJX6H9cj",
        "outputId": "51722cec-701a-47be-b9f7-b2815d92cd26"
      },
      "outputs": [
        {
          "data": {
            "text/plain": [
              "<haystack.pipeline.Pipeline at 0x7f7a11777490>"
            ]
          },
          "execution_count": 13,
          "metadata": {},
          "output_type": "execute_result"
        }
      ],
      "source": [
        "indexing = Pipeline()\n",
        "indexing.add_component(\"cleaner\", DocumentCleaner())\n",
        "indexing.add_component(\"splitter\", DocumentSplitter(split_by='sentence', split_length=2))\n",
        "indexing.add_component(\"writer\", DocumentWriter(document_store=document_store, policy=DuplicatePolicy.OVERWRITE))\n",
        "\n",
        "indexing.connect(\"cleaner\", \"splitter\")\n",
        "indexing.connect(\"splitter\", \"writer\")"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 19,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "ddizanfoIFz3",
        "outputId": "03da6778-fa99-4ff2-c9f4-865c6cc5b7cd"
      },
      "outputs": [
        {
          "data": {
            "text/plain": [
              "{'writer': {'documents_written': 1584}}"
            ]
          },
          "execution_count": 19,
          "metadata": {},
          "output_type": "execute_result"
        }
      ],
      "source": [
        "indexing.run({\"cleaner\":{\"documents\":raw_docs}})"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 20,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "KRv-TgV9IZcF",
        "outputId": "92b55c9a-2b89-4740-c512-864d3c210cd5"
      },
      "outputs": [
        {
          "data": {
            "text/plain": [
              "{'title': 'Audioslave',\n",
              " 'url': 'https://en.wikipedia.org/wiki/Audioslave',\n",
              " 'source_id': 'e3deff3d39ef107e8b0d69415ea61644b73175086cfbeee03d5f5d6946619fcf'}"
            ]
          },
          "execution_count": 20,
          "metadata": {},
          "output_type": "execute_result"
        }
      ],
      "source": [
        "document_store.filter_documents()[0].meta"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "Qk8v_s8xIdLV"
      },
      "source": [
        "### RAG Pipeline"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 29,
      "metadata": {
        "id": "wF7mPcnwIbfi"
      },
      "outputs": [],
      "source": [
        "from haystack.components.builders import PromptBuilder\n",
        "\n",
        "prompt_template = \"\"\"\n",
        "<start_of_turn>user\n",
        "Using the information contained in the context, give a comprehensive answer to the question.\n",
        "If the answer is contained in the context, also report the source URL.\n",
        "If the answer cannot be deduced from the context, do not give an answer.\n",
        "\n",
        "Context:\n",
        "  {% for doc in documents %}\n",
        "  {{ doc.content }} URL:{{ doc.meta['url'] }}\n",
        "  {% endfor %};\n",
        "  Question: {{query}}<end_of_turn>\n",
        "\n",
        "<start_of_turn>model\n",
        "\"\"\"\n",
        "prompt_builder = PromptBuilder(template=prompt_template)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "pbvNtRzxPSOe"
      },
      "source": [
        "Here, we use the `HuggingFaceAPIGenerator` since it is not a chat setting and we don't envision multi-turn conversations but just RAG."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 30,
      "metadata": {
        "id": "B2GTQqgXKMUO"
      },
      "outputs": [],
      "source": [
        "from haystack.components.generators import HuggingFaceAPIGenerator\n",
        "\n",
        "generator = HuggingFaceAPIGenerator(\n",
        "    api_type=\"serverless_inference_api\",\n",
        "    api_params={\"model\": \"google/gemma-7b-it\"},\n",
        "    generation_kwargs={\"max_new_tokens\": 500})"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 31,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "lx6PNcm-I1zF",
        "outputId": "a68372ad-8936-4197-e972-1d81c54a5404"
      },
      "outputs": [
        {
          "data": {
            "text/plain": [
              "<haystack.pipeline.Pipeline at 0x7f7a10ee5180>"
            ]
          },
          "execution_count": 31,
          "metadata": {},
          "output_type": "execute_result"
        }
      ],
      "source": [
        "from haystack.components.retrievers.in_memory import InMemoryBM25Retriever\n",
        "\n",
        "rag = Pipeline()\n",
        "rag.add_component(\"retriever\", InMemoryBM25Retriever(document_store=document_store, top_k=5))\n",
        "rag.add_component(\"prompt_builder\", prompt_builder)\n",
        "rag.add_component(\"llm\", generator)\n",
        "\n",
        "rag.connect(\"retriever.documents\", \"prompt_builder.documents\")\n",
        "rag.connect(\"prompt_builder.prompt\", \"llm.prompt\")"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "DrKccbWeMyjB"
      },
      "source": [
        "### Let's ask some questions!"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 36,
      "metadata": {
        "id": "kUsZ5NPzKCEO"
      },
      "outputs": [],
      "source": [
        "def get_generative_answer(query):\n",
        "\n",
        "  results = rag.run({\n",
        "      \"retriever\": {\"query\": query},\n",
        "      \"prompt_builder\": {\"query\": query}\n",
        "    }\n",
        "  )\n",
        "\n",
        "  answer = results[\"llm\"][\"replies\"][0]\n",
        "  rich.print(answer)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 43,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 209,
          "referenced_widgets": [
            "96f13cf06a814cae878244f42aefecbb",
            "6d14f15aa8bb4422af36f3603ec29dab",
            "455cc132a0de4967ac8064d8a68584b2",
            "cd5c0ba2ab1a453993ceeed76fe71bf8",
            "52ef4fd4cc2d49b6803995ee56369816",
            "e21d0fd8e3ca4b96b96d5eb0471efd38",
            "5ca2615632184ccb908628b62f2e8bbe",
            "8bac2d79ecb94883ba8b5c41bd827f3d",
            "23206a144ea9409a9850fdba5257d1d8",
            "b9c0b15ab5a54ef393d32f11f115ffcc",
            "5a679669b6ae4a26b4b9408d049529af"
          ]
        },
        "id": "LXxvLGuNKrKK",
        "outputId": "73850d48-d0cf-4cec-ebc6-0101690053f2"
      },
      "outputs": [
        {
          "data": {
            "application/vnd.jupyter.widget-view+json": {
              "model_id": "96f13cf06a814cae878244f42aefecbb",
              "version_major": 2,
              "version_minor": 0
            },
            "text/plain": [
              "Ranking by BM25...:   0%|          | 0/1565 [00:00<?, ? docs/s]"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "data": {
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">**Answer:**\n",
              "\n",
              "Sure, here is the answer to the question:\n",
              "\n",
              "Audioslave was formed by members of Soundgarden and Rage Against the Machine. The sound of Audioslave was a blend \n",
              "of the grunge sound of Soundgarden and the funk metal sound of Rage Against the Machine.\n",
              "\n",
              "**Source URL:**\n",
              "\n",
              "* <span style=\"font-weight: bold\">[</span>Audioslave Wikipedia page<span style=\"font-weight: bold\">](</span><span style=\"color: #800080; text-decoration-color: #800080\">/wiki/</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">Audioslave</span><span style=\"font-weight: bold\">)</span>\n",
              "</pre>\n"
            ],
            "text/plain": [
              "**Answer:**\n",
              "\n",
              "Sure, here is the answer to the question:\n",
              "\n",
              "Audioslave was formed by members of Soundgarden and Rage Against the Machine. The sound of Audioslave was a blend \n",
              "of the grunge sound of Soundgarden and the funk metal sound of Rage Against the Machine.\n",
              "\n",
              "**Source URL:**\n",
              "\n",
              "* \u001b[1m[\u001b[0mAudioslave Wikipedia page\u001b[1m]\u001b[0m\u001b[1m(\u001b[0m\u001b[35m/wiki/\u001b[0m\u001b[95mAudioslave\u001b[0m\u001b[1m)\u001b[0m\n"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        }
      ],
      "source": [
        "get_generative_answer(\"Audioslave was formed by members of two iconic bands. Can you name the bands and discuss the sound of Audioslave in comparison?\")"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 83,
      "metadata": {
        "id": "UsS-w7DSKvVN"
      },
      "outputs": [],
      "source": [
        "nice_questions_to_try=\"\"\"What was the original name of Sum 41?\n",
        "What was the title of Nirvana's breakthrough album released in 1991?\n",
        "Green Day's \"American Idiot\" is a rock opera. What's the story it tells?\n",
        "Audioslave was formed by members of two iconic bands. Can you name the bands and discuss the sound of Audioslave in comparison?\n",
        "Evanescence's \"Bring Me to Life\" features a male vocalist. Who is he, and how does his voice complement Amy Lee's in the song?\n",
        "What is Sum 41's debut studio album called?\n",
        "Who was the lead singer of Audioslave?\n",
        "When was Nirvana's first studio album, \"Bleach,\" released?\n",
        "Were the Smiths an influential band?\n",
        "What is the name of Evanescence's debut album?\n",
        "Which band was Morrissey the lead singer of before he formed The Smiths?\n",
        "Dire Straits' hit song \"Money for Nothing\" features a guest vocal by a famous artist. Who is this artist?\n",
        "Who played the song \"Like a stone\"?\"\"\".split('\\n')"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 90,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 162,
          "referenced_widgets": [
            "8e94c1f8262c46a5a46f4eb629188557",
            "9708a7a3233a4e519e729d7541ca207c",
            "edd419577fd648199e1145ae0c747a8f",
            "99f30cdec3074192a6f57005fbda7ae2",
            "6c178969648d455ea63722df7453ae3e",
            "4985c6a71c00480b803dfc60332c3506",
            "8ba060081bca4f62b0e9c71274d91b1a",
            "9fdc592ff60648ffbc9eb533a07c66a7",
            "c148d084abf84b338f42d12c302ba35b",
            "e8f39ef33c24475387672521c4e0d40c",
            "0157d75798fe48e8b7e58538e8d99065"
          ]
        },
        "id": "rnXFXEQMLijI",
        "outputId": "b84efcb4-f0fb-4ade-b6ce-a7bd6c8fd8d0"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "What was the original name of Sum 41?\n"
          ]
        },
        {
          "data": {
            "application/vnd.jupyter.widget-view+json": {
              "model_id": "8e94c1f8262c46a5a46f4eb629188557",
              "version_major": 2,
              "version_minor": 0
            },
            "text/plain": [
              "Ranking by BM25...:   0%|          | 0/1565 [00:00<?, ? docs/s]"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "data": {
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">**Answer:** Supernova\n",
              "\n",
              "**Source URL:**  en.wikipedia.org/wiki/Sum_41\n",
              "\n",
              "The text states that the band originally changed their name to Supernova, so the answer to the question is \n",
              "Supernova.\n",
              "</pre>\n"
            ],
            "text/plain": [
              "**Answer:** Supernova\n",
              "\n",
              "**Source URL:**  en.wikipedia.org/wiki/Sum_41\n",
              "\n",
              "The text states that the band originally changed their name to Supernova, so the answer to the question is \n",
              "Supernova.\n"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        }
      ],
      "source": [
        "q=random.choice(nice_questions_to_try)\n",
        "print(q)\n",
        "get_generative_answer(q)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "8Ap55HKoMSgx"
      },
      "source": [
        "This is a simple demo.\n",
        "We can improve the RAG Pipeline using better retrieval techniques: Embedding Retrieval, Hybrid Retrieval..."
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "Wo9JfscmOEb3"
      },
      "source": [
        "(*Notebook by [Stefano Fiorucci](https://github.com/anakin87)*)"
      ]
    }
  ],
  "metadata": {
    "accelerator": "GPU",
    "colab": {
      "gpuType": "T4",
      "provenance": []
    },
    "kernelspec": {
      "display_name": "Python 3",
      "name": "python3"
    },
    "language_info": {
      "name": "python"
    },
    "widgets": {
      "application/vnd.jupyter.widget-state+json": {
        "0157d75798fe48e8b7e58538e8d99065": {
          "model_module": "@jupyter-widgets/controls",
          "model_module_version": "1.5.0",
          "model_name": "DescriptionStyleModel",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "23206a144ea9409a9850fdba5257d1d8": {
          "model_module": "@jupyter-widgets/controls",
          "model_module_version": "1.5.0",
          "model_name": "ProgressStyleModel",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "ProgressStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "bar_color": null,
            "description_width": ""
          }
        },
        "455cc132a0de4967ac8064d8a68584b2": {
          "model_module": "@jupyter-widgets/controls",
          "model_module_version": "1.5.0",
          "model_name": "FloatProgressModel",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "FloatProgressModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "ProgressView",
            "bar_style": "success",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_8bac2d79ecb94883ba8b5c41bd827f3d",
            "max": 1565,
            "min": 0,
            "orientation": "horizontal",
            "style": "IPY_MODEL_23206a144ea9409a9850fdba5257d1d8",
            "value": 1565
          }
        },
        "4985c6a71c00480b803dfc60332c3506": {
          "model_module": "@jupyter-widgets/base",
          "model_module_version": "1.2.0",
          "model_name": "LayoutModel",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "52ef4fd4cc2d49b6803995ee56369816": {
          "model_module": "@jupyter-widgets/base",
          "model_module_version": "1.2.0",
          "model_name": "LayoutModel",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "5a679669b6ae4a26b4b9408d049529af": {
          "model_module": "@jupyter-widgets/controls",
          "model_module_version": "1.5.0",
          "model_name": "DescriptionStyleModel",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "5ca2615632184ccb908628b62f2e8bbe": {
          "model_module": "@jupyter-widgets/controls",
          "model_module_version": "1.5.0",
          "model_name": "DescriptionStyleModel",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "6c178969648d455ea63722df7453ae3e": {
          "model_module": "@jupyter-widgets/base",
          "model_module_version": "1.2.0",
          "model_name": "LayoutModel",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "6d14f15aa8bb4422af36f3603ec29dab": {
          "model_module": "@jupyter-widgets/controls",
          "model_module_version": "1.5.0",
          "model_name": "HTMLModel",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_e21d0fd8e3ca4b96b96d5eb0471efd38",
            "placeholder": "​",
            "style": "IPY_MODEL_5ca2615632184ccb908628b62f2e8bbe",
            "value": "Ranking by BM25...: 100%"
          }
        },
        "8ba060081bca4f62b0e9c71274d91b1a": {
          "model_module": "@jupyter-widgets/controls",
          "model_module_version": "1.5.0",
          "model_name": "DescriptionStyleModel",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "8bac2d79ecb94883ba8b5c41bd827f3d": {
          "model_module": "@jupyter-widgets/base",
          "model_module_version": "1.2.0",
          "model_name": "LayoutModel",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "8e94c1f8262c46a5a46f4eb629188557": {
          "model_module": "@jupyter-widgets/controls",
          "model_module_version": "1.5.0",
          "model_name": "HBoxModel",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HBoxModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HBoxView",
            "box_style": "",
            "children": [
              "IPY_MODEL_9708a7a3233a4e519e729d7541ca207c",
              "IPY_MODEL_edd419577fd648199e1145ae0c747a8f",
              "IPY_MODEL_99f30cdec3074192a6f57005fbda7ae2"
            ],
            "layout": "IPY_MODEL_6c178969648d455ea63722df7453ae3e"
          }
        },
        "96f13cf06a814cae878244f42aefecbb": {
          "model_module": "@jupyter-widgets/controls",
          "model_module_version": "1.5.0",
          "model_name": "HBoxModel",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HBoxModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HBoxView",
            "box_style": "",
            "children": [
              "IPY_MODEL_6d14f15aa8bb4422af36f3603ec29dab",
              "IPY_MODEL_455cc132a0de4967ac8064d8a68584b2",
              "IPY_MODEL_cd5c0ba2ab1a453993ceeed76fe71bf8"
            ],
            "layout": "IPY_MODEL_52ef4fd4cc2d49b6803995ee56369816"
          }
        },
        "9708a7a3233a4e519e729d7541ca207c": {
          "model_module": "@jupyter-widgets/controls",
          "model_module_version": "1.5.0",
          "model_name": "HTMLModel",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_4985c6a71c00480b803dfc60332c3506",
            "placeholder": "​",
            "style": "IPY_MODEL_8ba060081bca4f62b0e9c71274d91b1a",
            "value": "Ranking by BM25...: 100%"
          }
        },
        "99f30cdec3074192a6f57005fbda7ae2": {
          "model_module": "@jupyter-widgets/controls",
          "model_module_version": "1.5.0",
          "model_name": "HTMLModel",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_e8f39ef33c24475387672521c4e0d40c",
            "placeholder": "​",
            "style": "IPY_MODEL_0157d75798fe48e8b7e58538e8d99065",
            "value": " 1565/1565 [00:00&lt;00:00, 27387.90 docs/s]"
          }
        },
        "9fdc592ff60648ffbc9eb533a07c66a7": {
          "model_module": "@jupyter-widgets/base",
          "model_module_version": "1.2.0",
          "model_name": "LayoutModel",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "b9c0b15ab5a54ef393d32f11f115ffcc": {
          "model_module": "@jupyter-widgets/base",
          "model_module_version": "1.2.0",
          "model_name": "LayoutModel",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "c148d084abf84b338f42d12c302ba35b": {
          "model_module": "@jupyter-widgets/controls",
          "model_module_version": "1.5.0",
          "model_name": "ProgressStyleModel",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "ProgressStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "bar_color": null,
            "description_width": ""
          }
        },
        "cd5c0ba2ab1a453993ceeed76fe71bf8": {
          "model_module": "@jupyter-widgets/controls",
          "model_module_version": "1.5.0",
          "model_name": "HTMLModel",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_b9c0b15ab5a54ef393d32f11f115ffcc",
            "placeholder": "​",
            "style": "IPY_MODEL_5a679669b6ae4a26b4b9408d049529af",
            "value": " 1565/1565 [00:00&lt;00:00, 14446.98 docs/s]"
          }
        },
        "e21d0fd8e3ca4b96b96d5eb0471efd38": {
          "model_module": "@jupyter-widgets/base",
          "model_module_version": "1.2.0",
          "model_name": "LayoutModel",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "e8f39ef33c24475387672521c4e0d40c": {
          "model_module": "@jupyter-widgets/base",
          "model_module_version": "1.2.0",
          "model_name": "LayoutModel",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "edd419577fd648199e1145ae0c747a8f": {
          "model_module": "@jupyter-widgets/controls",
          "model_module_version": "1.5.0",
          "model_name": "FloatProgressModel",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "FloatProgressModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "ProgressView",
            "bar_style": "success",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_9fdc592ff60648ffbc9eb533a07c66a7",
            "max": 1565,
            "min": 0,
            "orientation": "horizontal",
            "style": "IPY_MODEL_c148d084abf84b338f42d12c302ba35b",
            "value": 1565
          }
        }
      }
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}
