{"cells":[{"cell_type":"markdown","metadata":{"id":"3p7vLrb-57Hq"},"source":["# Data Preparation"]},{"cell_type":"code","source":["from google.colab import drive\n","drive.mount('/content/drive')"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"df8tUqsfBPhr","executionInfo":{"status":"ok","timestamp":1735137420705,"user_tz":-330,"elapsed":4671,"user":{"displayName":"Malavika Nair Pambadiyil","userId":"11866192100661929468"}},"outputId":"a6ac71ec-9aa9-4c5c-f181-e08f9fd679da"},"execution_count":null,"outputs":[{"output_type":"stream","name":"stdout","text":["Drive already mounted at /content/drive; to attempt to forcibly remount, call drive.mount(\"/content/drive\", force_remount=True).\n"]}]},{"cell_type":"code","source":["%cd /content/drive/MyDrive/MisinformationTruthTell/"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"thclhHRNBPeY","executionInfo":{"status":"ok","timestamp":1735137424623,"user_tz":-330,"elapsed":600,"user":{"displayName":"Malavika Nair Pambadiyil","userId":"11866192100661929468"}},"outputId":"2dbb8e86-be50-44fa-f23b-c37aace1f8b4"},"execution_count":null,"outputs":[{"output_type":"stream","name":"stdout","text":["/content/drive/MyDrive/MisinformationTruthTell\n"]}]},{"cell_type":"code","source":["!pip install -q kaggle"],"metadata":{"id":"x-WfCbUXBPbW"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":["from google.colab import files\n","files.upload()"],"metadata":{"id":"3qM2-SIEBPQB"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":["!mkdir -p ~/.kaggle\n","!cp kaggle.json ~/.kaggle/\n","!chmod 600 ~/.kaggle/kaggle.json"],"metadata":{"id":"J1w8LiZQDqCF"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":["%cd /content/drive/MyDrive/MisinformationTruthTell/"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"SeGe2Pr_Dp-n","executionInfo":{"status":"ok","timestamp":1735137457638,"user_tz":-330,"elapsed":569,"user":{"displayName":"Malavika Nair Pambadiyil","userId":"11866192100661929468"}},"outputId":"c9c9ae84-c9f2-41f0-8895-ecf39c0f99ef"},"execution_count":null,"outputs":[{"output_type":"stream","name":"stdout","text":["/content/drive/MyDrive/MisinformationTruthTell\n"]}]},{"cell_type":"code","source":["! kaggle datasets download clmentbisaillon/fake-and-real-news-dataset"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"83M9FkN8Dp5V","executionInfo":{"status":"ok","timestamp":1735137463110,"user_tz":-330,"elapsed":2849,"user":{"displayName":"Malavika Nair Pambadiyil","userId":"11866192100661929468"}},"outputId":"e2758b57-2aff-4211-e315-27b13b44db21"},"execution_count":null,"outputs":[{"output_type":"stream","name":"stdout","text":["Dataset URL: https://www.kaggle.com/datasets/clmentbisaillon/fake-and-real-news-dataset\n","License(s): CC-BY-NC-SA-4.0\n","fake-and-real-news-dataset.zip: Skipping, found more recently modified local copy (use --force to force download)\n"]}]},{"cell_type":"code","source":["path = '/content/drive/MyDrive/MisinformationTruthTell'"],"metadata":{"id":"VEwwd6gXDp2Y"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":["! unzip fake-and-real-news-dataset.zip"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"f11AayAgGw6N","executionInfo":{"status":"ok","timestamp":1735137494582,"user_tz":-330,"elapsed":22923,"user":{"displayName":"Malavika Nair Pambadiyil","userId":"11866192100661929468"}},"outputId":"7b627453-5f12-4ab3-93e0-54ae5e6982ac"},"execution_count":null,"outputs":[{"output_type":"stream","name":"stdout","text":["Archive: fake-and-real-news-dataset.zip\n","replace Fake.csv? [y]es, [n]o, [A]ll, [N]one, [r]ename: y\n"," inflating: Fake.csv \n","replace True.csv? [y]es, [n]o, [A]ll, [N]one, [r]ename: y\n"," inflating: True.csv \n"]}]},{"cell_type":"code","source":["# Load Dataset\n","import pandas as pd\n","true_data = pd.read_csv('True.csv')\n","fake_data = pd.read_csv('Fake.csv')"],"metadata":{"id":"qgDU2JgpHDRF"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":["# Generate labels True/Fake under new Target Column in 'true_data' and 'fake_data'\n","true_data['Target'] = ['True']*len(true_data)\n","fake_data['Target'] = ['Fake']*len(fake_data)\n","\n"],"metadata":{"id":"MODGntIcHDN6"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":["# Merge 'true_data' and 'fake_data', by random mixing into a single df called 'data'\n","\n","\n","data = pd.concat([true_data, fake_data]).sample(frac=1).reset_index(drop=True)\n","\n","\n","# See how the data looks like\n","print(data.shape)\n","data.head()"],"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":224},"id":"LT9pUbAIHLr0","executionInfo":{"status":"ok","timestamp":1735137545461,"user_tz":-330,"elapsed":1225,"user":{"displayName":"Malavika Nair Pambadiyil","userId":"11866192100661929468"}},"outputId":"79497039-ea80-4c7b-8fb6-f990ff1855ff"},"execution_count":null,"outputs":[{"output_type":"stream","name":"stdout","text":["(44898, 5)\n"]},{"output_type":"execute_result","data":{"text/plain":[" title \\\n","0 THE LOST VIDEO: Watch MSNBC’S Mika Shamelessly... \n","1 Trump Is Now Threatening A Lawsuit Over Copyr... \n","2 Oklahoma Gun Range Refused Service To Muslim ... \n","3 Republican debate without Trump draws 12.5 mil... \n","4 SHOCKING REPORT: 50% of Babies in 24 States Bo... \n","\n"," text subject \\\n","0 With all the anger and nasty comments coming f... left-news \n","1 The artist who painted a nude portrait of Dona... News \n","2 You d think in the year 2016 we d no longer ha... News \n","3 LOS ANGELES (Reuters) - The Republican preside... politicsNews \n","4 New Mexico led all states with 72 percent of t... Government News \n","\n"," date Target \n","0 Jun 30, 2017 Fake \n","1 April 17, 2016 Fake \n","2 February 19, 2016 Fake \n","3 January 29, 2016 True \n","4 Mar 24, 2017 Fake "],"text/html":["\n","
\n","
\n","\n","\n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n","
titletextsubjectdateTarget
0THE LOST VIDEO: Watch MSNBC’S Mika Shamelessly...With all the anger and nasty comments coming f...left-newsJun 30, 2017Fake
1Trump Is Now Threatening A Lawsuit Over Copyr...The artist who painted a nude portrait of Dona...NewsApril 17, 2016Fake
2Oklahoma Gun Range Refused Service To Muslim ...You d think in the year 2016 we d no longer ha...NewsFebruary 19, 2016Fake
3Republican debate without Trump draws 12.5 mil...LOS ANGELES (Reuters) - The Republican preside...politicsNewsJanuary 29, 2016True
4SHOCKING REPORT: 50% of Babies in 24 States Bo...New Mexico led all states with 72 percent of t...Government NewsMar 24, 2017Fake
\n","
\n","
\n","\n","
\n"," \n","\n"," \n","\n"," \n","
\n","\n","\n","
\n"," \n","\n","\n","\n"," \n","
\n","\n","
\n","
\n"],"application/vnd.google.colaboratory.intrinsic+json":{"type":"dataframe","variable_name":"data","summary":"{\n \"name\": \"data\",\n \"rows\": 44898,\n \"fields\": [\n {\n \"column\": \"title\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 38729,\n \"samples\": [\n \" Fox News Is Collapsing Like A House Of Cards As Andrea Tantaros Names Bill O\\u2019Reilly In Lawsuit\",\n \"Fed turns to Trump agenda with rate hike nearly in the bag\",\n \" This Immigrant West Point Graduate Proves America Is Already Great (IMAGE)\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"text\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 38646,\n \"samples\": [\n \"WASHINGTON (Reuters) - The dark vision of America under siege described by Donald Trump in his acceptance speech for the Republican presidential nomination does not mesh with reality, U.S. President Barack Obama said on Friday. Obama noted that the \\u201cbirds were chirping and the sun was out\\u201d for most Americans after Trump\\u2019s Thursday night speech, which expounded on the threats to America from illegal immigrants, Islamic State militants, and race-related violence. \\u201cThis idea that America is somehow on the verge of collapse, this vision of violence and chaos everywhere, doesn\\u2019t really jibe with the experience of most people,\\u201d Obama said at a White House news conference after meeting with Mexican President Enrique Pena Nieto. Obama said the violent crime rate in America has been lower during his 7-1/2 years in office than any time during the last three or four decades, despite an \\u201cuptick\\u201d in murders in some cities this year, and the recent high-profile killings of black men and police officers. The timing of Obama\\u2019s quickly arranged short meeting with Pena Nieto presented both leaders with a convenient platform from which to criticize Trump. Just three weeks ago, Obama - who has six months left in the White House - invited the Mexican president to visit one last time before the U.S. president leaves on Jan. 20. Trump has pledged to build a wall at the Mexico border to keep out illegal immigrants and drugs, and to force Mexico to pay for it. The New York businessman has also promised to slap tariffs on some U.S. products made in Mexico, and seek radical changes or even discard the North American Free Trade Agreement (NAFTA) between the United States, Mexico and Canada. Pena Nieto was first to mention Trump, but said he respected both Trump and presumptive Democratic presidential nominee Hillary Clinton, and would work with constructively and in good faith with whoever wins the Nov. 8 election. In March, Pena Nieto likened Trump\\u2019s \\u201cstrident tone\\u201d to the ascent of dictators Adolf Hitler and Benito Mussolini. But he said on Friday that he had never pointed the finger at any of the candidates, saying that anything he had said had been taken out of context. And he stressed that the two nations\\u2019 futures were closely bound. \\u201cThe closeness between the United States and Mexico is more than a relationship between governments. It\\u2019s a solid and unbreakable relationship between millions of people who live in both nations,\\u201d Pena Nieto said. Obama said the rate of illegal immigration is down from past decades, and praised Mexico for helping to address a flood of migrants fleeing Central America and for work on drug trafficking. \\u201cA Mexico that has a healthy economy, a Mexico that can help us build stability and security in Central America, that\\u2019s going to do a lot more to solve any migration crisis or drug trafficking problem than a wall,\\u201d Obama said. Obama and Pena Nieto praised the 12-nation Trans-Pacific Partnership (TPP) trade deal as addressing some of the criticisms of NAFTA. Both Trump and Clinton have said they oppose the TPP, which has yet to be ratified by the U.S. Congress. \\u201cThere are going to be different visions about where we should go as a country,\\u201d Obama said, running down a list of economic issues facing the nation. \\u201cBut we\\u2019re not going to make good decisions based on fears that don\\u2019t have a basis in fact,\\u201d he said. \",\n \"Perhaps it s time to build a wall around Texas and let it fail as a country separate from the United States, because the Republican Party platform in the state is by far one of the most hateful and anti-American platforms ever produced in this country.The main theme of the Texas Republican platform this year is nullification and destruction of everything they oppose, including women s rights, ethnic diversity, comprehensive sex education, LGBT rights, the separation of church and state, voting rights, and the federal government.Right off the bat, Texas Republicans began their platform document with a preamble pledging their belief in God and and went on to list adherence to the laws of nature as a principle even though the Constitution makes no such references.But it only got worse from there.Texas Republicans openly called for nullifying federal laws and ignoring the rulings of federal courts:Federally mandated legislation, which infringes upon the 10th Amendment rights of Texas, should be ignored, opposed, refused, and nullified. Regulation of Commerce in Article I, Section 8 of the Constitution has exceeded the original intent. All attempts by the federal judiciary to rule in areas not expressly enumerated by the Untied States Constitution should be likewise nullified. Any federal enforcement activities that do occur in Texas should be conducted under the authority of the county sheriff.They openly called for eliminating several critical federal agencies which handle labor unions, healthcare, tax revenue collection, and illegal drugs and firearms:We oppose the appointment of unelected bureaucrats and we support defunding and abolishing the departments or agencies of the Internal Revenue Service, Education, Energy, Housing and Urban Development, Commerce, Health and Human Services, Labor, and Interior (specifically, the Bureau of Land Management), Transportation Security Administration, Alcohol, Tobacco, Firearms and Explosives and National Labor Relations Board.They also rejected environmental protection and called climate change a scam:We oppose environmentalism that obstructs legitimate business interests and private property use, including the regulatory taking of property by governmental agencies. We oppose the abuse of the Endangered Species Act to confiscate and limit the use of personal property and infringement on property owner s livelihood. Climate Change is a political agenda promoted to control every aspect of our lives. We support the defunding of climate justice initiatives and the abolition of the Environmental Protection Agency and repeal of the Endangered Species Act.They then called on Congress to repeal the Voting Rights Act:We urge that the Voter Rights Act of 1965, codified and updated in 1973, be repealed and not reauthorized.In addition, Texas Republicans included opposition to same-sex marriage in their platform by calling for the Supreme Court ruling in Obergefell v. Hodges to be overturned while also declaring the definition of marriage as a God-ordained, legal and moral commitment only between one natural man and one natural woman. The platform condemned homosexuality by claiming that it goes against God s law and the Constitution and also declared support of controversial ex-gay therapy.Texas Republicans were especially hostile toward a woman s right to choose, calling on the Texas state government to ignore Roe v. Wade and any federal laws and regulations making abortion legal and accessible. In short, Texas Republicans want to outlaw abortion even if it s constitutionally protected.The Texas GOP also expressed opposition to Social Security, which it called for phasing out, and called for making Medicaid a temporary program only.Education wasn t left untouched either. Texas Republicans not only called for teaching creationism in school, they condemned comprehensive sex education that could actually reduce the number of unwanted pregnancies that result in abortions in the first place.Texas Republicans are also all about forcing minorities to assimilate into their version of American culture and forcing immigrants to learn and speak English so that they can quickly assimilate. You can read the full platform here.It s time for Texas to be thrown out of the United States. The state no longer shares the values America has held dear for so long. Because of Republican majorities, the state has become an embarrassment that will likely continue as long as the GOP continues to strip away voting rights from people they see as a threat to their power.And it would only be a matter of time before Texas comes crawling back as they realize there is more to becoming an independent nation than simply seceding. If Texas really wants to nullify federal law and go it alone, I say let them go. At least that would deprive Republicans of the 38 electoral votes Texas holds in presidential elections. And it would save the federal government billions of dollars while sparing the rest of the nation from dealing with Texas stupidity.Featured image via Wikimedia\",\n \"MOSCOW (Reuters) - Russian President Vladimir Putin will meet South Korean counterpart Moon Jae-in on Wednesday to discuss the crisis around North Korea, Kremlin spokesman Dmitry Peskov said on Tuesday. The two leaders will meet on the sidelines of an economic forum in the Russian far eastern city of Vladivostok as international concerns grow over Pyongyang s recent nuclear tests that shook the Korean Peninsula. \"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"subject\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 8,\n \"samples\": [\n \"News\",\n \"worldnews\",\n \"left-news\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"date\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 2397,\n \"samples\": [\n \"August 22, 2017\",\n \"Apr 19, 2016\",\n \"January 1, 2017\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Target\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 2,\n \"samples\": [\n \"True\",\n \"Fake\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}"}},"metadata":{},"execution_count":13}]},{"cell_type":"code","execution_count":null,"metadata":{"id":"DD7vmDm-57Hs"},"outputs":[],"source":["data['text'] = data.apply(lambda x: str(x.title) + '. ' + str(x.text), axis=1)\n","data = data[['text', 'Target']]"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"c9TWItj457Ht"},"outputs":[],"source":["\n","data.to_csv('./train.csv', index=False)"]},{"cell_type":"markdown","metadata":{"id":"4z0T9oM157Ht"},"source":["# Training"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"zriTdjauH8iQ"},"outputs":[],"source":["#!pip install transformers\n","import transformers"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"TFh3upySL3XG"},"outputs":[],"source":["from transformers import Trainer, TrainingArguments, LineByLineTextDataset"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"H2Ym6YhyNfON"},"outputs":[],"source":["import pandas as pd"]},{"cell_type":"code","source":["!pip install datasets"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"x7zg-VCsIoUB","executionInfo":{"status":"ok","timestamp":1735137716468,"user_tz":-330,"elapsed":3170,"user":{"displayName":"Malavika Nair Pambadiyil","userId":"11866192100661929468"}},"outputId":"dea4b98c-f138-4c41-c354-7da2c034932c"},"execution_count":null,"outputs":[{"output_type":"stream","name":"stdout","text":["Requirement already satisfied: datasets in /usr/local/lib/python3.10/dist-packages (3.2.0)\n","Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from datasets) (3.16.1)\n","Requirement already satisfied: numpy>=1.17 in /usr/local/lib/python3.10/dist-packages (from datasets) (1.26.4)\n","Requirement already satisfied: pyarrow>=15.0.0 in /usr/local/lib/python3.10/dist-packages (from datasets) (17.0.0)\n","Requirement already satisfied: dill<0.3.9,>=0.3.0 in /usr/local/lib/python3.10/dist-packages (from datasets) (0.3.8)\n","Requirement already satisfied: pandas in /usr/local/lib/python3.10/dist-packages (from datasets) (2.2.2)\n","Requirement already satisfied: requests>=2.32.2 in /usr/local/lib/python3.10/dist-packages (from datasets) (2.32.3)\n","Requirement already satisfied: tqdm>=4.66.3 in /usr/local/lib/python3.10/dist-packages (from datasets) (4.67.1)\n","Requirement already satisfied: xxhash in /usr/local/lib/python3.10/dist-packages (from datasets) (3.5.0)\n","Requirement already satisfied: multiprocess<0.70.17 in /usr/local/lib/python3.10/dist-packages (from datasets) (0.70.16)\n","Requirement already satisfied: fsspec<=2024.9.0,>=2023.1.0 in /usr/local/lib/python3.10/dist-packages (from fsspec[http]<=2024.9.0,>=2023.1.0->datasets) (2024.9.0)\n","Requirement already satisfied: aiohttp in /usr/local/lib/python3.10/dist-packages (from datasets) (3.11.10)\n","Requirement already satisfied: huggingface-hub>=0.23.0 in /usr/local/lib/python3.10/dist-packages (from datasets) (0.27.0)\n","Requirement already satisfied: packaging in /usr/local/lib/python3.10/dist-packages (from datasets) (24.2)\n","Requirement already satisfied: pyyaml>=5.1 in /usr/local/lib/python3.10/dist-packages (from datasets) (6.0.2)\n","Requirement already satisfied: aiohappyeyeballs>=2.3.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets) (2.4.4)\n","Requirement already satisfied: aiosignal>=1.1.2 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets) (1.3.2)\n","Requirement already satisfied: async-timeout<6.0,>=4.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets) (4.0.3)\n","Requirement already satisfied: attrs>=17.3.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets) (24.3.0)\n","Requirement already satisfied: frozenlist>=1.1.1 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets) (1.5.0)\n","Requirement already satisfied: multidict<7.0,>=4.5 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets) (6.1.0)\n","Requirement already satisfied: propcache>=0.2.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets) (0.2.1)\n","Requirement already satisfied: yarl<2.0,>=1.17.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets) (1.18.3)\n","Requirement already satisfied: typing-extensions>=3.7.4.3 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.23.0->datasets) (4.12.2)\n","Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests>=2.32.2->datasets) (3.4.0)\n","Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests>=2.32.2->datasets) (3.10)\n","Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests>=2.32.2->datasets) (2.2.3)\n","Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests>=2.32.2->datasets) (2024.12.14)\n","Requirement already satisfied: python-dateutil>=2.8.2 in /usr/local/lib/python3.10/dist-packages (from pandas->datasets) (2.8.2)\n","Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/dist-packages (from pandas->datasets) (2024.2)\n","Requirement already satisfied: tzdata>=2022.7 in /usr/local/lib/python3.10/dist-packages (from pandas->datasets) (2024.2)\n","Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.10/dist-packages (from python-dateutil>=2.8.2->pandas->datasets) (1.17.0)\n"]}]},{"cell_type":"code","execution_count":null,"metadata":{"id":"ueRyDnvgNgpW"},"outputs":[],"source":["from datasets import Dataset"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"HVBCtqyjNhLn"},"outputs":[],"source":["df = pd.read_csv('./train.csv')"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":424},"id":"f7j8fEl1Nogb","outputId":"c446fd94-7702-4503-dfdc-d04224fe9794","executionInfo":{"status":"ok","timestamp":1735137731701,"user_tz":-330,"elapsed":1710,"user":{"displayName":"Malavika Nair Pambadiyil","userId":"11866192100661929468"}}},"outputs":[{"output_type":"execute_result","data":{"text/plain":[" text Target\n","0 THE LOST VIDEO: Watch MSNBC’S Mika Shamelessly... Fake\n","1 Trump Is Now Threatening A Lawsuit Over Copyr... Fake\n","2 Oklahoma Gun Range Refused Service To Muslim ... Fake\n","3 Republican debate without Trump draws 12.5 mil... True\n","4 SHOCKING REPORT: 50% of Babies in 24 States Bo... Fake\n","... ... ...\n","44893 Syrian Kurdish YPG accuses Turkey of Afrin agg... True\n","44894 Turkey's military says two Turkish soldiers ki... True\n","44895 On Election Eve for five states, Trump rips Cr... True\n","44896 EU's Juncker hails Macron speech as 'very Euro... True\n","44897 Jewish groups in Germany urge crackdown on ant... True\n","\n","[44898 rows x 2 columns]"],"text/html":["\n","
\n","
\n","\n","\n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n","
textTarget
0THE LOST VIDEO: Watch MSNBC’S Mika Shamelessly...Fake
1Trump Is Now Threatening A Lawsuit Over Copyr...Fake
2Oklahoma Gun Range Refused Service To Muslim ...Fake
3Republican debate without Trump draws 12.5 mil...True
4SHOCKING REPORT: 50% of Babies in 24 States Bo...Fake
.........
44893Syrian Kurdish YPG accuses Turkey of Afrin agg...True
44894Turkey's military says two Turkish soldiers ki...True
44895On Election Eve for five states, Trump rips Cr...True
44896EU's Juncker hails Macron speech as 'very Euro...True
44897Jewish groups in Germany urge crackdown on ant...True
\n","

44898 rows × 2 columns

\n","
\n","
\n","\n","
\n"," \n","\n"," \n","\n"," \n","
\n","\n","\n","
\n"," \n","\n","\n","\n"," \n","
\n","\n","
\n"," \n"," \n"," \n","
\n","\n","
\n","
\n"],"application/vnd.google.colaboratory.intrinsic+json":{"type":"dataframe","variable_name":"df","summary":"{\n \"name\": \"df\",\n \"rows\": 44898,\n \"fields\": [\n {\n \"column\": \"text\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 39105,\n \"samples\": [\n \"Seattle judge says Trump travel ban case should continue during appeals. SEATTLE (Reuters) - A U.S. federal judge on Monday said courtroom proceedings over President Donald Trump\\u2019s travel ban should continue in Seattle during an ongoing appeals court review. At a hearing, U.S. District Judge James Robart in Seattle said he was not prepared to slow down the case. Robart directed attorneys for the U.S. Justice Department and Washington state\\u2019s attorney general to prepare for further proceedings in Seattle. \",\n \" Federal Judge Tells Anti-Vaxxers To Go F*ck Themselves, Upholds Strict California Vaccination Law. Anti-vaccination advocates were hoping they could continue exposing the general public to diseases that had been largely wiped out by vaccines, but a judge dashed that hope on Friday.In 2015, California dealt with a months long measles epidemic stemming from a person who was visiting Disneyland.According to the Los Angeles Times:131 California residents were believed to have been infected with measles during the outbreak that began at Disneyland, as well as at least 26 people who resided in seven other states, Canada or Mexico, after visiting the Anaheim theme park or catching the virus from someone who went there.The outbreak created a health crisis in the state, especially since some schools have immunization rates around 50 percent or lower according to state epidemiologist, Dr. Gil Chavez.Measles had been eradicated in America by 2000, but because some crackpot researcher in England published a terribly flawed study claiming that vaccines cause autism, a claim that has been thoroughly debunked by scientists, many paranoid and ignorant parents have decided not to vaccinate their kids, which is why 7 in 10 Californians who got the measles were unvaccinated. If we had higher levels of immunity in the community, this outbreak would not have happened, Chavez said.And the risk of exposure was not just in California schools. Public health officials contacted thousands of Californians in 12 counties potentially exposed to measles, leading to warnings in airports, malls, schools, clinics and hospitals, the Times reported. In one hospital alone, a single person with measles exposed 14 pregnant women and 98 infants, including 44 in the neonatal intensive care unit. After California quelled the epidemic, state lawmakers went to work to make sure such an epidemic never happens again. To that effort, they took particular aim at personal and religious exemptions that anti-vaxxers have taken advantage of over the years to decline to vaccinate their kids. They soon passed a law requiring all children to be vaccinated. The only exemption allowed is if the child has a medical condition, such as a suppressed immune system, that would prevent them from getting the vaccine.But anti-vaxxers threw a hissy fit and filed a lawsuit last month in order to prevent lawmakers from protecting the public health and safety.And U.S. District Judge Dana Sabraw ruled that they can go f*ck themselves and laughed them out of court because state lawmakers have a long history of requiring children to be vaccinated as a condition to school enrollment and plaintiffs have not made a showing that they are entitled to the extraordinary remedy of a preliminary injunction. In short, the law will go into effect this year and now every child will be required to be vaccinated if they want to be enrolled.And that s a good thing.We cannot let irresponsible parents put the public health at risk just because they disagree with science. Measles is one of the most contagious diseases known to man and is even more contagious and deadlier than Ebola.Sixteen years ago this country had wiped out the disease within our shores, and all that effort went to waste because some parents listen more to celebrities like Jim Carrey and Jenny McCarthy than they do to doctors and scientists. That needs to change, and this California law is the first step.Featured image via CBS News\",\n \" Unarmed Black Man Tortured, Maimed, Then Executed By Mississippi Cop (VIDEO). On the night of June 18, Tupelo, Mississippi police officer Tyler Cook pulled over a vehicle for what authorities say was a routine traffic stop. Minutes later, Ronnie Shumpert, a 37-year-old Black father of five, was brutalized, maimed and tortured by that officer. Then he was shot dead.It was 9:38 pm when officer Cook pulled over the vehicle Shumpert was driving. The car belonged to his friend, Charles Foster. Foster was with Shumpert in the car. He witnessed much of what happened that night.Shumpert had a felony warrant for his arrest, yet there s no way the officer could have known that at the time of the traffic stop. He was never ID d. The car he was driving was not registered in his name. To officer Cook, he was just another Black man behind the wheel of a car.As soon as Cook pulled the car over Shumpert ran. Officer Cook pursued him with a police canine.According to witnesses, Shumpert was hiding underneath a house when Cook found him.Police say he immediately attacked the officer and the dog. Witnesses say otherwise. Foster and others say Shumpert immediately tried to surrender, but Cook turned the dog loose on the unarmed man. It attacked his groin, ripping off his testicles.Autopsy photos show that there were deep gashes across his body. Several of Shumpert s teeth were knocked out, others were shoved into his gums.By this time Ronnie Shumpert was likely bleeding out from a gash so large you could fit a baseball in it. His testicles had been shredded by a vicious attack dog and he was suffering from devastating facial wounds. Yet Cook claims that the unarmed father was still a threat. That s why he had to execute him.According to Foster, less than five minutes passed before officer Cook shot Shumpert dead. He fired four shots. Three bullets ripped through Ronnie Shumpert s chest. A fourth bullet entered his stomach.Police say it was ten minutes before an ambulance was called. The nearest hospital was less than a minute away. Video from the night of the lynching shows an ambulance arriving one hour after Cook fired his weapon.Officer Cook has had excessive force complaints filed against him before. The most recent complaint was filed less than two months ago.According to Tupelo s white city attorney, Ben Logan, any accusations of racial profiling, police brutality and corruption in connection with the death of Ronnie Shumpert are just ridiculous. During a press conference held on June 27, Logan showed no concern over the nature and extent of Shumpert s injuries. Instead, he accused the dead man s family of being instigators, claiming that their cries for justice are endangering the peace of the community. Rather than being upset over the brutal torture and unjustifiable death of an unarmed Tupelo resident, Logan went on to stress that he is upset about statements made by the Shumpert family attorney, Carlos Moore, saying they shine a bad light on attorneys.Moore is calling on the Department of Justice to investigate the death of Ronnie Shumpert, as well as the entire Tupelo police department. The family is demanding that officer Cook be immediately terminated from the police force. They also want the canine that bit off Ronnie Shumpert s testicles retired immediately.Shumpert s family is also seeking answers from the police department. Some of the questions are about officer Cook s history and length of time on the force. They also want to know why the first ambulance arrived on the scene an hour after Ronnie Shumpert was shot.Aside from these demands, Moore is calling for the establishment of an independent citizen s review board to oversee accusations of police brutality and excessive force in Tupelo.Tupelo police are not equipped with body cameras. That s not acceptable in 2016.As reported by the Atlanta Black Star, New York Daily News and other media outlets, this was a modern day lynching. Out of sight of cameras, Officer Cook allowed his canine to mutilate Ronnie Shumpert in the most brutal way possible.Witness testimony shows that Shumpert was trying to surrender when Officer Cook and the canine attacked him. Autopsy photos demonstrate that after being brutalized by Cook and his attack dog, he was defenseless at the time the officer opened fire on him.Moore, accompanied by Ronnie Shumpert s family, held a press conference on June 27.Here s video from both the Shumpert family s press conference and the press conference held by Tupelo city attorney, Ben Logan, courtesy of Northeast Mississippi Daily Journal on YouTube. Image credit: Shumpert family photo\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Target\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 2,\n \"samples\": [\n \"True\",\n \"Fake\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}"}},"metadata":{},"execution_count":21}],"source":["df"]},{"cell_type":"code","source":["# Replace 'Fake' with 0 and 'True' with 1 in the Target column\n","df['Target'] = df['Target'].map({'Fake': 1, 'True': 0})\n","\n","# Verify the changes\n","print(df.head())"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"xCdVRc53P5ns","executionInfo":{"status":"ok","timestamp":1735137737766,"user_tz":-330,"elapsed":1055,"user":{"displayName":"Malavika Nair Pambadiyil","userId":"11866192100661929468"}},"outputId":"c1bc9373-f019-49f0-bc7c-dd2d289e661c"},"execution_count":null,"outputs":[{"output_type":"stream","name":"stdout","text":[" text Target\n","0 THE LOST VIDEO: Watch MSNBC’S Mika Shamelessly... 1\n","1 Trump Is Now Threatening A Lawsuit Over Copyr... 1\n","2 Oklahoma Gun Range Refused Service To Muslim ... 1\n","3 Republican debate without Trump draws 12.5 mil... 0\n","4 SHOCKING REPORT: 50% of Babies in 24 States Bo... 1\n"]}]},{"cell_type":"code","source":["df"],"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":424},"id":"q9RmfOzcRODo","executionInfo":{"status":"ok","timestamp":1735137755486,"user_tz":-330,"elapsed":2953,"user":{"displayName":"Malavika Nair Pambadiyil","userId":"11866192100661929468"}},"outputId":"44f3ff00-5108-473d-9735-abfc0420dd51"},"execution_count":null,"outputs":[{"output_type":"execute_result","data":{"text/plain":[" text Target\n","0 THE LOST VIDEO: Watch MSNBC’S Mika Shamelessly... 1\n","1 Trump Is Now Threatening A Lawsuit Over Copyr... 1\n","2 Oklahoma Gun Range Refused Service To Muslim ... 1\n","3 Republican debate without Trump draws 12.5 mil... 0\n","4 SHOCKING REPORT: 50% of Babies in 24 States Bo... 1\n","... ... ...\n","44893 Syrian Kurdish YPG accuses Turkey of Afrin agg... 0\n","44894 Turkey's military says two Turkish soldiers ki... 0\n","44895 On Election Eve for five states, Trump rips Cr... 0\n","44896 EU's Juncker hails Macron speech as 'very Euro... 0\n","44897 Jewish groups in Germany urge crackdown on ant... 0\n","\n","[44898 rows x 2 columns]"],"text/html":["\n","
\n","
\n","\n","\n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n","
textTarget
0THE LOST VIDEO: Watch MSNBC’S Mika Shamelessly...1
1Trump Is Now Threatening A Lawsuit Over Copyr...1
2Oklahoma Gun Range Refused Service To Muslim ...1
3Republican debate without Trump draws 12.5 mil...0
4SHOCKING REPORT: 50% of Babies in 24 States Bo...1
.........
44893Syrian Kurdish YPG accuses Turkey of Afrin agg...0
44894Turkey's military says two Turkish soldiers ki...0
44895On Election Eve for five states, Trump rips Cr...0
44896EU's Juncker hails Macron speech as 'very Euro...0
44897Jewish groups in Germany urge crackdown on ant...0
\n","

44898 rows × 2 columns

\n","
\n","
\n","\n","
\n"," \n","\n"," \n","\n"," \n","
\n","\n","\n","
\n"," \n","\n","\n","\n"," \n","
\n","\n","
\n"," \n"," \n"," \n","
\n","\n","
\n","
\n"],"application/vnd.google.colaboratory.intrinsic+json":{"type":"dataframe","variable_name":"df","summary":"{\n \"name\": \"df\",\n \"rows\": 44898,\n \"fields\": [\n {\n \"column\": \"text\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 39105,\n \"samples\": [\n \"Seattle judge says Trump travel ban case should continue during appeals. SEATTLE (Reuters) - A U.S. federal judge on Monday said courtroom proceedings over President Donald Trump\\u2019s travel ban should continue in Seattle during an ongoing appeals court review. At a hearing, U.S. District Judge James Robart in Seattle said he was not prepared to slow down the case. Robart directed attorneys for the U.S. Justice Department and Washington state\\u2019s attorney general to prepare for further proceedings in Seattle. \",\n \" Federal Judge Tells Anti-Vaxxers To Go F*ck Themselves, Upholds Strict California Vaccination Law. Anti-vaccination advocates were hoping they could continue exposing the general public to diseases that had been largely wiped out by vaccines, but a judge dashed that hope on Friday.In 2015, California dealt with a months long measles epidemic stemming from a person who was visiting Disneyland.According to the Los Angeles Times:131 California residents were believed to have been infected with measles during the outbreak that began at Disneyland, as well as at least 26 people who resided in seven other states, Canada or Mexico, after visiting the Anaheim theme park or catching the virus from someone who went there.The outbreak created a health crisis in the state, especially since some schools have immunization rates around 50 percent or lower according to state epidemiologist, Dr. Gil Chavez.Measles had been eradicated in America by 2000, but because some crackpot researcher in England published a terribly flawed study claiming that vaccines cause autism, a claim that has been thoroughly debunked by scientists, many paranoid and ignorant parents have decided not to vaccinate their kids, which is why 7 in 10 Californians who got the measles were unvaccinated. If we had higher levels of immunity in the community, this outbreak would not have happened, Chavez said.And the risk of exposure was not just in California schools. Public health officials contacted thousands of Californians in 12 counties potentially exposed to measles, leading to warnings in airports, malls, schools, clinics and hospitals, the Times reported. In one hospital alone, a single person with measles exposed 14 pregnant women and 98 infants, including 44 in the neonatal intensive care unit. After California quelled the epidemic, state lawmakers went to work to make sure such an epidemic never happens again. To that effort, they took particular aim at personal and religious exemptions that anti-vaxxers have taken advantage of over the years to decline to vaccinate their kids. They soon passed a law requiring all children to be vaccinated. The only exemption allowed is if the child has a medical condition, such as a suppressed immune system, that would prevent them from getting the vaccine.But anti-vaxxers threw a hissy fit and filed a lawsuit last month in order to prevent lawmakers from protecting the public health and safety.And U.S. District Judge Dana Sabraw ruled that they can go f*ck themselves and laughed them out of court because state lawmakers have a long history of requiring children to be vaccinated as a condition to school enrollment and plaintiffs have not made a showing that they are entitled to the extraordinary remedy of a preliminary injunction. In short, the law will go into effect this year and now every child will be required to be vaccinated if they want to be enrolled.And that s a good thing.We cannot let irresponsible parents put the public health at risk just because they disagree with science. Measles is one of the most contagious diseases known to man and is even more contagious and deadlier than Ebola.Sixteen years ago this country had wiped out the disease within our shores, and all that effort went to waste because some parents listen more to celebrities like Jim Carrey and Jenny McCarthy than they do to doctors and scientists. That needs to change, and this California law is the first step.Featured image via CBS News\",\n \" Unarmed Black Man Tortured, Maimed, Then Executed By Mississippi Cop (VIDEO). On the night of June 18, Tupelo, Mississippi police officer Tyler Cook pulled over a vehicle for what authorities say was a routine traffic stop. Minutes later, Ronnie Shumpert, a 37-year-old Black father of five, was brutalized, maimed and tortured by that officer. Then he was shot dead.It was 9:38 pm when officer Cook pulled over the vehicle Shumpert was driving. The car belonged to his friend, Charles Foster. Foster was with Shumpert in the car. He witnessed much of what happened that night.Shumpert had a felony warrant for his arrest, yet there s no way the officer could have known that at the time of the traffic stop. He was never ID d. The car he was driving was not registered in his name. To officer Cook, he was just another Black man behind the wheel of a car.As soon as Cook pulled the car over Shumpert ran. Officer Cook pursued him with a police canine.According to witnesses, Shumpert was hiding underneath a house when Cook found him.Police say he immediately attacked the officer and the dog. Witnesses say otherwise. Foster and others say Shumpert immediately tried to surrender, but Cook turned the dog loose on the unarmed man. It attacked his groin, ripping off his testicles.Autopsy photos show that there were deep gashes across his body. Several of Shumpert s teeth were knocked out, others were shoved into his gums.By this time Ronnie Shumpert was likely bleeding out from a gash so large you could fit a baseball in it. His testicles had been shredded by a vicious attack dog and he was suffering from devastating facial wounds. Yet Cook claims that the unarmed father was still a threat. That s why he had to execute him.According to Foster, less than five minutes passed before officer Cook shot Shumpert dead. He fired four shots. Three bullets ripped through Ronnie Shumpert s chest. A fourth bullet entered his stomach.Police say it was ten minutes before an ambulance was called. The nearest hospital was less than a minute away. Video from the night of the lynching shows an ambulance arriving one hour after Cook fired his weapon.Officer Cook has had excessive force complaints filed against him before. The most recent complaint was filed less than two months ago.According to Tupelo s white city attorney, Ben Logan, any accusations of racial profiling, police brutality and corruption in connection with the death of Ronnie Shumpert are just ridiculous. During a press conference held on June 27, Logan showed no concern over the nature and extent of Shumpert s injuries. Instead, he accused the dead man s family of being instigators, claiming that their cries for justice are endangering the peace of the community. Rather than being upset over the brutal torture and unjustifiable death of an unarmed Tupelo resident, Logan went on to stress that he is upset about statements made by the Shumpert family attorney, Carlos Moore, saying they shine a bad light on attorneys.Moore is calling on the Department of Justice to investigate the death of Ronnie Shumpert, as well as the entire Tupelo police department. The family is demanding that officer Cook be immediately terminated from the police force. They also want the canine that bit off Ronnie Shumpert s testicles retired immediately.Shumpert s family is also seeking answers from the police department. Some of the questions are about officer Cook s history and length of time on the force. They also want to know why the first ambulance arrived on the scene an hour after Ronnie Shumpert was shot.Aside from these demands, Moore is calling for the establishment of an independent citizen s review board to oversee accusations of police brutality and excessive force in Tupelo.Tupelo police are not equipped with body cameras. That s not acceptable in 2016.As reported by the Atlanta Black Star, New York Daily News and other media outlets, this was a modern day lynching. Out of sight of cameras, Officer Cook allowed his canine to mutilate Ronnie Shumpert in the most brutal way possible.Witness testimony shows that Shumpert was trying to surrender when Officer Cook and the canine attacked him. Autopsy photos demonstrate that after being brutalized by Cook and his attack dog, he was defenseless at the time the officer opened fire on him.Moore, accompanied by Ronnie Shumpert s family, held a press conference on June 27.Here s video from both the Shumpert family s press conference and the press conference held by Tupelo city attorney, Ben Logan, courtesy of Northeast Mississippi Daily Journal on YouTube. Image credit: Shumpert family photo\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Target\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0,\n \"min\": 0,\n \"max\": 1,\n \"num_unique_values\": 2,\n \"samples\": [\n 0,\n 1\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}"}},"metadata":{},"execution_count":23}]},{"cell_type":"code","execution_count":null,"metadata":{"id":"L0ET6Z83Pcxu"},"outputs":[],"source":["df['labels'] = df['Target']"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"39Zv6HBJPgEt"},"outputs":[],"source":["df = df[['text', 'labels']]"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"bPGVPY17NI7x"},"outputs":[],"source":["dataset = Dataset.from_pandas(df)"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"3LTGwWrINmZq","outputId":"b6b74da8-4ea3-401b-ab00-546d763410e0","executionInfo":{"status":"ok","timestamp":1735137775658,"user_tz":-330,"elapsed":687,"user":{"displayName":"Malavika Nair Pambadiyil","userId":"11866192100661929468"}}},"outputs":[{"output_type":"execute_result","data":{"text/plain":["Dataset({\n"," features: ['text', 'labels'],\n"," num_rows: 44898\n","})"]},"metadata":{},"execution_count":27}],"source":["dataset"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"3DrWrMiDd7e-","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1735137780559,"user_tz":-330,"elapsed":2560,"user":{"displayName":"Malavika Nair Pambadiyil","userId":"11866192100661929468"}},"outputId":"b5b395d4-7bc9-46b7-fc65-74439b89a27a"},"outputs":[{"output_type":"stream","name":"stderr","text":["/usr/local/lib/python3.10/dist-packages/huggingface_hub/utils/_auth.py:94: UserWarning: \n","The secret `HF_TOKEN` does not exist in your Colab secrets.\n","To authenticate with the Hugging Face Hub, create a token in your settings tab (https://huggingface.co/settings/tokens), set it as secret in your Google Colab and restart your session.\n","You will be able to reuse this secret in all of your notebooks.\n","Please note that authentication is recommended but still optional to access public models or datasets.\n"," warnings.warn(\n"]}],"source":["import torch\n","from transformers import AutoTokenizer, AutoModel, pipeline\n","\n","model_name = 'distilbert-base-uncased-finetuned-sst-2-english'\n","tokenizer = AutoTokenizer.from_pretrained(model_name)"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"dRJOO2c5PT3V"},"outputs":[],"source":["def preprocess_function(examples):\n"," return tokenizer(examples[\"text\"], padding=True, truncation=True)"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":49,"referenced_widgets":["8f2a9c284f3f4cd292f2cf82d9ac1058","12a29ededa3f4574aa23094b855b4170","8659bef2fe2d470389267d5ac2058855","922929a976374a91a65a4461fdd24184","78837b15b48e4637a37098980fad1114","7285cb5c22e74cdb8fb3301f74cedfd6","7d41d0ca750a4838bf1d58c6cf5d2e38","ea4f30d4f46143b5bf5310519866b93f","28b841ebcc084555bd01481d2d8542cd","325dab348bf8461ea6ae818535bd5d27","9cac6f2fbc2b41228769dd1a118ec603"]},"id":"hCxs-HasPQ7s","outputId":"f7d8b4f6-89ef-4597-e030-2bdfa21c3b0c","executionInfo":{"status":"ok","timestamp":1735137903759,"user_tz":-330,"elapsed":88621,"user":{"displayName":"Malavika Nair Pambadiyil","userId":"11866192100661929468"}}},"outputs":[{"output_type":"display_data","data":{"text/plain":["Map: 0%| | 0/44898 [00:00"],"text/html":["\n","
\n"," \n"," \n"," [6320/6320 2:01:21, Epoch 10/10]\n","
\n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n","
EpochTraining LossValidation LossAccuracy
11.1230000.6270890.688196
20.6186000.5550460.838307
30.5672000.5078000.847216
40.5023000.4751750.868820
50.4817000.4515930.874833
60.4665000.4351290.879287
70.4567000.4228200.879733
80.4404000.4156250.883296
90.4360000.4109880.883073
100.4309000.4097350.883296

"]},"metadata":{}},{"output_type":"execute_result","data":{"text/plain":["TrainOutput(global_step=6320, training_loss=0.5362479149540769, metrics={'train_runtime': 7283.4335, 'train_samples_per_second': 55.479, 'train_steps_per_second': 0.868, 'total_flos': 5.352742644891648e+16, 'train_loss': 0.5362479149540769, 'epoch': 10.0})"]},"metadata":{},"execution_count":39}],"source":["from transformers import Trainer, TrainingArguments\n","\n","trainer = Trainer(\n"," model=model, train_dataset=dataset_splitted['train'],\n"," eval_dataset=dataset_splitted['test'],\n"," compute_metrics=compute_metrics,\n"," args=TrainingArguments(\n"," load_best_model_at_end=True,\n"," output_dir=\"./my_saved_model\", overwrite_output_dir=True,\n"," num_train_epochs=10, per_device_train_batch_size=64,\n"," per_device_eval_batch_size=64,\n"," eval_strategy = \"epoch\",\n"," save_strategy = \"epoch\",\n"," save_steps=10_000, save_total_limit=2),\n",")\n","\n","trainer.train()"]},{"cell_type":"code","source":[],"metadata":{"id":"Z3JPGFryJyjA"},"execution_count":null,"outputs":[]}],"metadata":{"accelerator":"GPU","colab":{"provenance":[],"gpuType":"T4"},"kernelspec":{"display_name":"Python 3","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.7.12"},"widgets":{"application/vnd.jupyter.widget-state+json":{"8f2a9c284f3f4cd292f2cf82d9ac1058":{"model_module":"@jupyter-widgets/controls","model_name":"HBoxModel","model_module_version":"1.5.0","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_12a29ededa3f4574aa23094b855b4170","IPY_MODEL_8659bef2fe2d470389267d5ac2058855","IPY_MODEL_922929a976374a91a65a4461fdd24184"],"layout":"IPY_MODEL_78837b15b48e4637a37098980fad1114"}},"12a29ededa3f4574aa23094b855b4170":{"model_module":"@jupyter-widgets/controls","model_name":"HTMLModel","model_module_version":"1.5.0","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HTMLView","description":"","description_tooltip":null,"layout":"IPY_MODEL_7285cb5c22e74cdb8fb3301f74cedfd6","placeholder":"​","style":"IPY_MODEL_7d41d0ca750a4838bf1d58c6cf5d2e38","value":"Map: 100%"}},"8659bef2fe2d470389267d5ac2058855":{"model_module":"@jupyter-widgets/controls","model_name":"FloatProgressModel","model_module_version":"1.5.0","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"ProgressView","bar_style":"success","description":"","description_tooltip":null,"layout":"IPY_MODEL_ea4f30d4f46143b5bf5310519866b93f","max":44898,"min":0,"orientation":"horizontal","style":"IPY_MODEL_28b841ebcc084555bd01481d2d8542cd","value":44898}},"922929a976374a91a65a4461fdd24184":{"model_module":"@jupyter-widgets/controls","model_name":"HTMLModel","model_module_version":"1.5.0","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HTMLView","description":"","description_tooltip":null,"layout":"IPY_MODEL_325dab348bf8461ea6ae818535bd5d27","placeholder":"​","style":"IPY_MODEL_9cac6f2fbc2b41228769dd1a118ec603","value":" 44898/44898 [01:27<00:00, 487.66 examples/s]"}},"78837b15b48e4637a37098980fad1114":{"model_module":"@jupyter-widgets/base","model_name":"LayoutModel","model_module_version":"1.2.0","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"7285cb5c22e74cdb8fb3301f74cedfd6":{"model_module":"@jupyter-widgets/base","model_name":"LayoutModel","model_module_version":"1.2.0","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"7d41d0ca750a4838bf1d58c6cf5d2e38":{"model_module":"@jupyter-widgets/controls","model_name":"DescriptionStyleModel","model_module_version":"1.5.0","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}},"ea4f30d4f46143b5bf5310519866b93f":{"model_module":"@jupyter-widgets/base","model_name":"LayoutModel","model_module_version":"1.2.0","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"28b841ebcc084555bd01481d2d8542cd":{"model_module":"@jupyter-widgets/controls","model_name":"ProgressStyleModel","model_module_version":"1.5.0","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"325dab348bf8461ea6ae818535bd5d27":{"model_module":"@jupyter-widgets/base","model_name":"LayoutModel","model_module_version":"1.2.0","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"9cac6f2fbc2b41228769dd1a118ec603":{"model_module":"@jupyter-widgets/controls","model_name":"DescriptionStyleModel","model_module_version":"1.5.0","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}}}}},"nbformat":4,"nbformat_minor":0}