diff --git a/.github/workflows/nb_runner.yml b/.github/workflows/nb_runner.yml index 76c732e..fad2ce1 100644 --- a/.github/workflows/nb_runner.yml +++ b/.github/workflows/nb_runner.yml @@ -34,5 +34,6 @@ jobs: DS_NB_QA_DOC_HASH: ${{ vars.DS_NB_QA_DOC_HASH }} DS_NB_QUESTION: ${{ vars.DS_NB_QUESTION }} DS_NB_GEN_TIMEOUT: ${{ vars.DS_NB_GEN_TIMEOUT }} + DS_NB_GEN_CTX_WIN_SIZE: ${{ vars.DS_NB_GEN_CTX_WIN_SIZE }} DS_NB_INDEX_KEY: ${{ vars.DS_NB_INDEX_KEY }} run: poetry run python -m nbrunner.nb_runner diff --git a/examples/qa/qa_deep_dive.ipynb b/examples/qa/qa_deep_dive.ipynb index 27b70c0..5fa335f 100644 --- a/examples/qa/qa_deep_dive.ipynb +++ b/examples/qa/qa_deep_dive.ipynb @@ -60,7 +60,8 @@ " os.environ.get(\"DS_NB_SKIP_INGESTED_DOCS\", True)\n", ")\n", "RETR_K = os.environ.get(\"DS_NB_RETR_K\", 3) # number of search results to retrieve\n", - "GEN_TIMEOUT = os.environ.get(\"DS_NB_GEN_TIMEOUT\", 10) # generation timeout in seconds" + "GEN_TIMEOUT = os.environ.get(\"DS_NB_GEN_TIMEOUT\", 10) # generation timeout in seconds\n", + "GEN_CTX_WIN_SIZE = os.environ.get(\"DS_NB_GEN_CTX_WIN_SIZE\") # max gen ctx window size" ] }, { @@ -253,7 +254,7 @@ "text": [ "Help on function RAGQuery in module deepsearch.cps.queries:\n", "\n", - "RAGQuery(question: str, *, project: Union[str, deepsearch.cps.client.components.projects.Project], data_source: Union[deepsearch.cps.client.components.documents.PrivateDataDocumentSource, deepsearch.cps.client.components.documents.PrivateDataCollectionSource, deepsearch.cps.client.components.documents.PublicDataDocumentSource], retr_k: int = 10, rerank: bool = False, text_weight: typing.Annotated[float, FieldInfo(default=PydanticUndefined, ge=0.0, le=1.0, multiple_of=0.1, extra={'strict': True})] = 0.1, model_id: Optional[str] = None, prompt_template: Optional[str] = None, gen_params: Optional[Dict[str, Any]] = None, gen_ctx_extr_method: Literal['window', 'page'] = 'window', gen_ctx_window_size: int = 5000, gen_ctx_window_lead_weight: float = 0.5, return_prompt: bool = False, gen_timeout: Optional[float] = None) -> deepsearch.cps.client.queries.query.Query\n", + "RAGQuery(question: str, *, project: Union[str, deepsearch.cps.client.components.projects.Project], data_source: Union[deepsearch.cps.client.components.documents.PrivateDataDocumentSource, deepsearch.cps.client.components.documents.PrivateDataCollectionSource, deepsearch.cps.client.components.documents.PublicDataDocumentSource], retr_k: int = 10, rerank: bool = False, text_weight: typing.Annotated[float, FieldInfo(default=PydanticUndefined, ge=0.0, le=1.0, multiple_of=0.1, extra={'strict': True})] = 0.1, model_id: Optional[str] = None, prompt_template: Optional[str] = None, gen_params: Optional[Dict[str, Any]] = None, gen_ctx_extr_method: Literal['window', 'page'] = 'window', gen_ctx_window_size: int = 5000, gen_ctx_window_lead_weight: float = 0.5, return_prompt: bool = False, chunk_refs: Optional[List[deepsearch.cps.queries.results.ChunkRef]] = None, gen_timeout: Optional[float] = None) -> deepsearch.cps.client.queries.query.Query\n", " Create a RAG query\n", " \n", " Args:\n", @@ -270,6 +271,7 @@ " gen_ctx_window_size (int, optional): (relevant only if gen_ctx_extr_method==\"window\") max chars to use for extracted gen context (actual extraction quantized on doc item level); defaults to 5000\n", " gen_ctx_window_lead_weight (float, optional): (relevant only if gen_ctx_extr_method==\"window\") weight of leading text for distributing remaining window size after extracting the `main_path`; defaults to 0.5 (centered around `main_path`)\n", " return_prompt (bool, optional): whether to return the instantiated prompt; defaults to False\n", + " chunk_refs (Optional[List[ChunkRef]], optional): list of explicit chunk references to use instead of performing retrieval; defaults to None (i.e. retrieval-mode)\n", " gen_timeout (float, optional): timeout for LLM generation; defaults to None, i.e. determined by system\n", "\n" ] @@ -312,120 +314,95 @@ "
RAGResult(\n",
        "    answers=[\n",
        "        RAGAnswerItem(\n",
-       "            answer='The first European IBM lab was located in Adliswil, Switzerland, near Zurich.',\n",
+       "            answer='The first European IBM laboratory was located in Adliswil, Switzerland, near Zurich.',\n",
        "            grounding=RAGGroundingInfo(\n",
        "                retr_items=[\n",
        "                    SearchResultItem(\n",
        "                        doc_hash='b30bc667a324ae111d025526563b674a8d3fd869bc07c8fd204aa95b05d41f0c',\n",
+       "                        main_path='main-text.71',\n",
+       "                        path_group=['main-text.69', 'main-text.71'],\n",
        "                        chunk='Switzerland\\nIn 1956, IBM opened their first European research laboratory in \n",
        "Adliswil, Switzerland, near Zurich. The lab moved to its own campus in neighboring Rüschlikon in 1962. The Zurich \n",
        "lab is staffed by a multicultural and interdisciplinary team of a few hundred permanent research staff members, \n",
        "graduate students and post-doctoral fellows, representing about 45 nationalities. Collocated with the lab is a \n",
        "Client Center (formerly the Industry Solutions Lab), an executive briefing facility demonstrating technology \n",
        "prototypes and solutions.',\n",
-       "                        main_path='main-text.71',\n",
-       "                        path_group=['main-text.69', 'main-text.71'],\n",
        "                        source_is_text=True\n",
        "                    )\n",
        "                ],\n",
-       "                gen_ctx_paths=[\n",
-       "                    'main-text.60',\n",
-       "                    'main-text.61',\n",
-       "                    'main-text.62',\n",
-       "                    'main-text.63',\n",
-       "                    'main-text.64',\n",
-       "                    'main-text.65',\n",
-       "                    'main-text.66',\n",
-       "                    'main-text.67',\n",
-       "                    'main-text.68',\n",
-       "                    'main-text.69',\n",
-       "                    'main-text.70',\n",
-       "                    'main-text.71',\n",
-       "                    'main-text.72',\n",
-       "                    'main-text.73',\n",
-       "                    'main-text.74',\n",
-       "                    'main-text.75',\n",
-       "                    'main-text.76',\n",
-       "                    'main-text.77',\n",
-       "                    'main-text.78'\n",
-       "                ]\n",
+       "                gen_ctx_paths=['main-text.71']\n",
        "            ),\n",
-       "            prompt=\"Context information is below.\\n---------------------\\nIn 1987, IBM Japan Science Prize was \n",
-       "created to recognize researchers, who are not over 45 years old, working at Japanese universities or public \n",
-       "research institutes. It is awarded in physics, chemistry, computer science, and electronics. [54]\\n\\n## \n",
-       "Israel\\n\\nIBM Research-Haifa, previously known as the Haifa Research Lab (HRL) was founded as a small scientific \n",
-       "center in 1972. $^{[55]}$ Since then, it has grown into a major lab that leads the development of innovative \n",
-       "technologies and solutions for the IBM corporation. The lab's offices are situated in three locations across \n",
-       "Israel: Haifa, Tel Aviv, and Beer Sheva.\\n\\nIBM Research-Haifa employs researchers in a range of areas. Research \n",
-       "projects are being executed today in areas such as artificial intelligence, hybrid cloud, quantum computing, \n",
-       "blockchain, IoT, quality, cybersecurity, and industry domains such as healthcare.\\n\\nAya Soffer is IBM Vice \n",
-       "President of AI Technology and serves as the Director of the IBM Research Lab in Haifa, Israel.\\n\\n## History\\n\\nIn\n",
-       "its 30th year, the IBM Haifa Research Lab in Israel moved to a new home on the University of Haifa campus.\\n\\nThe \n",
-       "researchers at the Lab are involved in special projects with academic institutions across Israel, the United \n",
-       "States, and Europe, and actively participate in numerous consortiums as part of the EU Horizon 2020 programme. \n",
-       "Today in 2020, the Lab describes itself as having the highest number of employees in Israel's hi-tech industry who \n",
-       "hold advanced degrees in science, electrical engineering, mathematics, or related fields. Researchers participate \n",
-       "in international conferences and are published in professional publications.\\n\\nIn 2014, IBM Research announced the\n",
-       "Cybersecurity Center of Excellence (CCoE) in Beer Sheva in collaboration with Ben-Gurion University of the \n",
-       "Negev.\\n\\n## Switzerland\\n\\nIBM Research-Zurich (previously called IBM Zurich Research Laboratory, ZRL) is the \n",
-       "European branch of IBM Research. It was opened in 1956 and is located in Rüschlikon, near Zurich, \n",
-       "Switzerland.\\n\\nIn 1956, IBM opened their first European research laboratory in Adliswil, Switzerland, near Zurich.\n",
-       "The lab moved to its own campus in neighboring Rüschlikon in 1962. The Zurich lab is staffed by a multicultural and\n",
-       "interdisciplinary team of a few hundred permanent research staff members, graduate students and post-doctoral \n",
-       "fellows, representing about 45 nationalities. Collocated with the lab is a Client Center (formerly the Industry \n",
-       "Solutions Lab), an executive briefing facility demonstrating technology prototypes and solutions.\\n\\nThe Zurich lab\n",
-       "is world-renowned for its scientific achievements-most notably Nobel Prizes in physics in 1986 and 1987 for the \n",
-       "invention of the scanning tunneling microscope $^{[56]}$ and the discovery of high-temperature superconductivity, \n",
-       "[57] respectively. Other key inventions include trellis modulation, which revolutionized data transmission over \n",
-       "telephone lines; Token Ring, which became a standard for local area networks and a highly successful IBM product; \n",
-       "the Secure Electronic Transaction (SET) standard used for highly secure payments; and the Java Card OpenPlatform \n",
-       "(JCOP), a smart card operating system. Most recently the lab was involved in the development of SuperMUC, a \n",
-       "supercomputer that is cooled using hot water.\\n\\nThe Zurich lab focus areas are future chip technologies; \n",
-       "nanotechnology; data storage; quantum computing, brain-inspired computing; security and privacy; risk and \n",
-       "compliance; business optimization and transformation; server systems. The Zurich laboratory is involved in many \n",
-       "joint projects with universities throughout Europe, in research programs established by the European Union and the \n",
-       "Swiss government, and in cooperation agreements with research institutes of industrial partners. One of the lab's \n",
-       "most high-profile projects is called DOME, which is based on developing an IT roadmap for the Square Kilometer \n",
-       "Array.\\n\\nThe research projects pursued at the IBM Zurich lab are organized into four scientific and technical \n",
-       "departments: Science & Technology, Cloud and AI Systems Research, Cognitive Computing & Industry Solutions and \n",
-       "Security Research. The lab is currently managed by Alessandro Curioni.\\n\\nOn 17 May 2011, IBM and the Swiss Federal\n",
-       "Institute of Technology (ETH) Zurich opened the Binnig and Rohrer Nanotechnology Center, which is located on the \n",
-       "same campus in Rüschlikon. [58]\\n\\n## Publications\\n\\nIBM Journal of Research and Development \n",
-       "(https://research.ibm.com/publications?search=eyJ0e \n",
-       "XBlIjoic291cmNlIiwidmFsdWUiOnsiaWQiOiIxOTk3MSIsInRleHQiOiJJQk0gSi4gUmVzLiBEZXYifX 0)\\n\\n## \n",
-       "References\\n---------------------\\nGiven the context information and not prior knowledge, answer the query.\\nQuery:\n",
-       "Where was the first European IBM lab located?\\nAnswer:\\n\"\n",
+       "            prompt='Context information is below.\\n---------------------\\nIn 1956, IBM opened their first European \n",
+       "research laboratory in Adliswil, Switzerland, near Zurich. The lab moved to its own campus in neighboring \n",
+       "Rüschlikon in 1962. The Zurich lab is staffed by a multicultural and interdisciplinary team of a few hundred \n",
+       "permanent research staff members, graduate students and post-doctoral fellows, representing about 45 nationalities.\n",
+       "Collocated with the lab is a Client Center (formerly the Industry Solutions Lab), an executive briefing facility \n",
+       "demonstrating technology prototypes and solutions.\\n---------------------\\nGiven the context information and not \n",
+       "prior knowledge, answer the query.\\nQuery: Where was the first European IBM lab located?\\nAnswer:\\n'\n",
        "        )\n",
        "    ],\n",
        "    search_result_items=[\n",
        "        SearchResultItem(\n",
        "            doc_hash='b30bc667a324ae111d025526563b674a8d3fd869bc07c8fd204aa95b05d41f0c',\n",
+       "            main_path='main-text.71',\n",
+       "            path_group=['main-text.69', 'main-text.71'],\n",
        "            chunk='Switzerland\\nIn 1956, IBM opened their first European research laboratory in Adliswil, \n",
        "Switzerland, near Zurich. The lab moved to its own campus in neighboring Rüschlikon in 1962. The Zurich lab is \n",
        "staffed by a multicultural and interdisciplinary team of a few hundred permanent research staff members, graduate \n",
        "students and post-doctoral fellows, representing about 45 nationalities. Collocated with the lab is a Client Center\n",
        "(formerly the Industry Solutions Lab), an executive briefing facility demonstrating technology prototypes and \n",
        "solutions.',\n",
-       "            main_path='main-text.71',\n",
-       "            path_group=['main-text.69', 'main-text.71'],\n",
        "            source_is_text=True\n",
        "        ),\n",
        "        SearchResultItem(\n",
        "            doc_hash='b30bc667a324ae111d025526563b674a8d3fd869bc07c8fd204aa95b05d41f0c',\n",
-       "            chunk='Switzerland\\nIBM Research-Zurich (previously called IBM Zurich Research Laboratory, ZRL) is the \n",
-       "European branch of IBM Research. It was opened in 1956 and is located in Rüschlikon, near Zurich, Switzerland.',\n",
        "            main_path='main-text.70',\n",
        "            path_group=['main-text.69', 'main-text.70'],\n",
+       "            chunk='Switzerland\\nIBM Research-Zurich (previously called IBM Zurich Research Laboratory, ZRL) is the \n",
+       "European branch of IBM Research. It was opened in 1956 and is located in Rüschlikon, near Zurich, Switzerland.',\n",
        "            source_is_text=True\n",
        "        ),\n",
        "        SearchResultItem(\n",
        "            doc_hash='b30bc667a324ae111d025526563b674a8d3fd869bc07c8fd204aa95b05d41f0c',\n",
+       "            main_path='main-text.8',\n",
+       "            path_group=['main-text.7', 'main-text.8'],\n",
        "            chunk=\"History\\nThe roots of today's IBM Research began with the 1945 opening of the Watson Scientific \n",
        "Computing Laboratory at Columbia University. $^{[4]}$ This was the first IBM laboratory devoted to pure science and\n",
        "later expanded into additional IBM Research locations in Westchester County, New York, starting in the 1950s, \n",
        "$^{[5][6]}$ including the Thomas J. Watson Research Center in 1961. [5][6]\",\n",
-       "            main_path='main-text.8',\n",
-       "            path_group=['main-text.7', 'main-text.8'],\n",
+       "            source_is_text=True\n",
+       "        ),\n",
+       "        SearchResultItem(\n",
+       "            doc_hash='234bc5cf2c860d49574b0ff7191c354b7bbc11472a09972c8b6108c62375ffc3',\n",
+       "            main_path='main-text.86',\n",
+       "            path_group=['main-text.85', 'main-text.86'],\n",
+       "            chunk=\"Research\\nResearch has been part of IBM since its founding, and its organized efforts trace \n",
+       "their roots back to 1945, when the Watson Scientific Computing Laboratory was founded at Columbia University in New\n",
+       "York City, converting a renovated fraternity house on Manhattan's West Side into IBM's first laboratory. Now, IBM \n",
+       "Research constitutes the largest industrial research organization in the world, with 12 labs on 6 continents. [161]\n",
+       "IBM Research is headquartered at the Thomas J. Watson Research Center in New York, and facilities include the \n",
+       "Almaden lab in California, Austin lab in Texas, Australia lab in Melbourne, Brazil lab in São Paulo and Rio de \n",
+       "Janeiro, China lab in Beijing and Shanghai, Ireland lab in Dublin, Haifa lab in Israel, India lab in Delhi and \n",
+       "Bangalore, Tokyo lab, Zurichlab and Africa lab in Nairobi.\",\n",
+       "            source_is_text=True\n",
+       "        ),\n",
+       "        SearchResultItem(\n",
+       "            doc_hash='b30bc667a324ae111d025526563b674a8d3fd869bc07c8fd204aa95b05d41f0c',\n",
+       "            main_path='main-text.62',\n",
+       "            path_group=['main-text.61', 'main-text.62'],\n",
+       "            chunk=\"Israel\\nIBM Research-Haifa, previously known as the Haifa Research Lab (HRL) was founded as a \n",
+       "small scientific center in 1972. $^{[55]}$ Since then, it has grown into a major lab that leads the development of \n",
+       "innovative technologies and solutions for the IBM corporation. The lab's offices are situated in three locations \n",
+       "across Israel: Haifa, Tel Aviv, and Beer Sheva.\",\n",
+       "            source_is_text=True\n",
+       "        ),\n",
+       "        SearchResultItem(\n",
+       "            doc_hash='b30bc667a324ae111d025526563b674a8d3fd869bc07c8fd204aa95b05d41f0c',\n",
+       "            main_path='main-text.30',\n",
+       "            path_group=['main-text.16', 'main-text.30'],\n",
+       "            chunk='Laboratories\\nHistoric research centers for IBM also include IBM La Gaude (Nice), the Cambridge \n",
+       "Scientific Center, the IBM New York Scientific Center, 330 North Wabash (Chicago), IBM Austin Research Laboratory, \n",
+       "and IBM Laboratory Vienna. [33]',\n",
        "            source_is_text=True\n",
        "        )\n",
        "    ]\n",
@@ -436,120 +413,95 @@
        "\u001b[1;35mRAGResult\u001b[0m\u001b[1m(\u001b[0m\n",
        "    \u001b[33manswers\u001b[0m=\u001b[1m[\u001b[0m\n",
        "        \u001b[1;35mRAGAnswerItem\u001b[0m\u001b[1m(\u001b[0m\n",
-       "            \u001b[33manswer\u001b[0m=\u001b[32m'The first European IBM lab was located in Adliswil, Switzerland, near Zurich.'\u001b[0m,\n",
+       "            \u001b[33manswer\u001b[0m=\u001b[32m'The first European IBM laboratory was located in Adliswil, Switzerland, near Zurich.'\u001b[0m,\n",
        "            \u001b[33mgrounding\u001b[0m=\u001b[1;35mRAGGroundingInfo\u001b[0m\u001b[1m(\u001b[0m\n",
        "                \u001b[33mretr_items\u001b[0m=\u001b[1m[\u001b[0m\n",
        "                    \u001b[1;35mSearchResultItem\u001b[0m\u001b[1m(\u001b[0m\n",
        "                        \u001b[33mdoc_hash\u001b[0m=\u001b[32m'b30bc667a324ae111d025526563b674a8d3fd869bc07c8fd204aa95b05d41f0c'\u001b[0m,\n",
+       "                        \u001b[33mmain_path\u001b[0m=\u001b[32m'main-text.71'\u001b[0m,\n",
+       "                        \u001b[33mpath_group\u001b[0m=\u001b[1m[\u001b[0m\u001b[32m'main-text.69'\u001b[0m, \u001b[32m'main-text.71'\u001b[0m\u001b[1m]\u001b[0m,\n",
        "                        \u001b[33mchunk\u001b[0m=\u001b[32m'Switzerland\\nIn 1956, IBM opened their first European research laboratory in \u001b[0m\n",
        "\u001b[32mAdliswil, Switzerland, near Zurich. The lab moved to its own campus in neighboring Rüschlikon in 1962. The Zurich \u001b[0m\n",
        "\u001b[32mlab is staffed by a multicultural and interdisciplinary team of a few hundred permanent research staff members, \u001b[0m\n",
        "\u001b[32mgraduate students and post-doctoral fellows, representing about 45 nationalities. Collocated with the lab is a \u001b[0m\n",
        "\u001b[32mClient Center \u001b[0m\u001b[32m(\u001b[0m\u001b[32mformerly the Industry Solutions Lab\u001b[0m\u001b[32m)\u001b[0m\u001b[32m, an executive briefing facility demonstrating technology \u001b[0m\n",
        "\u001b[32mprototypes and solutions.'\u001b[0m,\n",
-       "                        \u001b[33mmain_path\u001b[0m=\u001b[32m'main-text.71'\u001b[0m,\n",
-       "                        \u001b[33mpath_group\u001b[0m=\u001b[1m[\u001b[0m\u001b[32m'main-text.69'\u001b[0m, \u001b[32m'main-text.71'\u001b[0m\u001b[1m]\u001b[0m,\n",
        "                        \u001b[33msource_is_text\u001b[0m=\u001b[3;92mTrue\u001b[0m\n",
        "                    \u001b[1m)\u001b[0m\n",
        "                \u001b[1m]\u001b[0m,\n",
-       "                \u001b[33mgen_ctx_paths\u001b[0m=\u001b[1m[\u001b[0m\n",
-       "                    \u001b[32m'main-text.60'\u001b[0m,\n",
-       "                    \u001b[32m'main-text.61'\u001b[0m,\n",
-       "                    \u001b[32m'main-text.62'\u001b[0m,\n",
-       "                    \u001b[32m'main-text.63'\u001b[0m,\n",
-       "                    \u001b[32m'main-text.64'\u001b[0m,\n",
-       "                    \u001b[32m'main-text.65'\u001b[0m,\n",
-       "                    \u001b[32m'main-text.66'\u001b[0m,\n",
-       "                    \u001b[32m'main-text.67'\u001b[0m,\n",
-       "                    \u001b[32m'main-text.68'\u001b[0m,\n",
-       "                    \u001b[32m'main-text.69'\u001b[0m,\n",
-       "                    \u001b[32m'main-text.70'\u001b[0m,\n",
-       "                    \u001b[32m'main-text.71'\u001b[0m,\n",
-       "                    \u001b[32m'main-text.72'\u001b[0m,\n",
-       "                    \u001b[32m'main-text.73'\u001b[0m,\n",
-       "                    \u001b[32m'main-text.74'\u001b[0m,\n",
-       "                    \u001b[32m'main-text.75'\u001b[0m,\n",
-       "                    \u001b[32m'main-text.76'\u001b[0m,\n",
-       "                    \u001b[32m'main-text.77'\u001b[0m,\n",
-       "                    \u001b[32m'main-text.78'\u001b[0m\n",
-       "                \u001b[1m]\u001b[0m\n",
+       "                \u001b[33mgen_ctx_paths\u001b[0m=\u001b[1m[\u001b[0m\u001b[32m'main-text.71'\u001b[0m\u001b[1m]\u001b[0m\n",
        "            \u001b[1m)\u001b[0m,\n",
-       "            \u001b[33mprompt\u001b[0m=\u001b[32m\"Context\u001b[0m\u001b[32m information is below.\\n---------------------\\nIn 1987, IBM Japan Science Prize was \u001b[0m\n",
-       "\u001b[32mcreated to recognize researchers, who are not over 45 years old, working at Japanese universities or public \u001b[0m\n",
-       "\u001b[32mresearch institutes. It is awarded in physics, chemistry, computer science, and electronics. \u001b[0m\u001b[32m[\u001b[0m\u001b[32m54\u001b[0m\u001b[32m]\u001b[0m\u001b[32m\\n\\n## \u001b[0m\n",
-       "\u001b[32mIsrael\\n\\nIBM Research-Haifa, previously known as the Haifa Research Lab \u001b[0m\u001b[32m(\u001b[0m\u001b[32mHRL\u001b[0m\u001b[32m)\u001b[0m\u001b[32m was founded as a small scientific \u001b[0m\n",
-       "\u001b[32mcenter in 1972. $^\u001b[0m\u001b[32m{\u001b[0m\u001b[32m[\u001b[0m\u001b[32m55\u001b[0m\u001b[32m]\u001b[0m\u001b[32m}\u001b[0m\u001b[32m$ Since then, it has grown into a major lab that leads the development of innovative \u001b[0m\n",
-       "\u001b[32mtechnologies and solutions for the IBM corporation. The lab's offices are situated in three locations across \u001b[0m\n",
-       "\u001b[32mIsrael: Haifa, Tel Aviv, and Beer Sheva.\\n\\nIBM Research-Haifa employs researchers in a range of areas. Research \u001b[0m\n",
-       "\u001b[32mprojects are being executed today in areas such as artificial intelligence, hybrid cloud, quantum computing, \u001b[0m\n",
-       "\u001b[32mblockchain, IoT, quality, cybersecurity, and industry domains such as healthcare.\\n\\nAya Soffer is IBM Vice \u001b[0m\n",
-       "\u001b[32mPresident of AI Technology and serves as the Director of the IBM Research Lab in Haifa, Israel.\\n\\n## History\\n\\nIn\u001b[0m\n",
-       "\u001b[32mits 30th year, the IBM Haifa Research Lab in Israel moved to a new home on the University of Haifa campus.\\n\\nThe \u001b[0m\n",
-       "\u001b[32mresearchers at the Lab are involved in special projects with academic institutions across Israel, the United \u001b[0m\n",
-       "\u001b[32mStates, and Europe, and actively participate in numerous consortiums as part of the EU Horizon 2020 programme. \u001b[0m\n",
-       "\u001b[32mToday in 2020, the Lab describes itself as having the highest number of employees in Israel's hi-tech industry who \u001b[0m\n",
-       "\u001b[32mhold advanced degrees in science, electrical engineering, mathematics, or related fields. Researchers participate \u001b[0m\n",
-       "\u001b[32min international conferences and are published in professional publications.\\n\\nIn 2014, IBM Research announced the\u001b[0m\n",
-       "\u001b[32mCybersecurity Center of Excellence \u001b[0m\u001b[32m(\u001b[0m\u001b[32mCCoE\u001b[0m\u001b[32m)\u001b[0m\u001b[32m in Beer Sheva in collaboration with Ben-Gurion University of the \u001b[0m\n",
-       "\u001b[32mNegev.\\n\\n## Switzerland\\n\\nIBM Research-Zurich \u001b[0m\u001b[32m(\u001b[0m\u001b[32mpreviously called IBM Zurich Research Laboratory, ZRL\u001b[0m\u001b[32m)\u001b[0m\u001b[32m is the \u001b[0m\n",
-       "\u001b[32mEuropean branch of IBM Research. It was opened in 1956 and is located in Rüschlikon, near Zurich, \u001b[0m\n",
-       "\u001b[32mSwitzerland.\\n\\nIn 1956, IBM opened their first European research laboratory in Adliswil, Switzerland, near Zurich.\u001b[0m\n",
-       "\u001b[32mThe lab moved to its own campus in neighboring Rüschlikon in 1962. The Zurich lab is staffed by a multicultural and\u001b[0m\n",
-       "\u001b[32minterdisciplinary team of a few hundred permanent research staff members, graduate students and post-doctoral \u001b[0m\n",
-       "\u001b[32mfellows, representing about 45 nationalities. Collocated with the lab is a Client Center \u001b[0m\u001b[32m(\u001b[0m\u001b[32mformerly the Industry \u001b[0m\n",
-       "\u001b[32mSolutions Lab\u001b[0m\u001b[32m)\u001b[0m\u001b[32m, an executive briefing facility demonstrating technology prototypes and solutions.\\n\\nThe Zurich lab\u001b[0m\n",
-       "\u001b[32mis world-renowned for its scientific achievements-most notably Nobel Prizes in physics in 1986 and 1987 for the \u001b[0m\n",
-       "\u001b[32minvention of the scanning tunneling microscope $^\u001b[0m\u001b[32m{\u001b[0m\u001b[32m[\u001b[0m\u001b[32m56\u001b[0m\u001b[32m]\u001b[0m\u001b[32m}\u001b[0m\u001b[32m$ and the discovery of high-temperature superconductivity, \u001b[0m\n",
-       "\u001b[32m[\u001b[0m\u001b[32m57\u001b[0m\u001b[32m]\u001b[0m\u001b[32m respectively. Other key inventions include trellis modulation, which revolutionized data transmission over \u001b[0m\n",
-       "\u001b[32mtelephone lines; Token Ring, which became a standard for local area networks and a highly successful IBM product; \u001b[0m\n",
-       "\u001b[32mthe Secure Electronic Transaction \u001b[0m\u001b[32m(\u001b[0m\u001b[32mSET\u001b[0m\u001b[32m)\u001b[0m\u001b[32m standard used for highly secure payments; and the Java Card OpenPlatform \u001b[0m\n",
-       "\u001b[32m(\u001b[0m\u001b[32mJCOP\u001b[0m\u001b[32m)\u001b[0m\u001b[32m, a smart card operating system. Most recently the lab was involved in the development of SuperMUC, a \u001b[0m\n",
-       "\u001b[32msupercomputer that is cooled using hot water.\\n\\nThe Zurich lab focus areas are future chip technologies; \u001b[0m\n",
-       "\u001b[32mnanotechnology; data storage; quantum computing, brain-inspired computing; security and privacy; risk and \u001b[0m\n",
-       "\u001b[32mcompliance; business optimization and transformation; server systems. The Zurich laboratory is involved in many \u001b[0m\n",
-       "\u001b[32mjoint projects with universities throughout Europe, in research programs established by the European Union and the \u001b[0m\n",
-       "\u001b[32mSwiss government, and in cooperation agreements with research institutes of industrial partners. One of the lab's \u001b[0m\n",
-       "\u001b[32mmost high-profile projects is called DOME, which is based on developing an IT roadmap for the Square Kilometer \u001b[0m\n",
-       "\u001b[32mArray.\\n\\nThe research projects pursued at the IBM Zurich lab are organized into four scientific and technical \u001b[0m\n",
-       "\u001b[32mdepartments: Science & Technology, Cloud and AI Systems Research, Cognitive Computing & Industry Solutions and \u001b[0m\n",
-       "\u001b[32mSecurity Research. The lab is currently managed by Alessandro Curioni.\\n\\nOn 17 May 2011, IBM and the Swiss Federal\u001b[0m\n",
-       "\u001b[32mInstitute of Technology \u001b[0m\u001b[32m(\u001b[0m\u001b[32mETH\u001b[0m\u001b[32m)\u001b[0m\u001b[32m Zurich opened the Binnig and Rohrer Nanotechnology Center, which is located on the \u001b[0m\n",
-       "\u001b[32msame campus in Rüschlikon. \u001b[0m\u001b[32m[\u001b[0m\u001b[32m58\u001b[0m\u001b[32m]\u001b[0m\u001b[32m\\n\\n## Publications\\n\\nIBM Journal of Research and Development \u001b[0m\n",
-       "\u001b[32m(\u001b[0m\u001b[32mhttps://research.ibm.com/publications?\u001b[0m\u001b[32msearch\u001b[0m\u001b[32m=\u001b[0m\u001b[32meyJ0e\u001b[0m\u001b[32m \u001b[0m\n",
-       "\u001b[32mXBlIjoic291cmNlIiwidmFsdWUiOnsiaWQiOiIxOTk3MSIsInRleHQiOiJJQk0gSi4gUmVzLiBEZXYifX 0\u001b[0m\u001b[32m)\u001b[0m\u001b[32m\\n\\n## \u001b[0m\n",
-       "\u001b[32mReferences\\n---------------------\\nGiven the context information and not prior knowledge, answer the query.\\nQuery:\u001b[0m\n",
-       "\u001b[32mWhere was the first European IBM lab located?\\nAnswer:\\n\"\u001b[0m\n",
+       "            \u001b[33mprompt\u001b[0m=\u001b[32m'Context information is below.\\n---------------------\\nIn 1956, IBM opened their first European \u001b[0m\n",
+       "\u001b[32mresearch laboratory in Adliswil, Switzerland, near Zurich. The lab moved to its own campus in neighboring \u001b[0m\n",
+       "\u001b[32mRüschlikon in 1962. The Zurich lab is staffed by a multicultural and interdisciplinary team of a few hundred \u001b[0m\n",
+       "\u001b[32mpermanent research staff members, graduate students and post-doctoral fellows, representing about 45 nationalities.\u001b[0m\n",
+       "\u001b[32mCollocated with the lab is a Client Center \u001b[0m\u001b[32m(\u001b[0m\u001b[32mformerly the Industry Solutions Lab\u001b[0m\u001b[32m)\u001b[0m\u001b[32m, an executive briefing facility \u001b[0m\n",
+       "\u001b[32mdemonstrating technology prototypes and solutions.\\n---------------------\\nGiven the context information and not \u001b[0m\n",
+       "\u001b[32mprior knowledge, answer the query.\\nQuery: Where was the first European IBM lab located?\\nAnswer:\\n'\u001b[0m\n",
        "        \u001b[1m)\u001b[0m\n",
        "    \u001b[1m]\u001b[0m,\n",
        "    \u001b[33msearch_result_items\u001b[0m=\u001b[1m[\u001b[0m\n",
        "        \u001b[1;35mSearchResultItem\u001b[0m\u001b[1m(\u001b[0m\n",
        "            \u001b[33mdoc_hash\u001b[0m=\u001b[32m'b30bc667a324ae111d025526563b674a8d3fd869bc07c8fd204aa95b05d41f0c'\u001b[0m,\n",
+       "            \u001b[33mmain_path\u001b[0m=\u001b[32m'main-text.71'\u001b[0m,\n",
+       "            \u001b[33mpath_group\u001b[0m=\u001b[1m[\u001b[0m\u001b[32m'main-text.69'\u001b[0m, \u001b[32m'main-text.71'\u001b[0m\u001b[1m]\u001b[0m,\n",
        "            \u001b[33mchunk\u001b[0m=\u001b[32m'Switzerland\\nIn 1956, IBM opened their first European research laboratory in Adliswil, \u001b[0m\n",
        "\u001b[32mSwitzerland, near Zurich. The lab moved to its own campus in neighboring Rüschlikon in 1962. The Zurich lab is \u001b[0m\n",
        "\u001b[32mstaffed by a multicultural and interdisciplinary team of a few hundred permanent research staff members, graduate \u001b[0m\n",
        "\u001b[32mstudents and post-doctoral fellows, representing about 45 nationalities. Collocated with the lab is a Client Center\u001b[0m\n",
        "\u001b[32m(\u001b[0m\u001b[32mformerly the Industry Solutions Lab\u001b[0m\u001b[32m)\u001b[0m\u001b[32m, an executive briefing facility demonstrating technology prototypes and \u001b[0m\n",
        "\u001b[32msolutions.'\u001b[0m,\n",
-       "            \u001b[33mmain_path\u001b[0m=\u001b[32m'main-text.71'\u001b[0m,\n",
-       "            \u001b[33mpath_group\u001b[0m=\u001b[1m[\u001b[0m\u001b[32m'main-text.69'\u001b[0m, \u001b[32m'main-text.71'\u001b[0m\u001b[1m]\u001b[0m,\n",
        "            \u001b[33msource_is_text\u001b[0m=\u001b[3;92mTrue\u001b[0m\n",
        "        \u001b[1m)\u001b[0m,\n",
        "        \u001b[1;35mSearchResultItem\u001b[0m\u001b[1m(\u001b[0m\n",
        "            \u001b[33mdoc_hash\u001b[0m=\u001b[32m'b30bc667a324ae111d025526563b674a8d3fd869bc07c8fd204aa95b05d41f0c'\u001b[0m,\n",
-       "            \u001b[33mchunk\u001b[0m=\u001b[32m'Switzerland\\nIBM Research-Zurich \u001b[0m\u001b[32m(\u001b[0m\u001b[32mpreviously called IBM Zurich Research Laboratory, ZRL\u001b[0m\u001b[32m)\u001b[0m\u001b[32m is the \u001b[0m\n",
-       "\u001b[32mEuropean branch of IBM Research. It was opened in 1956 and is located in Rüschlikon, near Zurich, Switzerland.'\u001b[0m,\n",
        "            \u001b[33mmain_path\u001b[0m=\u001b[32m'main-text.70'\u001b[0m,\n",
        "            \u001b[33mpath_group\u001b[0m=\u001b[1m[\u001b[0m\u001b[32m'main-text.69'\u001b[0m, \u001b[32m'main-text.70'\u001b[0m\u001b[1m]\u001b[0m,\n",
+       "            \u001b[33mchunk\u001b[0m=\u001b[32m'Switzerland\\nIBM Research-Zurich \u001b[0m\u001b[32m(\u001b[0m\u001b[32mpreviously called IBM Zurich Research Laboratory, ZRL\u001b[0m\u001b[32m)\u001b[0m\u001b[32m is the \u001b[0m\n",
+       "\u001b[32mEuropean branch of IBM Research. It was opened in 1956 and is located in Rüschlikon, near Zurich, Switzerland.'\u001b[0m,\n",
        "            \u001b[33msource_is_text\u001b[0m=\u001b[3;92mTrue\u001b[0m\n",
        "        \u001b[1m)\u001b[0m,\n",
        "        \u001b[1;35mSearchResultItem\u001b[0m\u001b[1m(\u001b[0m\n",
        "            \u001b[33mdoc_hash\u001b[0m=\u001b[32m'b30bc667a324ae111d025526563b674a8d3fd869bc07c8fd204aa95b05d41f0c'\u001b[0m,\n",
+       "            \u001b[33mmain_path\u001b[0m=\u001b[32m'main-text.8'\u001b[0m,\n",
+       "            \u001b[33mpath_group\u001b[0m=\u001b[1m[\u001b[0m\u001b[32m'main-text.7'\u001b[0m, \u001b[32m'main-text.8'\u001b[0m\u001b[1m]\u001b[0m,\n",
        "            \u001b[33mchunk\u001b[0m=\u001b[32m\"History\u001b[0m\u001b[32m\\nThe roots of today's IBM Research began with the 1945 opening of the Watson Scientific \u001b[0m\n",
        "\u001b[32mComputing Laboratory at Columbia University. $^\u001b[0m\u001b[32m{\u001b[0m\u001b[32m[\u001b[0m\u001b[32m4\u001b[0m\u001b[32m]\u001b[0m\u001b[32m}\u001b[0m\u001b[32m$ This was the first IBM laboratory devoted to pure science and\u001b[0m\n",
        "\u001b[32mlater expanded into additional IBM Research locations in Westchester County, New York, starting in the 1950s, \u001b[0m\n",
        "\u001b[32m$^\u001b[0m\u001b[32m{\u001b[0m\u001b[32m[\u001b[0m\u001b[32m5\u001b[0m\u001b[32m]\u001b[0m\u001b[32m[\u001b[0m\u001b[32m6\u001b[0m\u001b[32m]\u001b[0m\u001b[32m}\u001b[0m\u001b[32m$ including the Thomas J. Watson Research Center in 1961. \u001b[0m\u001b[32m[\u001b[0m\u001b[32m5\u001b[0m\u001b[32m]\u001b[0m\u001b[32m[\u001b[0m\u001b[32m6\u001b[0m\u001b[32m]\u001b[0m\u001b[32m\"\u001b[0m,\n",
-       "            \u001b[33mmain_path\u001b[0m=\u001b[32m'main-text.8'\u001b[0m,\n",
-       "            \u001b[33mpath_group\u001b[0m=\u001b[1m[\u001b[0m\u001b[32m'main-text.7'\u001b[0m, \u001b[32m'main-text.8'\u001b[0m\u001b[1m]\u001b[0m,\n",
+       "            \u001b[33msource_is_text\u001b[0m=\u001b[3;92mTrue\u001b[0m\n",
+       "        \u001b[1m)\u001b[0m,\n",
+       "        \u001b[1;35mSearchResultItem\u001b[0m\u001b[1m(\u001b[0m\n",
+       "            \u001b[33mdoc_hash\u001b[0m=\u001b[32m'234bc5cf2c860d49574b0ff7191c354b7bbc11472a09972c8b6108c62375ffc3'\u001b[0m,\n",
+       "            \u001b[33mmain_path\u001b[0m=\u001b[32m'main-text.86'\u001b[0m,\n",
+       "            \u001b[33mpath_group\u001b[0m=\u001b[1m[\u001b[0m\u001b[32m'main-text.85'\u001b[0m, \u001b[32m'main-text.86'\u001b[0m\u001b[1m]\u001b[0m,\n",
+       "            \u001b[33mchunk\u001b[0m=\u001b[32m\"Research\u001b[0m\u001b[32m\\nResearch has been part of IBM since its founding, and its organized efforts trace \u001b[0m\n",
+       "\u001b[32mtheir roots back to 1945, when the Watson Scientific Computing Laboratory was founded at Columbia University in New\u001b[0m\n",
+       "\u001b[32mYork City, converting a renovated fraternity house on Manhattan's West Side into IBM's first laboratory. Now, IBM \u001b[0m\n",
+       "\u001b[32mResearch constitutes the largest industrial research organization in the world, with 12 labs on 6 continents. \u001b[0m\u001b[32m[\u001b[0m\u001b[32m161\u001b[0m\u001b[32m]\u001b[0m\n",
+       "\u001b[32mIBM Research is headquartered at the Thomas J. Watson Research Center in New York, and facilities include the \u001b[0m\n",
+       "\u001b[32mAlmaden lab in California, Austin lab in Texas, Australia lab in Melbourne, Brazil lab in São Paulo and Rio de \u001b[0m\n",
+       "\u001b[32mJaneiro, China lab in Beijing and Shanghai, Ireland lab in Dublin, Haifa lab in Israel, India lab in Delhi and \u001b[0m\n",
+       "\u001b[32mBangalore, Tokyo lab, Zurichlab and Africa lab in Nairobi.\"\u001b[0m,\n",
+       "            \u001b[33msource_is_text\u001b[0m=\u001b[3;92mTrue\u001b[0m\n",
+       "        \u001b[1m)\u001b[0m,\n",
+       "        \u001b[1;35mSearchResultItem\u001b[0m\u001b[1m(\u001b[0m\n",
+       "            \u001b[33mdoc_hash\u001b[0m=\u001b[32m'b30bc667a324ae111d025526563b674a8d3fd869bc07c8fd204aa95b05d41f0c'\u001b[0m,\n",
+       "            \u001b[33mmain_path\u001b[0m=\u001b[32m'main-text.62'\u001b[0m,\n",
+       "            \u001b[33mpath_group\u001b[0m=\u001b[1m[\u001b[0m\u001b[32m'main-text.61'\u001b[0m, \u001b[32m'main-text.62'\u001b[0m\u001b[1m]\u001b[0m,\n",
+       "            \u001b[33mchunk\u001b[0m=\u001b[32m\"Israel\u001b[0m\u001b[32m\\nIBM Research-Haifa, previously known as the Haifa Research Lab \u001b[0m\u001b[32m(\u001b[0m\u001b[32mHRL\u001b[0m\u001b[32m)\u001b[0m\u001b[32m was founded as a \u001b[0m\n",
+       "\u001b[32msmall scientific center in 1972. $^\u001b[0m\u001b[32m{\u001b[0m\u001b[32m[\u001b[0m\u001b[32m55\u001b[0m\u001b[32m]\u001b[0m\u001b[32m}\u001b[0m\u001b[32m$ Since then, it has grown into a major lab that leads the development of \u001b[0m\n",
+       "\u001b[32minnovative technologies and solutions for the IBM corporation. The lab's offices are situated in three locations \u001b[0m\n",
+       "\u001b[32macross Israel: Haifa, Tel Aviv, and Beer Sheva.\"\u001b[0m,\n",
+       "            \u001b[33msource_is_text\u001b[0m=\u001b[3;92mTrue\u001b[0m\n",
+       "        \u001b[1m)\u001b[0m,\n",
+       "        \u001b[1;35mSearchResultItem\u001b[0m\u001b[1m(\u001b[0m\n",
+       "            \u001b[33mdoc_hash\u001b[0m=\u001b[32m'b30bc667a324ae111d025526563b674a8d3fd869bc07c8fd204aa95b05d41f0c'\u001b[0m,\n",
+       "            \u001b[33mmain_path\u001b[0m=\u001b[32m'main-text.30'\u001b[0m,\n",
+       "            \u001b[33mpath_group\u001b[0m=\u001b[1m[\u001b[0m\u001b[32m'main-text.16'\u001b[0m, \u001b[32m'main-text.30'\u001b[0m\u001b[1m]\u001b[0m,\n",
+       "            \u001b[33mchunk\u001b[0m=\u001b[32m'Laboratories\\nHistoric research centers for IBM also include IBM La Gaude \u001b[0m\u001b[32m(\u001b[0m\u001b[32mNice\u001b[0m\u001b[32m)\u001b[0m\u001b[32m, the Cambridge \u001b[0m\n",
+       "\u001b[32mScientific Center, the IBM New York Scientific Center, 330 North Wabash \u001b[0m\u001b[32m(\u001b[0m\u001b[32mChicago\u001b[0m\u001b[32m)\u001b[0m\u001b[32m, IBM Austin Research Laboratory, \u001b[0m\n",
+       "\u001b[32mand IBM Laboratory Vienna. \u001b[0m\u001b[32m[\u001b[0m\u001b[32m33\u001b[0m\u001b[32m]\u001b[0m\u001b[32m'\u001b[0m,\n",
        "            \u001b[33msource_is_text\u001b[0m=\u001b[3;92mTrue\u001b[0m\n",
        "        \u001b[1m)\u001b[0m\n",
        "    \u001b[1m]\u001b[0m\n",
@@ -568,6 +520,7 @@
     "    retr_k=RETR_K,\n",
     "    return_prompt=True,\n",
     "    gen_timeout=GEN_TIMEOUT,\n",
+    "    gen_ctx_window_size=GEN_CTX_WIN_SIZE,\n",
     ")\n",
     "api_output = api.queries.run(question_query)\n",
     "rag_result = RAGResult.from_api_output(api_output)\n",
@@ -629,16 +582,17 @@
      "data": {
       "text/html": [
        "
QueryTimings(\n",
-       "    overall=1.606383173726499,\n",
+       "    overall=0.6126572471112013,\n",
        "    tasks={\n",
        "        'QA': TaskTimings(\n",
-       "            overall=1.6060180617496371,\n",
+       "            overall=0.6123144757002592,\n",
        "            details={\n",
-       "                'pipeline': 1.115321146324277,\n",
-       "                'encode': 0.028653355315327644,\n",
-       "                'search': 0.02463858388364315,\n",
+       "                'pipeline': 0.5076748670544475,\n",
+       "                'encode': 0.02719842502847314,\n",
+       "                'search': 0.025227335980162024,\n",
        "                'rerank': 0.0,\n",
-       "                'generate': 1.0093672648072243\n",
+       "                'extr_gen_ctx': 0.03297079307958484,\n",
+       "                'generate': 0.42107926099561155\n",
        "            }\n",
        "        )\n",
        "    }\n",
@@ -647,16 +601,17 @@
       ],
       "text/plain": [
        "\u001b[1;35mQueryTimings\u001b[0m\u001b[1m(\u001b[0m\n",
-       "    \u001b[33moverall\u001b[0m=\u001b[1;36m1\u001b[0m\u001b[1;36m.606383173726499\u001b[0m,\n",
+       "    \u001b[33moverall\u001b[0m=\u001b[1;36m0\u001b[0m\u001b[1;36m.6126572471112013\u001b[0m,\n",
        "    \u001b[33mtasks\u001b[0m=\u001b[1m{\u001b[0m\n",
        "        \u001b[32m'QA'\u001b[0m: \u001b[1;35mTaskTimings\u001b[0m\u001b[1m(\u001b[0m\n",
-       "            \u001b[33moverall\u001b[0m=\u001b[1;36m1\u001b[0m\u001b[1;36m.6060180617496371\u001b[0m,\n",
+       "            \u001b[33moverall\u001b[0m=\u001b[1;36m0\u001b[0m\u001b[1;36m.6123144757002592\u001b[0m,\n",
        "            \u001b[33mdetails\u001b[0m=\u001b[1m{\u001b[0m\n",
-       "                \u001b[32m'pipeline'\u001b[0m: \u001b[1;36m1.115321146324277\u001b[0m,\n",
-       "                \u001b[32m'encode'\u001b[0m: \u001b[1;36m0.028653355315327644\u001b[0m,\n",
-       "                \u001b[32m'search'\u001b[0m: \u001b[1;36m0.02463858388364315\u001b[0m,\n",
+       "                \u001b[32m'pipeline'\u001b[0m: \u001b[1;36m0.5076748670544475\u001b[0m,\n",
+       "                \u001b[32m'encode'\u001b[0m: \u001b[1;36m0.02719842502847314\u001b[0m,\n",
+       "                \u001b[32m'search'\u001b[0m: \u001b[1;36m0.025227335980162024\u001b[0m,\n",
        "                \u001b[32m'rerank'\u001b[0m: \u001b[1;36m0.0\u001b[0m,\n",
-       "                \u001b[32m'generate'\u001b[0m: \u001b[1;36m1.0093672648072243\u001b[0m\n",
+       "                \u001b[32m'extr_gen_ctx'\u001b[0m: \u001b[1;36m0.03297079307958484\u001b[0m,\n",
+       "                \u001b[32m'generate'\u001b[0m: \u001b[1;36m0.42107926099561155\u001b[0m\n",
        "            \u001b[1m}\u001b[0m\n",
        "        \u001b[1m)\u001b[0m\n",
        "    \u001b[1m}\u001b[0m\n",
@@ -671,6 +626,175 @@
     "rich.print(api_output.timings)"
    ]
   },
+  {
+   "cell_type": "markdown",
+   "id": "b86295f6",
+   "metadata": {},
+   "source": [
+    "### Generating next-best answers"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "id": "9a275567",
+   "metadata": {},
+   "source": [
+    "To generate next-best answers, we can make follow-up queries with respective `chunk_refs` based on a reference RAG result.\n",
+    "\n",
+    "For example, below we use the previous RAG result as reference and generate answers based on its second-best and third-best items."
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 11,
+   "id": "117eec49",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "from typing import List\n",
+    "\n",
+    "from deepsearch.cps.queries.results import RAGAnswerItem\n",
+    "\n",
+    "reference_rag_result = rag_result\n",
+    "\n",
+    "answer_items: List[RAGAnswerItem] = []\n",
+    "for i in range(1, 3):\n",
+    "\n",
+    "    chunk_refs = [reference_rag_result.search_result_items[i]]\n",
+    "\n",
+    "    question_query = RAGQuery(\n",
+    "        question=QUESTION,\n",
+    "        project=PROJ_KEY,\n",
+    "        data_source=data_source,\n",
+    "        retr_k=RETR_K,\n",
+    "        return_prompt=True,\n",
+    "        chunk_refs=chunk_refs,  # <==\n",
+    "        gen_ctx_window_size=GEN_CTX_WIN_SIZE,\n",
+    "        gen_timeout=GEN_TIMEOUT,\n",
+    "    )\n",
+    "    api_output = api.queries.run(question_query)\n",
+    "    new_rag_result = RAGResult.from_api_output(api_output)\n",
+    "    answer_items.append(new_rag_result.answers[0])"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "id": "bc337982",
+   "metadata": {},
+   "source": [
+    "Here we print the resulting next-best answers in a table:"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 12,
+   "id": "ae92b1de",
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/html": [
+       "
                                         Next-best answers                                          \n",
+       "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n",
+       "┃ Prompt                                           Answer                                         ┃\n",
+       "┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩\n",
+       "│ Context information is below.                    The first European IBM lab was located in      │\n",
+       "│ ---------------------                            Zurich, Switzerland, and opened in 1956. It is │\n",
+       "│ IBM Research-Zurich (previously called IBM       currently known as IBM Research-Zurich.        │\n",
+       "│ Zurich Research Laboratory, ZRL) is the                                                         │\n",
+       "│ European branch of IBM Research. It was opened                                                  │\n",
+       "│ in 1956 and is located in Rüschlikon, near                                                      │\n",
+       "│ Zurich, Switzerland.                                                                            │\n",
+       "│ ---------------------                                                                           │\n",
+       "│ Given the context information and not prior                                                     │\n",
+       "│ knowledge, answer the query.                                                                    │\n",
+       "│ Query: Where was the first European IBM lab                                                     │\n",
+       "│ located?                                                                                        │\n",
+       "│ Answer:                                                                                         │\n",
+       "│                                                                                                 │\n",
+       "├─────────────────────────────────────────────────┼────────────────────────────────────────────────┤\n",
+       "│ Context information is below.                    The information does not directly state where  │\n",
+       "│ ---------------------                            the first European IBM lab was located; it     │\n",
+       "│ The roots of today's IBM Research began with     only mentions the Watson Scientific Computing  │\n",
+       "│ the 1945 opening of the Watson Scientific        Laboratory at Columbia University as the first │\n",
+       "│ Computing Laboratory at Columbia University.     IBM laboratory devoted to pure science.        │\n",
+       "│ $^{[4]}$ This was the first IBM laboratory       However, it does mention the expansion of IBM  │\n",
+       "│ devoted to pure science and later expanded into  Research into locations in Westchester County, │\n",
+       "│ additional IBM Research locations in             New York, in the 1950s. To find out where the  │\n",
+       "│ Westchester County, New York, starting in the    first European IBM lab was located, one would  │\n",
+       "│ 1950s, $^{[5][6]}$ including the Thomas J.       need additional information.                   │\n",
+       "│ Watson Research Center in 1961. [5][6]                                                          │\n",
+       "│ ---------------------                                                                           │\n",
+       "│ Given the context information and not prior                                                     │\n",
+       "│ knowledge, answer the query.                                                                    │\n",
+       "│ Query: Where was the first European IBM lab                                                     │\n",
+       "│ located?                                                                                        │\n",
+       "│ Answer:                                                                                         │\n",
+       "│                                                                                                 │\n",
+       "└─────────────────────────────────────────────────┴────────────────────────────────────────────────┘\n",
+       "
\n" + ], + "text/plain": [ + "\u001b[3m Next-best answers \u001b[0m\n", + "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n", + "┃\u001b[1m \u001b[0m\u001b[1mPrompt \u001b[0m\u001b[1m \u001b[0m┃\u001b[1m \u001b[0m\u001b[1mAnswer \u001b[0m\u001b[1m \u001b[0m┃\n", + "┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩\n", + "│\u001b[33m \u001b[0m\u001b[33mContext information is below. \u001b[0m\u001b[33m \u001b[0m│\u001b[32m \u001b[0m\u001b[32mThe first European IBM lab was located in \u001b[0m\u001b[32m \u001b[0m│\n", + "│\u001b[33m \u001b[0m\u001b[33m--------------------- \u001b[0m\u001b[33m \u001b[0m│\u001b[32m \u001b[0m\u001b[32mZurich, Switzerland, and opened in 1956. It is\u001b[0m\u001b[32m \u001b[0m│\n", + "│\u001b[33m \u001b[0m\u001b[33mIBM Research-Zurich (previously called IBM \u001b[0m\u001b[33m \u001b[0m│\u001b[32m \u001b[0m\u001b[32mcurrently known as IBM Research-Zurich. \u001b[0m\u001b[32m \u001b[0m│\n", + "│\u001b[33m \u001b[0m\u001b[33mZurich Research Laboratory, ZRL) is the \u001b[0m\u001b[33m \u001b[0m│\u001b[32m \u001b[0m│\n", + "│\u001b[33m \u001b[0m\u001b[33mEuropean branch of IBM Research. It was opened \u001b[0m\u001b[33m \u001b[0m│\u001b[32m \u001b[0m│\n", + "│\u001b[33m \u001b[0m\u001b[33min 1956 and is located in Rüschlikon, near \u001b[0m\u001b[33m \u001b[0m│\u001b[32m \u001b[0m│\n", + "│\u001b[33m \u001b[0m\u001b[33mZurich, Switzerland. \u001b[0m\u001b[33m \u001b[0m│\u001b[32m \u001b[0m│\n", + "│\u001b[33m \u001b[0m\u001b[33m--------------------- \u001b[0m\u001b[33m \u001b[0m│\u001b[32m \u001b[0m│\n", + "│\u001b[33m \u001b[0m\u001b[33mGiven the context information and not prior \u001b[0m\u001b[33m \u001b[0m│\u001b[32m \u001b[0m│\n", + "│\u001b[33m \u001b[0m\u001b[33mknowledge, answer the query. \u001b[0m\u001b[33m \u001b[0m│\u001b[32m \u001b[0m│\n", + "│\u001b[33m \u001b[0m\u001b[33mQuery: Where was the first European IBM lab \u001b[0m\u001b[33m \u001b[0m│\u001b[32m \u001b[0m│\n", + "│\u001b[33m \u001b[0m\u001b[33mlocated? \u001b[0m\u001b[33m \u001b[0m│\u001b[32m \u001b[0m│\n", + "│\u001b[33m \u001b[0m\u001b[33mAnswer: \u001b[0m\u001b[33m \u001b[0m│\u001b[32m \u001b[0m│\n", + "│\u001b[33m \u001b[0m\u001b[33m \u001b[0m\u001b[33m \u001b[0m│\u001b[32m \u001b[0m│\n", + "├─────────────────────────────────────────────────┼────────────────────────────────────────────────┤\n", + "│\u001b[33m \u001b[0m\u001b[33mContext information is below. \u001b[0m\u001b[33m \u001b[0m│\u001b[32m \u001b[0m\u001b[32mThe information does not directly state where \u001b[0m\u001b[32m \u001b[0m│\n", + "│\u001b[33m \u001b[0m\u001b[33m--------------------- \u001b[0m\u001b[33m \u001b[0m│\u001b[32m \u001b[0m\u001b[32mthe first European IBM lab was located; it \u001b[0m\u001b[32m \u001b[0m│\n", + "│\u001b[33m \u001b[0m\u001b[33mThe roots of today's IBM Research began with \u001b[0m\u001b[33m \u001b[0m│\u001b[32m \u001b[0m\u001b[32monly mentions the Watson Scientific Computing \u001b[0m\u001b[32m \u001b[0m│\n", + "│\u001b[33m \u001b[0m\u001b[33mthe 1945 opening of the Watson Scientific \u001b[0m\u001b[33m \u001b[0m│\u001b[32m \u001b[0m\u001b[32mLaboratory at Columbia University as the first\u001b[0m\u001b[32m \u001b[0m│\n", + "│\u001b[33m \u001b[0m\u001b[33mComputing Laboratory at Columbia University. \u001b[0m\u001b[33m \u001b[0m│\u001b[32m \u001b[0m\u001b[32mIBM laboratory devoted to pure science. \u001b[0m\u001b[32m \u001b[0m│\n", + "│\u001b[33m \u001b[0m\u001b[33m$^{[4]}$ This was the first IBM laboratory \u001b[0m\u001b[33m \u001b[0m│\u001b[32m \u001b[0m\u001b[32mHowever, it does mention the expansion of IBM \u001b[0m\u001b[32m \u001b[0m│\n", + "│\u001b[33m \u001b[0m\u001b[33mdevoted to pure science and later expanded into\u001b[0m\u001b[33m \u001b[0m│\u001b[32m \u001b[0m\u001b[32mResearch into locations in Westchester County,\u001b[0m\u001b[32m \u001b[0m│\n", + "│\u001b[33m \u001b[0m\u001b[33madditional IBM Research locations in \u001b[0m\u001b[33m \u001b[0m│\u001b[32m \u001b[0m\u001b[32mNew York, in the 1950s. To find out where the \u001b[0m\u001b[32m \u001b[0m│\n", + "│\u001b[33m \u001b[0m\u001b[33mWestchester County, New York, starting in the \u001b[0m\u001b[33m \u001b[0m│\u001b[32m \u001b[0m\u001b[32mfirst European IBM lab was located, one would \u001b[0m\u001b[32m \u001b[0m│\n", + "│\u001b[33m \u001b[0m\u001b[33m1950s, $^{[5][6]}$ including the Thomas J. \u001b[0m\u001b[33m \u001b[0m│\u001b[32m \u001b[0m\u001b[32mneed additional information. \u001b[0m\u001b[32m \u001b[0m│\n", + "│\u001b[33m \u001b[0m\u001b[33mWatson Research Center in 1961. [5][6] \u001b[0m\u001b[33m \u001b[0m│\u001b[32m \u001b[0m│\n", + "│\u001b[33m \u001b[0m\u001b[33m--------------------- \u001b[0m\u001b[33m \u001b[0m│\u001b[32m \u001b[0m│\n", + "│\u001b[33m \u001b[0m\u001b[33mGiven the context information and not prior \u001b[0m\u001b[33m \u001b[0m│\u001b[32m \u001b[0m│\n", + "│\u001b[33m \u001b[0m\u001b[33mknowledge, answer the query. \u001b[0m\u001b[33m \u001b[0m│\u001b[32m \u001b[0m│\n", + "│\u001b[33m \u001b[0m\u001b[33mQuery: Where was the first European IBM lab \u001b[0m\u001b[33m \u001b[0m│\u001b[32m \u001b[0m│\n", + "│\u001b[33m \u001b[0m\u001b[33mlocated? \u001b[0m\u001b[33m \u001b[0m│\u001b[32m \u001b[0m│\n", + "│\u001b[33m \u001b[0m\u001b[33mAnswer: \u001b[0m\u001b[33m \u001b[0m│\u001b[32m \u001b[0m│\n", + "│\u001b[33m \u001b[0m\u001b[33m \u001b[0m\u001b[33m \u001b[0m│\u001b[32m \u001b[0m│\n", + "└─────────────────────────────────────────────────┴────────────────────────────────────────────────┘\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "from rich.console import Console\n", + "from rich.table import Table\n", + "\n", + "table = Table(title=\"Next-best answers\", show_lines=True, width=100)\n", + "\n", + "table.add_column(\"Prompt\", style=\"yellow\")\n", + "table.add_column(\"Answer\", style=\"green\")\n", + "\n", + "for answer_item in answer_items:\n", + " table.add_row(answer_item.prompt, answer_item.answer)\n", + "\n", + "console = Console()\n", + "console.print(table)" + ] + }, { "cell_type": "markdown", "id": "61e1cca5", @@ -683,7 +807,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 13, "id": "1598dbe8", "metadata": {}, "outputs": [ @@ -724,7 +848,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 14, "id": "22953ad3", "metadata": {}, "outputs": [ @@ -748,32 +872,71 @@ " search_result_items=[\n", " SearchResultItem(\n", " doc_hash='b30bc667a324ae111d025526563b674a8d3fd869bc07c8fd204aa95b05d41f0c',\n", - " chunk=\"History\\nThe roots of today's IBM Research began with the 1945 opening of the Watson Scientific \n", - "Computing Laboratory at Columbia University. $^{[4]}$ This was the first IBM laboratory devoted to pure science and\n", - "later expanded into additional IBM Research locations in Westchester County, New York, starting in the 1950s, \n", - "$^{[5][6]}$ including the Thomas J. Watson Research Center in 1961. [5][6]\",\n", - " main_path='main-text.8',\n", - " path_group=['main-text.7', 'main-text.8'],\n", - " source_is_text=True\n", - " ),\n", - " SearchResultItem(\n", - " doc_hash='b30bc667a324ae111d025526563b674a8d3fd869bc07c8fd204aa95b05d41f0c',\n", + " main_path='main-text.71',\n", + " path_group=['main-text.69', 'main-text.71'],\n", " chunk='Switzerland\\nIn 1956, IBM opened their first European research laboratory in Adliswil, \n", "Switzerland, near Zurich. The lab moved to its own campus in neighboring Rüschlikon in 1962. The Zurich lab is \n", "staffed by a multicultural and interdisciplinary team of a few hundred permanent research staff members, graduate \n", "students and post-doctoral fellows, representing about 45 nationalities. Collocated with the lab is a Client Center\n", "(formerly the Industry Solutions Lab), an executive briefing facility demonstrating technology prototypes and \n", "solutions.',\n", - " main_path='main-text.71',\n", - " path_group=['main-text.69', 'main-text.71'],\n", + " source_is_text=True\n", + " ),\n", + " SearchResultItem(\n", + " doc_hash='234bc5cf2c860d49574b0ff7191c354b7bbc11472a09972c8b6108c62375ffc3',\n", + " main_path='main-text.86',\n", + " path_group=['main-text.85', 'main-text.86'],\n", + " chunk=\"Research\\nResearch has been part of IBM since its founding, and its organized efforts trace \n", + "their roots back to 1945, when the Watson Scientific Computing Laboratory was founded at Columbia University in New\n", + "York City, converting a renovated fraternity house on Manhattan's West Side into IBM's first laboratory. Now, IBM \n", + "Research constitutes the largest industrial research organization in the world, with 12 labs on 6 continents. [161]\n", + "IBM Research is headquartered at the Thomas J. Watson Research Center in New York, and facilities include the \n", + "Almaden lab in California, Austin lab in Texas, Australia lab in Melbourne, Brazil lab in São Paulo and Rio de \n", + "Janeiro, China lab in Beijing and Shanghai, Ireland lab in Dublin, Haifa lab in Israel, India lab in Delhi and \n", + "Bangalore, Tokyo lab, Zurichlab and Africa lab in Nairobi.\",\n", " source_is_text=True\n", " ),\n", " SearchResultItem(\n", " doc_hash='b30bc667a324ae111d025526563b674a8d3fd869bc07c8fd204aa95b05d41f0c',\n", - " chunk='Switzerland\\nIBM Research-Zurich (previously called IBM Zurich Research Laboratory, ZRL) is the \n", - "European branch of IBM Research. It was opened in 1956 and is located in Rüschlikon, near Zurich, Switzerland.',\n", " main_path='main-text.70',\n", " path_group=['main-text.69', 'main-text.70'],\n", + " chunk='Switzerland\\nIBM Research-Zurich (previously called IBM Zurich Research Laboratory, ZRL) is the \n", + "European branch of IBM Research. It was opened in 1956 and is located in Rüschlikon, near Zurich, Switzerland.',\n", + " source_is_text=True\n", + " ),\n", + " SearchResultItem(\n", + " doc_hash='b30bc667a324ae111d025526563b674a8d3fd869bc07c8fd204aa95b05d41f0c',\n", + " main_path='main-text.62',\n", + " path_group=['main-text.61', 'main-text.62'],\n", + " chunk=\"Israel\\nIBM Research-Haifa, previously known as the Haifa Research Lab (HRL) was founded as a \n", + "small scientific center in 1972. $^{[55]}$ Since then, it has grown into a major lab that leads the development of \n", + "innovative technologies and solutions for the IBM corporation. The lab's offices are situated in three locations \n", + "across Israel: Haifa, Tel Aviv, and Beer Sheva.\",\n", + " source_is_text=True\n", + " ),\n", + " SearchResultItem(\n", + " doc_hash='b30bc667a324ae111d025526563b674a8d3fd869bc07c8fd204aa95b05d41f0c',\n", + " main_path='main-text.44',\n", + " path_group=['main-text.43', 'main-text.44'],\n", + " chunk=\"Australia\\nIBM Research-Australia is a research and development laboratory established by IBM \n", + "Research in 2009 in Melbourne. [39] It is involved in social media, interactive content, healthcare analytics and \n", + "services research, multimedia analytics, and genomics. The lab is headed by Vice President and Lab Director Joanna \n", + "Batstone. [40] It was to be the company's first laboratory combining research and development in a single \n", + "organisation. [41]\",\n", + " source_is_text=True\n", + " ),\n", + " SearchResultItem(\n", + " doc_hash='fa7ce2f66a7a5e061813d36348425f81d9e7ebc23454d8e63359fb5e28ab8dd0',\n", + " main_path='main-text.1',\n", + " path_group=['main-text.0', 'main-text.1'],\n", + " chunk=\"Deep Blue (chess computer)\\nDeep Blue was a chess-playing expert system run on a unique \n", + "purpose-built IBM supercomputer. It was the first computer to win a game, and the first to win a match, against a \n", + "reigning world champion under regular time controls. Development began in 1985 at Carnegie Mellon University under \n", + "the name ChipTest. It then moved to IBM, where it was first renamed Deep Thought, then again in 1989 to Deep Blue. \n", + "It first played world champion Garry Kasparov in a six-game match in 1996, where it lost four games to two. It was \n", + "upgraded in 1997 and in a six-game rematch, it defeated Kasparov by winning two games and drawing three. Deep \n", + "Blue's victory is considered a milestone in the history of artificial intelligence and has been the subject of \n", + "several books and films.\",\n", " source_is_text=True\n", " )\n", " ]\n", @@ -785,32 +948,71 @@ " \u001b[33msearch_result_items\u001b[0m=\u001b[1m[\u001b[0m\n", " \u001b[1;35mSearchResultItem\u001b[0m\u001b[1m(\u001b[0m\n", " \u001b[33mdoc_hash\u001b[0m=\u001b[32m'b30bc667a324ae111d025526563b674a8d3fd869bc07c8fd204aa95b05d41f0c'\u001b[0m,\n", - " \u001b[33mchunk\u001b[0m=\u001b[32m\"History\u001b[0m\u001b[32m\\nThe roots of today's IBM Research began with the 1945 opening of the Watson Scientific \u001b[0m\n", - "\u001b[32mComputing Laboratory at Columbia University. $^\u001b[0m\u001b[32m{\u001b[0m\u001b[32m[\u001b[0m\u001b[32m4\u001b[0m\u001b[32m]\u001b[0m\u001b[32m}\u001b[0m\u001b[32m$ This was the first IBM laboratory devoted to pure science and\u001b[0m\n", - "\u001b[32mlater expanded into additional IBM Research locations in Westchester County, New York, starting in the 1950s, \u001b[0m\n", - "\u001b[32m$^\u001b[0m\u001b[32m{\u001b[0m\u001b[32m[\u001b[0m\u001b[32m5\u001b[0m\u001b[32m]\u001b[0m\u001b[32m[\u001b[0m\u001b[32m6\u001b[0m\u001b[32m]\u001b[0m\u001b[32m}\u001b[0m\u001b[32m$ including the Thomas J. Watson Research Center in 1961. \u001b[0m\u001b[32m[\u001b[0m\u001b[32m5\u001b[0m\u001b[32m]\u001b[0m\u001b[32m[\u001b[0m\u001b[32m6\u001b[0m\u001b[32m]\u001b[0m\u001b[32m\"\u001b[0m,\n", - " \u001b[33mmain_path\u001b[0m=\u001b[32m'main-text.8'\u001b[0m,\n", - " \u001b[33mpath_group\u001b[0m=\u001b[1m[\u001b[0m\u001b[32m'main-text.7'\u001b[0m, \u001b[32m'main-text.8'\u001b[0m\u001b[1m]\u001b[0m,\n", - " \u001b[33msource_is_text\u001b[0m=\u001b[3;92mTrue\u001b[0m\n", - " \u001b[1m)\u001b[0m,\n", - " \u001b[1;35mSearchResultItem\u001b[0m\u001b[1m(\u001b[0m\n", - " \u001b[33mdoc_hash\u001b[0m=\u001b[32m'b30bc667a324ae111d025526563b674a8d3fd869bc07c8fd204aa95b05d41f0c'\u001b[0m,\n", + " \u001b[33mmain_path\u001b[0m=\u001b[32m'main-text.71'\u001b[0m,\n", + " \u001b[33mpath_group\u001b[0m=\u001b[1m[\u001b[0m\u001b[32m'main-text.69'\u001b[0m, \u001b[32m'main-text.71'\u001b[0m\u001b[1m]\u001b[0m,\n", " \u001b[33mchunk\u001b[0m=\u001b[32m'Switzerland\\nIn 1956, IBM opened their first European research laboratory in Adliswil, \u001b[0m\n", "\u001b[32mSwitzerland, near Zurich. The lab moved to its own campus in neighboring Rüschlikon in 1962. The Zurich lab is \u001b[0m\n", "\u001b[32mstaffed by a multicultural and interdisciplinary team of a few hundred permanent research staff members, graduate \u001b[0m\n", "\u001b[32mstudents and post-doctoral fellows, representing about 45 nationalities. Collocated with the lab is a Client Center\u001b[0m\n", "\u001b[32m(\u001b[0m\u001b[32mformerly the Industry Solutions Lab\u001b[0m\u001b[32m)\u001b[0m\u001b[32m, an executive briefing facility demonstrating technology prototypes and \u001b[0m\n", "\u001b[32msolutions.'\u001b[0m,\n", - " \u001b[33mmain_path\u001b[0m=\u001b[32m'main-text.71'\u001b[0m,\n", - " \u001b[33mpath_group\u001b[0m=\u001b[1m[\u001b[0m\u001b[32m'main-text.69'\u001b[0m, \u001b[32m'main-text.71'\u001b[0m\u001b[1m]\u001b[0m,\n", + " \u001b[33msource_is_text\u001b[0m=\u001b[3;92mTrue\u001b[0m\n", + " \u001b[1m)\u001b[0m,\n", + " \u001b[1;35mSearchResultItem\u001b[0m\u001b[1m(\u001b[0m\n", + " \u001b[33mdoc_hash\u001b[0m=\u001b[32m'234bc5cf2c860d49574b0ff7191c354b7bbc11472a09972c8b6108c62375ffc3'\u001b[0m,\n", + " \u001b[33mmain_path\u001b[0m=\u001b[32m'main-text.86'\u001b[0m,\n", + " \u001b[33mpath_group\u001b[0m=\u001b[1m[\u001b[0m\u001b[32m'main-text.85'\u001b[0m, \u001b[32m'main-text.86'\u001b[0m\u001b[1m]\u001b[0m,\n", + " \u001b[33mchunk\u001b[0m=\u001b[32m\"Research\u001b[0m\u001b[32m\\nResearch has been part of IBM since its founding, and its organized efforts trace \u001b[0m\n", + "\u001b[32mtheir roots back to 1945, when the Watson Scientific Computing Laboratory was founded at Columbia University in New\u001b[0m\n", + "\u001b[32mYork City, converting a renovated fraternity house on Manhattan's West Side into IBM's first laboratory. Now, IBM \u001b[0m\n", + "\u001b[32mResearch constitutes the largest industrial research organization in the world, with 12 labs on 6 continents. \u001b[0m\u001b[32m[\u001b[0m\u001b[32m161\u001b[0m\u001b[32m]\u001b[0m\n", + "\u001b[32mIBM Research is headquartered at the Thomas J. Watson Research Center in New York, and facilities include the \u001b[0m\n", + "\u001b[32mAlmaden lab in California, Austin lab in Texas, Australia lab in Melbourne, Brazil lab in São Paulo and Rio de \u001b[0m\n", + "\u001b[32mJaneiro, China lab in Beijing and Shanghai, Ireland lab in Dublin, Haifa lab in Israel, India lab in Delhi and \u001b[0m\n", + "\u001b[32mBangalore, Tokyo lab, Zurichlab and Africa lab in Nairobi.\"\u001b[0m,\n", " \u001b[33msource_is_text\u001b[0m=\u001b[3;92mTrue\u001b[0m\n", " \u001b[1m)\u001b[0m,\n", " \u001b[1;35mSearchResultItem\u001b[0m\u001b[1m(\u001b[0m\n", " \u001b[33mdoc_hash\u001b[0m=\u001b[32m'b30bc667a324ae111d025526563b674a8d3fd869bc07c8fd204aa95b05d41f0c'\u001b[0m,\n", - " \u001b[33mchunk\u001b[0m=\u001b[32m'Switzerland\\nIBM Research-Zurich \u001b[0m\u001b[32m(\u001b[0m\u001b[32mpreviously called IBM Zurich Research Laboratory, ZRL\u001b[0m\u001b[32m)\u001b[0m\u001b[32m is the \u001b[0m\n", - "\u001b[32mEuropean branch of IBM Research. It was opened in 1956 and is located in Rüschlikon, near Zurich, Switzerland.'\u001b[0m,\n", " \u001b[33mmain_path\u001b[0m=\u001b[32m'main-text.70'\u001b[0m,\n", " \u001b[33mpath_group\u001b[0m=\u001b[1m[\u001b[0m\u001b[32m'main-text.69'\u001b[0m, \u001b[32m'main-text.70'\u001b[0m\u001b[1m]\u001b[0m,\n", + " \u001b[33mchunk\u001b[0m=\u001b[32m'Switzerland\\nIBM Research-Zurich \u001b[0m\u001b[32m(\u001b[0m\u001b[32mpreviously called IBM Zurich Research Laboratory, ZRL\u001b[0m\u001b[32m)\u001b[0m\u001b[32m is the \u001b[0m\n", + "\u001b[32mEuropean branch of IBM Research. It was opened in 1956 and is located in Rüschlikon, near Zurich, Switzerland.'\u001b[0m,\n", + " \u001b[33msource_is_text\u001b[0m=\u001b[3;92mTrue\u001b[0m\n", + " \u001b[1m)\u001b[0m,\n", + " \u001b[1;35mSearchResultItem\u001b[0m\u001b[1m(\u001b[0m\n", + " \u001b[33mdoc_hash\u001b[0m=\u001b[32m'b30bc667a324ae111d025526563b674a8d3fd869bc07c8fd204aa95b05d41f0c'\u001b[0m,\n", + " \u001b[33mmain_path\u001b[0m=\u001b[32m'main-text.62'\u001b[0m,\n", + " \u001b[33mpath_group\u001b[0m=\u001b[1m[\u001b[0m\u001b[32m'main-text.61'\u001b[0m, \u001b[32m'main-text.62'\u001b[0m\u001b[1m]\u001b[0m,\n", + " \u001b[33mchunk\u001b[0m=\u001b[32m\"Israel\u001b[0m\u001b[32m\\nIBM Research-Haifa, previously known as the Haifa Research Lab \u001b[0m\u001b[32m(\u001b[0m\u001b[32mHRL\u001b[0m\u001b[32m)\u001b[0m\u001b[32m was founded as a \u001b[0m\n", + "\u001b[32msmall scientific center in 1972. $^\u001b[0m\u001b[32m{\u001b[0m\u001b[32m[\u001b[0m\u001b[32m55\u001b[0m\u001b[32m]\u001b[0m\u001b[32m}\u001b[0m\u001b[32m$ Since then, it has grown into a major lab that leads the development of \u001b[0m\n", + "\u001b[32minnovative technologies and solutions for the IBM corporation. The lab's offices are situated in three locations \u001b[0m\n", + "\u001b[32macross Israel: Haifa, Tel Aviv, and Beer Sheva.\"\u001b[0m,\n", + " \u001b[33msource_is_text\u001b[0m=\u001b[3;92mTrue\u001b[0m\n", + " \u001b[1m)\u001b[0m,\n", + " \u001b[1;35mSearchResultItem\u001b[0m\u001b[1m(\u001b[0m\n", + " \u001b[33mdoc_hash\u001b[0m=\u001b[32m'b30bc667a324ae111d025526563b674a8d3fd869bc07c8fd204aa95b05d41f0c'\u001b[0m,\n", + " \u001b[33mmain_path\u001b[0m=\u001b[32m'main-text.44'\u001b[0m,\n", + " \u001b[33mpath_group\u001b[0m=\u001b[1m[\u001b[0m\u001b[32m'main-text.43'\u001b[0m, \u001b[32m'main-text.44'\u001b[0m\u001b[1m]\u001b[0m,\n", + " \u001b[33mchunk\u001b[0m=\u001b[32m\"Australia\u001b[0m\u001b[32m\\nIBM Research-Australia is a research and development laboratory established by IBM \u001b[0m\n", + "\u001b[32mResearch in 2009 in Melbourne. \u001b[0m\u001b[32m[\u001b[0m\u001b[32m39\u001b[0m\u001b[32m]\u001b[0m\u001b[32m It is involved in social media, interactive content, healthcare analytics and \u001b[0m\n", + "\u001b[32mservices research, multimedia analytics, and genomics. The lab is headed by Vice President and Lab Director Joanna \u001b[0m\n", + "\u001b[32mBatstone. \u001b[0m\u001b[32m[\u001b[0m\u001b[32m40\u001b[0m\u001b[32m]\u001b[0m\u001b[32m It was to be the company's first laboratory combining research and development in a single \u001b[0m\n", + "\u001b[32morganisation. \u001b[0m\u001b[32m[\u001b[0m\u001b[32m41\u001b[0m\u001b[32m]\u001b[0m\u001b[32m\"\u001b[0m,\n", + " \u001b[33msource_is_text\u001b[0m=\u001b[3;92mTrue\u001b[0m\n", + " \u001b[1m)\u001b[0m,\n", + " \u001b[1;35mSearchResultItem\u001b[0m\u001b[1m(\u001b[0m\n", + " \u001b[33mdoc_hash\u001b[0m=\u001b[32m'fa7ce2f66a7a5e061813d36348425f81d9e7ebc23454d8e63359fb5e28ab8dd0'\u001b[0m,\n", + " \u001b[33mmain_path\u001b[0m=\u001b[32m'main-text.1'\u001b[0m,\n", + " \u001b[33mpath_group\u001b[0m=\u001b[1m[\u001b[0m\u001b[32m'main-text.0'\u001b[0m, \u001b[32m'main-text.1'\u001b[0m\u001b[1m]\u001b[0m,\n", + " \u001b[33mchunk\u001b[0m=\u001b[32m\"Deep\u001b[0m\u001b[32m Blue \u001b[0m\u001b[32m(\u001b[0m\u001b[32mchess computer\u001b[0m\u001b[32m)\u001b[0m\u001b[32m\\nDeep Blue was a chess-playing expert system run on a unique \u001b[0m\n", + "\u001b[32mpurpose-built IBM supercomputer. It was the first computer to win a game, and the first to win a match, against a \u001b[0m\n", + "\u001b[32mreigning world champion under regular time controls. Development began in 1985 at Carnegie Mellon University under \u001b[0m\n", + "\u001b[32mthe name ChipTest. It then moved to IBM, where it was first renamed Deep Thought, then again in 1989 to Deep Blue. \u001b[0m\n", + "\u001b[32mIt first played world champion Garry Kasparov in a six-game match in 1996, where it lost four games to two. It was \u001b[0m\n", + "\u001b[32mupgraded in 1997 and in a six-game rematch, it defeated Kasparov by winning two games and drawing three. Deep \u001b[0m\n", + "\u001b[32mBlue's victory is considered a milestone in the history of artificial intelligence and has been the subject of \u001b[0m\n", + "\u001b[32mseveral books and films.\"\u001b[0m,\n", " \u001b[33msource_is_text\u001b[0m=\u001b[3;92mTrue\u001b[0m\n", " \u001b[1m)\u001b[0m\n", " \u001b[1m]\u001b[0m\n", @@ -848,7 +1050,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 15, "id": "4b6ce608", "metadata": {}, "outputs": [ @@ -856,15 +1058,15 @@ "data": { "text/html": [ "
QueryTimings(\n",
-       "    overall=1.1053222483024001,\n",
+       "    overall=2.1080491673201323,\n",
        "    tasks={\n",
        "        'QA': TaskTimings(\n",
-       "            overall=1.1050042947754264,\n",
+       "            overall=2.1076935632154346,\n",
        "            details={\n",
-       "                'pipeline': 0.6090765688568354,\n",
-       "                'encode': 0.026338623836636543,\n",
-       "                'search': 0.025418167933821678,\n",
-       "                'rerank': 0.5562568940222263\n",
+       "                'pipeline': 1.79485984146595,\n",
+       "                'encode': 0.028432318940758705,\n",
+       "                'search': 0.023948708549141884,\n",
+       "                'rerank': 1.7413393948227167\n",
        "            }\n",
        "        )\n",
        "    }\n",
@@ -873,15 +1075,15 @@
       ],
       "text/plain": [
        "\u001b[1;35mQueryTimings\u001b[0m\u001b[1m(\u001b[0m\n",
-       "    \u001b[33moverall\u001b[0m=\u001b[1;36m1\u001b[0m\u001b[1;36m.1053222483024001\u001b[0m,\n",
+       "    \u001b[33moverall\u001b[0m=\u001b[1;36m2\u001b[0m\u001b[1;36m.1080491673201323\u001b[0m,\n",
        "    \u001b[33mtasks\u001b[0m=\u001b[1m{\u001b[0m\n",
        "        \u001b[32m'QA'\u001b[0m: \u001b[1;35mTaskTimings\u001b[0m\u001b[1m(\u001b[0m\n",
-       "            \u001b[33moverall\u001b[0m=\u001b[1;36m1\u001b[0m\u001b[1;36m.1050042947754264\u001b[0m,\n",
+       "            \u001b[33moverall\u001b[0m=\u001b[1;36m2\u001b[0m\u001b[1;36m.1076935632154346\u001b[0m,\n",
        "            \u001b[33mdetails\u001b[0m=\u001b[1m{\u001b[0m\n",
-       "                \u001b[32m'pipeline'\u001b[0m: \u001b[1;36m0.6090765688568354\u001b[0m,\n",
-       "                \u001b[32m'encode'\u001b[0m: \u001b[1;36m0.026338623836636543\u001b[0m,\n",
-       "                \u001b[32m'search'\u001b[0m: \u001b[1;36m0.025418167933821678\u001b[0m,\n",
-       "                \u001b[32m'rerank'\u001b[0m: \u001b[1;36m0.5562568940222263\u001b[0m\n",
+       "                \u001b[32m'pipeline'\u001b[0m: \u001b[1;36m1.79485984146595\u001b[0m,\n",
+       "                \u001b[32m'encode'\u001b[0m: \u001b[1;36m0.028432318940758705\u001b[0m,\n",
+       "                \u001b[32m'search'\u001b[0m: \u001b[1;36m0.023948708549141884\u001b[0m,\n",
+       "                \u001b[32m'rerank'\u001b[0m: \u001b[1;36m1.7413393948227167\u001b[0m\n",
        "            \u001b[1m}\u001b[0m\n",
        "        \u001b[1m)\u001b[0m\n",
        "    \u001b[1m}\u001b[0m\n",
diff --git a/poetry.lock b/poetry.lock
index dcd9f10..889e18e 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -1,4 +1,4 @@
-# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand.
+# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand.
 
 [[package]]
 name = "aiohttp"
@@ -1019,13 +1019,13 @@ textColor = ">=3.0.1,<4.0.0"
 
 [[package]]
 name = "deepsearch-toolkit"
-version = "0.47.0"
+version = "0.48.0"
 description = "Interact with the Deep Search platform for new knowledge explorations and discoveries"
 optional = false
 python-versions = "<4.0,>=3.8"
 files = [
-    {file = "deepsearch_toolkit-0.47.0-py3-none-any.whl", hash = "sha256:da4ce926a248fc135f1a01399b132d17bfa0ced14a8d008df0eb4d896fc61935"},
-    {file = "deepsearch_toolkit-0.47.0.tar.gz", hash = "sha256:c87f1bea1b171ef77e685fe098d30479b72d365ccd2ccd84e7ef7858d4900f9c"},
+    {file = "deepsearch_toolkit-0.48.0-py3-none-any.whl", hash = "sha256:4f3140a36cdc8345e43545995480b7a6a6d32741ea38951177c71b3e25596b50"},
+    {file = "deepsearch_toolkit-0.48.0.tar.gz", hash = "sha256:c0dab8138e56ab6c22c41c08970eb518f62a3d0a73ac82fe81ace4c31a24d529"},
 ]
 
 [package.dependencies]
@@ -3618,7 +3618,6 @@ files = [
     {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"},
     {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"},
     {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"},
-    {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"},
     {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"},
     {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"},
     {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"},
@@ -5300,4 +5299,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "jaraco.test", "more
 [metadata]
 lock-version = "2.0"
 python-versions = ">= 3.8, <3.11"
-content-hash = "a2247ecd526e89ddb97d1e01052ccea7a72c6bf0cd425274a67f106aec6bf2fd"
+content-hash = "17c6665a4cf1daae54cc4f35544f0053991e39a82ead6ada944cb5f7889b82a5"
diff --git a/pyproject.toml b/pyproject.toml
index ddb0485..422447c 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -11,7 +11,7 @@ packages = [
 
 [tool.poetry.dependencies]
 python = ">= 3.8, <3.11"
-deepsearch-toolkit = "0.47.0"
+deepsearch-toolkit = "0.48.0"
 jupyter = "^1.0.0"
 ipywidgets = "^7"  # previous major release is needed bcause of mols2grid
 numpy = "^1.23.4"
diff --git a/requirements.txt b/requirements.txt
index 9c12249..3ff4690 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -35,7 +35,7 @@ cymem==2.0.8 ; python_version >= "3.8" and python_version < "3.11"
 debugpy==1.8.1 ; python_version >= "3.8" and python_version < "3.11"
 decorator==5.1.1 ; python_version >= "3.8" and python_version < "3.11"
 deepsearch-glm==0.16.2 ; python_version >= "3.8" and python_version < "3.11" and sys_platform != "win32"
-deepsearch-toolkit==0.47.0 ; python_version >= "3.8" and python_version < "3.11"
+deepsearch-toolkit==0.48.0 ; python_version >= "3.8" and python_version < "3.11"
 defusedxml==0.7.1 ; python_version >= "3.8" and python_version < "3.11"
 deprecated==1.2.14 ; python_version >= "3.8" and python_version < "3.11"
 et-xmlfile==1.1.0 ; python_version >= "3.8" and python_version < "3.11"