{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Harvard USPTO Dataset Training" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Importing Packages\n", "\n", "We first need to import the actual USPTO dataset." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Requirement already satisfied: datasets in /opt/conda/lib/python3.10/site-packages (2.11.0)\n", "Requirement already satisfied: fsspec[http]>=2021.11.1 in /opt/conda/lib/python3.10/site-packages (from datasets) (2022.8.2)\n", "Requirement already satisfied: numpy>=1.17 in /opt/conda/lib/python3.10/site-packages (from datasets) (1.23.3)\n", "Requirement already satisfied: tqdm>=4.62.1 in /opt/conda/lib/python3.10/site-packages (from datasets) (4.64.1)\n", "Requirement already satisfied: requests>=2.19.0 in /opt/conda/lib/python3.10/site-packages (from datasets) (2.28.1)\n", "Requirement already satisfied: pyarrow>=8.0.0 in /opt/conda/lib/python3.10/site-packages (from datasets) (9.0.0)\n", "Requirement already satisfied: pyyaml>=5.1 in /opt/conda/lib/python3.10/site-packages (from datasets) (6.0)\n", "Requirement already satisfied: pandas in /opt/conda/lib/python3.10/site-packages (from datasets) (1.5.0)\n", "Requirement already satisfied: huggingface-hub<1.0.0,>=0.11.0 in /opt/conda/lib/python3.10/site-packages (from datasets) (0.13.4)\n", "Requirement already satisfied: responses<0.19 in /opt/conda/lib/python3.10/site-packages (from datasets) (0.18.0)\n", "Requirement already satisfied: xxhash in /opt/conda/lib/python3.10/site-packages (from datasets) (3.2.0)\n", "Requirement already satisfied: dill<0.3.7,>=0.3.0 in /opt/conda/lib/python3.10/site-packages (from datasets) (0.3.6)\n", "Requirement already satisfied: aiohttp in /opt/conda/lib/python3.10/site-packages (from datasets) (3.8.4)\n", "Requirement already satisfied: packaging in /opt/conda/lib/python3.10/site-packages (from datasets) (21.3)\n", "Requirement already satisfied: multiprocess in /opt/conda/lib/python3.10/site-packages (from datasets) (0.70.14)\n", "Requirement already satisfied: attrs>=17.3.0 in /opt/conda/lib/python3.10/site-packages (from aiohttp->datasets) (22.1.0)\n", "Requirement already satisfied: aiosignal>=1.1.2 in /opt/conda/lib/python3.10/site-packages (from aiohttp->datasets) (1.3.1)\n", "Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in /opt/conda/lib/python3.10/site-packages (from aiohttp->datasets) (4.0.2)\n", "Requirement already satisfied: multidict<7.0,>=4.5 in /opt/conda/lib/python3.10/site-packages (from aiohttp->datasets) (6.0.4)\n", "Requirement already satisfied: yarl<2.0,>=1.0 in /opt/conda/lib/python3.10/site-packages (from aiohttp->datasets) (1.8.2)\n", "Requirement already satisfied: frozenlist>=1.1.1 in /opt/conda/lib/python3.10/site-packages (from aiohttp->datasets) (1.3.3)\n", "Requirement already satisfied: charset-normalizer<4.0,>=2.0 in /opt/conda/lib/python3.10/site-packages (from aiohttp->datasets) (2.1.1)\n", "Requirement already satisfied: typing-extensions>=3.7.4.3 in /opt/conda/lib/python3.10/site-packages (from huggingface-hub<1.0.0,>=0.11.0->datasets) (4.4.0)\n", "Requirement already satisfied: filelock in /opt/conda/lib/python3.10/site-packages (from huggingface-hub<1.0.0,>=0.11.0->datasets) (3.12.0)\n", "Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in /opt/conda/lib/python3.10/site-packages (from packaging->datasets) (3.0.9)\n", "Requirement already satisfied: certifi>=2017.4.17 in /opt/conda/lib/python3.10/site-packages (from requests>=2.19.0->datasets) (2022.9.24)\n", "Requirement already satisfied: idna<4,>=2.5 in /opt/conda/lib/python3.10/site-packages (from requests>=2.19.0->datasets) (3.4)\n", "Requirement already satisfied: urllib3<1.27,>=1.21.1 in /opt/conda/lib/python3.10/site-packages (from requests>=2.19.0->datasets) (1.26.11)\n", "Requirement already satisfied: python-dateutil>=2.8.1 in /opt/conda/lib/python3.10/site-packages (from pandas->datasets) (2.8.2)\n", "Requirement already satisfied: pytz>=2020.1 in /opt/conda/lib/python3.10/site-packages (from pandas->datasets) (2022.4)\n", "Requirement already satisfied: six>=1.5 in /opt/conda/lib/python3.10/site-packages (from python-dateutil>=2.8.1->pandas->datasets) (1.16.0)\n" ] } ], "source": [ "!pip install datasets" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "from datasets import load_dataset\n", "import pandas as pd\n", "import numpy as np" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Loading the Dataset" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We need to extract the dataset. We filter only for those in January 2016." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Found cached dataset hupd (/home/jovyan/.cache/huggingface/datasets/HUPD___hupd/sample-a4eeba92b4229e93/0.0.0/6920d2def8fd7767046c0470603357f76866e5a09c97e19571896bfdca521142)\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "e39fd26828774c8e9d159a8b5d91c4f5", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/2 [00:00\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", " \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", " \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", "
patent_numberdecisiontitleabstractclaimsbackgroundsummarydescriptioncpc_labelipc_labelfiling_datepatent_issue_datedate_publishedexaminer_id
013261748ACCEPTEDMINI-OPTICAL NETWORK TERMINAL (ONT)The present invention relates to passive optic...1. A compact optical network terminal, compris...<SOH> BACKGROUND OF THE INVENTION <EOH>A netwo...<SOH> SUMMARY OF THE INVENTION <EOH>An aspect ...FIELD OF THE INVENTION The present invention r...H04Q110071H04Q110020160120201706062016052695191.0
113995128ACCEPTEDAPPARATUS FOR FORMING AND READING AN IDENTIFIC...Embodiments of the invention provide a method ...1. A method comprising: using a first reader t...<SOH> BACKGROUND OF THE INVENTION <EOH>Identif...<SOH> SUMMARY OF THE INVENTION <EOH>In accorda...CROSS-REFERENCE TO RELATED APPLICATIONS The pr...G06K500G06K50020160112201603222014010259514.0
214241799PENDINGPORTABLE DRUG DISPENSERA portable drug dispenser includes a chamber f...1. A portable drug dispenser, comprising: a ch...This application claims priority from U.S. app...A61J70084A61J700201601042017111695928.0
314348792ACCEPTEDLIQUID-COOLED HEAT EXCHANGERA crystal growth furnace comprising a crucible...1. A crystal growth furnace for growing a crys...<SOH> BACKGROUND OF THE INVENTION <EOH>1. Fiel...<SOH> SUMMARY OF THE INVENTION <EOH>The presen...CROSS-REFERENCE TO RELATED APPLICATIONS The pr...C30B11003C30B110020160111201805292016051263013.0
414360978REJECTEDSOLE MEMBER OF FOOTWEARA shoe midsole is composed of a base plate (1)...1. A sole member of footwear comprising a base...<SOH> BACKGROUND ART <EOH>When the heel touche...<SOH> BRIEF DESCRIPTION OF THE DRAWINGS <EOH>F...TECHNICAL FIELD The present invention relates ...A43B13181A43B1318201601132016051294490.0
.............................................
1614815002394ACCEPTEDROBOT HAND CONTROLLING METHOD AND ROBOTICS DEVICEA robot hand controlling method executes calcu...1. A controlling method of a robot hand, the r...<SOH> BACKGROUND OF THE INVENTION <EOH>1. Fiel...<SOH> SUMMARY OF THE INVENTION <EOH>An object ...BACKGROUND OF THE INVENTION 1. Field of the In...B25J91612B25J91620160120201807102016080466148.0
1614915002396REJECTEDIMMUNOGLOBULIN FUSION PROTEINS AND USES THEREOFA fusion protein is disclosed. The fusion prot...1. A fusion protein comprising an Fc fragment ...<SOH> BACKGROUND OF THE INVENTION <EOH>An immu...<SOH> SUMMARY OF THE INVENTION <EOH>The presen...The present application is a U.S. Nonprovision...C07K14745C07K14745201601202016121595819.0
1615015330955REJECTEDPIPE EXTRACTION TOOLA pipe extraction tool that grips the inside o...1. A pipe extraction tool for extracting a pip...<SOH> BACKGROUND OF THE INVENTION <EOH>1. Fiel...<SOH> BRIEF SUMMARY OF THE INVENTION <EOH>The ...CROSS-REFERENCES TO RELATED APPLICATIONS Not a...B25B2714B25B2714201601202017090795661.0
1615115330961PENDINGMolded parts with thermoplastic cellulose biop...A longitudinal extending body with oriented fi...1. A longitudinal body of a solidified organic...<SOH> BACKGROUND OF INVENTION <EOH>In the medi...<SOH> BRIEF SUMMARY OF THE PRESENT INVENTION <...CROSS REFERENCES Application claims priority o...A61L3106A61L3106201601112017101996956.0
1615215330968PENDINGTransmission method with double directivityA transmission method using a massive MIMO (Mu...1. Transmission method with double directivity...<SOH> BACKGROUND OF THE INVENTION <EOH><SOH> BRIEF SUMMARY OF THE INVENTION <EOH>The ...BACKGROUND OF THE INVENTION Field of the Inven...H04B7043H04B704201601142018032970883.0
\n", "

16153 rows × 14 columns

\n", "" ], "text/plain": [ " patent_number decision \\\n", "0 13261748 ACCEPTED \n", "1 13995128 ACCEPTED \n", "2 14241799 PENDING \n", "3 14348792 ACCEPTED \n", "4 14360978 REJECTED \n", "... ... ... \n", "16148 15002394 ACCEPTED \n", "16149 15002396 REJECTED \n", "16150 15330955 REJECTED \n", "16151 15330961 PENDING \n", "16152 15330968 PENDING \n", "\n", " title \\\n", "0 MINI-OPTICAL NETWORK TERMINAL (ONT) \n", "1 APPARATUS FOR FORMING AND READING AN IDENTIFIC... \n", "2 PORTABLE DRUG DISPENSER \n", "3 LIQUID-COOLED HEAT EXCHANGER \n", "4 SOLE MEMBER OF FOOTWEAR \n", "... ... \n", "16148 ROBOT HAND CONTROLLING METHOD AND ROBOTICS DEVICE \n", "16149 IMMUNOGLOBULIN FUSION PROTEINS AND USES THEREOF \n", "16150 PIPE EXTRACTION TOOL \n", "16151 Molded parts with thermoplastic cellulose biop... \n", "16152 Transmission method with double directivity \n", "\n", " abstract \\\n", "0 The present invention relates to passive optic... \n", "1 Embodiments of the invention provide a method ... \n", "2 A portable drug dispenser includes a chamber f... \n", "3 A crystal growth furnace comprising a crucible... \n", "4 A shoe midsole is composed of a base plate (1)... \n", "... ... \n", "16148 A robot hand controlling method executes calcu... \n", "16149 A fusion protein is disclosed. The fusion prot... \n", "16150 A pipe extraction tool that grips the inside o... \n", "16151 A longitudinal extending body with oriented fi... \n", "16152 A transmission method using a massive MIMO (Mu... \n", "\n", " claims \\\n", "0 1. A compact optical network terminal, compris... \n", "1 1. A method comprising: using a first reader t... \n", "2 1. A portable drug dispenser, comprising: a ch... \n", "3 1. A crystal growth furnace for growing a crys... \n", "4 1. A sole member of footwear comprising a base... \n", "... ... \n", "16148 1. A controlling method of a robot hand, the r... \n", "16149 1. A fusion protein comprising an Fc fragment ... \n", "16150 1. A pipe extraction tool for extracting a pip... \n", "16151 1. A longitudinal body of a solidified organic... \n", "16152 1. Transmission method with double directivity... \n", "\n", " background \\\n", "0 BACKGROUND OF THE INVENTION A netwo... \n", "1 BACKGROUND OF THE INVENTION Identif... \n", "2 \n", "3 BACKGROUND OF THE INVENTION 1. Fiel... \n", "4 BACKGROUND ART When the heel touche... \n", "... ... \n", "16148 BACKGROUND OF THE INVENTION 1. Fiel... \n", "16149 BACKGROUND OF THE INVENTION An immu... \n", "16150 BACKGROUND OF THE INVENTION 1. Fiel... \n", "16151 BACKGROUND OF INVENTION In the medi... \n", "16152 BACKGROUND OF THE INVENTION \n", "\n", " summary \\\n", "0 SUMMARY OF THE INVENTION An aspect ... \n", "1 SUMMARY OF THE INVENTION In accorda... \n", "2 \n", "3 SUMMARY OF THE INVENTION The presen... \n", "4 BRIEF DESCRIPTION OF THE DRAWINGS F... \n", "... ... \n", "16148 SUMMARY OF THE INVENTION An object ... \n", "16149 SUMMARY OF THE INVENTION The presen... \n", "16150 BRIEF SUMMARY OF THE INVENTION The ... \n", "16151 BRIEF SUMMARY OF THE PRESENT INVENTION <... \n", "16152 BRIEF SUMMARY OF THE INVENTION The ... \n", "\n", " description cpc_label \\\n", "0 FIELD OF THE INVENTION The present invention r... H04Q110071 \n", "1 CROSS-REFERENCE TO RELATED APPLICATIONS The pr... G06K500 \n", "2 This application claims priority from U.S. app... A61J70084 \n", "3 CROSS-REFERENCE TO RELATED APPLICATIONS The pr... C30B11003 \n", "4 TECHNICAL FIELD The present invention relates ... A43B13181 \n", "... ... ... \n", "16148 BACKGROUND OF THE INVENTION 1. Field of the In... B25J91612 \n", "16149 The present application is a U.S. Nonprovision... C07K14745 \n", "16150 CROSS-REFERENCES TO RELATED APPLICATIONS Not a... B25B2714 \n", "16151 CROSS REFERENCES Application claims priority o... A61L3106 \n", "16152 BACKGROUND OF THE INVENTION Field of the Inven... H04B7043 \n", "\n", " ipc_label filing_date patent_issue_date date_published examiner_id \n", "0 H04Q1100 20160120 20170606 20160526 95191.0 \n", "1 G06K500 20160112 20160322 20140102 59514.0 \n", "2 A61J700 20160104 20171116 95928.0 \n", "3 C30B1100 20160111 20180529 20160512 63013.0 \n", "4 A43B1318 20160113 20160512 94490.0 \n", "... ... ... ... ... ... \n", "16148 B25J916 20160120 20180710 20160804 66148.0 \n", "16149 C07K14745 20160120 20161215 95819.0 \n", "16150 B25B2714 20160120 20170907 95661.0 \n", "16151 A61L3106 20160111 20171019 96956.0 \n", "16152 H04B704 20160114 20180329 70883.0 \n", "\n", "[16153 rows x 14 columns]" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_train" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Pre-Processing the Data" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We are interested in the following columns:\n", "- Abstract\n", "- Claims\n", "- Decision <- our `y`\n", "\n", "Let's preprocess them both out of our training and validation data\n", "\n", "Also, consider that the \"Decision\" column has three types of values: \"Accepted\", \"Rejected\", and \"Pending\". To remove unecessary baggage, we will be only looking for \"Accepted\" and \"Rejected\"." ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "necessary_columns = [\"abstract\",\"claims\",\"decision\"]\n", "output_values = ['ACCEPTED','REJECTED'] " ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "trainFeaturesToDrop = [col for col in list(df_train.columns) if col not in necessary_columns]\n", "trainDF = df_train.dropna()\n", "trainDF.drop(columns=trainFeaturesToDrop, inplace=True)\n", "trainDF = trainDF[trainDF['decision'].isin(output_values)]" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
decisionabstractclaims
0ACCEPTEDThe present invention relates to passive optic...1. A compact optical network terminal, compris...
1ACCEPTEDEmbodiments of the invention provide a method ...1. A method comprising: using a first reader t...
3ACCEPTEDA crystal growth furnace comprising a crucible...1. A crystal growth furnace for growing a crys...
4REJECTEDA shoe midsole is composed of a base plate (1)...1. A sole member of footwear comprising a base...
5ACCEPTEDA ratchet tool includes a shaft member, a hand...1. A ratchet tool, comprising a shaft member, ...
............
16144ACCEPTEDA wavelength tunable laser device, including: ...1. A wavelength tunable laser device, comprisi...
16145ACCEPTEDIn one aspect, a method for use in preparing a...1. (canceled) 2. The method of claim 19, where...
16148ACCEPTEDA robot hand controlling method executes calcu...1. A controlling method of a robot hand, the r...
16149REJECTEDA fusion protein is disclosed. The fusion prot...1. A fusion protein comprising an Fc fragment ...
16150REJECTEDA pipe extraction tool that grips the inside o...1. A pipe extraction tool for extracting a pip...
\n", "

8719 rows × 3 columns

\n", "
" ], "text/plain": [ " decision abstract \\\n", "0 ACCEPTED The present invention relates to passive optic... \n", "1 ACCEPTED Embodiments of the invention provide a method ... \n", "3 ACCEPTED A crystal growth furnace comprising a crucible... \n", "4 REJECTED A shoe midsole is composed of a base plate (1)... \n", "5 ACCEPTED A ratchet tool includes a shaft member, a hand... \n", "... ... ... \n", "16144 ACCEPTED A wavelength tunable laser device, including: ... \n", "16145 ACCEPTED In one aspect, a method for use in preparing a... \n", "16148 ACCEPTED A robot hand controlling method executes calcu... \n", "16149 REJECTED A fusion protein is disclosed. The fusion prot... \n", "16150 REJECTED A pipe extraction tool that grips the inside o... \n", "\n", " claims \n", "0 1. A compact optical network terminal, compris... \n", "1 1. A method comprising: using a first reader t... \n", "3 1. A crystal growth furnace for growing a crys... \n", "4 1. A sole member of footwear comprising a base... \n", "5 1. A ratchet tool, comprising a shaft member, ... \n", "... ... \n", "16144 1. A wavelength tunable laser device, comprisi... \n", "16145 1. (canceled) 2. The method of claim 19, where... \n", "16148 1. A controlling method of a robot hand, the r... \n", "16149 1. A fusion protein comprising an Fc fragment ... \n", "16150 1. A pipe extraction tool for extracting a pip... \n", "\n", "[8719 rows x 3 columns]" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "trainDF" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "valFeaturesToDrop = [col for col in list(df_val.columns) if col not in necessary_columns]\n", "valDF = df_val.dropna()\n", "valDF.drop(columns=valFeaturesToDrop, inplace=True)\n", "valDF = valDF[valDF['decision'].isin(output_values)]" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
decisionabstractclaims
0REJECTEDRegimen for the treatment of rosacea include t...1. A treatment regimen comprising: cleansing a...
1ACCEPTEDA clamp arrangement includes a pair of bracket...1. A clamp arrangement for supporting a fractu...
2REJECTEDA system and method for device action and conf...1-20. (canceled) 21. A mobile device comprisin...
4REJECTEDSystems and methods for managing datasets prod...1. A method, comprising: executing, by one or ...
9ACCEPTEDA scan driving circuit is provided. The scan d...1. A scan driving circuit for driving a scan l...
............
9085REJECTEDThe non-rigid gate device as described may be ...1; A non-rigid blocking apparatus referred to ...
9090REJECTEDThe present invention provides an improved unc...1. A method for rendering a plastic surface am...
9091ACCEPTEDA method for detecting a software-race conditi...1. A method for detecting a software-race cond...
9092ACCEPTEDThe present application relates to multi-stage...1. A multi-stage amplitude modulation-based me...
9093ACCEPTEDA paper feeder includes a housing, a driving u...1. A paper feeder, comprising: a housing; a dr...
\n", "

4888 rows × 3 columns

\n", "
" ], "text/plain": [ " decision abstract \\\n", "0 REJECTED Regimen for the treatment of rosacea include t... \n", "1 ACCEPTED A clamp arrangement includes a pair of bracket... \n", "2 REJECTED A system and method for device action and conf... \n", "4 REJECTED Systems and methods for managing datasets prod... \n", "9 ACCEPTED A scan driving circuit is provided. The scan d... \n", "... ... ... \n", "9085 REJECTED The non-rigid gate device as described may be ... \n", "9090 REJECTED The present invention provides an improved unc... \n", "9091 ACCEPTED A method for detecting a software-race conditi... \n", "9092 ACCEPTED The present application relates to multi-stage... \n", "9093 ACCEPTED A paper feeder includes a housing, a driving u... \n", "\n", " claims \n", "0 1. A treatment regimen comprising: cleansing a... \n", "1 1. A clamp arrangement for supporting a fractu... \n", "2 1-20. (canceled) 21. A mobile device comprisin... \n", "4 1. A method, comprising: executing, by one or ... \n", "9 1. A scan driving circuit for driving a scan l... \n", "... ... \n", "9085 1; A non-rigid blocking apparatus referred to ... \n", "9090 1. A method for rendering a plastic surface am... \n", "9091 1. A method for detecting a software-race cond... \n", "9092 1. A multi-stage amplitude modulation-based me... \n", "9093 1. A paper feeder, comprising: a housing; a dr... \n", "\n", "[4888 rows x 3 columns]" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "valDF" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We need to replace the values in the `decision` column to numerical representations. We will set \"ACCEPTED\" as `1` and \"REJECTED\" as `0`." ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [], "source": [ "yKey = {\"ACCEPTED\":1,\"REJECTED\":0}" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [], "source": [ "trainDF2 = trainDF.replace({\"decision\": yKey})\n", "valDF2 = valDF.replace({\"decision\": yKey})" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
decisionabstractclaims
01The present invention relates to passive optic...1. A compact optical network terminal, compris...
11Embodiments of the invention provide a method ...1. A method comprising: using a first reader t...
31A crystal growth furnace comprising a crucible...1. A crystal growth furnace for growing a crys...
40A shoe midsole is composed of a base plate (1)...1. A sole member of footwear comprising a base...
51A ratchet tool includes a shaft member, a hand...1. A ratchet tool, comprising a shaft member, ...
............
161441A wavelength tunable laser device, including: ...1. A wavelength tunable laser device, comprisi...
161451In one aspect, a method for use in preparing a...1. (canceled) 2. The method of claim 19, where...
161481A robot hand controlling method executes calcu...1. A controlling method of a robot hand, the r...
161490A fusion protein is disclosed. The fusion prot...1. A fusion protein comprising an Fc fragment ...
161500A pipe extraction tool that grips the inside o...1. A pipe extraction tool for extracting a pip...
\n", "

8719 rows × 3 columns

\n", "
" ], "text/plain": [ " decision abstract \\\n", "0 1 The present invention relates to passive optic... \n", "1 1 Embodiments of the invention provide a method ... \n", "3 1 A crystal growth furnace comprising a crucible... \n", "4 0 A shoe midsole is composed of a base plate (1)... \n", "5 1 A ratchet tool includes a shaft member, a hand... \n", "... ... ... \n", "16144 1 A wavelength tunable laser device, including: ... \n", "16145 1 In one aspect, a method for use in preparing a... \n", "16148 1 A robot hand controlling method executes calcu... \n", "16149 0 A fusion protein is disclosed. The fusion prot... \n", "16150 0 A pipe extraction tool that grips the inside o... \n", "\n", " claims \n", "0 1. A compact optical network terminal, compris... \n", "1 1. A method comprising: using a first reader t... \n", "3 1. A crystal growth furnace for growing a crys... \n", "4 1. A sole member of footwear comprising a base... \n", "5 1. A ratchet tool, comprising a shaft member, ... \n", "... ... \n", "16144 1. A wavelength tunable laser device, comprisi... \n", "16145 1. (canceled) 2. The method of claim 19, where... \n", "16148 1. A controlling method of a robot hand, the r... \n", "16149 1. A fusion protein comprising an Fc fragment ... \n", "16150 1. A pipe extraction tool for extracting a pip... \n", "\n", "[8719 rows x 3 columns]" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "trainDF2" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
decisionabstractclaims
00Regimen for the treatment of rosacea include t...1. A treatment regimen comprising: cleansing a...
11A clamp arrangement includes a pair of bracket...1. A clamp arrangement for supporting a fractu...
20A system and method for device action and conf...1-20. (canceled) 21. A mobile device comprisin...
40Systems and methods for managing datasets prod...1. A method, comprising: executing, by one or ...
91A scan driving circuit is provided. The scan d...1. A scan driving circuit for driving a scan l...
............
90850The non-rigid gate device as described may be ...1; A non-rigid blocking apparatus referred to ...
90900The present invention provides an improved unc...1. A method for rendering a plastic surface am...
90911A method for detecting a software-race conditi...1. A method for detecting a software-race cond...
90921The present application relates to multi-stage...1. A multi-stage amplitude modulation-based me...
90931A paper feeder includes a housing, a driving u...1. A paper feeder, comprising: a housing; a dr...
\n", "

4888 rows × 3 columns

\n", "
" ], "text/plain": [ " decision abstract \\\n", "0 0 Regimen for the treatment of rosacea include t... \n", "1 1 A clamp arrangement includes a pair of bracket... \n", "2 0 A system and method for device action and conf... \n", "4 0 Systems and methods for managing datasets prod... \n", "9 1 A scan driving circuit is provided. The scan d... \n", "... ... ... \n", "9085 0 The non-rigid gate device as described may be ... \n", "9090 0 The present invention provides an improved unc... \n", "9091 1 A method for detecting a software-race conditi... \n", "9092 1 The present application relates to multi-stage... \n", "9093 1 A paper feeder includes a housing, a driving u... \n", "\n", " claims \n", "0 1. A treatment regimen comprising: cleansing a... \n", "1 1. A clamp arrangement for supporting a fractu... \n", "2 1-20. (canceled) 21. A mobile device comprisin... \n", "4 1. A method, comprising: executing, by one or ... \n", "9 1. A scan driving circuit for driving a scan l... \n", "... ... \n", "9085 1; A non-rigid blocking apparatus referred to ... \n", "9090 1. A method for rendering a plastic surface am... \n", "9091 1. A method for detecting a software-race cond... \n", "9092 1. A multi-stage amplitude modulation-based me... \n", "9093 1. A paper feeder, comprising: a housing; a dr... \n", "\n", "[4888 rows x 3 columns]" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "valDF2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We combine the `abstract` and `claims` columns into a single `text` column. We also re-label the `decision` column to `label`." ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "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", "
labeltext
01The present invention relates to passive optic...
11Embodiments of the invention provide a method ...
31A crystal growth furnace comprising a crucible...
40A shoe midsole is composed of a base plate (1)...
51A ratchet tool includes a shaft member, a hand...
.........
161441A wavelength tunable laser device, including: ...
161451In one aspect, a method for use in preparing a...
161481A robot hand controlling method executes calcu...
161490A fusion protein is disclosed. The fusion prot...
161500A pipe extraction tool that grips the inside o...
\n", "

8719 rows × 2 columns

\n", "
" ], "text/plain": [ " label text\n", "0 1 The present invention relates to passive optic...\n", "1 1 Embodiments of the invention provide a method ...\n", "3 1 A crystal growth furnace comprising a crucible...\n", "4 0 A shoe midsole is composed of a base plate (1)...\n", "5 1 A ratchet tool includes a shaft member, a hand...\n", "... ... ...\n", "16144 1 A wavelength tunable laser device, including: ...\n", "16145 1 In one aspect, a method for use in preparing a...\n", "16148 1 A robot hand controlling method executes calcu...\n", "16149 0 A fusion protein is disclosed. The fusion prot...\n", "16150 0 A pipe extraction tool that grips the inside o...\n", "\n", "[8719 rows x 2 columns]" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "trainDF3 = trainDF2.rename(columns={'decision': 'label'})\n", "trainDF3['text'] = trainDF3['abstract'] + ' ' + trainDF3['claims']\n", "trainDF3.drop(columns=[\"abstract\",\"claims\"],inplace=True)\n", "trainDF3" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "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", "
labeltext
00Regimen for the treatment of rosacea include t...
11A clamp arrangement includes a pair of bracket...
20A system and method for device action and conf...
40Systems and methods for managing datasets prod...
91A scan driving circuit is provided. The scan d...
.........
90850The non-rigid gate device as described may be ...
90900The present invention provides an improved unc...
90911A method for detecting a software-race conditi...
90921The present application relates to multi-stage...
90931A paper feeder includes a housing, a driving u...
\n", "

4888 rows × 2 columns

\n", "
" ], "text/plain": [ " label text\n", "0 0 Regimen for the treatment of rosacea include t...\n", "1 1 A clamp arrangement includes a pair of bracket...\n", "2 0 A system and method for device action and conf...\n", "4 0 Systems and methods for managing datasets prod...\n", "9 1 A scan driving circuit is provided. The scan d...\n", "... ... ...\n", "9085 0 The non-rigid gate device as described may be ...\n", "9090 0 The present invention provides an improved unc...\n", "9091 1 A method for detecting a software-race conditi...\n", "9092 1 The present application relates to multi-stage...\n", "9093 1 A paper feeder includes a housing, a driving u...\n", "\n", "[4888 rows x 2 columns]" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "valDF3 = valDF2.rename(columns={'decision': 'label'})\n", "valDF3['text'] = valDF3['abstract'] + ' ' + valDF3['claims']\n", "valDF3.drop(columns=[\"abstract\",\"claims\"],inplace=True)\n", "valDF3" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can grab the data for each column so that we have a list of values for training labels, training texts, validation labels, and validation texts." ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [], "source": [ "trainLabels = trainDF3[\"label\"].tolist()\n", "trainText = trainDF3[\"text\"].tolist()\n", "\n", "valLabels = valDF3[\"label\"].tolist()\n", "valText = valDF3[\"text\"].tolist()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Loading the Trainer\n", "\n", "Now we can start training! This time, we will just go with `distilbert-base-uncased` for simplicity." ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Requirement already satisfied: torch in /opt/conda/lib/python3.10/site-packages (2.0.0)\n", "Requirement already satisfied: nvidia-cusparse-cu11==11.7.4.91 in /opt/conda/lib/python3.10/site-packages (from torch) (11.7.4.91)\n", "Requirement already satisfied: nvidia-nvtx-cu11==11.7.91 in /opt/conda/lib/python3.10/site-packages (from torch) (11.7.91)\n", "Requirement already satisfied: jinja2 in /opt/conda/lib/python3.10/site-packages (from torch) (3.1.2)\n", "Requirement already satisfied: typing-extensions in /opt/conda/lib/python3.10/site-packages (from torch) (4.4.0)\n", "Requirement already satisfied: nvidia-curand-cu11==10.2.10.91 in /opt/conda/lib/python3.10/site-packages (from torch) (10.2.10.91)\n", "Requirement already satisfied: nvidia-cusolver-cu11==11.4.0.1 in /opt/conda/lib/python3.10/site-packages (from torch) (11.4.0.1)\n", "Requirement already satisfied: nvidia-cublas-cu11==11.10.3.66 in /opt/conda/lib/python3.10/site-packages (from torch) (11.10.3.66)\n", "Requirement already satisfied: nvidia-cufft-cu11==10.9.0.58 in /opt/conda/lib/python3.10/site-packages (from torch) (10.9.0.58)\n", "Requirement already satisfied: sympy in /opt/conda/lib/python3.10/site-packages (from torch) (1.11.1)\n", "Requirement already satisfied: nvidia-cuda-runtime-cu11==11.7.99 in /opt/conda/lib/python3.10/site-packages (from torch) (11.7.99)\n", "Requirement already satisfied: triton==2.0.0 in /opt/conda/lib/python3.10/site-packages (from torch) (2.0.0)\n", "Requirement already satisfied: filelock in /opt/conda/lib/python3.10/site-packages (from torch) (3.12.0)\n", "Requirement already satisfied: networkx in /opt/conda/lib/python3.10/site-packages (from torch) (2.8.7)\n", "Requirement already satisfied: nvidia-nccl-cu11==2.14.3 in /opt/conda/lib/python3.10/site-packages (from torch) (2.14.3)\n", "Requirement already satisfied: nvidia-cuda-cupti-cu11==11.7.101 in /opt/conda/lib/python3.10/site-packages (from torch) (11.7.101)\n", "Requirement already satisfied: nvidia-cuda-nvrtc-cu11==11.7.99 in /opt/conda/lib/python3.10/site-packages (from torch) (11.7.99)\n", "Requirement already satisfied: nvidia-cudnn-cu11==8.5.0.96 in /opt/conda/lib/python3.10/site-packages (from torch) (8.5.0.96)\n", "Requirement already satisfied: setuptools in /opt/conda/lib/python3.10/site-packages (from nvidia-cublas-cu11==11.10.3.66->torch) (65.4.1)\n", "Requirement already satisfied: wheel in /opt/conda/lib/python3.10/site-packages (from nvidia-cublas-cu11==11.10.3.66->torch) (0.37.1)\n", "Requirement already satisfied: cmake in /opt/conda/lib/python3.10/site-packages (from triton==2.0.0->torch) (3.26.3)\n", "Requirement already satisfied: lit in /opt/conda/lib/python3.10/site-packages (from triton==2.0.0->torch) (16.0.1)\n", "Requirement already satisfied: MarkupSafe>=2.0 in /opt/conda/lib/python3.10/site-packages (from jinja2->torch) (2.1.1)\n", "Requirement already satisfied: mpmath>=0.19 in /opt/conda/lib/python3.10/site-packages (from sympy->torch) (1.2.1)\n", "Requirement already satisfied: transformers in /opt/conda/lib/python3.10/site-packages (4.28.1)\n", "Requirement already satisfied: huggingface-hub<1.0,>=0.11.0 in /opt/conda/lib/python3.10/site-packages (from transformers) (0.13.4)\n", "Requirement already satisfied: pyyaml>=5.1 in /opt/conda/lib/python3.10/site-packages (from transformers) (6.0)\n", "Requirement already satisfied: numpy>=1.17 in /opt/conda/lib/python3.10/site-packages (from transformers) (1.23.3)\n", "Requirement already satisfied: filelock in /opt/conda/lib/python3.10/site-packages (from transformers) (3.12.0)\n", "Requirement already satisfied: regex!=2019.12.17 in /opt/conda/lib/python3.10/site-packages (from transformers) (2023.3.23)\n", "Requirement already satisfied: tqdm>=4.27 in /opt/conda/lib/python3.10/site-packages (from transformers) (4.64.1)\n", "Requirement already satisfied: requests in /opt/conda/lib/python3.10/site-packages (from transformers) (2.28.1)\n", "Requirement already satisfied: tokenizers!=0.11.3,<0.14,>=0.11.1 in /opt/conda/lib/python3.10/site-packages (from transformers) (0.13.3)\n", "Requirement already satisfied: packaging>=20.0 in /opt/conda/lib/python3.10/site-packages (from transformers) (21.3)\n", "Requirement already satisfied: typing-extensions>=3.7.4.3 in /opt/conda/lib/python3.10/site-packages (from huggingface-hub<1.0,>=0.11.0->transformers) (4.4.0)\n", "Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in /opt/conda/lib/python3.10/site-packages (from packaging>=20.0->transformers) (3.0.9)\n", "Requirement already satisfied: urllib3<1.27,>=1.21.1 in /opt/conda/lib/python3.10/site-packages (from requests->transformers) (1.26.11)\n", "Requirement already satisfied: certifi>=2017.4.17 in /opt/conda/lib/python3.10/site-packages (from requests->transformers) (2022.9.24)\n", "Requirement already satisfied: idna<4,>=2.5 in /opt/conda/lib/python3.10/site-packages (from requests->transformers) (3.4)\n", "Requirement already satisfied: charset-normalizer<3,>=2 in /opt/conda/lib/python3.10/site-packages (from requests->transformers) (2.1.1)\n" ] } ], "source": [ "!pip install torch\n", "!pip install transformers" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [], "source": [ "import torch\n", "from torch.utils.data import Dataset\n", "from transformers import DistilBertTokenizerFast, DistilBertForSequenceClassification\n", "from transformers import Trainer, TrainingArguments" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [], "source": [ "model_name = \"distilbert-base-uncased\"\n", "class USPTODataset(Dataset):\n", " def __init__(self, encodings, labels):\n", " self.encodings = encodings\n", " self.labels = labels\n", " def __getitem__(self, idx):\n", " item = {key: torch.tensor(val[idx]) for key, val in self.encoding.items()}\n", " item['labels'] = torch.tensor(self.labels[idx])\n", " return item\n", " def __len__(self):\n", " return len(self.labels)\n" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [], "source": [ "tokenizer = DistilBertTokenizerFast.from_pretrained(model_name)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "train_encodings = tokenizer(trainText, truncation=True, padding=True)\n", "val_encodings = tokenizer(valText, truncation=True, padding=True)\n", "\n", "train_dataset = USPTODataset(train_encodings, trainLabels)\n", "val_dataset = USPTODataset(val_encodings, valLabels)\n", "\n", "train_args = TrainingArguments(\n", " output_dir=\"./results\",\n", " num_train_epochs=2,\n", " per_device_train_batch_size=16,\n", " per_device_eval_batch_size=64,\n", " warmup_steps=500,\n", " learning_rate=5e-5,\n", " weight_decay=0.01,\n", " logging_dir=\"./logs\",\n", " logging_steps=10\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "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.10.6" } }, "nbformat": 4, "nbformat_minor": 4 }