diff --git a/branchREADME.md b/branchREADME.md new file mode 100644 index 00000000000..f3678097a4c --- /dev/null +++ b/branchREADME.md @@ -0,0 +1 @@ +# TensorFlow BERT QA Android\nForked from tensorflow/examples, built with Gradle 8.7, AGP 8.5.0, Kotlin 1.9.20, and compileSdk 35. Tested on SDK36 Beta Pixel9XL virtual \nManaged by Chris-Hamid. diff --git a/lite/examples/bert_qa/android/CONTRIBUTING.md b/lite/examples/bert_qa/android/CONTRIBUTING.md new file mode 100644 index 00000000000..57c83e6474b --- /dev/null +++ b/lite/examples/bert_qa/android/CONTRIBUTING.md @@ -0,0 +1,26 @@ +Overview: +This project is a fork of the TensorFlow BERT QA Android app from tensorflow/examples, updated to support modern Android development practices. It uses BERT (Bidirectional Encoder Representations from Transformers) for question-answering tasks on mobile devices. + +Build Details: +Gradle: 8.7 +Android Gradle Plugin (AGP): 8.5.0 +Kotlin: 1.9.20 +Compile SDK: 35 +Tested on: API 36 Beta (Pixel 9 XL virtual emulator) + +How to Build and Run : +Clone the repository: ```bash git clone https://github.com/Chris-Hamid/tensorflow-examples.git ``` +Open the project in Android Studio (version 2024.1.1 or later recommended). +Ensure the BERT model files are in `lite/examples/bert_qa/android/app/src/main/assets/`: +Download `mobilebert_float.tflite` from https://storage.googleapis.com/download.tensorflow.org/models/tflite/bert_qa/mobilebert_float.tflite +Download `vocab.txt` from https://storage.googleapis.com/download.tensorflow.org/models/tflite/bert_qa/vocab.txt +Sync the project with Gradle (`File > Sync Project with Gradle Files`). +Build and run on an emulator or device with API 26+. +or Build APK & install on device with API 26+ + +Contributions: +This project is maintained by Chris-Hamid. Contributions are welcome! Please see the TensorFlow contribution guidelines for more details. + +License : +This project is licensed under the Apache License 2.0, as per the original TensorFlow repository. See LICENSE for details. +" > lite/examples/bert_qa/android/README.md diff --git a/lite/examples/bert_qa/android/app/build.gradle b/lite/examples/bert_qa/android/app/build.gradle index a6d1ae313a1..8af2ff28c8e 100644 --- a/lite/examples/bert_qa/android/app/build.gradle +++ b/lite/examples/bert_qa/android/app/build.gradle @@ -7,18 +7,16 @@ plugins { } android { - compileSdk 32 - + namespace 'org.tensorflow.lite.examples.bertqa' + compileSdk 35 defaultConfig { applicationId "org.tensorflow.lite.examples.bertqa" minSdk 23 - targetSdk 32 + targetSdk 35 versionCode 1 versionName "1.0" - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } - buildTypes { release { minifyEnabled false @@ -26,11 +24,11 @@ android { } } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_11 + targetCompatibility JavaVersion.VERSION_11 } kotlinOptions { - jvmTarget = '1.8' + jvmTarget = '11' } buildFeatures { viewBinding true @@ -40,58 +38,30 @@ android { } } -// import DownloadModels task project.ext.ASSET_DIR = projectDir.toString() + '/src/main/assets' project.ext.TEST_ASSETS_DIR = projectDir.toString() + '/src/androidTest/assets' - -// Download default models; if you wish to use your own models then -// place them in the "assets" directory and comment out this line. apply from: 'download_models.gradle' dependencies { - // Kotlin lang implementation 'androidx.core:core-ktx:1.15.0' - - // App compat and UI things - implementation 'androidx.appcompat:appcompat:1.4.2' - implementation 'com.google.android.material:material:1.6.1' + implementation 'androidx.appcompat:appcompat:1.7.0' + implementation 'com.google.android.material:material:1.12.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' - - // Navigation library - def nav_version = "2.5.0" + def nav_version = "2.7.7" implementation "androidx.navigation:navigation-fragment-ktx:$nav_version" implementation "androidx.navigation:navigation-ui-ktx:$nav_version" - - // CameraX core library def camerax_version = '1.2.0-alpha03' implementation "androidx.camera:camera-core:$camerax_version" - - // CameraX Camera2 extensions implementation "androidx.camera:camera-camera2:$camerax_version" - - // CameraX Lifecycle library implementation "androidx.camera:camera-lifecycle:$camerax_version" - - // CameraX View class implementation "androidx.camera:camera-view:$camerax_version" - - //WindowManager implementation 'androidx.window:window:1.1.0-alpha02' - - // Unit testing testImplementation 'junit:junit:4.13.2' - - // Instrumented testing androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' - - // Gson library - implementation 'com.google.code.gson:gson:2.9.0' + implementation 'com.google.code.gson:gson:2.10.1' implementation 'com.google.guava:guava:28.1-android' - - // Import tensorflow library implementation 'org.tensorflow:tensorflow-lite-task-text:0.3.0' - // Import the GPU delegate plugin Library for GPU inference implementation 'org.tensorflow:tensorflow-lite-gpu-delegate-plugin:0.4.0' implementation 'org.tensorflow:tensorflow-lite-gpu:2.9.0' -} +} \ No newline at end of file diff --git a/lite/examples/bert_qa/android/app/src/main/assets/qa.json b/lite/examples/bert_qa/android/app/src/main/assets/qa.json new file mode 100644 index 00000000000..94b7c9c4b50 --- /dev/null +++ b/lite/examples/bert_qa/android/app/src/main/assets/qa.json @@ -0,0 +1 @@ +{"titles": [["Super_Bowl_50"], ["Warsaw"], ["Normans"], ["Nikola_Tesla"], ["Computational_complexity_theory"], ["Teacher"], ["Martin_Luther"], ["Southern_California"], ["Sky_(United_Kingdom)"], ["Victoria_(Australia)"], ["Huguenot"], ["Steam_engine"], ["Oxygen"], ["1973_oil_crisis"], ["Apollo_program"], ["European_Union_law"], ["Amazon_rainforest"], ["Ctenophora"], ["Fresno,_California"], ["Packet_switching"], ["Black_Death"], ["Geology"], ["Newcastle_upon_Tyne"], ["Victoria_and_Albert_Museum"], ["American_Broadcasting_Company"], ["Genghis_Khan"], ["Pharmacy"], ["Immune_system"], ["Civil_disobedience"], ["Construction"], ["Private_school"], ["Harvard_University"], ["Jacksonville,_Florida"], ["Economic_inequality"], ["Doctor_Who"], ["University_of_Chicago"], ["Yuan_dynasty"], ["Kenya"], ["Intergovernmental_Panel_on_Climate_Change"], ["Chloroplast"], ["Prime_number"], ["Rhine"], ["Scottish_Parliament"], ["Islamism"], ["Imperialism"], ["United_Methodist_Church"], ["French_and_Indian_War"], ["Force"]], "contents": [["Super Bowl 50 was an American football game to determine the champion of the National Football League (NFL) for the 2015 season. The American Football Conference (AFC) champion Denver Broncos defeated the National Football Conference (NFC) champion Carolina Panthers 24\u201310 to earn their third Super Bowl title. The game was played on February 7, 2016, at Levi's Stadium in the San Francisco Bay Area at Santa Clara, California. As this was the 50th Super Bowl, the league emphasized the \"golden anniversary\" with various gold-themed initiatives, as well as temporarily suspending the tradition of naming each Super Bowl game with Roman numerals (under which the game would have been known as \"Super Bowl L\"), so that the logo could prominently feature the Arabic numerals 50."], ["One of the most famous people born in Warsaw was Maria Sk\u0142odowska-Curie, who achieved international recognition for her research on radioactivity and was the first female recipient of the Nobel Prize. Famous musicians include W\u0142adys\u0142aw Szpilman and Fr\u00e9d\u00e9ric Chopin. Though Chopin was born in the village of \u017belazowa Wola, about 60 km (37 mi) from Warsaw, he moved to the city with his family when he was seven months old. Casimir Pulaski, a Polish general and hero of the American Revolutionary War, was born here in 1745."], ["The Normans (Norman: Nourmands; French: Normands; Latin: Normanni) were the people who in the 10th and 11th centuries gave their name to Normandy, a region in France. They were descended from Norse (\"Norman\" comes from \"Norseman\") raiders and pirates from Denmark, Iceland and Norway who, under their leader Rollo, agreed to swear fealty to King Charles III of West Francia. Through generations of assimilation and mixing with the native Frankish and Roman-Gaulish populations, their descendants would gradually merge with the Carolingian-based cultures of West Francia. The distinct cultural and ethnic identity of the Normans emerged initially in the first half of the 10th century, and it continued to evolve over the succeeding centuries."], ["Nikola Tesla (Serbian Cyrillic: \u041d\u0438\u043a\u043e\u043b\u0430 \u0422\u0435\u0441\u043b\u0430; 10 July 1856 \u2013 7 January 1943) was a Serbian American inventor, electrical engineer, mechanical engineer, physicist, and futurist best known for his contributions to the design of the modern alternating current (AC) electricity supply system."], ["Computational complexity theory is a branch of the theory of computation in theoretical computer science that focuses on classifying computational problems according to their inherent difficulty, and relating those classes to each other. A computational problem is understood to be a task that is in principle amenable to being solved by a computer, which is equivalent to stating that the problem may be solved by mechanical application of mathematical steps, such as an algorithm."], ["The role of teacher is often formal and ongoing, carried out at a school or other place of formal education. In many countries, a person who wishes to become a teacher must first obtain specified professional qualifications or credentials from a university or college. These professional qualifications may include the study of pedagogy, the science of teaching. Teachers, like other professionals, may have to continue their education after they qualify, a process known as continuing professional development. Teachers may use a lesson plan to facilitate student learning, providing a course of study which is called the curriculum."], ["Martin Luther (/\u02c8lu\u02d0\u03b8\u0259r/ or /\u02c8lu\u02d0\u00f0\u0259r/; German: [\u02c8ma\u0250\u032fti\u02d0n \u02c8l\u028at\u0250] ( listen); 10 November 1483 \u2013 18 February 1546) was a German professor of theology, composer, priest, former monk and a seminal figure in the Protestant Reformation. Luther came to reject several teachings and practices of the Late Medieval Catholic Church. He strongly disputed the claim that freedom from God's punishment for sin could be purchased with money. He proposed an academic discussion of the power and usefulness of indulgences in his Ninety-Five Theses of 1517. His refusal to retract all of his writings at the demand of Pope Leo X in 1520 and the Holy Roman Emperor Charles V at the Diet of Worms in 1521 resulted in his excommunication by the Pope and condemnation as an outlaw by the Emperor."], ["Southern California, often abbreviated SoCal, is a geographic and cultural region that generally comprises California's southernmost 10 counties. The region is traditionally described as \"eight counties\", based on demographics and economic ties: Imperial, Los Angeles, Orange, Riverside, San Bernardino, San Diego, Santa Barbara, and Ventura. The more extensive 10-county definition, including Kern and San Luis Obispo counties, is also used based on historical political divisions. Southern California is a major economic center for the state of California and the United States."], ["Formed in November 1990 by the equal merger of Sky Television and British Satellite Broadcasting, BSkyB became the UK's largest digital subscription television company. Following BSkyB's 2014 acquisition of Sky Italia and a majority 90.04% interest in Sky Deutschland in November 2014, its holding company British Sky Broadcasting Group plc changed its name to Sky plc. The United Kingdom operations also changed the company name from British Sky Broadcasting Limited to Sky UK Limited, still trading as Sky."], ["The economy of Victoria is highly diversified: service sectors including financial and property services, health, education, wholesale, retail, hospitality and manufacturing constitute the majority of employment. Victoria's total gross state product (GSP) is ranked second in Australia, although Victoria is ranked fourth in terms of GSP per capita because of its limited mining activity. Culturally, Melbourne is home to a number of museums, art galleries and theatres and is also described as the \"sporting capital of Australia\". The Melbourne Cricket Ground is the largest stadium in Australia, and the host of the 1956 Summer Olympics and the 2006 Commonwealth Games. The ground is also considered the \"spiritual home\" of Australian cricket and Australian rules football, and hosts the grand final of the Australian Football League (AFL) each year, usually drawing crowds of over 95,000 people. Victoria includes eight public universities, with the oldest, the University of Melbourne, having been founded in 1853."], ["Huguenot numbers peaked near an estimated two million by 1562, concentrated mainly in the southern and central parts of France, about one-eighth the number of French Catholics. As Huguenots gained influence and more openly displayed their faith, Catholic hostility grew, in spite of increasingly liberal political concessions and edicts of toleration from the French crown. A series of religious conflicts followed, known as the Wars of Religion, fought intermittently from 1562 to 1598. The wars finally ended with the granting of the Edict of Nantes, which granted the Huguenots substantial religious, political and military autonomy."], ["Steam engines are external combustion engines, where the working fluid is separate from the combustion products. Non-combustion heat sources such as solar power, nuclear power or geothermal energy may be used. The ideal thermodynamic cycle used to analyze this process is called the Rankine cycle. In the cycle, water is heated and transforms into steam within a boiler operating at a high pressure. When expanded through pistons or turbines, mechanical work is done. The reduced-pressure steam is then condensed and pumped back into the boiler."], ["Oxygen is a chemical element with symbol O and atomic number 8. It is a member of the chalcogen group on the periodic table and is a highly reactive nonmetal and oxidizing agent that readily forms compounds (notably oxides) with most elements. By mass, oxygen is the third-most abundant element in the universe, after hydrogen and helium. At standard temperature and pressure, two atoms of the element bind to form dioxygen, a colorless and odorless diatomic gas with the formula O\n2. Diatomic oxygen gas constitutes 20.8% of the Earth's atmosphere. However, monitoring of atmospheric oxygen levels show a global downward trend, because of fossil-fuel burning. Oxygen is the most abundant element by mass in the Earth's crust as part of oxide compounds such as silicon dioxide, making up almost half of the crust's mass."], ["The 1973 oil crisis began in October 1973 when the members of the Organization of Arab Petroleum Exporting Countries (OAPEC, consisting of the Arab members of OPEC plus Egypt and Syria) proclaimed an oil embargo. By the end of the embargo in March 1974, the price of oil had risen from US$3 per barrel to nearly $12 globally; US prices were significantly higher. The embargo caused an oil crisis, or \"shock\", with many short- and long-term effects on global politics and the global economy. It was later called the \"first oil shock\", followed by the 1979 oil crisis, termed the \"second oil shock.\""], ["The Apollo program, also known as Project Apollo, was the third United States human spaceflight program carried out by the National Aeronautics and Space Administration (NASA), which accomplished landing the first humans on the Moon from 1969 to 1972. First conceived during Dwight D. Eisenhower's administration as a three-man spacecraft to follow the one-man Project Mercury which put the first Americans in space, Apollo was later dedicated to President John F. Kennedy's national goal of \"landing a man on the Moon and returning him safely to the Earth\" by the end of the 1960s, which he proposed in a May 25, 1961, address to Congress. Project Mercury was followed by the two-man Project Gemini (1962\u201366). The first manned flight of Apollo was in 1968."], ["European Union law is a body of treaties and legislation, such as Regulations and Directives, which have direct effect or indirect effect on the laws of European Union member states. The three sources of European Union law are primary law, secondary law and supplementary law. The main sources of primary law are the Treaties establishing the European Union. Secondary sources include regulations and directives which are based on the Treaties. The legislature of the European Union is principally composed of the European Parliament and the Council of the European Union, which under the Treaties may establish secondary law to pursue the objective set out in the Treaties."], ["The Amazon rainforest (Portuguese: Floresta Amaz\u00f4nica or Amaz\u00f4nia; Spanish: Selva Amaz\u00f3nica, Amazon\u00eda or usually Amazonia; French: For\u00eat amazonienne; Dutch: Amazoneregenwoud), also known in English as Amazonia or the Amazon Jungle, is a moist broadleaf forest that covers most of the Amazon basin of South America. This basin encompasses 7,000,000 square kilometres (2,700,000 sq mi), of which 5,500,000 square kilometres (2,100,000 sq mi) are covered by the rainforest. This region includes territory belonging to nine nations. The majority of the forest is contained within Brazil, with 60% of the rainforest, followed by Peru with 13%, Colombia with 10%, and with minor amounts in Venezuela, Ecuador, Bolivia, Guyana, Suriname and French Guiana. States or departments in four nations contain \"Amazonas\" in their names. The Amazon represents over half of the planet's remaining rainforests, and comprises the largest and most biodiverse tract of tropical rainforest in the world, with an estimated 390 billion individual trees divided into 16,000 species."], ["Ctenophora (/t\u1d7b\u02c8n\u0252f\u0259r\u0259/; singular ctenophore, /\u02c8t\u025bn\u0259f\u0254\u02d0r/ or /\u02c8ti\u02d0n\u0259f\u0254\u02d0r/; from the Greek \u03ba\u03c4\u03b5\u03af\u03c2 kteis 'comb' and \u03c6\u03ad\u03c1\u03c9 pher\u014d 'carry'; commonly known as comb jellies) is a phylum of animals that live in marine waters worldwide. Their most distinctive feature is the \u2018combs\u2019 \u2013 groups of cilia which they use for swimming \u2013 they are the largest animals that swim by means of cilia. Adults of various species range from a few millimeters to 1.5 m (4 ft 11 in) in size. Like cnidarians, their bodies consist of a mass of jelly, with one layer of cells on the outside and another lining the internal cavity. In ctenophores, these layers are two cells deep, while those in cnidarians are only one cell deep. Some authors combined ctenophores and cnidarians in one phylum, Coelenterata, as both groups rely on water flow through the body cavity for both digestion and respiration. Increasing awareness of the differences persuaded more recent authors to classify them as separate phyla."], ["Fresno (/\u02c8fr\u025bzno\u028a/ FREZ-noh), the county seat of Fresno County, is a city in the U.S. state of California. As of 2015, the city's population was 520,159, making it the fifth-largest city in California, the largest inland city in California and the 34th-largest in the nation. Fresno is in the center of the San Joaquin Valley and is the largest city in the Central Valley, which contains the San Joaquin Valley. It is approximately 220 miles (350 km) northwest of Los Angeles, 170 miles (270 km) south of the state capital, Sacramento, or 185 miles (300 km) south of San Francisco. The name Fresno means \"ash tree\" in Spanish, and an ash leaf is featured on the city's flag."], ["Starting in the late 1950s, American computer scientist Paul Baran developed the concept Distributed Adaptive Message Block Switching with the goal to provide a fault-tolerant, efficient routing method for telecommunication messages as part of a research program at the RAND Corporation, funded by the US Department of Defense. This concept contrasted and contradicted the theretofore established principles of pre-allocation of network bandwidth, largely fortified by the development of telecommunications in the Bell System. The new concept found little resonance among network implementers until the independent work of Donald Davies at the National Physical Laboratory (United Kingdom) (NPL) in the late 1960s. Davies is credited with coining the modern name packet switching and inspiring numerous packet switching networks in Europe in the decade following, including the incorporation of the concept in the early ARPANET in the United States."], ["The Black Death is thought to have originated in the arid plains of Central Asia, where it then travelled along the Silk Road, reaching Crimea by 1343. From there, it was most likely carried by Oriental rat fleas living on the black rats that were regular passengers on merchant ships. Spreading throughout the Mediterranean and Europe, the Black Death is estimated to have killed 30\u201360% of Europe's total population. In total, the plague reduced the world population from an estimated 450 million down to 350\u2013375 million in the 14th century. The world population as a whole did not recover to pre-plague levels until the 17th century. The plague recurred occasionally in Europe until the 19th century."], ["There are three major types of rock: igneous, sedimentary, and metamorphic. The rock cycle is an important concept in geology which illustrates the relationships between these three types of rock, and magma. When a rock crystallizes from melt (magma and/or lava), it is an igneous rock. This rock can be weathered and eroded, and then redeposited and lithified into a sedimentary rock, or be turned into a metamorphic rock due to heat and pressure that change the mineral content of the rock which gives it a characteristic fabric. The sedimentary rock can then be subsequently turned into a metamorphic rock due to heat and pressure and is then weathered, eroded, deposited, and lithified, ultimately becoming a sedimentary rock. Sedimentary rock may also be re-eroded and redeposited, and metamorphic rock may also undergo additional metamorphism. All three types of rocks may be re-melted; when this happens, a new magma is formed, from which an igneous rock may once again crystallize."], ["Newcastle upon Tyne (RP: i/\u02ccnju\u02d0k\u0251\u02d0s\u0259l \u0259\u02ccp\u0252n \u02c8ta\u026an/; Locally: i/nju\u02d0\u02cck\u00e6s\u0259l \u0259\u02ccp\u0259n \u02c8ta\u026an/), commonly known as Newcastle, is a city in Tyne and Wear, North East England, 103 miles (166 km) south of Edinburgh and 277 miles (446 km) north of London on the northern bank of the River Tyne, 8.5 mi (13.7 km) from the North Sea. Newcastle is the most populous city in the North East and Tyneside the eighth most populous conurbation in the United Kingdom. Newcastle is a member of the English Core Cities Group and is a member of the Eurocities network of European cities. Newcastle was part of the county of Northumberland until 1400, when it became a county itself, a status it retained until becoming part of Tyne and Wear in 1974.[not in citation given] The regional nickname and dialect for people from Newcastle and the surrounding area is Geordie."], ["The Victoria and Albert Museum (often abbreviated as the V&A), London, is the world's largest museum of decorative arts and design, housing a permanent collection of over 4.5 million objects. It was founded in 1852 and named after Queen Victoria and Prince Albert. The V&A is located in the Brompton district of the Royal Borough of Kensington and Chelsea, in an area that has become known as \"Albertopolis\" because of its association with Prince Albert, the Albert Memorial and the major cultural institutions with which he was associated. These include the Natural History Museum, the Science Museum and the Royal Albert Hall. The museum is a non-departmental public body sponsored by the Department for Culture, Media and Sport. Like other national British museums, entrance to the museum has been free since 2001."], ["The American Broadcasting Company (ABC) (stylized in its logo as abc since 1957) is an American commercial broadcast television network that is owned by the Disney\u2013ABC Television Group, a subsidiary of Disney Media Networks division of The Walt Disney Company. The network is part of the Big Three television networks. The network is headquartered on Columbus Avenue and West 66th Street in Manhattan, with additional major offices and production facilities in New York City, Los Angeles and Burbank, California."], ["He came to power by uniting many of the nomadic tribes of Northeast Asia. After founding the Mongol Empire and being proclaimed \"Genghis Khan\", he started the Mongol invasions that resulted in the conquest of most of Eurasia. These included raids or invasions of the Qara Khitai, Caucasus, Khwarezmid Empire, Western Xia and Jin dynasties. These campaigns were often accompanied by wholesale massacres of the civilian populations \u2013 especially in the Khwarezmian and Xia controlled lands. By the end of his life, the Mongol Empire occupied a substantial portion of Central Asia and China."], ["The word pharmacy is derived from its root word pharma which was a term used since the 15th\u201317th centuries. However, the original Greek roots from pharmakos imply sorcery or even poison. In addition to pharma responsibilities, the pharma offered general medical advice and a range of services that are now performed solely by other specialist practitioners, such as surgery and midwifery. The pharma (as it was referred to) often operated through a retail shop which, in addition to ingredients for medicines, sold tobacco and patent medicines. Often the place that did this was called an apothecary and several languages have this as the dominant term, though their practices are more akin to a modern pharmacy, in English the term apothecary would today be seen as outdated or only approproriate if herbal remedies were on offer to a large extent. The pharmas also used many other herbs not listed. The Greek word Pharmakeia (Greek: \u03c6\u03b1\u03c1\u03bc\u03b1\u03ba\u03b5\u03af\u03b1) derives from pharmakon (\u03c6\u03ac\u03c1\u03bc\u03b1\u03ba\u03bf\u03bd), meaning \"drug\", \"medicine\" (or \"poison\").[n 1]"], ["The immune system is a system of many biological structures and processes within an organism that protects against disease. To function properly, an immune system must detect a wide variety of agents, known as pathogens, from viruses to parasitic worms, and distinguish them from the organism's own healthy tissue. In many species, the immune system can be classified into subsystems, such as the innate immune system versus the adaptive immune system, or humoral immunity versus cell-mediated immunity. In humans, the blood\u2013brain barrier, blood\u2013cerebrospinal fluid barrier, and similar fluid\u2013brain barriers separate the peripheral immune system from the neuroimmune system which protects the brain."], ["One of its earliest massive implementations was brought about by Egyptians against the British occupation in the 1919 Revolution. Civil disobedience is one of the many ways people have rebelled against what they deem to be unfair laws. It has been used in many nonviolent resistance movements in India (Gandhi's campaigns for independence from the British Empire), in Czechoslovakia's Velvet Revolution and in East Germany to oust their communist governments, In South Africa in the fight against apartheid, in the American Civil Rights Movement, in the Singing Revolution to bring independence to the Baltic countries from the Soviet Union, recently with the 2003 Rose Revolution in Georgia and the 2004 Orange Revolution in Ukraine, among other various movements worldwide."], ["Construction is the process of constructing a building or infrastructure. Construction differs from manufacturing in that manufacturing typically involves mass production of similar items without a designated purchaser, while construction typically takes place on location for a known client. Construction as an industry comprises six to nine percent of the gross domestic product of developed countries. Construction starts with planning,[citation needed] design, and financing and continues until the project is built and ready for use."], ["Private schools, also known as independent schools, non-governmental, or nonstate schools, are not administered by local, state or national governments; thus, they retain the right to select their students and are funded in whole or in part by charging their students tuition, rather than relying on mandatory taxation through public (government) funding; at some private schools students may be able to get a scholarship, which makes the cost cheaper, depending on a talent the student may have (e.g. sport scholarship, art scholarship, academic scholarship), financial need, or tax credit scholarships that might be available."], ["Established originally by the Massachusetts legislature and soon thereafter named for John Harvard (its first benefactor), Harvard is the United States' oldest institution of higher learning, and the Harvard Corporation (formally, the President and Fellows of Harvard College) is its first chartered corporation. Although never formally affiliated with any denomination, the early College primarily trained Congregationalist and Unitarian clergy. Its curriculum and student body were gradually secularized during the 18th century, and by the 19th century Harvard had emerged as the central cultural establishment among Boston elites. Following the American Civil War, President Charles W. Eliot's long tenure (1869\u20131909) transformed the college and affiliated professional schools into a modern research university; Harvard was a founding member of the Association of American Universities in 1900. James Bryant Conant led the university through the Great Depression and World War II and began to reform the curriculum and liberalize admissions after the war. The undergraduate college became coeducational after its 1977 merger with Radcliffe College."], ["Jacksonville is the largest city by population in the U.S. state of Florida, and the largest city by area in the contiguous United States. It is the county seat of Duval County, with which the city government consolidated in 1968. Consolidation gave Jacksonville its great size and placed most of its metropolitan population within the city limits; with an estimated population of 853,382 in 2014, it is the most populous city proper in Florida and the Southeast, and the 12th most populous in the United States. Jacksonville is the principal city in the Jacksonville metropolitan area, with a population of 1,345,596 in 2010."], ["A study by the World Institute for Development Economics Research at United Nations University reports that the richest 1% of adults alone owned 40% of global assets in the year 2000. The three richest people in the world possess more financial assets than the lowest 48 nations combined. The combined wealth of the \"10 million dollar millionaires\" grew to nearly $41 trillion in 2008. A January 2014 report by Oxfam claims that the 85 wealthiest individuals in the world have a combined wealth equal to that of the bottom 50% of the world's population, or about 3.5 billion people. According to a Los Angeles Times analysis of the report, the wealthiest 1% owns 46% of the world's wealth; the 85 richest people, a small part of the wealthiest 1%, own about 0.7% of the human population's wealth, which is the same as the bottom half of the population. More recently, in January 2015, Oxfam reported that the wealthiest 1 percent will own more than half of the global wealth by 2016. An October 2014 study by Credit Suisse also claims that the top 1% now own nearly half of the world's wealth and that the accelerating disparity could trigger a recession. In October 2015, Credit Suisse published a study which shows global inequality continues to increase, and that half of the world's wealth is now in the hands of those in the top percentile, whose assets each exceed $759,900. A 2016 report by Oxfam claims that the 62 wealthiest individuals own as much wealth as the poorer half of the global population combined. Oxfam's claims have however been questioned on the basis of the methodology used: by using net wealth (adding up assets and subtracting debts), the Oxfam report, for instance, finds that there are more poor people in the United States and Western Europe than in China (due to a greater tendency to take on debts).[unreliable source?][unreliable source?] Anthony Shorrocks, the lead author of the Credit Suisse report which is one of the sources of Oxfam's data, considers the criticism about debt to be a \"silly argument\" and \"a non-issue . . . a diversion.\""], ["Doctor Who is a British science-fiction television programme produced by the BBC since 1963. The programme depicts the adventures of the Doctor, a Time Lord\u2014a space and time-travelling humanoid alien. He explores the universe in his TARDIS, a sentient time-travelling space ship. Its exterior appears as a blue British police box, which was a common sight in Britain in 1963 when the series first aired. Accompanied by companions, the Doctor combats a variety of foes, while working to save civilisations and help people in need."], ["The University of Chicago (UChicago, Chicago, or U of C) is a private research university in Chicago. The university, established in 1890, consists of The College, various graduate programs, interdisciplinary committees organized into four academic research divisions and seven professional schools. Beyond the arts and sciences, Chicago is also well known for its professional schools, which include the Pritzker School of Medicine, the University of Chicago Booth School of Business, the Law School, the School of Social Service Administration, the Harris School of Public Policy Studies, the Graham School of Continuing Liberal and Professional Studies and the Divinity School. The university currently enrolls approximately 5,000 students in the College and around 15,000 students overall."], ["The Yuan dynasty (Chinese: \u5143\u671d; pinyin: Yu\u00e1n Ch\u00e1o), officially the Great Yuan (Chinese: \u5927\u5143; pinyin: D\u00e0 Yu\u00e1n; Mongolian: Yehe Yuan Ulus[a]), was the empire or ruling dynasty of China established by Kublai Khan, leader of the Mongolian Borjigin clan. Although the Mongols had ruled territories including today's North China for decades, it was not until 1271 that Kublai Khan officially proclaimed the dynasty in the traditional Chinese style. His realm was, by this point, isolated from the other khanates and controlled most of present-day China and its surrounding areas, including modern Mongolia and Korea. It was the first foreign dynasty to rule all of China and lasted until 1368, after which its Genghisid rulers returned to their Mongolian homeland and continued to rule the Northern Yuan dynasty. Some of the Mongolian Emperors of the Yuan mastered the Chinese language, while others only used their native language (i.e. Mongolian) and the 'Phags-pa script."], ["Kenya (/\u02c8k\u025bnj\u0259/; locally [\u02c8k\u025b\u0272a] ( listen)), officially the Republic of Kenya, is a country in Africa and a founding member of the East African Community (EAC). Its capital and largest city is Nairobi. Kenya's territory lies on the equator and overlies the East African Rift covering a diverse and expansive terrain that extends roughly from Lake Victoria to Lake Turkana (formerly called Lake Rudolf) and further south-east to the Indian Ocean. It is bordered by Tanzania to the south, Uganda to the west, South Sudan to the north-west, Ethiopia to the north and Somalia to the north-east. Kenya covers 581,309 km2 (224,445 sq mi), and had a population of approximately 45 million people in July 2014."], ["The Intergovernmental Panel on Climate Change (IPCC) is a scientific intergovernmental body under the auspices of the United Nations, set up at the request of member governments. It was first established in 1988 by two United Nations organizations, the World Meteorological Organization (WMO) and the United Nations Environment Programme (UNEP), and later endorsed by the United Nations General Assembly through Resolution 43/53. Membership of the IPCC is open to all members of the WMO and UNEP. The IPCC produces reports that support the United Nations Framework Convention on Climate Change (UNFCCC), which is the main international treaty on climate change. The ultimate objective of the UNFCCC is to \"stabilize greenhouse gas concentrations in the atmosphere at a level that would prevent dangerous anthropogenic [i.e., human-induced] interference with the climate system\". IPCC reports cover \"the scientific, technical and socio-economic information relevant to understanding the scientific basis of risk of human-induced climate change, its potential impacts and options for adaptation and mitigation.\""], ["Chloroplasts' main role is to conduct photosynthesis, where the photosynthetic pigment chlorophyll captures the energy from sunlight and converts it and stores it in the energy-storage molecules ATP and NADPH while freeing oxygen from water. They then use the ATP and NADPH to make organic molecules from carbon dioxide in a process known as the Calvin cycle. Chloroplasts carry out a number of other functions, including fatty acid synthesis, much amino acid synthesis, and the immune response in plants. The number of chloroplasts per cell varies from 1 in algae up to 100 in plants like Arabidopsis and wheat."], ["A prime number (or a prime) is a natural number greater than 1 that has no positive divisors other than 1 and itself. A natural number greater than 1 that is not a prime number is called a composite number. For example, 5 is prime because 1 and 5 are its only positive integer factors, whereas 6 is composite because it has the divisors 2 and 3 in addition to 1 and 6. The fundamental theorem of arithmetic establishes the central role of primes in number theory: any integer greater than 1 can be expressed as a product of primes that is unique up to ordering. The uniqueness in this theorem requires excluding 1 as a prime because one can include arbitrarily many instances of 1 in any factorization, e.g., 3, 1 \u00b7 3, 1 \u00b7 1 \u00b7 3, etc. are all valid factorizations of 3."], ["The Rhine (Romansh: Rein, German: Rhein, French: le Rhin, Dutch: Rijn) is a European river that begins in the Swiss canton of Graub\u00fcnden in the southeastern Swiss Alps, forms part of the Swiss-Austrian, Swiss-Liechtenstein border, Swiss-German and then the Franco-German border, then flows through the Rhineland and eventually empties into the North Sea in the Netherlands. The biggest city on the river Rhine is Cologne, Germany with a population of more than 1,050,000 people. It is the second-longest river in Central and Western Europe (after the Danube), at about 1,230 km (760 mi),[note 2][note 1] with an average discharge of about 2,900 m3/s (100,000 cu ft/s)."], ["Following a referendum in 1997, in which the Scottish electorate voted for devolution, the current Parliament was convened by the Scotland Act 1998, which sets out its powers as a devolved legislature. The Act delineates the legislative competence of the Parliament \u2013 the areas in which it can make laws \u2013 by explicitly specifying powers that are \"reserved\" to the Parliament of the United Kingdom. The Scottish Parliament has the power to legislate in all areas that are not explicitly reserved to Westminster. The British Parliament retains the ability to amend the terms of reference of the Scottish Parliament, and can extend or reduce the areas in which it can make laws. The first meeting of the new Parliament took place on 12 May 1999."], ["Islamism, also known as Political Islam (Arabic: \u0625\u0633\u0644\u0627\u0645 \u0633\u064a\u0627\u0633\u064a\u200e isl\u0101m siy\u0101s\u012b), is an Islamic revival movement often characterized by moral conservatism, literalism, and the attempt \"to implement Islamic values in all spheres of life.\" Islamism favors the reordering of government and society in accordance with the Shari'a. The different Islamist movements have been described as \"oscillating between two poles\": at one end is a strategy of Islamization of society through state power seized by revolution or invasion; at the other \"reformist\" pole Islamists work to Islamize society gradually \"from the bottom up\". The movements have \"arguably altered the Middle East more than any trend since the modern states gained independence\", redefining \"politics and even borders\" according to one journalist (Robin Wright)."], ["Imperialism is a type of advocacy of empire. Its name originated from the Latin word \"imperium\", which means to rule over large territories. Imperialism is \"a policy of extending a country's power and influence through colonization, use of military force, or other means\". Imperialism has greatly shaped the contemporary world. It has also allowed for the rapid spread of technologies and ideas. The term imperialism has been applied to Western (and Japanese) political and economic dominance especially in Asia and Africa in the 19th and 20th centuries. Its precise meaning continues to be debated by scholars. Some writers, such as Edward Said, use the term more broadly to describe any system of domination and subordination organised with an imperial center and a periphery."], ["The United Methodist Church (UMC) is a mainline Protestant Methodist denomination. In the 19th century its main predecessor was a leader in Evangelicalism. Founded in 1968 by the union of the Methodist Church (USA) and the Evangelical United Brethren Church, the UMC traces its roots back to the revival movement of John and Charles Wesley in England as well as the Great Awakening in the United States. As such, the church's theological orientation is decidedly Wesleyan. It embraces both liturgical and evangelical elements."], ["The French and Indian War (1754\u20131763) was the North American theater of the worldwide Seven Years' War. The war was fought between the colonies of British America and New France, with both sides supported by military units from their parent countries of Great Britain and France, as well as Native American allies. At the start of the war, the French North American colonies had a population of roughly 60,000 European settlers, compared with 2 million in the British North American colonies. The outnumbered French particularly depended on the Indians. Long in conflict, the metropole nations declared war on each other in 1756, escalating the war from a regional affair into an intercontinental conflict."], ["Philosophers in antiquity used the concept of force in the study of stationary and moving objects and simple machines, but thinkers such as Aristotle and Archimedes retained fundamental errors in understanding force. In part this was due to an incomplete understanding of the sometimes non-obvious force of friction, and a consequently inadequate view of the nature of natural motion. A fundamental error was the belief that a force is required to maintain motion, even at a constant velocity. Most of the previous misunderstandings about motion and force were eventually corrected by Galileo Galilei and Sir Isaac Newton. With his mathematical insight, Sir Isaac Newton formulated laws of motion that were not improved-on for nearly three hundred years. By the early 20th century, Einstein developed a theory of relativity that correctly predicted the action of forces on objects with increasing momenta near the speed of light, and also provided insight into the forces produced by gravitation and inertia."]], "questions": [["Which NFL team represented the AFC at Super Bowl 50?", "Which NFL team represented the NFC at Super Bowl 50?", "Where did Super Bowl 50 take place?", "Which NFL team won Super Bowl 50?", "What color was used to emphasize the 50th anniversary of the Super Bowl?", "What was the theme of Super Bowl 50?", "What day was the game played on?", "What is the AFC short for?", "What was the theme of Super Bowl 50?", "What does AFC stand for?", "What day was the Super Bowl played on?", "Who won Super Bowl 50?", "What venue did Super Bowl 50 take place in?", "What city did Super Bowl 50 take place in?", "If Roman numerals were used, what would Super Bowl 50 have been called?", "Super Bowl 50 decided the NFL champion for what season?", "What year did the Denver Broncos secure a Super Bowl title for the third time?", "What city did Super Bowl 50 take place in?", "What stadium did Super Bowl 50 take place in?", "What was the final score of Super Bowl 50? ", "What month, day and year did Super Bowl 50 take place? ", "What year was Super Bowl 50?", "What team was the AFC champion?", "What team was the NFC champion?", "Who won Super Bowl 50?", "Super Bowl 50 determined the NFL champion for what season?", "Which team won Super Bowl 50.", "Where was Super Bowl 50 held?", "The name of the NFL championship game is?", "What 2015 NFL team one the AFC playoff?"], ["What was Maria Curie the first female recipient of?", "What year was Casimir Pulaski born in Warsaw?", "Who was one of the most famous people born in Warsaw?", "Who was Fr\u00e9d\u00e9ric Chopin?", "How old was Chopin when he moved to Warsaw with his family?"], ["In what country is Normandy located?", "When were the Normans in Normandy?", "From which countries did the Norse originate?", "Who was the Norse leader?", "What century did the Normans first gain their separate identity?"], ["In what year was Nikola Tesla born? ", "What was Nikola Tesla's ethnicity?", "In what year did Tesla die? ", "When was Nikola Tesla born?", "In what year did Tesla die?", "What is Tesla's home country?", "What does AC stand for?"], ["What branch of theoretical computer science deals with broadly classifying computational problems by difficulty and class of relationship?", "By what main attribute are computational problems classified utilizing computational complexity theory? ", "What is the term for a task that generally lends itself to being solved by a computer?"], ["What is a course of study called?", "What is another name to describe the science of teaching?", "Where do most teachers get their credentials from?", "What can a teacher use to help students learn?", "Where is a teacher most likely to be teaching at?"], ["Of what nationality was Martin Luther?", "When did Martin Luther die?", "What organization's teaching did Luther reject?", "What did the Church claim could be avoided with money?", "What did the Church do when Luther refused to retract his writings?"], ["What is Southern California often abbreviated as?", "Despite being traditionall described as \"eight counties\", how many counties does this region actually have?", "What is a major importance of Southern California in relation to California and the United States?", "What are the ties that best described what the \"eight counties\" are based on?", "The reasons for the las two counties to be added are based on what?"], ["What company was formed by the merger of Sky Television and British Satellite Broadcasting?", "Who is the UK's largest digital subscription television company?", "What year did BSkyB acquire Sky Italia?", "What is the name of the holding company for BSkyB?", "What is the name of the United Kingdom operation for BSkyB?"], ["What kind of economy does Victoria have?", "Where according to gross state product does Victoria rank in Australia?", "At what rank does GPS per capita set Victoria?", "What city in Victoria is called the sporting capital of Australia?", "What is the largest stadium in Australia?"], ["Where was France's Huguenot population largely centered?", "What was the proportion of Huguenots to Catholics at their peak?", "When were the Wars of Religion fought?", "What treaty ended the Wars of Religion?", "What did this agreement do?"], ["Along with geothermal and nuclear, what is a notable non-combustion heat source?", "What ideal thermodynamic cycle analyzes the process by which steam engines work?", "In the Rankine cycle, what does water turn into when heated?", "At what pressure is water heated in the Rankine cycle?", "What types of engines are steam engines?"], ["The atomic number of the periodic table for oxygen?", "What is the second most abundant element?", "How many atoms combine to form dioxygen?", "Roughly, how much oxygen makes up the Earth crust?", "Which gas makes up 20.8% of the Earth's atmosphere?", "How much of the earth's atmosphere is diatomic oxygen?", "What element makes up almost half of the earth's crust by mass?", "What is the atomic number for oxygen?", "Are atmospheric oxygen levels going up, down, or staying the same?", "What are the three most abundent elements of the universe by mass?", "What is the atomic number of the element oxygen?", "Of what group in the periodic table is oxygen a member?", "What type of compounds does oxygen most commonly form?", "Compared to other elements, how abundant does oxygen rank?", "Under normal conditions, what do two atoms of oxygen form?"], ["When did the 1973 oil crisis begin?", "What was the price of oil in March of 1974?", "When was the second oil crisis?", "What was another term used for the oil crisis?", "Who proclaimed the oil embargo?"], ["What project put the first Americans into space?", "What program was created to carry out these projects and missions?", "What year did the first manned Apollo flight occur?", "What President is credited with the original notion of putting Americans in space?", "How many people were on the project that followed Project Mercury?"], ["What are the three sources of European Union law?", "What is European Union Law?", "What are the main sources of primary law?", "What are the secondary sources of primary law?", "What are the two bodies that make up the European Union's legislature?", "What is European Union law?", "What effect does European Union law have on laws of member states?", "What are the three sources of European Union law?", "What are the main legislative bodies of the European Union?", "What are the three main sources of European Union law?", "What are the main sources of primary law?", "What is the legislature of the European Union comprised of?", "How many sources of European Union law are there?"], ["Which name is also used to describe the Amazon rainforest in English?", "How many square kilometers of rainforest is covered in the basin?", "How many nations control this region in total?", "How many nations contain \"Amazonas\" in their names?", "What percentage does the Amazon represents in rainforests on the planet?", "What is the Dutch word for the Amazon rainforest?", "What rainforest covers the majority of the Amazon basin in South America?", "In what country can most of the Amazon rainforest be found?", "The Amazon rainforest makes up what amount of Earth's rainforests?", "How many species of trees can be found in the Amazon rainforest?", "What kind of forest is the Amazon rainforest?", "How many square kilometers is the Amazon Basin?", "How many nations are within the Amazon Basin?", "Which nation contains the majority of the amazon forest?", "What is the estimate for the amount of tree species in the amazon tropical rain forest?"], ["What are Ctenophora commonly known as?", "Where do Ctenophora live?", "What size are adult Ctenophora?", "What is a ctenophora?", "What does the ctenophora use to swim?", "What does ctenophora use for digestion and respiration?", "How large can ctenophora grow?", "What is the most distinctive feature of ctenophora?", "What are ctenophora commonly known as?", "How big can ctenophora grow?", "What does ctenophora rely on for digestion and respiration?", "What does ctenophora mean in Greek?", "Where do ctenophora live?"], ["Which city is the fifth-largest city in California?", "How far is Fresno from Los Angeles?", "What does the name Fresno mean in Spanish?", "What is featured on the city of Fresno's city flag?", "How do you pronounce Fresno?"], ["What did Paul Baran develop ", "What did Distributed Adaptive Message Block Switching do", "What did this concept contradict ", "What is Donald Davies credited with ", "What did Paul Baran develop in the late 1950's", "What was the goal of the system ", "Who is credited with the modern name for this system "], ["Where did the black death originate?", "How did the black death make it to the Mediterranean and Europe?", "How much of the European population did the black death kill?", "When did the world's population finally recover from the black death?", "For how long did the plague stick around?"], ["An igneous rock is a rock that crystallizes from what?", "Sedimentary rock can be turned into which of the three types of rock?", "When the three types of rock are re-melted what is formed? ", "What are the three major types of rock? ", "What changes the mineral content of a rock?"], ["How many miles south of Edinburgh is Newcastle?", "How many miles from the north Sea is Newcastle?", "What network is Newcastle a member of?", "What county was Newcastle a part of until 1400?", "What's the regional nickname for Newcastle and its surrounding area?"], ["where is the Victoria and Albert Museum located?", "how many permanent objects are located there?", "when was the Victoria and Albert museum founded?", "Who is the museum named for?", "In which London borough is the Victoria and Albert Museum located?", "In what year was the Victoria and Albert Museum founded?", "Which monarchs was the Victoria and Albert Museum named after?", "Which department sponsors the Victoria and Albert Museum?", "In which year did the museum started charging free admission fees?"], ["What company owns the American Broadcasting Company?", "In what year did ABC stylize it's logo as abc?", "In what borough of New York City is ABC headquartered?", "On what streets is the ABC headquarters located", "Disney-ABC Television Group is a subsidiary of what division of the Walt Disney Company?"], ["What do we call the empire that Genghis Khan founded?", "Who did Genghis Khan unite before he began conquering the rest of Eurasia?", "In which regions in particular did Genghis Khan's armies massacre civilians?", "What areas did Genghis Khan control at the end of his life?", "Which other empires or dynasties did Genghis Khan conquer?"], ["What word is the word pharmacy taken from?", "What goods were sold in a pharma?", "What did the Greek root pharmakos imply?", "How would the word apothecary be viewed by contemporary English speakers?", "What else was used by pharmas?"], ["What is the immune system?", "What does the immune system protect against?", "What are two of its subsystems?", "What is the subsystem that protects the human brain?", "What is the immune system?", "What does the immune system protect against?", "What are two of its subsystems?", "The immune system protects organisms against what?", "What are the agents the immune system detects known as?", "Which part of the immune system protects the brain?", "What separates the neuroimmune system and peripheral immune system in humans?", "What are the agents detected by the immune system called?", "What are the two major subsystems of the immune system?", "What are the two different types of immunity?", "What is the immune system of the brained known as?"], ["What is it called when people in society rebel against laws they think are unfair?", "What is an example of major civil disobedience in South Africa?", "What was the the movement called that brought Baltic countries independence from the Soviet Union?", "In 2004 the Orange revolution occurred in what country?", "Where was the location of the 2003 Rose revolution?", "Which people brought forward one of the earliest examples of Civil Disobedience?", "Who was one of the earliest examples of Civil Disobedience against?", "Why do people chose civil disobedience to protest?", "What does civil disobedience protest against?", "What civil rights movement in the US was known for it's disobedience?"], ["What is the process of constructing a building or infrastructure?", "What typically involves mass production of similar items without a designated purchaser?", "What percentile of gross domestic product is construction comprised of?", "What three things are needed for construction to take place?", "Construction takes place on location for who?"], ["Along with non-governmental and nonstate schools, what is another name for private schools?", "Along with sport and art, what is a type of talent scholarship?", "Rather than taxation, what are private schools largely funded by?", "What right do private schools have that public schools don't?"], ["What individual is the school named after?", "When did the undergraduate program become coeducational?", "What was the name of the leader through the Great Depression and World War II?", "What organization did Harvard found in 1900?", "What president of the university transformed it into a modern research university?"], ["Which Florida city has the biggest population?", "What was the population Jacksonville city as of 2010?", "Based on population alone, what is Jacksonville's ranking in the United States?", "In which county does Jacksonville reside?", "What year did consolidation cause Jacksonville to become part of Duval County?"], ["What percentage of global assets does the richest 1% of people have?", "According to Oxfam, the 85 richest people have wealth equal to how many average people?", "In order to be considered in the top percentile, a person would need to amass how much money each year?", "What has caused Oxfam's findings to be questioned?", "Why does Oxfam and Credit Suisse believe their findings are being doubted?", "What percent of the global assets in 2000 were owned by just 1% of adults?", "What do the three richest people in the world posses more of than the lowest 48 nations together?", "How much was the combined wealth of the \"10 Million dollar millionaires\" in 2008?", "How much of the global wealth will the wealthiest 1 percent own by 2016?", "Why are there more poor people in the United States and Europe than China?"], ["Who is the producer of Doctor Who?", "What year did Doctor Who first show on TV?", "What is Doctor Who's space ship called?", "What does the outside of the Tardis resemble?", "What type/genre of TV show is Doctor Who?"], ["What kind of university is the University of Chicago?", "When was the University of Chicago established?", "How many professional schools does the University of Chicago have?", "How many academic research divisions does the University of Chicago have?", "How many students does the University of Chicago have enlisted?"], ["What is the Chinese name for the Yuan dynasty?", "What is the Yuan dynasty's official name?", "Who started the Yuan dynasty?", "Who led the Mongolian Borjigin clan?", "When did Khan formally declare the Yuan dynasty?"], ["Where is Kenya located?", "What is Kenya a founding member of?", "What is the capitol of Kenya?", "What country boarders the south of Kenya?", "What was the population of Kenya in 2014?"], ["What organization is the IPCC a part of?", "What UN organizations established the IPCC?", "What does the UN want to stabilize?", "What is the UN's climate change treaty?", "What UN resolution endorsed the IPCC?"], ["What is the primary purpose of chloroplasts?", "What does ATP store?", "What does NADPH store?", "What is the process of turning CO2 into organic molecules called?", "How many chloroplasts per cell does algae have?"], ["What is the only divisor besides 1 that a prime number can have?", "What are numbers greater than 1 that can be divided by 3 or more numbers called?", "What theorem defines the main role of primes in number theory?", "Any number larger than 1 can be represented as a product of what?", "Why must one be excluded in order to preserve the uniqueness of the fundamental theorem?"], ["Where does the Rhine begin? ", "Where does the Rhine empty?", "What is the largest city the Rhine runs through? ", "What river is larger than the Rhine?", "How long is the Rhine?", "Where is the Rhine? ", "What country does the Rhine empty?", "How long is the Rhine? "], ["When was the current parliament of Scotland convened?", "What act set out the Parliament's powers as a devolved legislature?", "The legislative competence of the Parliament species what areas?", "To what body are certain powers explicitly specified as being reserved for?", "The Scottish Parliament may legislate as it pleases as long as the powers aren't already reserved by where?"], ["What is an Islamic revival movement?", "What aspects of life does Islamism seek to integrate itself into?", "What goal does Islamism have when it comes to society and government?", "What have the two different Islamist movements been described as oscillating between?", "One strategy of Islamization is to seize power by what methods?"], ["The word imperialism has it's origins in which ancient language? ", "By what means is imperialism usually administered?", "The term imperialism has been applied to western countries, and which eastern county?", "Imperialism is responsible for the rapid spread of what?"], ["What does UMC stand for?", "What is the United Methodist Church?", "When was the UMC founded?", "Who founded the UMC?", "What is the church's theological orientation?"], ["When was the French and Indian War?", "Who fought in the French and Indian war?", "How many people were in French North American Colonies?", "How many people were in British North American Colonies?"], ["What concept did philosophers in antiquity use to study simple machines?", "What was the belief that maintaining motion required force?", "Who had mathmatical insite?", "How long did it take to improve on Sir Isaac Newton's laws of motion?", "Who develped the theory of relativity?"]]} \ No newline at end of file diff --git a/lite/examples/bert_qa/android/build.gradle b/lite/examples/bert_qa/android/build.gradle index e3d1c52f8a5..96b9e63a03a 100644 --- a/lite/examples/bert_qa/android/build.gradle +++ b/lite/examples/bert_qa/android/build.gradle @@ -1,14 +1,14 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { dependencies { - classpath 'androidx.navigation:navigation-safe-args-gradle-plugin:2.5.0' - classpath 'de.undercouch:gradle-download-task:4.1.2' + classpath 'androidx.navigation:navigation-safe-args-gradle-plugin:2.7.7' + classpath 'de.undercouch:gradle-download-task:5.6.0' } } + plugins { - id 'com.android.application' version '7.2.0' apply false - id 'com.android.library' version '7.2.0' apply false - id 'org.jetbrains.kotlin.android' version '1.6.21' apply false + id 'com.android.application' version '8.5.0' apply false // Update to 8.5.0 + id 'com.android.library' version '8.5.0' apply false // Update to 8.5.0 + id 'org.jetbrains.kotlin.android' version '1.9.20' apply false } task clean(type: Delete) { diff --git a/lite/examples/bert_qa/android/gradle/wrapper/gradle-wrapper.properties b/lite/examples/bert_qa/android/gradle/wrapper/gradle-wrapper.properties index 1af9e0930b8..b82aa23a4f0 100644 --- a/lite/examples/bert_qa/android/gradle/wrapper/gradle-wrapper.properties +++ b/lite/examples/bert_qa/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/lite/examples/generative_ai/android/gradle/wrapper/gradle-wrapper.jar b/lite/examples/generative_ai/android/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000000..a4b76b9530d Binary files /dev/null and b/lite/examples/generative_ai/android/gradle/wrapper/gradle-wrapper.jar differ diff --git a/lite/examples/generative_ai/android/gradle/wrapper/gradle-wrapper.properties b/lite/examples/generative_ai/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000000..cea7a793a84 --- /dev/null +++ b/lite/examples/generative_ai/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/lite/examples/generative_ai/android/gradlew b/lite/examples/generative_ai/android/gradlew new file mode 100644 index 00000000000..f3b75f3b0d4 --- /dev/null +++ b/lite/examples/generative_ai/android/gradlew @@ -0,0 +1,251 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/lite/examples/generative_ai/android/gradlew.bat b/lite/examples/generative_ai/android/gradlew.bat new file mode 100644 index 00000000000..9d21a21834d --- /dev/null +++ b/lite/examples/generative_ai/android/gradlew.bat @@ -0,0 +1,94 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/lite/examples/generative_ai/convert_model.py b/lite/examples/generative_ai/convert_model.py new file mode 100644 index 00000000000..9760dfcf4e6 --- /dev/null +++ b/lite/examples/generative_ai/convert_model.py @@ -0,0 +1,12 @@ +import tensorflow as tf +from keras_nlp.models import GPT2CausalLM + +# Load a pre-trained model (e.g., GPT-2 for text generation) +model = GPT2CausalLM.from_preset("gpt2_base_en") +# Convert to TFLite +converter = tf.lite.TFLiteConverter.from_keras_model(model) +converter.optimizations = [tf.lite.Optimize.DEFAULT] +tflite_model = converter.convert() +# Save as autocomplete.tflite +with open("autocomplete.tflite", "wb") as f: + f.write(tflite_model) \ No newline at end of file