{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Load SQuAD data" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import os\n", "import numpy as np\n", "import pandas as pd\n", "from transformers.agents import agent_types\n", "from tqdm.notebook import tqdm\n", "import logging\n", "from semscore import EmbeddingModelWrapper\n", "from statistics import mean\n", "\n", "\n", "def display_text_df(df):\n", " display(df.style.set_properties(**{'white-space': 'pre-wrap'}).set_table_styles(\n", " [{'selector': 'th', 'props': [('text-align', 'left')]},\n", " {'selector': 'td', 'props': [('text-align', 'left')]}\n", " ]\n", " ).hide())\n" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Initializing Data...\n", "Download: False\n", "Loading data...\n", "Raw Data loaded\n", "Chroma DB already exists\n", "Loading index...\n", "Index loaded\n" ] } ], "source": [ "from data import get_data\n", "data = get_data(download=False)\n" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
Title | \n", "Context | \n", "Question | \n", "Answer | \n", "
---|---|---|---|
University_of_Notre_Dame | \n", "Architecturally, the school has a Catholic character. Atop the Main Building's gold dome is a golden statue of the Virgin Mary. Immediately in front of the Main Building and facing it, is a copper statue of Christ with arms upraised with the legend \"Venite Ad Me Omnes\". Next to the Main Building is the Basilica of the Sacred Heart. Immediately behind the basilica is the Grotto, a Marian place of prayer and reflection. It is a replica of the grotto at Lourdes, France where the Virgin Mary reputedly appeared to Saint Bernadette Soubirous in 1858. At the end of the main drive (and in a direct line that connects through 3 statues and the Gold Dome), is a simple, modern stone statue of Mary. | \n", "To whom did the Virgin Mary allegedly appear in 1858 in Lourdes France? | \n", "Saint Bernadette Soubirous | \n", "
University_of_Notre_Dame | \n", "Architecturally, the school has a Catholic character. Atop the Main Building's gold dome is a golden statue of the Virgin Mary. Immediately in front of the Main Building and facing it, is a copper statue of Christ with arms upraised with the legend \"Venite Ad Me Omnes\". Next to the Main Building is the Basilica of the Sacred Heart. Immediately behind the basilica is the Grotto, a Marian place of prayer and reflection. It is a replica of the grotto at Lourdes, France where the Virgin Mary reputedly appeared to Saint Bernadette Soubirous in 1858. At the end of the main drive (and in a direct line that connects through 3 statues and the Gold Dome), is a simple, modern stone statue of Mary. | \n", "What is in front of the Notre Dame Main Building? | \n", "a copper statue of Christ | \n", "
University_of_Notre_Dame | \n", "Architecturally, the school has a Catholic character. Atop the Main Building's gold dome is a golden statue of the Virgin Mary. Immediately in front of the Main Building and facing it, is a copper statue of Christ with arms upraised with the legend \"Venite Ad Me Omnes\". Next to the Main Building is the Basilica of the Sacred Heart. Immediately behind the basilica is the Grotto, a Marian place of prayer and reflection. It is a replica of the grotto at Lourdes, France where the Virgin Mary reputedly appeared to Saint Bernadette Soubirous in 1858. At the end of the main drive (and in a direct line that connects through 3 statues and the Gold Dome), is a simple, modern stone statue of Mary. | \n", "The Basilica of the Sacred heart at Notre Dame is beside to which structure? | \n", "the Main Building | \n", "
Title | \n", "Context | \n", "Question | \n", "Answer | \n", "
---|---|---|---|
Institute_of_technology | \n", "The world's first institution of technology or technical university with tertiary technical education is the Banská Akadémia in Banská Štiavnica, Slovakia, founded in 1735, Academy since December 13, 1762 established by queen Maria Theresa in order to train specialists of silver and gold mining and metallurgy in neighbourhood. Teaching started in 1764. Later the department of Mathematics, Mechanics and Hydraulics and department of Forestry were settled. University buildings are still at their place today and are used for teaching. University has launched the first book of electrotechnics in the world. | \n", "What year was the Banská Akadémia founded? | \n", "1735 | \n", "
Film_speed | \n", "The standard specifies how speed ratings should be reported by the camera. If the noise-based speed (40:1) is higher than the saturation-based speed, the noise-based speed should be reported, rounded downwards to a standard value (e.g. 200, 250, 320, or 400). The rationale is that exposure according to the lower saturation-based speed would not result in a visibly better image. In addition, an exposure latitude can be specified, ranging from the saturation-based speed to the 10:1 noise-based speed. If the noise-based speed (40:1) is lower than the saturation-based speed, or undefined because of high noise, the saturation-based speed is specified, rounded upwards to a standard value, because using the noise-based speed would lead to overexposed images. The camera may also report the SOS-based speed (explicitly as being an SOS speed), rounded to the nearest standard speed rating. | \n", "What is another speed that can also be reported by the camera? | \n", "SOS-based speed | \n", "
Sumer | \n", "The most impressive and famous of Sumerian buildings are the ziggurats, large layered platforms which supported temples. Sumerian cylinder seals also depict houses built from reeds not unlike those built by the Marsh Arabs of Southern Iraq until as recently as 400 CE. The Sumerians also developed the arch, which enabled them to develop a strong type of dome. They built this by constructing and linking several arches. Sumerian temples and palaces made use of more advanced materials and techniques,[citation needed] such as buttresses, recesses, half columns, and clay nails. | \n", "Where were the use of advanced materials and techniques on display in Sumer? | \n", "Sumerian temples and palaces | \n", "
Ann_Arbor,_Michigan | \n", "Ann Arbor has a council-manager form of government. The City Council has 11 voting members: the mayor and 10 city council members. The mayor and city council members serve two-year terms: the mayor is elected every even-numbered year, while half of the city council members are up for election annually (five in even-numbered and five in odd-numbered years). Two council members are elected from each of the city's five wards. The mayor is elected citywide. The mayor is the presiding officer of the City Council and has the power to appoint all Council committee members as well as board and commission members, with the approval of the City Council. The current mayor of Ann Arbor is Christopher Taylor, a Democrat who was elected as mayor in 2014. Day-to-day city operations are managed by a city administrator chosen by the city council. | \n", "Who is elected every even numbered year? | \n", "mayor | \n", "
John_von_Neumann | \n", "Shortly before his death, when he was already quite ill, von Neumann headed the United States government's top secret ICBM committee, and it would sometimes meet in his home. Its purpose was to decide on the feasibility of building an ICBM large enough to carry a thermonuclear weapon. Von Neumann had long argued that while the technical obstacles were sizable, they could be overcome in time. The SM-65 Atlas passed its first fully functional test in 1959, two years after his death. The feasibility of an ICBM owed as much to improved, smaller warheads as it did to developments in rocketry, and his understanding of the former made his advice invaluable. | \n", "What was the purpose of top secret ICBM committee? | \n", "decide on the feasibility of building an ICBM large enough to carry a thermonuclear weapon | \n", "
Pope_Paul_VI | \n", "Some critiqued Paul VI's decision; the newly created Synod of Bishops had an advisory role only and could not make decisions on their own, although the Council decided exactly that. During the pontificate of Paul VI, five such synods took place, and he is on record of implementing all their decisions. Related questions were raised about the new National Bishop Conferences, which became mandatory after Vatican II. Others questioned his Ostpolitik and contacts with Communism and the deals he engaged in for the faithful. | \n", "What conferences became a requirement after Vatican II? | \n", "National Bishop Conferences | \n", "
Spectre_(2015_film) | \n", "Bond and Swann return to London where they meet M, Bill Tanner, Q, and Moneypenny; they intend to arrest C and stop Nine Eyes from going online. Swann leaves Bond, telling him she cannot be part of a life involving espionage, and is subsequently kidnapped. On the way, the group is ambushed and Bond is kidnapped, but the rest still proceed with the plan. After Q succeeds in preventing the Nine Eyes from going online, a brief struggle between M and C ends with the latter falling to his death. Meanwhile, Bond is taken to the old MI6 building, which is scheduled for demolition, and frees himself. Moving throughout the ruined labyrinth, he encounters a disfigured Blofeld, who tells him that he has three minutes to escape the building before explosives are detonated or die trying to save Swann. Bond finds Swann and the two escape by boat as the building collapses. Bond shoots down Blofeld's helicopter, which crashes onto Westminster Bridge. As Blofeld crawls away from the wreckage, Bond confronts him but ultimately leaves him to be arrested by M. Bond leaves the bridge with Swann. | \n", "Who does M fight with? | \n", "C | \n", "
Antarctica | \n", "About 1150 species of fungi have been recorded from Antarctica, of which about 750 are non-lichen-forming and 400 are lichen-forming. Some of these species are cryptoendoliths as a result of evolution under extreme conditions, and have significantly contributed to shaping the impressive rock formations of the McMurdo Dry Valleys and surrounding mountain ridges. The apparently simple morphology, scarcely differentiated structures, metabolic systems and enzymes still active at very low temperatures, and reduced life cycles shown by such fungi make them particularly suited to harsh environments such as the McMurdo Dry Valleys. In particular, their thick-walled and strongly melanized cells make them resistant to UV light. Those features can also be observed in algae and cyanobacteria, suggesting that these are adaptations to the conditions prevailing in Antarctica. This has led to speculation that, if life ever occurred on Mars, it might have looked similar to Antarctic fungi such as Cryomyces minteri. Some of these fungi are also apparently endemic to Antarctica. Endemic Antarctic fungi also include certain dung-inhabiting species which have had to evolve in response to the double challenge of extreme cold while growing on dung, and the need to survive passage through the gut of warm-blooded animals. | \n", "How many species of fungi have been found on Antarctica? | \n", "1150 | \n", "
North_Carolina | \n", "In the Battle of Cowan's Ford, Cornwallis met resistance along the banks of the Catawba River at Cowan's Ford on February 1, 1781, in an attempt to engage General Morgan's forces during a tactical withdrawal. Morgan had moved to the northern part of the state to combine with General Greene's newly recruited forces. Generals Greene and Cornwallis finally met at the Battle of Guilford Courthouse in present-day Greensboro on March 15, 1781. Although the British troops held the field at the end of the battle, their casualties at the hands of the numerically superior Continental Army were crippling. Following this \"Pyrrhic victory\", Cornwallis chose to move to the Virginia coastline to get reinforcements, and to allow the Royal Navy to protect his battered army. This decision would result in Cornwallis' eventual defeat at Yorktown, Virginia, later in 1781. The Patriots' victory there guaranteed American independence. | \n", "After losing the battle of Guilford Courthouse, Cornawallis moved his troops where? | \n", "Virginia coastline | \n", "
2008_Summer_Olympics_torch_relay | \n", "The Olympic Torch is based on traditional scrolls and uses a traditional Chinese design known as \"Lucky Cloud\". It is made from aluminum. It is 72 centimetres high and weighs 985 grams. The torch is designed to remain lit in 65 kilometre per hour (37 mile per hour) winds, and in rain of up to 50 millimetres (2 inches) per hour. An ignition key is used to ignite and extinguish the flame. The torch is fueled by cans of propane. Each can will light the torch for 15 minutes. It is designed by a team from Lenovo Group. The Torch is designed in reference to the traditional Chinese concept of the 5 elements that make up the entire universe. | \n", "What is the Olympic Torch made from? | \n", "aluminum. | \n", "
Title | \n", "Context | \n", "Question | \n", "Answer | \n", "Predicted Answer | \n", "Similarity | \n", "
---|---|---|---|---|---|
Institute_of_technology | \n", "The world's first institution of technology or technical university with tertiary technical education is the Banská Akadémia in Banská Štiavnica, Slovakia, founded in 1735, Academy since December 13, 1762 established by queen Maria Theresa in order to train specialists of silver and gold mining and metallurgy in neighbourhood. Teaching started in 1764. Later the department of Mathematics, Mechanics and Hydraulics and department of Forestry were settled. University buildings are still at their place today and are used for teaching. University has launched the first book of electrotechnics in the world. | \n", "What year was the Banská Akadémia founded? | \n", "1735 | \n", "1735 | \n", "1.000000 | \n", "
Film_speed | \n", "The standard specifies how speed ratings should be reported by the camera. If the noise-based speed (40:1) is higher than the saturation-based speed, the noise-based speed should be reported, rounded downwards to a standard value (e.g. 200, 250, 320, or 400). The rationale is that exposure according to the lower saturation-based speed would not result in a visibly better image. In addition, an exposure latitude can be specified, ranging from the saturation-based speed to the 10:1 noise-based speed. If the noise-based speed (40:1) is lower than the saturation-based speed, or undefined because of high noise, the saturation-based speed is specified, rounded upwards to a standard value, because using the noise-based speed would lead to overexposed images. The camera may also report the SOS-based speed (explicitly as being an SOS speed), rounded to the nearest standard speed rating. | \n", "What is another speed that can also be reported by the camera? | \n", "SOS-based speed | \n", "saturation-based speed | \n", "0.555529 | \n", "
Sumer | \n", "The most impressive and famous of Sumerian buildings are the ziggurats, large layered platforms which supported temples. Sumerian cylinder seals also depict houses built from reeds not unlike those built by the Marsh Arabs of Southern Iraq until as recently as 400 CE. The Sumerians also developed the arch, which enabled them to develop a strong type of dome. They built this by constructing and linking several arches. Sumerian temples and palaces made use of more advanced materials and techniques,[citation needed] such as buttresses, recesses, half columns, and clay nails. | \n", "Where were the use of advanced materials and techniques on display in Sumer? | \n", "Sumerian temples and palaces | \n", "temples and palaces | \n", "0.726322 | \n", "
Ann_Arbor,_Michigan | \n", "Ann Arbor has a council-manager form of government. The City Council has 11 voting members: the mayor and 10 city council members. The mayor and city council members serve two-year terms: the mayor is elected every even-numbered year, while half of the city council members are up for election annually (five in even-numbered and five in odd-numbered years). Two council members are elected from each of the city's five wards. The mayor is elected citywide. The mayor is the presiding officer of the City Council and has the power to appoint all Council committee members as well as board and commission members, with the approval of the City Council. The current mayor of Ann Arbor is Christopher Taylor, a Democrat who was elected as mayor in 2014. Day-to-day city operations are managed by a city administrator chosen by the city council. | \n", "Who is elected every even numbered year? | \n", "mayor | \n", "The mayor is elected every even-numbered year. | \n", "0.493396 | \n", "
John_von_Neumann | \n", "Shortly before his death, when he was already quite ill, von Neumann headed the United States government's top secret ICBM committee, and it would sometimes meet in his home. Its purpose was to decide on the feasibility of building an ICBM large enough to carry a thermonuclear weapon. Von Neumann had long argued that while the technical obstacles were sizable, they could be overcome in time. The SM-65 Atlas passed its first fully functional test in 1959, two years after his death. The feasibility of an ICBM owed as much to improved, smaller warheads as it did to developments in rocketry, and his understanding of the former made his advice invaluable. | \n", "What was the purpose of top secret ICBM committee? | \n", "decide on the feasibility of building an ICBM large enough to carry a thermonuclear weapon | \n", "decide on the feasibility of building an ICBM large enough to carry a thermonuclear weapon | \n", "1.000000 | \n", "
Pope_Paul_VI | \n", "Some critiqued Paul VI's decision; the newly created Synod of Bishops had an advisory role only and could not make decisions on their own, although the Council decided exactly that. During the pontificate of Paul VI, five such synods took place, and he is on record of implementing all their decisions. Related questions were raised about the new National Bishop Conferences, which became mandatory after Vatican II. Others questioned his Ostpolitik and contacts with Communism and the deals he engaged in for the faithful. | \n", "What conferences became a requirement after Vatican II? | \n", "National Bishop Conferences | \n", "The National Bishop Conferences became mandatory after Vatican II. | \n", "0.442729 | \n", "
Spectre_(2015_film) | \n", "Bond and Swann return to London where they meet M, Bill Tanner, Q, and Moneypenny; they intend to arrest C and stop Nine Eyes from going online. Swann leaves Bond, telling him she cannot be part of a life involving espionage, and is subsequently kidnapped. On the way, the group is ambushed and Bond is kidnapped, but the rest still proceed with the plan. After Q succeeds in preventing the Nine Eyes from going online, a brief struggle between M and C ends with the latter falling to his death. Meanwhile, Bond is taken to the old MI6 building, which is scheduled for demolition, and frees himself. Moving throughout the ruined labyrinth, he encounters a disfigured Blofeld, who tells him that he has three minutes to escape the building before explosives are detonated or die trying to save Swann. Bond finds Swann and the two escape by boat as the building collapses. Bond shoots down Blofeld's helicopter, which crashes onto Westminster Bridge. As Blofeld crawls away from the wreckage, Bond confronts him but ultimately leaves him to be arrested by M. Bond leaves the bridge with Swann. | \n", "Who does M fight with? | \n", "C | \n", "C | \n", "1.000000 | \n", "
Antarctica | \n", "About 1150 species of fungi have been recorded from Antarctica, of which about 750 are non-lichen-forming and 400 are lichen-forming. Some of these species are cryptoendoliths as a result of evolution under extreme conditions, and have significantly contributed to shaping the impressive rock formations of the McMurdo Dry Valleys and surrounding mountain ridges. The apparently simple morphology, scarcely differentiated structures, metabolic systems and enzymes still active at very low temperatures, and reduced life cycles shown by such fungi make them particularly suited to harsh environments such as the McMurdo Dry Valleys. In particular, their thick-walled and strongly melanized cells make them resistant to UV light. Those features can also be observed in algae and cyanobacteria, suggesting that these are adaptations to the conditions prevailing in Antarctica. This has led to speculation that, if life ever occurred on Mars, it might have looked similar to Antarctic fungi such as Cryomyces minteri. Some of these fungi are also apparently endemic to Antarctica. Endemic Antarctic fungi also include certain dung-inhabiting species which have had to evolve in response to the double challenge of extreme cold while growing on dung, and the need to survive passage through the gut of warm-blooded animals. | \n", "How many species of fungi have been found on Antarctica? | \n", "1150 | \n", "1150 | \n", "1.000000 | \n", "
North_Carolina | \n", "In the Battle of Cowan's Ford, Cornwallis met resistance along the banks of the Catawba River at Cowan's Ford on February 1, 1781, in an attempt to engage General Morgan's forces during a tactical withdrawal. Morgan had moved to the northern part of the state to combine with General Greene's newly recruited forces. Generals Greene and Cornwallis finally met at the Battle of Guilford Courthouse in present-day Greensboro on March 15, 1781. Although the British troops held the field at the end of the battle, their casualties at the hands of the numerically superior Continental Army were crippling. Following this \"Pyrrhic victory\", Cornwallis chose to move to the Virginia coastline to get reinforcements, and to allow the Royal Navy to protect his battered army. This decision would result in Cornwallis' eventual defeat at Yorktown, Virginia, later in 1781. The Patriots' victory there guaranteed American independence. | \n", "After losing the battle of Guilford Courthouse, Cornawallis moved his troops where? | \n", "Virginia coastline | \n", "the Virginia coastline | \n", "0.948570 | \n", "
2008_Summer_Olympics_torch_relay | \n", "The Olympic Torch is based on traditional scrolls and uses a traditional Chinese design known as \"Lucky Cloud\". It is made from aluminum. It is 72 centimetres high and weighs 985 grams. The torch is designed to remain lit in 65 kilometre per hour (37 mile per hour) winds, and in rain of up to 50 millimetres (2 inches) per hour. An ignition key is used to ignite and extinguish the flame. The torch is fueled by cans of propane. Each can will light the torch for 15 minutes. It is designed by a team from Lenovo Group. The Torch is designed in reference to the traditional Chinese concept of the 5 elements that make up the entire universe. | \n", "What is the Olympic Torch made from? | \n", "aluminum. | \n", "aluminum | \n", "0.973508 | \n", "