{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "chBgl-RHFAKi"
      },
      "source": [
        "# Using Hypothetical Document Embeddings (HyDE) to Improve Retrieval\n",
        "\n",
        "> 📚 This cookbook has an accompanying article with a complete walkthrough [\"Optimizing Retrival with HyDE\"](https://haystack.deepset.ai/blog/optimizing-retrieval-with-hyde)\n",
        "\n",
        "In this coookbook, we are building Haystack components that allow us to easily incorporate HyDE into our RAG pipelines, to optimize retrieval.\n",
        "\n",
        "> To learn more about HyDE and when it's useful, check out our [guide to Hypothetical Document Embeddings (HyDE)](https://docs.haystack.deepset.ai/docs/hypothetical-document-embeddings-hyde)\n",
        "\n",
        "## Install Requirements"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 1,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "_ZIUJlvQCDvF",
        "outputId": "2879cabf-1d6e-49c4-ab60-17c2688f88ea"
      },
      "outputs": [],
      "source": [
        "!pip install haystack-ai sentence-transformers-haystack datasets"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "Kr6_UhFyFh-c"
      },
      "source": [
        "In the following sections, we will be using the `OpenAIChatGenerator`, so we need to provide our API key 👇"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 2,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "J5l8zljUB1wc",
        "outputId": "228bc893-03a8-4185-f298-eedc309eccf9"
      },
      "outputs": [],
      "source": [
        "from getpass import getpass\n",
        "import os\n",
        "\n",
        "os.environ[\"OPENAI_API_KEY\"] = getpass(\"Enter your openAI key:\")"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "yiIk0Bt2GVbl"
      },
      "source": [
        "## Building a Pipeline for Hypothetical Document Embeddings\n",
        "\n",
        "We will build a Haystack pipeline that generates 'fake' documents.\n",
        "For this part, we are using the `OpenAIChatGenerator` with a `PromptBuilder` that instructs the model to generate paragraphs."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 3,
      "metadata": {
        "id": "q7vs3ubjB7PB"
      },
      "outputs": [
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "ChatPromptBuilder has 1 prompt variables, but `required_variables` is not set. By default, all prompt variables are treated as optional, which may lead to unintended behavior in multi-branch pipelines. To avoid unexpected execution, ensure that variables intended to be required are explicitly set in `required_variables`.\n"
        }
      ],
      "source": [
        "from haystack.components.builders import ChatPromptBuilder\n",
        "from haystack.components.generators.chat import OpenAIChatGenerator\n",
        "from haystack.dataclasses import ChatMessage\n",
        "\n",
        "generator = OpenAIChatGenerator(\n",
        "    model=\"gpt-4o-mini\",\n",
        "    generation_kwargs={\"n\": 5, \"temperature\": 0.75, \"max_tokens\": 400},\n",
        ")\n",
        "\n",
        "template = [\n",
        "    ChatMessage.from_user(\n",
        "        \"\"\"Given a question, generate a paragraph of text that answers the question.\n",
        "            Question: {{question}}\n",
        "            Paragraph:\"\"\"\n",
        "    )\n",
        "]\n",
        "\n",
        "prompt_builder = ChatPromptBuilder(template=template)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "dJVyxytsG6Zc"
      },
      "source": [
        "Next, we use the `OutputAdapter` to transform the generated paragraphs into a List of Documents. This way, we will be able to use the `SentenceTransformersDocumentEmbedder` to create embeddings, since this component expects `List[Document]`"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 4,
      "metadata": {
        "id": "K72gcW84CFtT"
      },
      "outputs": [
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "Unsafe mode is enabled. This allows execution of arbitrary code in the Jinja template. Use this only if you trust the source of the template.\n"
        }
      ],
      "source": [
        "from haystack import Document\n",
        "from haystack.components.converters import OutputAdapter\n",
        "from haystack_integrations.components.embedders.sentence_transformers import SentenceTransformersDocumentEmbedder\n",
        "from typing import List\n",
        "\n",
        "adapter = OutputAdapter(\n",
        "    template=\"{{answers | build_doc}}\",\n",
        "    output_type=List[Document],\n",
        "    unsafe=True,\n",
        "    custom_filters={\"build_doc\": lambda data: [Document(content=d.text) for d in data]}\n",
        ")\n",
        "\n",
        "embedder = SentenceTransformersDocumentEmbedder(model=\"sentence-transformers/all-MiniLM-L6-v2\")"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "j6L5jXO0HcQo"
      },
      "source": [
        "Finally, we create a custom component, `HypotheticalDocumentEmbedder`, that expects `documents` and can return a list of `hypotethetical_embeddings` which is the average of the embeddings from the \"hypothetical\" (fake) documents. To learn more about this technique and where it's useful, check out our [Guide to HyDE](https://docs.haystack.deepset.ai/docs/hypothetical-document-embeddings-hyde)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 5,
      "metadata": {
        "id": "5A7nb9MaCXTH"
      },
      "outputs": [],
      "source": [
        "from numpy import array, mean\n",
        "from haystack import component\n",
        "\n",
        "@component\n",
        "class HypotheticalDocumentEmbedder:\n",
        "\n",
        "  @component.output_types(hypothetical_embedding=List[float])\n",
        "  def run(self, documents: List[Document]):\n",
        "    stacked_embeddings = array([doc.embedding for doc in documents])\n",
        "    avg_embeddings = mean(stacked_embeddings, axis=0)\n",
        "    hyde_vector = avg_embeddings.reshape((1, len(avg_embeddings)))\n",
        "    return {\"hypothetical_embedding\": hyde_vector[0].tolist()}"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "0vCg130JIW3A"
      },
      "source": [
        "We add all of our components into a pipeline to genereate a hypothetical document embedding 🚀👇"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 6,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 49,
          "referenced_widgets": [
            "e37e414744b04538a24a6ee4d9a5ba90",
            "3a1bc15fb77943988919ca6f504f6d4f",
            "66455f3ba9594dada59f669a43c85e8f",
            "866bb81e20e24caaa363784f4fd048ec",
            "d437b2869445412e8cdbbfccc1c40101",
            "a4be69c6d110405ab55510b59b9a6f41",
            "0b4c12dbf599431c987339d2861fcb78",
            "5d4aebc2bf35465dbb6b02f6f3512d0b",
            "49d16d19959c43bb9bd5cd4ce9fd3850",
            "625f9cd6cb934f1984e2d4108d238c43",
            "c519b25093884b60bf9a826ea1ef36f3"
          ]
        },
        "id": "2sa91tDQCaHC",
        "outputId": "92359ba0-26e0-4ba0-85a1-5b9740d4ba66"
      },
      "outputs": [
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "\rLoading weights:   0%|          | 0/103 [00:00<?, ?it/s]"
        },
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "\rLoading weights: 100%|██████████| 103/103 [00:00<00:00, 27177.49it/s]"
        },
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "\rBatches:   0%|          | 0/1 [00:00<?, ?it/s]"
        },
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "\rBatches: 100%|██████████| 1/1 [00:00<00:00,  3.29it/s]"
        },
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "\rBatches: 100%|██████████| 1/1 [00:00<00:00,  3.28it/s]"
        }
      ],
      "source": [
        "from haystack import Pipeline\n",
        "\n",
        "hyde = HypotheticalDocumentEmbedder()\n",
        "\n",
        "pipeline = Pipeline()\n",
        "pipeline.add_component(name=\"prompt_builder\", instance=prompt_builder)\n",
        "pipeline.add_component(name=\"generator\", instance=generator)\n",
        "pipeline.add_component(name=\"adapter\", instance=adapter)\n",
        "pipeline.add_component(name=\"embedder\", instance=embedder)\n",
        "pipeline.add_component(name=\"hyde\", instance=hyde)\n",
        "\n",
        "pipeline.connect(\"prompt_builder\", \"generator\")\n",
        "pipeline.connect(\"generator.replies\", \"adapter.answers\")\n",
        "pipeline.connect(\"adapter.output\", \"embedder.documents\")\n",
        "pipeline.connect(\"embedder.documents\", \"hyde.documents\")\n",
        "\n",
        "query = \"What should I do if I have a fever?\"\n",
        "result = pipeline.run(data={\"prompt_builder\": {\"question\": query}})"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 7,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "AtR8JLUmKqwI",
        "outputId": "80cec7d3-e66b-487d-8c05-a4f362146645"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "{'hypothetical_embedding': [0.015035115397768094, 0.022311289981007575, 0.014800459146499634, 0.04781631901860237, 0.05377841778099537, -0.007497696485370397, -0.001430824538692832, 0.03486817292869091, -0.01328050666488707, -0.007570043951272964, -0.0716647446155548, -0.07587027549743652, 0.09023183435201645, 0.08400671184062958, 0.04074135832488537, -0.08057147264480591, 0.04599575623869896, -0.0078834380954504, -0.013114662002772092, -0.00549622048092715, -0.09688156098127365, -0.007439425634220243, -0.0412241093814373, 0.0412985198199749, -0.019667316786944868, 0.09434134066104889, 0.03630377873778343, 0.018605682626366617, -0.025802867393940686, 0.056856955587863925, 0.0014920824440196156, -0.039135830476880074, 0.019377342984080316, -0.02350237648934126, -0.02898340942338109, 0.07681925743818283, -0.026194417849183083, -0.04505717568099499, -0.06816742196679115, 0.03818172626197338, 0.015487049706280231, 0.11821166723966599, 0.0001829079817980528, 0.005290473252534867, 0.09504245221614838, 0.04263758957386017, -0.08618756234645844, 0.10480208545923234, 0.048721858859062196, 0.04472056180238724, 0.03383471742272377, 0.07492847964167595, 0.012344201002269984, 0.07476185783743858, -0.07458378598093987, 0.06480421498417854, -0.05092479661107063, -0.08131629973649979, -0.01475139781832695, 0.026946894405409694, -0.0977133959531784, 0.04066347926855087, 0.0029776593670248984, -0.04740148410201073, -0.006695220898836851, -0.03927275240421295, -0.04418590068817139, 0.02182939611375332, 0.03376236595213413, 0.09963428527116776, -0.0056303685763850805, -0.03385130539536476, 0.05819617323577404, -0.020869446266442538, -0.0210247453302145, -0.06340052299201489, 0.06667115315794944, -0.06403390169143677, 0.006154567748308182, 0.0237329276278615, 0.02136063240468502, -0.01846354575827718, 0.10780620574951172, 0.03446544073522091, 0.0009003515122458338, 0.002460768911987543, 0.12373750805854797, 0.0697945460677147, 0.003803186863660812, 0.0484909787774086, 0.02392057776451111, -0.035149064287543295, 0.008754059392958879, 0.008502830099314452, 0.06016909331083298, 0.06471320241689682, -0.004472523462027311, 0.025225765909999608, -0.03710203394293785, -0.0036379349883645775, -0.036154814064502716, -0.11532035619020461, -0.026330546103417875, 0.0496743943542242, 0.09747569113969803, -0.015265899494988844, 0.057376538217067716, -0.0613860122859478, 0.06421283632516861, -0.050106524303555486, -0.017273312993347646, 0.039566781371831894, -0.03222834728658199, -0.004811333026736975, 0.01570878764614463, -0.03076768300961703, 0.010851665027439594, 0.030876786261796952, -0.033069641515612605, -0.0024691203609108923, 0.03182302750647068, -0.01174709489569068, 0.04780556783080101, -0.006249496573582291, 0.024953756667673587, 0.0604756087064743, 0.04070237539708614, 2.0998460784658203e-33, 0.024645864102058112, 0.05620456263422966, 0.05014222413301468, 0.043565908446908, 0.03193302545696497, -0.02083879578858614, -0.05147956386208534, 0.027357493154704572, 0.016304877144284545, 0.006163722975179553, 0.08700849562883377, -0.03099062815308571, -0.03276656121015549, 0.028544880077242853, -0.08663911670446396, 0.015713617857545614, -0.009683303534984589, 0.005756492516957224, 0.06991162821650505, 0.03869074881076813, 0.02372922021895647, -0.05927006080746651, -0.011217374599073082, 0.02452812120318413, -0.019169802218675612, 0.04833342023193836, 0.013515884149819612, 0.06402035132050514, 0.0072388299740850925, -0.023720794916152955, -0.04966608211398125, -0.09192386716604233, -0.03482206091284752, 0.018235548119992017, -0.07051616087555886, 0.023174641653895378, -0.11934928894042969, 0.03543294407427311, 0.033151273429393766, 0.02048722542822361, 0.07183996587991714, 0.015971646551042794, -0.03302178923040629, 0.058217187970876695, 0.07181184440851211, 0.04492171928286552, -0.08479476273059845, 0.035099282115697863, -0.08043982535600662, -0.02791498340666294, -0.009288656385615468, 0.003966866177506745, 0.06842890083789825, -0.039114794507622716, -0.05228988826274872, -0.07581480294466018, -0.005623953882604837, 0.009592881426215172, 0.020639165118336678, 0.001155541924526915, 0.04959487989544868, -0.016919028107076885, -0.020367209978940082, 0.00872098095715046, -0.0030504848342388867, -0.002698228391818702, -0.01909295842051506, -0.04816768392920494, -0.011136522464221343, -0.05451123341917992, -0.021540519408881666, 0.029553933441638945, 0.02123446501791477, 0.08602444976568221, -0.01820984361693263, 0.019312142994203897, 0.061223684996366504, -0.07920290157198906, -0.06354795992374421, -0.05585315115749836, -0.029926067404448985, 0.012732043513096869, 0.1273974284529686, 0.07231361120939254, 0.0462229197844863, -0.11416103839874267, -0.0831082820892334, 0.048063277080655095, -0.018720276188105345, -0.002275504369754344, -0.02625810895115137, -0.03050612211227417, -0.03131186719983816, 0.09321162402629853, -0.02846040641888976, -1.7544262094065768e-33, 0.06430951654911041, -0.030954782105982303, 0.002161326352506876, -0.010693906107917428, -0.09214278012514114, 0.029083314165472985, 0.020818993635475635, 0.007737182578421198, 0.018562823318643496, -0.025214019976556302, 0.04902476966381073, -0.09969492703676223, -0.02748006898909807, -0.07910332679748536, -0.01897855754941702, 0.03307177312672138, 0.037622788175940516, 0.04159457720816136, 0.009639577521011234, 0.0634861558675766, -0.09313838481903076, -0.03718243800103664, 0.04988836571574211, -0.005722942855209112, 0.03687952160835266, -0.022539655677974224, 0.06129344329237938, -0.08551847413182259, -0.044972962141036986, -0.029563935473561287, 0.022904086858034134, -0.02473417352885008, 0.02150938423583284, -0.01281003151088953, -0.021427424252033235, 0.032634392753243445, 0.10440869629383087, -0.0673379734158516, 0.002980098081752658, 0.035191428102552894, 0.014779465086758137, 0.012716439319774508, 0.005632004979997873, 0.038913477957248685, 0.04140591025352478, 0.052784348279237746, -0.04024335406720638, -0.020942305261269212, -0.008763612248003483, 0.07682150602340698, 0.008743736939504743, -0.09469334781169891, -0.039635109901428225, 0.04159890804439783, -0.01810033917427063, -0.08182143568992614, -0.10088304728269577, -0.06673290878534317, -0.0338058315217495, -0.017894662579055875, 0.008300257893279196, -0.07147932946681976, -0.03844297304749489, 0.06460779905319214, -0.0710708074271679, 0.038372567296028136, -0.016174491308629513, 0.050388279184699056, 0.02313370183110237, -0.005298992898315191, -0.03528955578804016, -0.03575320616364479, -0.038761899992823604, 0.01999993617646396, 0.07564125135540962, -0.03806028142571449, -0.004509310703724623, 0.03742423839867115, 0.03036624565720558, -0.026994739845395088, -0.03282553851604462, 0.035579908452928063, -0.04076139889657497, -0.05573610700666905, 0.008099883049726486, -0.04963710717856884, 0.036762436479330064, -0.003313001990318298, -0.018975147604942323, -0.011497917259112, 0.019010885152965784, -0.05539939627051353, -0.011752848798641935, 0.1015914723277092, -0.009438093844801187, -4.2338253081197766e-08, 0.003402694221585989, -0.031196068454300986, 0.0361574461683631, 0.023457700759172438, -0.05988355278968811, -0.024971202574670316, -0.034812802262604234, -0.04802888631820679, 0.00333986293990165, 0.015034126583486795, -0.017881500348448754, 0.0681377924978733, 0.07569429352879524, 0.0029936685517895968, -0.09262868613004685, -0.04499559681862593, 0.007345652906224132, -0.014889834262430669, 0.010202807059977203, -0.005971974041312933, -0.00496124904602766, -0.038670070469379425, 0.007559894258156419, 0.026682470738887788, 0.11738967448472977, -0.002729848539456725, 0.03076525595970452, -0.003353365231305361, 0.021001309156417847, -0.037698839977383616, -0.09637439250946045, -0.0010945137124508618, -0.05566137135028839, -0.0611220508813858, 0.007357743382453918, -0.050835716724395755, 0.1034580871462822, 0.024460506811738014, 0.057897952198982236, 0.00311977774836123, 0.021442409534938634, -0.04201583825051784, -0.06657073870301247, -0.01729635214433074, 0.023117180168628692, -0.10118804275989532, 0.00858052116818726, 0.029922755248844624, 0.04716964364051819, -0.04468020349740982, 0.1100489228963852, -0.011313453014008702, 0.04777287095785141, 0.053694383800029756, -0.09335483312606811, -0.01984857637435198, -0.04761600941419601, 0.02250123294070363, 0.0244669271633029, -0.056726131588220596, -0.026276426017284395, -0.05268378518521786, -0.15388669967651367, -0.04325874485075474]}\n"
          ]
        }
      ],
      "source": [
        "print(result[\"hyde\"])"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "8TaYDwNmKzkH"
      },
      "source": [
        "## Build a HyDE Component That Encapsulates the Whole Logic\n",
        "\n",
        "This section shows you how to create a `HypotheticalDocumentEmbedder` that instead, encapsulates the entire logic, and also allows us to provide the embedding model as an optional parameter.\n",
        "\n",
        "This \"mega\" components does a few things:\n",
        "\n",
        "- Allows the user to pick the LLM which generates the hypothetical documents\n",
        "- Allows users to define how many documents should be created with `nr_completions`\n",
        "- Allows users to define the embedding model they want to use to generate the HyDE embeddings.\n",
        "\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 8,
      "metadata": {
        "id": "_57Um_GtKsfM"
      },
      "outputs": [],
      "source": [
        "from haystack import Pipeline, component, Document, default_to_dict, default_from_dict\n",
        "from haystack.components.converters import OutputAdapter\n",
        "from haystack.components.embedders.sentence_transformers_document_embedder import (\n",
        "    SentenceTransformersDocumentEmbedder,\n",
        ")\n",
        "from haystack.components.generators.chat import OpenAIChatGenerator\n",
        "from haystack.components.builders import ChatPromptBuilder\n",
        "\n",
        "from typing import Dict, Any, List\n",
        "from numpy import array, mean\n",
        "from haystack.utils import Secret\n",
        "\n",
        "\n",
        "@component\n",
        "class HypotheticalDocumentEmbedder:\n",
        "\n",
        "    def __init__(\n",
        "        self,\n",
        "        instruct_llm: str = \"gpt-4o-mini\",\n",
        "        instruct_llm_api_key: Secret = Secret.from_env_var(\"OPENAI_API_KEY\"),\n",
        "        nr_completions: int = 5,\n",
        "        embedder_model: str = \"sentence-transformers/all-MiniLM-L6-v2\",\n",
        "    ):\n",
        "        self.instruct_llm = instruct_llm\n",
        "        self.instruct_llm_api_key = instruct_llm_api_key\n",
        "        self.nr_completions = nr_completions\n",
        "        self.embedder_model = embedder_model\n",
        "        self.generator = OpenAIChatGenerator(\n",
        "            api_key=self.instruct_llm_api_key,\n",
        "            model=self.instruct_llm,\n",
        "            generation_kwargs={\n",
        "                \"n\": self.nr_completions,\n",
        "                \"temperature\": 0.75,\n",
        "                \"max_tokens\": 400,\n",
        "            },\n",
        "        )\n",
        "        template = [\n",
        "            ChatMessage.from_user(\n",
        "                \"\"\"Given a question, generate a paragraph of text that answers the question.\n",
        "            Question: {{question}}\n",
        "            Paragraph:\n",
        "            \"\"\"\n",
        "            )\n",
        "        ]\n",
        "        self.prompt_builder = ChatPromptBuilder(template=template)\n",
        "\n",
        "        self.adapter = OutputAdapter(\n",
        "            template=\"{{answers | build_doc}}\",\n",
        "            output_type=List[Document],\n",
        "    unsafe=True,\n",
        "            custom_filters={\n",
        "                \"build_doc\": lambda data: [Document(content=d.text) for d in data]\n",
        "            },\n",
        "        )\n",
        "\n",
        "        self.embedder = SentenceTransformersDocumentEmbedder(model=embedder_model, progress_bar=False)\n",
        "\n",
        "        self.pipeline = Pipeline()\n",
        "        self.pipeline.add_component(name=\"prompt_builder\", instance=self.prompt_builder)\n",
        "        self.pipeline.add_component(name=\"generator\", instance=self.generator)\n",
        "        self.pipeline.add_component(name=\"adapter\", instance=self.adapter)\n",
        "        self.pipeline.add_component(name=\"embedder\", instance=self.embedder)\n",
        "        self.pipeline.connect(\"prompt_builder\", \"generator\")\n",
        "        self.pipeline.connect(\"generator.replies\", \"adapter.answers\")\n",
        "        self.pipeline.connect(\"adapter.output\", \"embedder.documents\")\n",
        "\n",
        "    def to_dict(self) -> Dict[str, Any]:\n",
        "        data = default_to_dict(\n",
        "            self,\n",
        "            instruct_llm=self.instruct_llm,\n",
        "            instruct_llm_api_key=self.instruct_llm_api_key,\n",
        "            nr_completions=self.nr_completions,\n",
        "            embedder_model=self.embedder_model,\n",
        "        )\n",
        "        data[\"pipeline\"] = self.pipeline.to_dict()\n",
        "        return data\n",
        "\n",
        "    @classmethod\n",
        "    def from_dict(cls, data: Dict[str, Any]) -> \"HypotheticalDocumentEmbedder\":\n",
        "        hyde_obj = default_from_dict(cls, data)\n",
        "        hyde_obj.pipeline = Pipeline.from_dict(data[\"pipeline\"])\n",
        "        return hyde_obj\n",
        "\n",
        "    @component.output_types(hypothetical_embedding=List[float])\n",
        "    def run(self, query: str):\n",
        "        result = self.pipeline.run(data={\"prompt_builder\": {\"question\": query}})\n",
        "        # return a single query vector embedding representing the average of the hypothetical document embeddings\n",
        "        stacked_embeddings = array(\n",
        "            [doc.embedding for doc in result[\"embedder\"][\"documents\"]]\n",
        "        )\n",
        "        avg_embeddings = mean(stacked_embeddings, axis=0)\n",
        "        hyde_vector = avg_embeddings.reshape((1, len(avg_embeddings)))\n",
        "        return {\"hypothetical_embedding\": hyde_vector[0].tolist()}"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "z3BTZF6qMtTY"
      },
      "source": [
        "## Use HyDE For Retrieval\n",
        "\n",
        "Let's see how we can use this component in a full pipeline. First, let's index some documents into an `InMemoryDocumentStore`"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 9,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 145,
          "referenced_widgets": [
            "76720573a77442408a924d14c563d711",
            "d15fb403b71d4bff843c5a387a5ea36c",
            "9d8125468bf74c1589fcbe04b0623926",
            "efbcd9eaef6c40f48721cd1ef81ad4ea",
            "f6b5bb6382964c36999cd4c6982b664f",
            "897db75b6abc4cd0923d7caf2448e82b",
            "3afaf53201e94c7e8ba391b95fc1c3d8",
            "1ae296845e2142f0a78b743ecd22ace2",
            "fa5edd6cc3544e2b8ed9165b1536a8fe",
            "43f1affb1f9d4597b2ed08f4dccfa82d",
            "7f8a1097e0b54ac9bede391ae62a5ea0",
            "bfa1065e3afd4d6ab9d8b9cce855730f",
            "b0b397924c2f498db32d7cb57b2648db",
            "8c691d394cf24eb2b6eb61b2d17d59c7",
            "23c5ec7c16144c2e83e57ff396a9a98b",
            "cdbec1d537854931b737ffa577dd3fa6",
            "c7913c050b574b298c8a11ee6ab0fcfd",
            "d689fe03f55f4148b4f62445873b055c",
            "4ef80343c53e40a7804aae8be58bc24e",
            "f0e778c920f043349c44ddc66518b59b",
            "c3db2230ae9e40c597548a551bc5e4d6",
            "a561031934464b0194d648c18fa96076",
            "0cd8313fe64c4f62aa1235b778266137",
            "c7eb9ba2c7794e68a5e3b4f73e5b069a",
            "d3ae8fb928144977823d719cc71bf943",
            "1295414dbaf6409d8c78091e4003c8f6",
            "61119518e3104ccab011ece38978abc5",
            "716bec098dc240fd849be1e70c23b958",
            "e830d27e5dc4418588a65af93c32f7e6",
            "434bd85cc1694c76bd76cfd62f9a9be5",
            "d02c59ff64d64a619df33657727c2ac4",
            "df4fb8b15c8e4464b5834c6a3dbd12c9",
            "9df88f66f7854edaa8c37253a159a51e",
            "09b1b88ae086428ea2f2fcce7fec4be1",
            "2d6db0c1041744dd9671f0b9c7352dd5",
            "752a21d454cc468abb9dcff5c12ecd2d",
            "37e00469a4f94143a488879c6e6535bf",
            "3ec4e9cbfaad40d9827a4d879fded0bc",
            "4ce3d94567de4eb48ae6653d16a53b03",
            "16b211c5cad1464d9c50a7bad22a2e24",
            "7ea1fc96fc7f46699ce20eed96902e8f",
            "d9a5c93f47954f00bb4d7b2562b87e60",
            "efdebbeba075454c896231a39ecd9002",
            "c30cb96c9c9f4846ab4bf94fe2e2ad9d"
          ]
        },
        "id": "9tb9zO_vMzuf",
        "outputId": "f059661e-6656-46b0-9e0f-344999d7de0d"
      },
      "outputs": [
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "\rBatches:   0%|          | 0/82 [00:00<?, ?it/s]"
        },
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "\rBatches:   1%|          | 1/82 [00:00<00:14,  5.64it/s]"
        },
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "\rBatches:   2%|▏         | 2/82 [00:00<00:10,  7.40it/s]"
        },
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "\rBatches:   4%|▎         | 3/82 [00:00<00:09,  8.32it/s]"
        },
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "\rBatches:   6%|▌         | 5/82 [00:00<00:08,  9.47it/s]"
        },
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "\rBatches:   9%|▊         | 7/82 [00:00<00:07, 10.22it/s]"
        },
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "\rBatches:  11%|█         | 9/82 [00:00<00:06, 10.70it/s]"
        },
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "\rBatches:  13%|█▎        | 11/82 [00:01<00:06, 11.08it/s]"
        },
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "\rBatches:  16%|█▌        | 13/82 [00:01<00:06, 11.40it/s]"
        },
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "\rBatches:  18%|█▊        | 15/82 [00:01<00:05, 11.68it/s]"
        },
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "\rBatches:  21%|██        | 17/82 [00:01<00:05, 11.89it/s]"
        },
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "\rBatches:  23%|██▎       | 19/82 [00:01<00:05, 12.08it/s]"
        },
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "\rBatches:  26%|██▌       | 21/82 [00:01<00:05, 12.07it/s]"
        },
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "\rBatches:  28%|██▊       | 23/82 [00:02<00:04, 12.23it/s]"
        },
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "\rBatches:  30%|███       | 25/82 [00:02<00:04, 12.12it/s]"
        },
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "\rBatches:  33%|███▎      | 27/82 [00:02<00:04, 11.89it/s]"
        },
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "\rBatches:  35%|███▌      | 29/82 [00:02<00:04, 12.16it/s]"
        },
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "\rBatches:  38%|███▊      | 31/82 [00:02<00:04, 12.38it/s]"
        },
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "\rBatches:  40%|████      | 33/82 [00:02<00:04, 11.82it/s]"
        },
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "\rBatches:  43%|████▎     | 35/82 [00:03<00:04, 11.73it/s]"
        },
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "\rBatches:  45%|████▌     | 37/82 [00:03<00:03, 12.16it/s]"
        },
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "\rBatches:  48%|████▊     | 39/82 [00:03<00:03, 12.01it/s]"
        },
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "\rBatches:  50%|█████     | 41/82 [00:03<00:03, 11.85it/s]"
        },
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "\rBatches:  52%|█████▏    | 43/82 [00:03<00:03, 12.67it/s]"
        },
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "\rBatches:  55%|█████▍    | 45/82 [00:03<00:02, 13.19it/s]"
        },
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "\rBatches:  57%|█████▋    | 47/82 [00:03<00:02, 14.05it/s]"
        },
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "\rBatches:  60%|█████▉    | 49/82 [00:04<00:02, 14.17it/s]"
        },
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "\rBatches:  62%|██████▏   | 51/82 [00:04<00:02, 15.13it/s]"
        },
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "\rBatches:  65%|██████▍   | 53/82 [00:04<00:01, 15.41it/s]"
        },
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "\rBatches:  67%|██████▋   | 55/82 [00:04<00:01, 15.87it/s]"
        },
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "\rBatches:  71%|███████   | 58/82 [00:04<00:01, 17.59it/s]"
        },
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "\rBatches:  74%|███████▍  | 61/82 [00:04<00:01, 18.73it/s]"
        },
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "\rBatches:  77%|███████▋  | 63/82 [00:04<00:01, 18.69it/s]"
        },
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "\rBatches:  80%|████████  | 66/82 [00:04<00:00, 20.75it/s]"
        },
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "\rBatches:  84%|████████▍ | 69/82 [00:05<00:00, 22.83it/s]"
        },
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "\rBatches:  89%|████████▉ | 73/82 [00:05<00:00, 25.44it/s]"
        },
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "\rBatches:  93%|█████████▎| 76/82 [00:05<00:00, 26.07it/s]"
        },
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "\rBatches:  99%|█████████▉| 81/82 [00:05<00:00, 30.09it/s]"
        },
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "\rBatches: 100%|██████████| 82/82 [00:05<00:00, 14.99it/s]"
        }
      ],
      "source": [
        "from datasets import load_dataset, Dataset\n",
        "\n",
        "from haystack import Pipeline, Document\n",
        "from haystack_integrations.components.embedders.sentence_transformers import SentenceTransformersDocumentEmbedder\n",
        "from haystack.components.preprocessors import DocumentCleaner, DocumentSplitter\n",
        "from haystack.components.writers import DocumentWriter\n",
        "from haystack.document_stores.in_memory import InMemoryDocumentStore\n",
        "\n",
        "embedder_model = \"sentence-transformers/all-MiniLM-L6-v2\"\n",
        "\n",
        "\n",
        "def index_docs(data: Dataset):\n",
        "    # create a data store and indexing pipeline with the components\n",
        "    document_store = InMemoryDocumentStore()\n",
        "\n",
        "    pipeline = Pipeline()\n",
        "    pipeline.add_component(\"cleaner\", DocumentCleaner())\n",
        "    pipeline.add_component(\"splitter\", DocumentSplitter(split_by=\"sentence\", split_length=10))\n",
        "    pipeline.add_component(\"embedder\", SentenceTransformersDocumentEmbedder(model=embedder_model))\n",
        "    pipeline.add_component(\"writer\", DocumentWriter(document_store=document_store, policy=\"skip\"))\n",
        "\n",
        "    # connect the components\n",
        "    pipeline.connect(\"cleaner\", \"splitter\")\n",
        "    pipeline.connect(\"splitter\", \"embedder\")\n",
        "    pipeline.connect(\"embedder\", \"writer\")\n",
        "\n",
        "    # index the documents and return the data store\n",
        "    pipeline.run({\"cleaner\": {\"documents\": [Document.from_dict(doc) for doc in data[\"train\"]]}})\n",
        "    return document_store\n",
        "\n",
        "\n",
        "data = load_dataset(\"Tuana/game-of-thrones\")\n",
        "doc_store = index_docs(data)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "b0Fq-oSUNkvE"
      },
      "source": [
        "We can now run a retrieval pipeline that doesn't just retrieve based on the query embeddings, instead, it uses the `HypotheticalDocumentEmbedder` to create hypothetical document embeddings based on our `query` and uses these new embeddings to retrieve documents."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 10,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "whyIdwT_M5QQ",
        "outputId": "e8b0dada-c7f6-4169-c784-150a5d0f5f76"
      },
      "outputs": [
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "ChatPromptBuilder has 1 prompt variables, but `required_variables` is not set. By default, all prompt variables are treated as optional, which may lead to unintended behavior in multi-branch pipelines. To avoid unexpected execution, ensure that variables intended to be required are explicitly set in `required_variables`.\n"
        },
        {
          "name": "stderr",
          "output_type": "stream",
          "text": "Unsafe mode is enabled. This allows execution of arbitrary code in the Jinja template. Use this only if you trust the source of the template.\n"
        },
        {
          "data": {
            "text/plain": [
              "{'retriever': {'documents': [Document(id=13455c3b3919ce620d3162e283945ec69afadc4344f27c455824965dbb022c73, content: ''''Arya Stark''' is a fictional character in American author George R. R. Martin's ''A Song of Ice a...', meta: {'name': '43_Arya_Stark.txt', 'source_id': '557ad8704d47b0e12aef859563c87c86782b832f3d06909ede1c0e36dc039540', 'page_number': 1, 'split_id': 0, 'split_idx_start': 0}, score: 0.7386384665504466),\n",
              "   Document(id=61fb96ce7d85d4f3c20966843258929c32c46e7deb6cee2cee5a4afc8f199096, content: '===Arya Stark===\n",
              "   '''Arya Stark''' portrayed by Maisie Williams. Arya Stark of House Stark is the you...', meta: {'name': '349_List_of_Game_of_Thrones_characters.txt', 'source_id': '4c711b50138e5db004b183dd8e5e7a3fe3bf7360b317d61f0a31168fbd311c1e', 'page_number': 1, 'split_id': 0, 'split_idx_start': 0}, score: 0.7003756517328896),\n",
              "   Document(id=ed201bfe347bfe99775f7769a3e94b4e996cba140567ab2cd75555d5dd7d40ff, content: '=== Sansa Stark ===\n",
              "   Sansa Stark is the second child and elder daughter of Eddard and Catelyn Stark. ...', meta: {'name': '30_List_of_A_Song_of_Ice_and_Fire_characters.txt', 'source_id': '0c945854b1eb4db6cde79229fb608b5d22933274396a52b0fb0c1945e8fcde36', 'page_number': 1, 'split_id': 0, 'split_idx_start': 0}, score: 0.6659366356548289),\n",
              "   Document(id=439b170b840630f03221b44010d582e27079cebc28804198c2598343a092dae5, content: '=== Arya Stark ===\n",
              "   Arya Stark is the third child and younger daughter of Eddard and Catelyn Stark. S...', meta: {'name': '30_List_of_A_Song_of_Ice_and_Fire_characters.txt', 'source_id': '149b834592e852fb81df0b4d0b7f31fcb4253b4987da2ea6fda829e322e4b105', 'page_number': 1, 'split_id': 0, 'split_idx_start': 0}, score: 0.6612393519508206),\n",
              "   Document(id=e823ca31597b658378993dada385f4a5d40fc2c5721ac0a246a11534bd7ab933, content: '=== Description ===\n",
              "   Arya is left-handed and talented in sums and housekeeping, and is excellent at h...', meta: {'name': '43_Arya_Stark.txt', 'source_id': 'f4c365b77acb29b51df03583eb2868977cf5435bbaaa307d59f97d864b892b8c', 'page_number': 1, 'split_id': 0, 'split_idx_start': 0}, score: 0.6552145816576516)]}}"
            ]
          },
          "execution_count": 10,
          "metadata": {},
          "output_type": "execute_result"
        }
      ],
      "source": [
        "from haystack.components.retrievers.in_memory import InMemoryEmbeddingRetriever\n",
        "\n",
        "def retriever_with_hyde(doc_store):\n",
        "    hyde = HypotheticalDocumentEmbedder(instruct_llm=\"gpt-4o-mini\", nr_completions=5)\n",
        "    retriever = InMemoryEmbeddingRetriever(document_store=doc_store)\n",
        "\n",
        "    retrieval_pipeline = Pipeline()\n",
        "    retrieval_pipeline.add_component(instance=hyde, name=\"query_embedder\")\n",
        "    retrieval_pipeline.add_component(instance=retriever, name=\"retriever\")\n",
        "\n",
        "    retrieval_pipeline.connect(\"query_embedder.hypothetical_embedding\", \"retriever.query_embedding\")\n",
        "    return retrieval_pipeline\n",
        "\n",
        "retrieval_pipeline = retriever_with_hyde(doc_store)\n",
        "query = \"Who is Araya Stark?\"\n",
        "retrieval_pipeline.run(data={\"query_embedder\": {\"query\": query}, \"retriever\": {\"top_k\": 5}})"
      ]
    }
  ],
  "metadata": {
    "colab": {
      "provenance": []
    },
    "kernelspec": {
      "display_name": "Python 3",
      "name": "python3"
    },
    "language_info": {
      "name": "python"
    },
    "widgets": {
      "application/vnd.jupyter.widget-state+json": {
        "09b1b88ae086428ea2f2fcce7fec4be1": {
          "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_2d6db0c1041744dd9671f0b9c7352dd5",
              "IPY_MODEL_752a21d454cc468abb9dcff5c12ecd2d",
              "IPY_MODEL_37e00469a4f94143a488879c6e6535bf"
            ],
            "layout": "IPY_MODEL_3ec4e9cbfaad40d9827a4d879fded0bc"
          }
        },
        "0b4c12dbf599431c987339d2861fcb78": {
          "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": ""
          }
        },
        "0cd8313fe64c4f62aa1235b778266137": {
          "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_c7eb9ba2c7794e68a5e3b4f73e5b069a",
              "IPY_MODEL_d3ae8fb928144977823d719cc71bf943",
              "IPY_MODEL_1295414dbaf6409d8c78091e4003c8f6"
            ],
            "layout": "IPY_MODEL_61119518e3104ccab011ece38978abc5"
          }
        },
        "1295414dbaf6409d8c78091e4003c8f6": {
          "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_df4fb8b15c8e4464b5834c6a3dbd12c9",
            "placeholder": "​",
            "style": "IPY_MODEL_9df88f66f7854edaa8c37253a159a51e",
            "value": " 2357/2357 [00:00&lt;00:00, 25078.51 examples/s]"
          }
        },
        "16b211c5cad1464d9c50a7bad22a2e24": {
          "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": ""
          }
        },
        "1ae296845e2142f0a78b743ecd22ace2": {
          "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
          }
        },
        "23c5ec7c16144c2e83e57ff396a9a98b": {
          "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_c3db2230ae9e40c597548a551bc5e4d6",
            "placeholder": "​",
            "style": "IPY_MODEL_a561031934464b0194d648c18fa96076",
            "value": " 1.53M/1.53M [00:00&lt;00:00, 2.73MB/s]"
          }
        },
        "2d6db0c1041744dd9671f0b9c7352dd5": {
          "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_4ce3d94567de4eb48ae6653d16a53b03",
            "placeholder": "​",
            "style": "IPY_MODEL_16b211c5cad1464d9c50a7bad22a2e24",
            "value": "Batches: 100%"
          }
        },
        "37e00469a4f94143a488879c6e6535bf": {
          "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_efdebbeba075454c896231a39ecd9002",
            "placeholder": "​",
            "style": "IPY_MODEL_c30cb96c9c9f4846ab4bf94fe2e2ad9d",
            "value": " 103/103 [07:13&lt;00:00,  2.40it/s]"
          }
        },
        "3a1bc15fb77943988919ca6f504f6d4f": {
          "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_a4be69c6d110405ab55510b59b9a6f41",
            "placeholder": "​",
            "style": "IPY_MODEL_0b4c12dbf599431c987339d2861fcb78",
            "value": "Batches: 100%"
          }
        },
        "3afaf53201e94c7e8ba391b95fc1c3d8": {
          "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": ""
          }
        },
        "3ec4e9cbfaad40d9827a4d879fded0bc": {
          "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
          }
        },
        "434bd85cc1694c76bd76cfd62f9a9be5": {
          "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
          }
        },
        "43f1affb1f9d4597b2ed08f4dccfa82d": {
          "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
          }
        },
        "49d16d19959c43bb9bd5cd4ce9fd3850": {
          "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": ""
          }
        },
        "4ce3d94567de4eb48ae6653d16a53b03": {
          "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
          }
        },
        "4ef80343c53e40a7804aae8be58bc24e": {
          "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
          }
        },
        "5d4aebc2bf35465dbb6b02f6f3512d0b": {
          "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
          }
        },
        "61119518e3104ccab011ece38978abc5": {
          "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
          }
        },
        "625f9cd6cb934f1984e2d4108d238c43": {
          "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
          }
        },
        "66455f3ba9594dada59f669a43c85e8f": {
          "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_5d4aebc2bf35465dbb6b02f6f3512d0b",
            "max": 1,
            "min": 0,
            "orientation": "horizontal",
            "style": "IPY_MODEL_49d16d19959c43bb9bd5cd4ce9fd3850",
            "value": 1
          }
        },
        "716bec098dc240fd849be1e70c23b958": {
          "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
          }
        },
        "752a21d454cc468abb9dcff5c12ecd2d": {
          "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_7ea1fc96fc7f46699ce20eed96902e8f",
            "max": 103,
            "min": 0,
            "orientation": "horizontal",
            "style": "IPY_MODEL_d9a5c93f47954f00bb4d7b2562b87e60",
            "value": 103
          }
        },
        "76720573a77442408a924d14c563d711": {
          "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_d15fb403b71d4bff843c5a387a5ea36c",
              "IPY_MODEL_9d8125468bf74c1589fcbe04b0623926",
              "IPY_MODEL_efbcd9eaef6c40f48721cd1ef81ad4ea"
            ],
            "layout": "IPY_MODEL_f6b5bb6382964c36999cd4c6982b664f"
          }
        },
        "7ea1fc96fc7f46699ce20eed96902e8f": {
          "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
          }
        },
        "7f8a1097e0b54ac9bede391ae62a5ea0": {
          "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": ""
          }
        },
        "866bb81e20e24caaa363784f4fd048ec": {
          "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_625f9cd6cb934f1984e2d4108d238c43",
            "placeholder": "​",
            "style": "IPY_MODEL_c519b25093884b60bf9a826ea1ef36f3",
            "value": " 1/1 [00:00&lt;00:00,  2.45it/s]"
          }
        },
        "897db75b6abc4cd0923d7caf2448e82b": {
          "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
          }
        },
        "8c691d394cf24eb2b6eb61b2d17d59c7": {
          "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_4ef80343c53e40a7804aae8be58bc24e",
            "max": 1534236,
            "min": 0,
            "orientation": "horizontal",
            "style": "IPY_MODEL_f0e778c920f043349c44ddc66518b59b",
            "value": 1534236
          }
        },
        "9d8125468bf74c1589fcbe04b0623926": {
          "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_1ae296845e2142f0a78b743ecd22ace2",
            "max": 1510,
            "min": 0,
            "orientation": "horizontal",
            "style": "IPY_MODEL_fa5edd6cc3544e2b8ed9165b1536a8fe",
            "value": 1510
          }
        },
        "9df88f66f7854edaa8c37253a159a51e": {
          "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": ""
          }
        },
        "a4be69c6d110405ab55510b59b9a6f41": {
          "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
          }
        },
        "a561031934464b0194d648c18fa96076": {
          "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": ""
          }
        },
        "b0b397924c2f498db32d7cb57b2648db": {
          "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_c7913c050b574b298c8a11ee6ab0fcfd",
            "placeholder": "​",
            "style": "IPY_MODEL_d689fe03f55f4148b4f62445873b055c",
            "value": "Downloading data: 100%"
          }
        },
        "bfa1065e3afd4d6ab9d8b9cce855730f": {
          "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_b0b397924c2f498db32d7cb57b2648db",
              "IPY_MODEL_8c691d394cf24eb2b6eb61b2d17d59c7",
              "IPY_MODEL_23c5ec7c16144c2e83e57ff396a9a98b"
            ],
            "layout": "IPY_MODEL_cdbec1d537854931b737ffa577dd3fa6"
          }
        },
        "c30cb96c9c9f4846ab4bf94fe2e2ad9d": {
          "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": ""
          }
        },
        "c3db2230ae9e40c597548a551bc5e4d6": {
          "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
          }
        },
        "c519b25093884b60bf9a826ea1ef36f3": {
          "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": ""
          }
        },
        "c7913c050b574b298c8a11ee6ab0fcfd": {
          "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
          }
        },
        "c7eb9ba2c7794e68a5e3b4f73e5b069a": {
          "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_716bec098dc240fd849be1e70c23b958",
            "placeholder": "​",
            "style": "IPY_MODEL_e830d27e5dc4418588a65af93c32f7e6",
            "value": "Generating train split: 100%"
          }
        },
        "cdbec1d537854931b737ffa577dd3fa6": {
          "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
          }
        },
        "d02c59ff64d64a619df33657727c2ac4": {
          "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": ""
          }
        },
        "d15fb403b71d4bff843c5a387a5ea36c": {
          "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_897db75b6abc4cd0923d7caf2448e82b",
            "placeholder": "​",
            "style": "IPY_MODEL_3afaf53201e94c7e8ba391b95fc1c3d8",
            "value": "Downloading metadata: 100%"
          }
        },
        "d3ae8fb928144977823d719cc71bf943": {
          "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_434bd85cc1694c76bd76cfd62f9a9be5",
            "max": 2357,
            "min": 0,
            "orientation": "horizontal",
            "style": "IPY_MODEL_d02c59ff64d64a619df33657727c2ac4",
            "value": 2357
          }
        },
        "d437b2869445412e8cdbbfccc1c40101": {
          "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
          }
        },
        "d689fe03f55f4148b4f62445873b055c": {
          "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": ""
          }
        },
        "d9a5c93f47954f00bb4d7b2562b87e60": {
          "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": ""
          }
        },
        "df4fb8b15c8e4464b5834c6a3dbd12c9": {
          "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
          }
        },
        "e37e414744b04538a24a6ee4d9a5ba90": {
          "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_3a1bc15fb77943988919ca6f504f6d4f",
              "IPY_MODEL_66455f3ba9594dada59f669a43c85e8f",
              "IPY_MODEL_866bb81e20e24caaa363784f4fd048ec"
            ],
            "layout": "IPY_MODEL_d437b2869445412e8cdbbfccc1c40101"
          }
        },
        "e830d27e5dc4418588a65af93c32f7e6": {
          "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": ""
          }
        },
        "efbcd9eaef6c40f48721cd1ef81ad4ea": {
          "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_43f1affb1f9d4597b2ed08f4dccfa82d",
            "placeholder": "​",
            "style": "IPY_MODEL_7f8a1097e0b54ac9bede391ae62a5ea0",
            "value": " 1.51k/1.51k [00:00&lt;00:00, 56.3kB/s]"
          }
        },
        "efdebbeba075454c896231a39ecd9002": {
          "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
          }
        },
        "f0e778c920f043349c44ddc66518b59b": {
          "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": ""
          }
        },
        "f6b5bb6382964c36999cd4c6982b664f": {
          "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
          }
        },
        "fa5edd6cc3544e2b8ed9165b1536a8fe": {
          "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": ""
          }
        }
      }
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}
