File size: 114,089 Bytes
a60b694 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 |
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"gpuType": "T4"
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
},
"accelerator": "GPU"
},
"cells": [
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "H-2L-S6b4ukm",
"outputId": "a13cc6d9-211b-4ad3-d1b3-c1f1bb0d63b3"
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Requirement already satisfied: transformers in /usr/local/lib/python3.10/dist-packages (4.35.2)\n",
"Requirement already satisfied: datasets in /usr/local/lib/python3.10/dist-packages (2.15.0)\n",
"Requirement already satisfied: huggingface_hub in /usr/local/lib/python3.10/dist-packages (0.19.4)\n",
"Requirement already satisfied: sentence-transformers in /usr/local/lib/python3.10/dist-packages (2.2.2)\n",
"Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from transformers) (3.13.1)\n",
"Requirement already satisfied: numpy>=1.17 in /usr/local/lib/python3.10/dist-packages (from transformers) (1.23.5)\n",
"Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.10/dist-packages (from transformers) (23.2)\n",
"Requirement already satisfied: pyyaml>=5.1 in /usr/local/lib/python3.10/dist-packages (from transformers) (6.0.1)\n",
"Requirement already satisfied: regex!=2019.12.17 in /usr/local/lib/python3.10/dist-packages (from transformers) (2023.6.3)\n",
"Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (from transformers) (2.31.0)\n",
"Requirement already satisfied: tokenizers<0.19,>=0.14 in /usr/local/lib/python3.10/dist-packages (from transformers) (0.15.0)\n",
"Requirement already satisfied: safetensors>=0.3.1 in /usr/local/lib/python3.10/dist-packages (from transformers) (0.4.1)\n",
"Requirement already satisfied: tqdm>=4.27 in /usr/local/lib/python3.10/dist-packages (from transformers) (4.66.1)\n",
"Requirement already satisfied: pyarrow>=8.0.0 in /usr/local/lib/python3.10/dist-packages (from datasets) (10.0.1)\n",
"Requirement already satisfied: pyarrow-hotfix in /usr/local/lib/python3.10/dist-packages (from datasets) (0.6)\n",
"Requirement already satisfied: dill<0.3.8,>=0.3.0 in /usr/local/lib/python3.10/dist-packages (from datasets) (0.3.7)\n",
"Requirement already satisfied: pandas in /usr/local/lib/python3.10/dist-packages (from datasets) (1.5.3)\n",
"Requirement already satisfied: xxhash in /usr/local/lib/python3.10/dist-packages (from datasets) (3.4.1)\n",
"Requirement already satisfied: multiprocess in /usr/local/lib/python3.10/dist-packages (from datasets) (0.70.15)\n",
"Requirement already satisfied: fsspec[http]<=2023.10.0,>=2023.1.0 in /usr/local/lib/python3.10/dist-packages (from datasets) (2023.6.0)\n",
"Requirement already satisfied: aiohttp in /usr/local/lib/python3.10/dist-packages (from datasets) (3.9.1)\n",
"Requirement already satisfied: typing-extensions>=3.7.4.3 in /usr/local/lib/python3.10/dist-packages (from huggingface_hub) (4.5.0)\n",
"Requirement already satisfied: torch>=1.6.0 in /usr/local/lib/python3.10/dist-packages (from sentence-transformers) (2.1.0+cu121)\n",
"Requirement already satisfied: torchvision in /usr/local/lib/python3.10/dist-packages (from sentence-transformers) (0.16.0+cu121)\n",
"Requirement already satisfied: scikit-learn in /usr/local/lib/python3.10/dist-packages (from sentence-transformers) (1.2.2)\n",
"Requirement already satisfied: scipy in /usr/local/lib/python3.10/dist-packages (from sentence-transformers) (1.11.4)\n",
"Requirement already satisfied: nltk in /usr/local/lib/python3.10/dist-packages (from sentence-transformers) (3.8.1)\n",
"Requirement already satisfied: sentencepiece in /usr/local/lib/python3.10/dist-packages (from sentence-transformers) (0.1.99)\n",
"Requirement already satisfied: attrs>=17.3.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets) (23.1.0)\n",
"Requirement already satisfied: multidict<7.0,>=4.5 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets) (6.0.4)\n",
"Requirement already satisfied: yarl<2.0,>=1.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets) (1.9.4)\n",
"Requirement already satisfied: frozenlist>=1.1.1 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets) (1.4.0)\n",
"Requirement already satisfied: aiosignal>=1.1.2 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets) (1.3.1)\n",
"Requirement already satisfied: async-timeout<5.0,>=4.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets) (4.0.3)\n",
"Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests->transformers) (3.3.2)\n",
"Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests->transformers) (3.6)\n",
"Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests->transformers) (2.0.7)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests->transformers) (2023.11.17)\n",
"Requirement already satisfied: sympy in /usr/local/lib/python3.10/dist-packages (from torch>=1.6.0->sentence-transformers) (1.12)\n",
"Requirement already satisfied: networkx in /usr/local/lib/python3.10/dist-packages (from torch>=1.6.0->sentence-transformers) (3.2.1)\n",
"Requirement already satisfied: jinja2 in /usr/local/lib/python3.10/dist-packages (from torch>=1.6.0->sentence-transformers) (3.1.2)\n",
"Requirement already satisfied: triton==2.1.0 in /usr/local/lib/python3.10/dist-packages (from torch>=1.6.0->sentence-transformers) (2.1.0)\n",
"Requirement already satisfied: click in /usr/local/lib/python3.10/dist-packages (from nltk->sentence-transformers) (8.1.7)\n",
"Requirement already satisfied: joblib in /usr/local/lib/python3.10/dist-packages (from nltk->sentence-transformers) (1.3.2)\n",
"Requirement already satisfied: python-dateutil>=2.8.1 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) (2023.3.post1)\n",
"Requirement already satisfied: threadpoolctl>=2.0.0 in /usr/local/lib/python3.10/dist-packages (from scikit-learn->sentence-transformers) (3.2.0)\n",
"Requirement already satisfied: pillow!=8.3.*,>=5.3.0 in /usr/local/lib/python3.10/dist-packages (from torchvision->sentence-transformers) (9.4.0)\n",
"Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.10/dist-packages (from python-dateutil>=2.8.1->pandas->datasets) (1.16.0)\n",
"Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.10/dist-packages (from jinja2->torch>=1.6.0->sentence-transformers) (2.1.3)\n",
"Requirement already satisfied: mpmath>=0.19 in /usr/local/lib/python3.10/dist-packages (from sympy->torch>=1.6.0->sentence-transformers) (1.3.0)\n"
]
}
],
"source": [
"pip install transformers datasets huggingface_hub sentence-transformers"
]
},
{
"cell_type": "code",
"source": [
"import re\n",
"import nltk\n",
"from nltk.corpus import stopwords\n",
"import torch\n",
"from torch.utils.data import DataLoader, TensorDataset\n",
"from transformers import AutoTokenizer, AutoModelForMaskedLM, AdamW\n",
"import pandas as pd\n",
"from tqdm import tqdm"
],
"metadata": {
"id": "Jk533_F14yV8"
},
"execution_count": 13,
"outputs": []
},
{
"cell_type": "code",
"source": [
"# Load your unlabeled dataset\n",
"resumes = pd.read_csv('/content/MyResume2.csv')"
],
"metadata": {
"id": "IR-KIxHd5iyu"
},
"execution_count": 14,
"outputs": []
},
{
"cell_type": "code",
"source": [
"resumes.head(5)"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 206
},
"id": "Y0sgNBwr5mzH",
"outputId": "7d303582-9067-4426-ad13-0d86a4bba2df"
},
"execution_count": 15,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
" Resumes\n",
"0 Global Sales Administrator Biamp Systems Globa...\n",
"1 Python Developer <span class=\"hl\">Python</span...\n",
"2 IT Project Manager <span class=\"hl\">IT</span> ...\n",
"3 UI Front End Developer UI <span class=\"hl\">Fro...\n",
"4 IT Security Analyst <span class=\"hl\">IT</span>..."
],
"text/html": [
"\n",
" <div id=\"df-898c6a0a-0e3f-44dd-9455-3da629e7ed0b\" class=\"colab-df-container\">\n",
" <div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Resumes</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Global Sales Administrator Biamp Systems Globa...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>Python Developer <span class=\"hl\">Python</span...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>IT Project Manager <span class=\"hl\">IT</span> ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>UI Front End Developer UI <span class=\"hl\">Fro...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>IT Security Analyst <span class=\"hl\">IT</span>...</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>\n",
" <div class=\"colab-df-buttons\">\n",
"\n",
" <div class=\"colab-df-container\">\n",
" <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-898c6a0a-0e3f-44dd-9455-3da629e7ed0b')\"\n",
" title=\"Convert this dataframe to an interactive table.\"\n",
" style=\"display:none;\">\n",
"\n",
" <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
" <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
" </svg>\n",
" </button>\n",
"\n",
" <style>\n",
" .colab-df-container {\n",
" display:flex;\n",
" gap: 12px;\n",
" }\n",
"\n",
" .colab-df-convert {\n",
" background-color: #E8F0FE;\n",
" border: none;\n",
" border-radius: 50%;\n",
" cursor: pointer;\n",
" display: none;\n",
" fill: #1967D2;\n",
" height: 32px;\n",
" padding: 0 0 0 0;\n",
" width: 32px;\n",
" }\n",
"\n",
" .colab-df-convert:hover {\n",
" background-color: #E2EBFA;\n",
" box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
" fill: #174EA6;\n",
" }\n",
"\n",
" .colab-df-buttons div {\n",
" margin-bottom: 4px;\n",
" }\n",
"\n",
" [theme=dark] .colab-df-convert {\n",
" background-color: #3B4455;\n",
" fill: #D2E3FC;\n",
" }\n",
"\n",
" [theme=dark] .colab-df-convert:hover {\n",
" background-color: #434B5C;\n",
" box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
" filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
" fill: #FFFFFF;\n",
" }\n",
" </style>\n",
"\n",
" <script>\n",
" const buttonEl =\n",
" document.querySelector('#df-898c6a0a-0e3f-44dd-9455-3da629e7ed0b button.colab-df-convert');\n",
" buttonEl.style.display =\n",
" google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
"\n",
" async function convertToInteractive(key) {\n",
" const element = document.querySelector('#df-898c6a0a-0e3f-44dd-9455-3da629e7ed0b');\n",
" const dataTable =\n",
" await google.colab.kernel.invokeFunction('convertToInteractive',\n",
" [key], {});\n",
" if (!dataTable) return;\n",
"\n",
" const docLinkHtml = 'Like what you see? Visit the ' +\n",
" '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
" + ' to learn more about interactive tables.';\n",
" element.innerHTML = '';\n",
" dataTable['output_type'] = 'display_data';\n",
" await google.colab.output.renderOutput(dataTable, element);\n",
" const docLink = document.createElement('div');\n",
" docLink.innerHTML = docLinkHtml;\n",
" element.appendChild(docLink);\n",
" }\n",
" </script>\n",
" </div>\n",
"\n",
"\n",
"<div id=\"df-618f113a-80fd-42c0-b5c0-ac87d14021bb\">\n",
" <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-618f113a-80fd-42c0-b5c0-ac87d14021bb')\"\n",
" title=\"Suggest charts\"\n",
" style=\"display:none;\">\n",
"\n",
"<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
" width=\"24px\">\n",
" <g>\n",
" <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
" </g>\n",
"</svg>\n",
" </button>\n",
"\n",
"<style>\n",
" .colab-df-quickchart {\n",
" --bg-color: #E8F0FE;\n",
" --fill-color: #1967D2;\n",
" --hover-bg-color: #E2EBFA;\n",
" --hover-fill-color: #174EA6;\n",
" --disabled-fill-color: #AAA;\n",
" --disabled-bg-color: #DDD;\n",
" }\n",
"\n",
" [theme=dark] .colab-df-quickchart {\n",
" --bg-color: #3B4455;\n",
" --fill-color: #D2E3FC;\n",
" --hover-bg-color: #434B5C;\n",
" --hover-fill-color: #FFFFFF;\n",
" --disabled-bg-color: #3B4455;\n",
" --disabled-fill-color: #666;\n",
" }\n",
"\n",
" .colab-df-quickchart {\n",
" background-color: var(--bg-color);\n",
" border: none;\n",
" border-radius: 50%;\n",
" cursor: pointer;\n",
" display: none;\n",
" fill: var(--fill-color);\n",
" height: 32px;\n",
" padding: 0;\n",
" width: 32px;\n",
" }\n",
"\n",
" .colab-df-quickchart:hover {\n",
" background-color: var(--hover-bg-color);\n",
" box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
" fill: var(--button-hover-fill-color);\n",
" }\n",
"\n",
" .colab-df-quickchart-complete:disabled,\n",
" .colab-df-quickchart-complete:disabled:hover {\n",
" background-color: var(--disabled-bg-color);\n",
" fill: var(--disabled-fill-color);\n",
" box-shadow: none;\n",
" }\n",
"\n",
" .colab-df-spinner {\n",
" border: 2px solid var(--fill-color);\n",
" border-color: transparent;\n",
" border-bottom-color: var(--fill-color);\n",
" animation:\n",
" spin 1s steps(1) infinite;\n",
" }\n",
"\n",
" @keyframes spin {\n",
" 0% {\n",
" border-color: transparent;\n",
" border-bottom-color: var(--fill-color);\n",
" border-left-color: var(--fill-color);\n",
" }\n",
" 20% {\n",
" border-color: transparent;\n",
" border-left-color: var(--fill-color);\n",
" border-top-color: var(--fill-color);\n",
" }\n",
" 30% {\n",
" border-color: transparent;\n",
" border-left-color: var(--fill-color);\n",
" border-top-color: var(--fill-color);\n",
" border-right-color: var(--fill-color);\n",
" }\n",
" 40% {\n",
" border-color: transparent;\n",
" border-right-color: var(--fill-color);\n",
" border-top-color: var(--fill-color);\n",
" }\n",
" 60% {\n",
" border-color: transparent;\n",
" border-right-color: var(--fill-color);\n",
" }\n",
" 80% {\n",
" border-color: transparent;\n",
" border-right-color: var(--fill-color);\n",
" border-bottom-color: var(--fill-color);\n",
" }\n",
" 90% {\n",
" border-color: transparent;\n",
" border-bottom-color: var(--fill-color);\n",
" }\n",
" }\n",
"</style>\n",
"\n",
" <script>\n",
" async function quickchart(key) {\n",
" const quickchartButtonEl =\n",
" document.querySelector('#' + key + ' button');\n",
" quickchartButtonEl.disabled = true; // To prevent multiple clicks.\n",
" quickchartButtonEl.classList.add('colab-df-spinner');\n",
" try {\n",
" const charts = await google.colab.kernel.invokeFunction(\n",
" 'suggestCharts', [key], {});\n",
" } catch (error) {\n",
" console.error('Error during call to suggestCharts:', error);\n",
" }\n",
" quickchartButtonEl.classList.remove('colab-df-spinner');\n",
" quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
" }\n",
" (() => {\n",
" let quickchartButtonEl =\n",
" document.querySelector('#df-618f113a-80fd-42c0-b5c0-ac87d14021bb button');\n",
" quickchartButtonEl.style.display =\n",
" google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
" })();\n",
" </script>\n",
"</div>\n",
" </div>\n",
" </div>\n"
]
},
"metadata": {},
"execution_count": 15
}
]
},
{
"cell_type": "code",
"source": [
"# Define the function for cleaning text\n",
"def clean_text(text):\n",
" return re.sub(r\"<span class=\\\"hl\\\">(.*?)</span>\", r\"\\1\", text)\n",
"# Apply the function to the entire column\n",
"resumes['Resumes'] = resumes['Resumes'].apply(clean_text)"
],
"metadata": {
"id": "MrCrvWv65nAw"
},
"execution_count": 16,
"outputs": []
},
{
"cell_type": "code",
"source": [
"import nltk\n",
"nltk.download('punkt')"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "aUdNZquW4yXo",
"outputId": "39821786-1a0b-4cfa-c2cc-86622675ccee"
},
"execution_count": 17,
"outputs": [
{
"output_type": "stream",
"name": "stderr",
"text": [
"[nltk_data] Downloading package punkt to /root/nltk_data...\n",
"[nltk_data] Package punkt is already up-to-date!\n"
]
},
{
"output_type": "execute_result",
"data": {
"text/plain": [
"True"
]
},
"metadata": {},
"execution_count": 17
}
]
},
{
"cell_type": "code",
"source": [
"import nltk\n",
"nltk.download('stopwords')"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "09C8uhGu51Vh",
"outputId": "0dd144a6-228e-4522-cddf-1a613642e995"
},
"execution_count": 18,
"outputs": [
{
"output_type": "stream",
"name": "stderr",
"text": [
"[nltk_data] Downloading package stopwords to /root/nltk_data...\n",
"[nltk_data] Package stopwords is already up-to-date!\n"
]
},
{
"output_type": "execute_result",
"data": {
"text/plain": [
"True"
]
},
"metadata": {},
"execution_count": 18
}
]
},
{
"cell_type": "code",
"source": [
"def clean_resume(resume):\n",
" if isinstance(resume, str):\n",
" # Convert to lowercase\n",
" resume = resume.lower()\n",
"\n",
" # Remove URLs, RT, cc, hashtags, mentions, non-ASCII characters, punctuation, and extra whitespace\n",
" resume = re.sub('http\\S+\\s*|RT|cc|#\\S+|@\\S+|[^\\x00-\\x7f]|[^\\w\\s]', ' ', resume)\n",
" resume = re.sub('\\s+', ' ', resume).strip()\n",
"\n",
" return resume\n",
" else:\n",
" return ''\n",
"\n",
"# Applying the cleaning function to a Datasets\n",
"resumes['Resumes'] = resumes['Resumes'].apply(lambda x: clean_resume(x))"
],
"metadata": {
"id": "TWyPQ63w51kN"
},
"execution_count": 19,
"outputs": []
},
{
"cell_type": "code",
"source": [
"import pandas as pd\n",
"from transformers import AutoTokenizer, AutoModelForMaskedLM, AdamW\n",
"import torch\n",
"from torch.utils.data import DataLoader, TensorDataset\n",
"from tqdm import tqdm\n",
"\n",
"# Load the pre-trained model\n",
"mpnet = \"sentence-transformers/all-mpnet-base-v2\"\n",
"tokenizer = AutoTokenizer.from_pretrained(mpnet)\n",
"pretrained_model = AutoModelForMaskedLM.from_pretrained(mpnet)\n",
"\n",
"# Assuming 'resumes' is a DataFrame with a column named 'Resumes'\n",
"texts = resumes['Resumes'].tolist()\n",
"\n",
"# Tokenize and encode the unlabeled data\n",
"encodings = tokenizer(texts, padding=True, truncation = True, return_tensors='pt')\n",
"\n",
"# Create a TensorDataset\n",
"dataset = TensorDataset(encodings['input_ids'], encodings['attention_mask'])\n",
"\n",
"# Move the model to the appropriate device (CPU or GPU)\n",
"device = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n",
"pretrained_model.to(device)\n",
"\n",
"# Initialize the optimizer\n",
"optimizer = AdamW(pretrained_model.parameters(), lr=1e-5)\n",
"\n",
"batch_size = 8\n",
"epochs = 3\n",
"import math\n",
"\n",
"# Experiment with different chunk sizes\n",
"chunk_sizes_to_try = [200] # Can add more sizes later\n",
"\n",
"for chunk_size in chunk_sizes_to_try:\n",
" for epoch in range(epochs):\n",
" tqdm_dataloader = tqdm(DataLoader(dataset, batch_size=batch_size, shuffle=True), desc=f'Epoch {epoch + 1}/{epochs}')\n",
"\n",
" pretrained_model.train()\n",
" for batch in tqdm_dataloader:\n",
" input_ids, attention_mask = batch\n",
" input_ids, attention_mask = input_ids.to(device), attention_mask.to(device)\n",
"\n",
" # Calculate number of chunks for current batch\n",
" sequence_length = input_ids.size(1) # Get actual sequence length\n",
" num_chunks = math.ceil(sequence_length / chunk_size)\n",
"\n",
" for i in range(num_chunks):\n",
" start_idx = i * chunk_size\n",
" end_idx = min((i + 1) * chunk_size, sequence_length) # Handle final chunk\n",
"\n",
" # Extract chunk data\n",
" input_ids_chunk = input_ids[:, start_idx:end_idx]\n",
" attention_mask_chunk = attention_mask[:, start_idx:end_idx]\n",
"\n",
" # Forward pass\n",
" outputs = pretrained_model(\n",
" input_ids_chunk, attention_mask=attention_mask_chunk, labels=input_ids_chunk.reshape(-1)\n",
" )\n",
"\n",
" # Calculate loss\n",
" loss = outputs.loss\n",
"\n",
" # Backward pass and optimization\n",
" optimizer.zero_grad()\n",
" loss.backward()\n",
" optimizer.step()\n",
"\n",
" # Update progress bar\n",
" tqdm_dataloader.set_postfix({'Loss': loss.item(), 'Chunk Size': chunk_size})"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "kypmxXhz4ybO",
"outputId": "0b46968a-5485-4e2e-dc4d-f1c9e023090b"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stderr",
"text": [
"Some weights of the model checkpoint at sentence-transformers/all-mpnet-base-v2 were not used when initializing MPNetForMaskedLM: ['pooler.dense.weight', 'pooler.dense.bias']\n",
"- This IS expected if you are initializing MPNetForMaskedLM from the checkpoint of a model trained on another task or with another architecture (e.g. initializing a BertForSequenceClassification model from a BertForPreTraining model).\n",
"- This IS NOT expected if you are initializing MPNetForMaskedLM from the checkpoint of a model that you expect to be exactly identical (initializing a BertForSequenceClassification model from a BertForSequenceClassification model).\n",
"Some weights of MPNetForMaskedLM were not initialized from the model checkpoint at sentence-transformers/all-mpnet-base-v2 and are newly initialized: ['lm_head.bias', 'lm_head.dense.bias', 'lm_head.layer_norm.weight', 'lm_head.decoder.bias', 'lm_head.dense.weight', 'lm_head.layer_norm.bias']\n",
"You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.\n",
"Epoch 1/3: 2%|▏ | 67/3202 [01:06<54:36, 1.04s/it, Loss=3.44, Chunk Size=200]"
]
}
]
},
{
"cell_type": "code",
"source": [
"from google.colab import drive\n",
"drive.mount('/content/gdrive')"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "GrFenXiepxRA",
"outputId": "84732ce8-bd2f-40de-a7e4-573ffa880ade"
},
"execution_count": 10,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Mounted at /content/gdrive\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"pretrained_model.save_pretrained('/content/gdrive/My Drive/Finetunedmodel/fine_tuned_mpnet_base_v2')\n",
"tokenizer.save_pretrained('/content/gdrive/My Drive/Finetunedmodel/fine_tuned_mpnet_base_v2')"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "h2jJmGCQgnUK",
"outputId": "5c8811d8-bb6f-46be-a5b2-1112d07b5d91"
},
"execution_count": 11,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"('/content/gdrive/My Drive/Finetunedmodel/fine_tuned_mpnet_v2/tokenizer_config.json',\n",
" '/content/gdrive/My Drive/Finetunedmodel/fine_tuned_mpnet_v2/special_tokens_map.json',\n",
" '/content/gdrive/My Drive/Finetunedmodel/fine_tuned_mpnet_v2/vocab.txt',\n",
" '/content/gdrive/My Drive/Finetunedmodel/fine_tuned_mpnet_v2/added_tokens.json',\n",
" '/content/gdrive/My Drive/Finetunedmodel/fine_tuned_mpnet_v2/tokenizer.json')"
]
},
"metadata": {},
"execution_count": 11
}
]
},
{
"cell_type": "code",
"source": [
"ls"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "FxxiUXhStwLk",
"outputId": "12b2967d-c5fa-405d-87e9-70dbf78eea55"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"\u001b[0m\u001b[01;34mfine_tuned_mpnet\u001b[0m/ \u001b[01;34mfine_tuned_resumes\u001b[0m/ resumes6000.csv the_resumesFirst.csv\n",
"fine_tuned_mpnet.zip \u001b[01;34mgdrive\u001b[0m/ \u001b[01;34msample_data\u001b[0m/\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"pwd"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 35
},
"id": "x4KmqwXJt2AK",
"outputId": "8f359dba-ee83-41f7-da9c-755dda297926"
},
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"'/content'"
],
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
}
},
"metadata": {},
"execution_count": 96
}
]
},
{
"cell_type": "code",
"source": [
"cd /content"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "na5_rkhhtIFS",
"outputId": "039a56d3-e2ce-49dd-b1a7-450300e2bdf8"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"/content\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"# Save the fine-tuned model\n",
"pretrained_model.save_pretrained('fine_tuned_mpnet_v1')\n",
"tokenizer.save_pretrained('fine_tuned_mpnet_v1')"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "Yt-tBcsCvXss",
"outputId": "b025722e-79a8-4361-930a-804a702ac232"
},
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"('fine_tuned_mpnet_v1/tokenizer_config.json',\n",
" 'fine_tuned_mpnet_v1/special_tokens_map.json',\n",
" 'fine_tuned_mpnet_v1/vocab.txt',\n",
" 'fine_tuned_mpnet_v1/added_tokens.json',\n",
" 'fine_tuned_mpnet_v1/tokenizer.json')"
]
},
"metadata": {},
"execution_count": 100
}
]
},
{
"cell_type": "code",
"source": [
"ls"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "Wd7txZXhn3YX",
"outputId": "5ea0c99a-6541-4ea9-f6c6-e6bc8daf27ed"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"\u001b[0m\u001b[01;34mfine_tuned_mpnet\u001b[0m/ fine_tuned_mpnet.zip \u001b[01;34mgdrive\u001b[0m/ \u001b[01;34msample_data\u001b[0m/\n",
"\u001b[01;34mfine_tuned_mpnet_v1\u001b[0m/ \u001b[01;34mfine_tuned_resumes\u001b[0m/ resumes6000.csv the_resumesFirst.csv\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"pretrained_model.save_pretrained('/content/gdrive/My Drive/Finetunedmodel/fine_tuned_mpnet_v1')\n",
"tokenizer.save_pretrained('/content/gdrive/My Drive/Finetunedmodel/fine_tuned_mpnet_v1')\n"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "ppk2Js4Tv7-5",
"outputId": "8ac4a813-f674-46fb-a5d4-0323d4f8125a"
},
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"('/content/gdrive/My Drive/Finetunedmodel/fine_tuned_mpnet_v1/tokenizer_config.json',\n",
" '/content/gdrive/My Drive/Finetunedmodel/fine_tuned_mpnet_v1/special_tokens_map.json',\n",
" '/content/gdrive/My Drive/Finetunedmodel/fine_tuned_mpnet_v1/vocab.txt',\n",
" '/content/gdrive/My Drive/Finetunedmodel/fine_tuned_mpnet_v1/added_tokens.json',\n",
" '/content/gdrive/My Drive/Finetunedmodel/fine_tuned_mpnet_v1/tokenizer.json')"
]
},
"metadata": {},
"execution_count": 102
}
]
},
{
"cell_type": "code",
"source": [
"from transformers import AutoTokenizer, AutoModelForMaskedLM\n",
"\n",
"model= 'DeroG/mpnet_new'\n",
"tokenizer = AutoTokenizer.from_pretrained(model)\n",
"model = AutoModelForMaskedLM.from_pretrained(model)"
],
"metadata": {
"id": "7wXwExyi6rYK"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"pip install hnswlib"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "pKDy0s9g9gcK",
"outputId": "5d796c7e-39cf-4465-a964-6ca4791aba4a"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Collecting hnswlib\n",
" Downloading hnswlib-0.8.0.tar.gz (36 kB)\n",
" Installing build dependencies ... \u001b[?25l\u001b[?25hdone\n",
" Getting requirements to build wheel ... \u001b[?25l\u001b[?25hdone\n",
" Preparing metadata (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n",
"Requirement already satisfied: numpy in /usr/local/lib/python3.10/dist-packages (from hnswlib) (1.23.5)\n",
"Building wheels for collected packages: hnswlib\n",
" Building wheel for hnswlib (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n",
" Created wheel for hnswlib: filename=hnswlib-0.8.0-cp310-cp310-linux_x86_64.whl size=2287618 sha256=f1176656b86f12880d251e5a85b8562e1be1a45d5618ecfa55f021001c459f48\n",
" Stored in directory: /root/.cache/pip/wheels/af/a9/3e/3e5d59ee41664eb31a4e6de67d1846f86d16d93c45f277c4e7\n",
"Successfully built hnswlib\n",
"Installing collected packages: hnswlib\n",
"Successfully installed hnswlib-0.8.0\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"pip install -U sentence-transformers"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "-inPZMW9-ask",
"outputId": "06585972-e9fc-4b8f-80fc-ea34f49aa247"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Requirement already satisfied: sentence-transformers in /usr/local/lib/python3.10/dist-packages (2.2.2)\n",
"Requirement already satisfied: transformers<5.0.0,>=4.6.0 in /usr/local/lib/python3.10/dist-packages (from sentence-transformers) (4.35.2)\n",
"Requirement already satisfied: tqdm in /usr/local/lib/python3.10/dist-packages (from sentence-transformers) (4.66.1)\n",
"Requirement already satisfied: torch>=1.6.0 in /usr/local/lib/python3.10/dist-packages (from sentence-transformers) (2.1.0+cu121)\n",
"Requirement already satisfied: torchvision in /usr/local/lib/python3.10/dist-packages (from sentence-transformers) (0.16.0+cu121)\n",
"Requirement already satisfied: numpy in /usr/local/lib/python3.10/dist-packages (from sentence-transformers) (1.23.5)\n",
"Requirement already satisfied: scikit-learn in /usr/local/lib/python3.10/dist-packages (from sentence-transformers) (1.2.2)\n",
"Requirement already satisfied: scipy in /usr/local/lib/python3.10/dist-packages (from sentence-transformers) (1.11.4)\n",
"Requirement already satisfied: nltk in /usr/local/lib/python3.10/dist-packages (from sentence-transformers) (3.8.1)\n",
"Requirement already satisfied: sentencepiece in /usr/local/lib/python3.10/dist-packages (from sentence-transformers) (0.1.99)\n",
"Requirement already satisfied: huggingface-hub>=0.4.0 in /usr/local/lib/python3.10/dist-packages (from sentence-transformers) (0.19.4)\n",
"Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.4.0->sentence-transformers) (3.13.1)\n",
"Requirement already satisfied: fsspec>=2023.5.0 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.4.0->sentence-transformers) (2023.6.0)\n",
"Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.4.0->sentence-transformers) (2.31.0)\n",
"Requirement already satisfied: pyyaml>=5.1 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.4.0->sentence-transformers) (6.0.1)\n",
"Requirement already satisfied: typing-extensions>=3.7.4.3 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.4.0->sentence-transformers) (4.5.0)\n",
"Requirement already satisfied: packaging>=20.9 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.4.0->sentence-transformers) (23.2)\n",
"Requirement already satisfied: sympy in /usr/local/lib/python3.10/dist-packages (from torch>=1.6.0->sentence-transformers) (1.12)\n",
"Requirement already satisfied: networkx in /usr/local/lib/python3.10/dist-packages (from torch>=1.6.0->sentence-transformers) (3.2.1)\n",
"Requirement already satisfied: jinja2 in /usr/local/lib/python3.10/dist-packages (from torch>=1.6.0->sentence-transformers) (3.1.2)\n",
"Requirement already satisfied: triton==2.1.0 in /usr/local/lib/python3.10/dist-packages (from torch>=1.6.0->sentence-transformers) (2.1.0)\n",
"Requirement already satisfied: regex!=2019.12.17 in /usr/local/lib/python3.10/dist-packages (from transformers<5.0.0,>=4.6.0->sentence-transformers) (2023.6.3)\n",
"Requirement already satisfied: tokenizers<0.19,>=0.14 in /usr/local/lib/python3.10/dist-packages (from transformers<5.0.0,>=4.6.0->sentence-transformers) (0.15.0)\n",
"Requirement already satisfied: safetensors>=0.3.1 in /usr/local/lib/python3.10/dist-packages (from transformers<5.0.0,>=4.6.0->sentence-transformers) (0.4.1)\n",
"Requirement already satisfied: click in /usr/local/lib/python3.10/dist-packages (from nltk->sentence-transformers) (8.1.7)\n",
"Requirement already satisfied: joblib in /usr/local/lib/python3.10/dist-packages (from nltk->sentence-transformers) (1.3.2)\n",
"Requirement already satisfied: threadpoolctl>=2.0.0 in /usr/local/lib/python3.10/dist-packages (from scikit-learn->sentence-transformers) (3.2.0)\n",
"Requirement already satisfied: pillow!=8.3.*,>=5.3.0 in /usr/local/lib/python3.10/dist-packages (from torchvision->sentence-transformers) (9.4.0)\n",
"Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.10/dist-packages (from jinja2->torch>=1.6.0->sentence-transformers) (2.1.3)\n",
"Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests->huggingface-hub>=0.4.0->sentence-transformers) (3.3.2)\n",
"Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests->huggingface-hub>=0.4.0->sentence-transformers) (3.6)\n",
"Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests->huggingface-hub>=0.4.0->sentence-transformers) (2.0.7)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests->huggingface-hub>=0.4.0->sentence-transformers) (2023.11.17)\n",
"Requirement already satisfied: mpmath>=0.19 in /usr/local/lib/python3.10/dist-packages (from sympy->torch>=1.6.0->sentence-transformers) (1.3.0)\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"import numpy as np\n",
"import pandas as pd\n",
"import re\n",
"# Download the NLTK stopwords\n",
"import nltk\n",
"nltk.download('punkt')\n",
"from nltk.corpus import stopwords\n",
"import pickle\n",
"import hnswlib\n",
"import sentence_transformers as st\n",
"from sentence_transformers import SentenceTransformer, util\n",
"import time\n",
"from tqdm import tqdm\n",
"import numpy as np\n",
"from math import ceil\n",
"from torch.nn import functional as F"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "eoyL885S9kbH",
"outputId": "d01de86b-0643-4096-dbd5-a183db05a961"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stderr",
"text": [
"[nltk_data] Downloading package punkt to /root/nltk_data...\n",
"[nltk_data] Package punkt is already up-to-date!\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"resumes = pd.read_csv(\"/content/the_resumesFirst.csv\")"
],
"metadata": {
"id": "cWM655E56wvO"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"resumes.head(5)"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 206
},
"id": "-EKdhiiF9Zgc",
"outputId": "598b2c0d-e0ee-467a-9597-4e3077ad9e24"
},
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
" Resume Category\n",
"0 CESAR CABAL Financial Analyst ccabal43emailcom... Digital Marketing\n",
"1 Selamawit Yemane Customer Service Manager sela... Digital Marketing\n",
"2 DRISTAN ARTHUR BUDGET ANALYST CONTACT darthure... Digital Marketing\n",
"3 BENTLI FALLA CAREER OBJECTIVE Creative and wit... Digital Marketing\n",
"4 First Last Advertising Copy Writer Bay Area Ca... Digital Marketing"
],
"text/html": [
"\n",
" <div id=\"df-cb778921-ea34-41bc-bfda-7d3326b53b96\" class=\"colab-df-container\">\n",
" <div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Resume</th>\n",
" <th>Category</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>CESAR CABAL Financial Analyst ccabal43emailcom...</td>\n",
" <td>Digital Marketing</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>Selamawit Yemane Customer Service Manager sela...</td>\n",
" <td>Digital Marketing</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>DRISTAN ARTHUR BUDGET ANALYST CONTACT darthure...</td>\n",
" <td>Digital Marketing</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>BENTLI FALLA CAREER OBJECTIVE Creative and wit...</td>\n",
" <td>Digital Marketing</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>First Last Advertising Copy Writer Bay Area Ca...</td>\n",
" <td>Digital Marketing</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>\n",
" <div class=\"colab-df-buttons\">\n",
"\n",
" <div class=\"colab-df-container\">\n",
" <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-cb778921-ea34-41bc-bfda-7d3326b53b96')\"\n",
" title=\"Convert this dataframe to an interactive table.\"\n",
" style=\"display:none;\">\n",
"\n",
" <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
" <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
" </svg>\n",
" </button>\n",
"\n",
" <style>\n",
" .colab-df-container {\n",
" display:flex;\n",
" gap: 12px;\n",
" }\n",
"\n",
" .colab-df-convert {\n",
" background-color: #E8F0FE;\n",
" border: none;\n",
" border-radius: 50%;\n",
" cursor: pointer;\n",
" display: none;\n",
" fill: #1967D2;\n",
" height: 32px;\n",
" padding: 0 0 0 0;\n",
" width: 32px;\n",
" }\n",
"\n",
" .colab-df-convert:hover {\n",
" background-color: #E2EBFA;\n",
" box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
" fill: #174EA6;\n",
" }\n",
"\n",
" .colab-df-buttons div {\n",
" margin-bottom: 4px;\n",
" }\n",
"\n",
" [theme=dark] .colab-df-convert {\n",
" background-color: #3B4455;\n",
" fill: #D2E3FC;\n",
" }\n",
"\n",
" [theme=dark] .colab-df-convert:hover {\n",
" background-color: #434B5C;\n",
" box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
" filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
" fill: #FFFFFF;\n",
" }\n",
" </style>\n",
"\n",
" <script>\n",
" const buttonEl =\n",
" document.querySelector('#df-cb778921-ea34-41bc-bfda-7d3326b53b96 button.colab-df-convert');\n",
" buttonEl.style.display =\n",
" google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
"\n",
" async function convertToInteractive(key) {\n",
" const element = document.querySelector('#df-cb778921-ea34-41bc-bfda-7d3326b53b96');\n",
" const dataTable =\n",
" await google.colab.kernel.invokeFunction('convertToInteractive',\n",
" [key], {});\n",
" if (!dataTable) return;\n",
"\n",
" const docLinkHtml = 'Like what you see? Visit the ' +\n",
" '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
" + ' to learn more about interactive tables.';\n",
" element.innerHTML = '';\n",
" dataTable['output_type'] = 'display_data';\n",
" await google.colab.output.renderOutput(dataTable, element);\n",
" const docLink = document.createElement('div');\n",
" docLink.innerHTML = docLinkHtml;\n",
" element.appendChild(docLink);\n",
" }\n",
" </script>\n",
" </div>\n",
"\n",
"\n",
"<div id=\"df-0947ca76-4684-4844-a59a-85dccf611be8\">\n",
" <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-0947ca76-4684-4844-a59a-85dccf611be8')\"\n",
" title=\"Suggest charts\"\n",
" style=\"display:none;\">\n",
"\n",
"<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
" width=\"24px\">\n",
" <g>\n",
" <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
" </g>\n",
"</svg>\n",
" </button>\n",
"\n",
"<style>\n",
" .colab-df-quickchart {\n",
" --bg-color: #E8F0FE;\n",
" --fill-color: #1967D2;\n",
" --hover-bg-color: #E2EBFA;\n",
" --hover-fill-color: #174EA6;\n",
" --disabled-fill-color: #AAA;\n",
" --disabled-bg-color: #DDD;\n",
" }\n",
"\n",
" [theme=dark] .colab-df-quickchart {\n",
" --bg-color: #3B4455;\n",
" --fill-color: #D2E3FC;\n",
" --hover-bg-color: #434B5C;\n",
" --hover-fill-color: #FFFFFF;\n",
" --disabled-bg-color: #3B4455;\n",
" --disabled-fill-color: #666;\n",
" }\n",
"\n",
" .colab-df-quickchart {\n",
" background-color: var(--bg-color);\n",
" border: none;\n",
" border-radius: 50%;\n",
" cursor: pointer;\n",
" display: none;\n",
" fill: var(--fill-color);\n",
" height: 32px;\n",
" padding: 0;\n",
" width: 32px;\n",
" }\n",
"\n",
" .colab-df-quickchart:hover {\n",
" background-color: var(--hover-bg-color);\n",
" box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
" fill: var(--button-hover-fill-color);\n",
" }\n",
"\n",
" .colab-df-quickchart-complete:disabled,\n",
" .colab-df-quickchart-complete:disabled:hover {\n",
" background-color: var(--disabled-bg-color);\n",
" fill: var(--disabled-fill-color);\n",
" box-shadow: none;\n",
" }\n",
"\n",
" .colab-df-spinner {\n",
" border: 2px solid var(--fill-color);\n",
" border-color: transparent;\n",
" border-bottom-color: var(--fill-color);\n",
" animation:\n",
" spin 1s steps(1) infinite;\n",
" }\n",
"\n",
" @keyframes spin {\n",
" 0% {\n",
" border-color: transparent;\n",
" border-bottom-color: var(--fill-color);\n",
" border-left-color: var(--fill-color);\n",
" }\n",
" 20% {\n",
" border-color: transparent;\n",
" border-left-color: var(--fill-color);\n",
" border-top-color: var(--fill-color);\n",
" }\n",
" 30% {\n",
" border-color: transparent;\n",
" border-left-color: var(--fill-color);\n",
" border-top-color: var(--fill-color);\n",
" border-right-color: var(--fill-color);\n",
" }\n",
" 40% {\n",
" border-color: transparent;\n",
" border-right-color: var(--fill-color);\n",
" border-top-color: var(--fill-color);\n",
" }\n",
" 60% {\n",
" border-color: transparent;\n",
" border-right-color: var(--fill-color);\n",
" }\n",
" 80% {\n",
" border-color: transparent;\n",
" border-right-color: var(--fill-color);\n",
" border-bottom-color: var(--fill-color);\n",
" }\n",
" 90% {\n",
" border-color: transparent;\n",
" border-bottom-color: var(--fill-color);\n",
" }\n",
" }\n",
"</style>\n",
"\n",
" <script>\n",
" async function quickchart(key) {\n",
" const quickchartButtonEl =\n",
" document.querySelector('#' + key + ' button');\n",
" quickchartButtonEl.disabled = true; // To prevent multiple clicks.\n",
" quickchartButtonEl.classList.add('colab-df-spinner');\n",
" try {\n",
" const charts = await google.colab.kernel.invokeFunction(\n",
" 'suggestCharts', [key], {});\n",
" } catch (error) {\n",
" console.error('Error during call to suggestCharts:', error);\n",
" }\n",
" quickchartButtonEl.classList.remove('colab-df-spinner');\n",
" quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
" }\n",
" (() => {\n",
" let quickchartButtonEl =\n",
" document.querySelector('#df-0947ca76-4684-4844-a59a-85dccf611be8 button');\n",
" quickchartButtonEl.style.display =\n",
" google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
" })();\n",
" </script>\n",
"</div>\n",
"\n",
" </div>\n",
" </div>\n"
]
},
"metadata": {},
"execution_count": 175
}
]
},
{
"cell_type": "code",
"source": [
"import nltk\n",
"nltk.download('stopwords')"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "YPjo60K-AHGv",
"outputId": "3696fdd4-9095-4bb1-8768-06954b86dc3d"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stderr",
"text": [
"[nltk_data] Downloading package stopwords to /root/nltk_data...\n",
"[nltk_data] Package stopwords is already up-to-date!\n"
]
},
{
"output_type": "execute_result",
"data": {
"text/plain": [
"True"
]
},
"metadata": {},
"execution_count": 176
}
]
},
{
"cell_type": "code",
"source": [
"Preprop_resumes = resumes[\"Resume\"]"
],
"metadata": {
"id": "0o9HS80GE26g"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"# Function for cleaning and preprocessing the resume\n",
"def clean_resume(resume):\n",
" if isinstance(resume, str):\n",
" # Convert to lowercase\n",
" resume = resume.lower()\n",
"\n",
" # Remove URLs, RT, cc, hashtags, mentions, non-ASCII characters, punctuation, and extra whitespace\n",
" resume = re.sub('http\\S+\\s*|RT|cc|#\\S+|@\\S+|[^\\x00-\\x7f]|[^\\w\\s]', ' ', resume)\n",
" resume = re.sub('\\s+', ' ', resume).strip()\n",
"\n",
" # Tokenize the resume\n",
" tokens = nltk.word_tokenize(resume)\n",
"\n",
" # Remove stopwords\n",
" stop_words = set(stopwords.words('english'))\n",
" tokens = [token for token in tokens if token.lower() not in stop_words]\n",
"\n",
" # Join the tokens back into a sentence\n",
" preprocessed_resume = ' '.join(tokens)\n",
"\n",
" return preprocessed_resume\n",
" else:\n",
" return ''\n",
"# Applying the cleaning function to a Datasets\n",
"Preprop_resumes = Preprop_resumes.apply(lambda x: clean_resume(x))"
],
"metadata": {
"id": "tAQj28-z-rPO"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"resumes = resumes[\"Resume\"].tolist()"
],
"metadata": {
"id": "14d8JRdvFRgc"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"Preprop_resumes = Preprop_resumes.tolist()"
],
"metadata": {
"id": "UJgKODhmCeQc"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"from transformers import AutoTokenizer, AutoModelForMaskedLM\n",
"\n",
"model= 'DeroG/mpnet_new'\n",
"tokenizer = AutoTokenizer.from_pretrained(model)\n",
"model = AutoModelForMaskedLM.from_pretrained(model)"
],
"metadata": {
"id": "ML9r4WqyvymZ"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"from transformers import AutoTokenizer\n",
"import torch\n",
"from tqdm import tqdm\n",
"\n",
"def embed_resumes_with_progress(model, tokenizer, resumes, chunk_size=200):\n",
" \"\"\"\n",
" Embeds a list of resumes using the SentenceTransformer model with chunking and progress bar.\n",
"\n",
" Args:\n",
" model: The SentenceTransformer model.\n",
" tokenizer: The Hugging Face Tokenizer for text pre-processing.\n",
" resumes: A list of preprocessed resumes.\n",
" chunk_size: Maximum number of tokens per chunk (default: 200).\n",
"\n",
" Returns:\n",
" A numpy array containing the averaged embeddings for each resume.\n",
" \"\"\"\n",
" resume_embeddings = []\n",
"\n",
" with tqdm(total=len(Preprop_resumes)) as pbar:\n",
" for resume in Preprop_resumes:\n",
" encoded_chunks = []\n",
" chunks = [resume[i:i+chunk_size] for i in range(0, len(resume), chunk_size)]\n",
" for chunk in chunks:\n",
" encoded_chunk = tokenizer(chunk, padding=True, truncation=True, return_tensors=\"pt\")\n",
" with torch.no_grad():\n",
" chunk_embedding = model(**encoded_chunk)[0]\n",
" attention_mask = encoded_chunk[\"attention_mask\"]\n",
" encoded_chunks.append(chunk_embedding)\n",
"\n",
" # Concatenate the encoded chunks\n",
" concatenated_chunks = torch.cat(encoded_chunks, dim=1)\n",
" resume_embedding = torch.mean(concatenated_chunks, dim=1)\n",
" resume_embeddings.append(resume_embedding)\n",
"\n",
" pbar.update(1)\n",
"\n",
" return torch.cat(resume_embeddings)"
],
"metadata": {
"id": "IWhRAIEGznBW"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"# Get resume embeddings\n",
"import torch\n",
"resume_embeddings = embed_resumes_with_progress(model, tokenizer, Preprop_resumes)\n",
"\n",
"# Access individual embedding\n",
"first_resume_embedding = resume_embeddings[0]"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "cefhi-6uV0u0",
"outputId": "fccef929-1f33-4c1f-a361-bf5dd9cab61c"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stderr",
"text": [
"100%|██████████| 9/9 [00:22<00:00, 2.51s/it]\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"resume_embeddings.shape"
],
"metadata": {
"id": "FlG8BH8nG4Ys",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "409cb351-39df-4cff-94c8-7d658c3b558c"
},
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"torch.Size([9, 30527])"
]
},
"metadata": {},
"execution_count": 184
}
]
},
{
"cell_type": "code",
"source": [
"job_description = \"\"\"\n",
"\n",
"Boyave\n",
"Full-Time\n",
"Description\n",
"Content Creator\n",
"Job brief\n",
"We are looking for a Content Creator to write and publish various types of pieces for our company’s web pages, like articles, ebooks and social media posts.\n",
"Content Creator responsibilities include producing marketing copy to advertise our products, writing blog posts about industry-related topics and promoting our content on social media. To be successful in this role, you should have experience with digital publishing and generating traffic and leads for new business. Please share samples of your work (portfolio or links to published articles) along with your application.\n",
"Ultimately, you will help us reach our target audience by delivering both useful and appealing online information about our company and products.\n",
"Responsibilities\n",
"•\tResearch industry-related topics\n",
"•\tPrepare well-structured drafts using digital publishing platforms\n",
"•\tCreate and distribute marketing copy to advertise our company and products\n",
"•\tInterview industry professionals and incorporate their views in blog posts\n",
"•\tEdit and proofread written pieces before publication\n",
"•\tConduct keyword research and use SEO guidelines to optimize content\n",
"•\tPromote content on social networks and monitor engagement (e.g. comments and shares)\n",
"•\tIdentify customers’ needs and recommend new topics\n",
"•\tCoordinate with marketing and design teams to illustrate articles\n",
"•\tMeasure web traffic to content (e.g. conversion and bounce rates)\n",
"•\tUpdate our websites as needed\n",
"Requirements and skills\n",
"•\tProven work experience as a Content Creator, Copywriter or similar role\n",
"•\tPortfolio of published articles\n",
"•\tHands-on experience with Content Management Systems (e.g. WordPress)\n",
"•\tExcellent writing and editing skills in English\n",
"•\tAn ability to fact-check long-form content pieces\n",
"•\tTime-management skills\n",
"•\tFamiliarity with SEO\n",
"•\tBSc in Marketing, English, Journalism or relevant field\"\"\""
],
"metadata": {
"id": "9rePs2i2rE8Y"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"def clean_JD(JD):\n",
" \"\"\"\n",
" Preprocesses the provided JD by:\n",
" - Lowercasing all text\n",
" - Removing punctuation\n",
" - Removing stop words and punctuation and sympols\n",
" \"\"\"\n",
" JD = JD.lower()\n",
" JD = re.sub(r\"[^\\w\\s]\", \"\", JD)\n",
" stop_words = stopwords.words(\"english\")\n",
" filtered_words = [word for word in JD.split() if word not in stop_words]\n",
" cleaned_JD = \" \".join(filtered_words)\n",
" return cleaned_JD"
],
"metadata": {
"id": "fV2s-58itieE"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"cleaned_job_description = clean_JD(job_description)\n",
"print(\"Cleaned Job Description:\", cleaned_job_description)"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "W5Wg84rU5V_b",
"outputId": "caee6213-0826-4535-fa7f-e684c91c622a"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Cleaned Job Description: boyave fulltime description content creator job brief looking content creator write publish various types pieces companys web pages like articles ebooks social media posts content creator responsibilities include producing marketing copy advertise products writing blog posts industryrelated topics promoting content social media successful role experience digital publishing generating traffic leads new business please share samples work portfolio links published articles along application ultimately help us reach target audience delivering useful appealing online information company products responsibilities research industryrelated topics prepare wellstructured drafts using digital publishing platforms create distribute marketing copy advertise company products interview industry professionals incorporate views blog posts edit proofread written pieces publication conduct keyword research use seo guidelines optimize content promote content social networks monitor engagement eg comments shares identify customers needs recommend new topics coordinate marketing design teams illustrate articles measure web traffic content eg conversion bounce rates update websites needed requirements skills proven work experience content creator copywriter similar role portfolio published articles handson experience content management systems eg wordpress excellent writing editing skills english ability factcheck longform content pieces timemanagement skills familiarity seo bsc marketing english journalism relevant field\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"from transformers import AutoTokenizer\n",
"from tqdm import tqdm\n",
"\n",
"\n",
"def embed_JD_with_progress(model, tokenizer, cleaned_job_description, chunk_size=200):\n",
" \"\"\"\n",
" Embeds a job description using the SentenceTransformer model with chunking and progress bar.\n",
"\n",
" Args:\n",
" model: The SentenceTransformer model.\n",
" tokenizer: The Hugging Face Tokenizer for text pre-processing.\n",
" cleaned_job_description: A preprocessed job description string.\n",
" chunk_size: Maximum number of tokens per chunk (default: 200).\n",
"\n",
" Returns:\n",
" A numpy array containing the embedding for the job description.\n",
" \"\"\"\n",
"\n",
" encoded_chunks = []\n",
" chunks = [cleaned_job_description[i:i+chunk_size] for i in range(0, len(cleaned_job_description), chunk_size)]\n",
"\n",
" with tqdm(total=len(chunks), desc=\"Embedding Job Description\") as pbar:\n",
" for chunk in chunks:\n",
" encoded_chunk = tokenizer(chunk, padding=True, truncation=True, return_tensors=\"pt\")\n",
" with torch.no_grad():\n",
" chunk_embedding = model(**encoded_chunk)[0]\n",
" attention_mask = encoded_chunk[\"attention_mask\"]\n",
" encoded_chunks.append(chunk_embedding)\n",
" pbar.update(1)\n",
"\n",
" concatenated_chunks = torch.cat(encoded_chunks, dim=1)\n",
" JD_embeddings = torch.mean(concatenated_chunks, dim=1)\n",
" return JD_embeddings.cpu().numpy()\n"
],
"metadata": {
"id": "DUy5qjVk6_-l"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"# Get resume embeddings\n",
"import torch\n",
"JD_embeddings = embed_JD_with_progress(model, tokenizer, cleaned_job_description)\n",
"\n",
"# Access individual embedding\n",
"first_JD_embedding = JD_embeddings[0]"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "PBdXLtj_rFDn",
"outputId": "cb1b7d79-1fdc-4d84-c29e-fc3b7b231480"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stderr",
"text": [
"Embedding Job Description: 100%|██████████| 8/8 [00:01<00:00, 4.79it/s]\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"JD_embeddings.shape"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "LtcX_V638Qjh",
"outputId": "cfc786df-4c33-42b6-f421-b45d7c014d36"
},
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"(1, 30527)"
]
},
"metadata": {},
"execution_count": 190
}
]
},
{
"cell_type": "code",
"source": [
"# Access individual embedding\n",
"first_JD_embedding = JD_embeddings[0]"
],
"metadata": {
"id": "28E62owWtKE9"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"JD_embeddings"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "yoFomYiXtKG9",
"outputId": "26c5e508-b26b-414d-c40b-e764dabdc470"
},
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"array([[ 2.4844365, 0.6637995, 7.125794 , ..., -1.8927242, -3.2216737,\n",
" 3.1794276]], dtype=float32)"
]
},
"metadata": {},
"execution_count": 192
}
]
},
{
"cell_type": "code",
"source": [
"def similarity_percentage(similarity_score):\n",
" if similarity_score < 0.2:\n",
" return 0\n",
" elif 0.2 <= similarity_score < 0.3:\n",
" return similarity_score - 0.25\n",
" elif 0.3 <= similarity_score < 0.4:\n",
" return similarity_score - 0.23\n",
" elif 0.4 <= similarity_score < 0.55:\n",
" return similarity_score - 0.19\n",
" elif 0.55 <= similarity_score < 0.65:\n",
" return similarity_score - 0.14\n",
" else:\n",
" return similarity_score - 0.1"
],
"metadata": {
"id": "UG_zHu2iudVi"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"def create_hnsw_index(embeddings, max_elements, ef_construction, M, ef):\n",
" \"\"\"\n",
" Creates and initializes an HNSWLib index with the specified parameters.\n",
"\n",
" Args:\n",
" embeddings: A list of embedding vectors.\n",
" max_elements: Maximum number of elements to store in the index.\n",
" ef_construction: Number of elements to consider during index construction.\n",
" M: Maximum number of connections per node in the HNSW graph.\n",
" ef: Number of elements to consider during search.\n",
"\n",
" Returns:\n",
" An HNSWLib index object.\n",
" \"\"\"\n",
" embedding_size = 30527\n",
" index = hnswlib.Index(space='cosine', dim=embedding_size)\n",
" index.init_index(max_elements, ef_construction, M)\n",
" index.add_items(resume_embeddings, list(range(len(resume_embeddings))))\n",
" index.set_ef(ef)\n",
" return index"
],
"metadata": {
"id": "phQs8On6udc2"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"# Define parameters for the index\n",
"max_elements = len(resume_embeddings)\n",
"ef_construction = 2000\n",
"M = 200\n",
"ef = 50\n",
"index = create_hnsw_index(resume_embeddings, max_elements, ef_construction, M, ef)\n",
"print(\"Corpus loaded with {} resumes / embeddings\".format(len(resume_embeddings)))\n",
"\n",
"# Retrieve resumes based on job description\n",
"take_k_hits = int(input(\"\\nHow many top resumes do you want to be retrieved?\\n\\n\"))\n",
"\n",
"start_time = time.time()\n",
"\n",
"resume_ids, dist = index.knn_query(JD_embeddings, take_k_hits)\n",
"\n",
"# Calculate the similarity percentage and create a DataFrame\n",
"hits = [{'resume_id': id, 'Original_Score': 1 - score, 'Adjusted_Score': similarity_percentage(1 - score)} for id, score in zip(resume_ids[0], dist[0])]\n",
"hits = sorted(hits, key=lambda x: x['Adjusted_Score'], reverse=True)\n",
"\n",
"end_time = time.time()\n",
"\n",
"print(\"Results (after {:.3f} seconds):\".format(end_time - start_time))\n",
"\n",
"# Create a DataFrame with original and adjusted similarity scores\n",
"Resumeranking = pd.DataFrame(hits[:take_k_hits])\n",
"Resumeranking['Resumes'] = Resumeranking['resume_id'].map(lambda x: resumes[x])\n",
"Resumeranking = Resumeranking.drop(['resume_id'], axis=1)\n",
"\n",
"# Convert Adjusted_Score to percentage format\n",
"Resumeranking['Original_Score'] = Resumeranking['Original_Score']\n",
"Resumeranking['Adjusted_Score'] = (Resumeranking['Adjusted_Score'] * 100).round(2)\n",
"Resumeranking['Adjusted_Score'] = Resumeranking['Adjusted_Score'].astype(str) + '%'\n",
"\n",
"Resumeranking = Resumeranking[['Resumes', 'Original_Score', 'Adjusted_Score']]\n",
"Resumeranking"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 436
},
"id": "AlHtoaZ_udeq",
"outputId": "e769c65e-25f6-434f-df77-1e49efe9888b"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Corpus loaded with 9 resumes / embeddings\n",
"\n",
"How many top resumes do you want to be retrieved?\n",
"\n",
"9\n",
"Results (after 0.001 seconds):\n"
]
},
{
"output_type": "execute_result",
"data": {
"text/plain": [
" Resumes Original_Score \\\n",
"0 First Last Advertising Copy Writer Bay Area Ca... 0.980730 \n",
"1 BENTLI FALLA CAREER OBJECTIVE Creative and wit... 0.975105 \n",
"2 CESAR CABAL Financial Analyst ccabal43emailcom... 0.965548 \n",
"3 First Last Digital Marketing Manager WORK EXPE... 0.962464 \n",
"4 CHELSEY DEGA Marketing Manager chelseydegaemai... 0.959740 \n",
"5 Reinhardt Konig Human Resources Intern Driven ... 0.958368 \n",
"6 DRISTAN ARTHUR BUDGET ANALYST CONTACT darthure... 0.954127 \n",
"7 Selamawit Yemane Customer Service Manager sela... 0.953998 \n",
"8 OBJECTIVE To impart my knowledge in Veterinary... 0.931807 \n",
"\n",
" Adjusted_Score \n",
"0 88.07% \n",
"1 87.51% \n",
"2 86.55% \n",
"3 86.25% \n",
"4 85.97% \n",
"5 85.84% \n",
"6 85.41% \n",
"7 85.4% \n",
"8 83.18% "
],
"text/html": [
"\n",
" <div id=\"df-6b9f6639-6c3f-4f49-8160-46367492458b\" class=\"colab-df-container\">\n",
" <div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Resumes</th>\n",
" <th>Original_Score</th>\n",
" <th>Adjusted_Score</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>First Last Advertising Copy Writer Bay Area Ca...</td>\n",
" <td>0.980730</td>\n",
" <td>88.07%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>BENTLI FALLA CAREER OBJECTIVE Creative and wit...</td>\n",
" <td>0.975105</td>\n",
" <td>87.51%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>CESAR CABAL Financial Analyst ccabal43emailcom...</td>\n",
" <td>0.965548</td>\n",
" <td>86.55%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>First Last Digital Marketing Manager WORK EXPE...</td>\n",
" <td>0.962464</td>\n",
" <td>86.25%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>CHELSEY DEGA Marketing Manager chelseydegaemai...</td>\n",
" <td>0.959740</td>\n",
" <td>85.97%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>Reinhardt Konig Human Resources Intern Driven ...</td>\n",
" <td>0.958368</td>\n",
" <td>85.84%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>DRISTAN ARTHUR BUDGET ANALYST CONTACT darthure...</td>\n",
" <td>0.954127</td>\n",
" <td>85.41%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>Selamawit Yemane Customer Service Manager sela...</td>\n",
" <td>0.953998</td>\n",
" <td>85.4%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>OBJECTIVE To impart my knowledge in Veterinary...</td>\n",
" <td>0.931807</td>\n",
" <td>83.18%</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>\n",
" <div class=\"colab-df-buttons\">\n",
"\n",
" <div class=\"colab-df-container\">\n",
" <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-6b9f6639-6c3f-4f49-8160-46367492458b')\"\n",
" title=\"Convert this dataframe to an interactive table.\"\n",
" style=\"display:none;\">\n",
"\n",
" <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
" <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
" </svg>\n",
" </button>\n",
"\n",
" <style>\n",
" .colab-df-container {\n",
" display:flex;\n",
" gap: 12px;\n",
" }\n",
"\n",
" .colab-df-convert {\n",
" background-color: #E8F0FE;\n",
" border: none;\n",
" border-radius: 50%;\n",
" cursor: pointer;\n",
" display: none;\n",
" fill: #1967D2;\n",
" height: 32px;\n",
" padding: 0 0 0 0;\n",
" width: 32px;\n",
" }\n",
"\n",
" .colab-df-convert:hover {\n",
" background-color: #E2EBFA;\n",
" box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
" fill: #174EA6;\n",
" }\n",
"\n",
" .colab-df-buttons div {\n",
" margin-bottom: 4px;\n",
" }\n",
"\n",
" [theme=dark] .colab-df-convert {\n",
" background-color: #3B4455;\n",
" fill: #D2E3FC;\n",
" }\n",
"\n",
" [theme=dark] .colab-df-convert:hover {\n",
" background-color: #434B5C;\n",
" box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
" filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
" fill: #FFFFFF;\n",
" }\n",
" </style>\n",
"\n",
" <script>\n",
" const buttonEl =\n",
" document.querySelector('#df-6b9f6639-6c3f-4f49-8160-46367492458b button.colab-df-convert');\n",
" buttonEl.style.display =\n",
" google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
"\n",
" async function convertToInteractive(key) {\n",
" const element = document.querySelector('#df-6b9f6639-6c3f-4f49-8160-46367492458b');\n",
" const dataTable =\n",
" await google.colab.kernel.invokeFunction('convertToInteractive',\n",
" [key], {});\n",
" if (!dataTable) return;\n",
"\n",
" const docLinkHtml = 'Like what you see? Visit the ' +\n",
" '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
" + ' to learn more about interactive tables.';\n",
" element.innerHTML = '';\n",
" dataTable['output_type'] = 'display_data';\n",
" await google.colab.output.renderOutput(dataTable, element);\n",
" const docLink = document.createElement('div');\n",
" docLink.innerHTML = docLinkHtml;\n",
" element.appendChild(docLink);\n",
" }\n",
" </script>\n",
" </div>\n",
"\n",
"\n",
"<div id=\"df-1d11a2ab-dd76-48f3-853f-51c2a2ff51d5\">\n",
" <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-1d11a2ab-dd76-48f3-853f-51c2a2ff51d5')\"\n",
" title=\"Suggest charts\"\n",
" style=\"display:none;\">\n",
"\n",
"<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
" width=\"24px\">\n",
" <g>\n",
" <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
" </g>\n",
"</svg>\n",
" </button>\n",
"\n",
"<style>\n",
" .colab-df-quickchart {\n",
" --bg-color: #E8F0FE;\n",
" --fill-color: #1967D2;\n",
" --hover-bg-color: #E2EBFA;\n",
" --hover-fill-color: #174EA6;\n",
" --disabled-fill-color: #AAA;\n",
" --disabled-bg-color: #DDD;\n",
" }\n",
"\n",
" [theme=dark] .colab-df-quickchart {\n",
" --bg-color: #3B4455;\n",
" --fill-color: #D2E3FC;\n",
" --hover-bg-color: #434B5C;\n",
" --hover-fill-color: #FFFFFF;\n",
" --disabled-bg-color: #3B4455;\n",
" --disabled-fill-color: #666;\n",
" }\n",
"\n",
" .colab-df-quickchart {\n",
" background-color: var(--bg-color);\n",
" border: none;\n",
" border-radius: 50%;\n",
" cursor: pointer;\n",
" display: none;\n",
" fill: var(--fill-color);\n",
" height: 32px;\n",
" padding: 0;\n",
" width: 32px;\n",
" }\n",
"\n",
" .colab-df-quickchart:hover {\n",
" background-color: var(--hover-bg-color);\n",
" box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
" fill: var(--button-hover-fill-color);\n",
" }\n",
"\n",
" .colab-df-quickchart-complete:disabled,\n",
" .colab-df-quickchart-complete:disabled:hover {\n",
" background-color: var(--disabled-bg-color);\n",
" fill: var(--disabled-fill-color);\n",
" box-shadow: none;\n",
" }\n",
"\n",
" .colab-df-spinner {\n",
" border: 2px solid var(--fill-color);\n",
" border-color: transparent;\n",
" border-bottom-color: var(--fill-color);\n",
" animation:\n",
" spin 1s steps(1) infinite;\n",
" }\n",
"\n",
" @keyframes spin {\n",
" 0% {\n",
" border-color: transparent;\n",
" border-bottom-color: var(--fill-color);\n",
" border-left-color: var(--fill-color);\n",
" }\n",
" 20% {\n",
" border-color: transparent;\n",
" border-left-color: var(--fill-color);\n",
" border-top-color: var(--fill-color);\n",
" }\n",
" 30% {\n",
" border-color: transparent;\n",
" border-left-color: var(--fill-color);\n",
" border-top-color: var(--fill-color);\n",
" border-right-color: var(--fill-color);\n",
" }\n",
" 40% {\n",
" border-color: transparent;\n",
" border-right-color: var(--fill-color);\n",
" border-top-color: var(--fill-color);\n",
" }\n",
" 60% {\n",
" border-color: transparent;\n",
" border-right-color: var(--fill-color);\n",
" }\n",
" 80% {\n",
" border-color: transparent;\n",
" border-right-color: var(--fill-color);\n",
" border-bottom-color: var(--fill-color);\n",
" }\n",
" 90% {\n",
" border-color: transparent;\n",
" border-bottom-color: var(--fill-color);\n",
" }\n",
" }\n",
"</style>\n",
"\n",
" <script>\n",
" async function quickchart(key) {\n",
" const quickchartButtonEl =\n",
" document.querySelector('#' + key + ' button');\n",
" quickchartButtonEl.disabled = true; // To prevent multiple clicks.\n",
" quickchartButtonEl.classList.add('colab-df-spinner');\n",
" try {\n",
" const charts = await google.colab.kernel.invokeFunction(\n",
" 'suggestCharts', [key], {});\n",
" } catch (error) {\n",
" console.error('Error during call to suggestCharts:', error);\n",
" }\n",
" quickchartButtonEl.classList.remove('colab-df-spinner');\n",
" quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
" }\n",
" (() => {\n",
" let quickchartButtonEl =\n",
" document.querySelector('#df-1d11a2ab-dd76-48f3-853f-51c2a2ff51d5 button');\n",
" quickchartButtonEl.style.display =\n",
" google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
" })();\n",
" </script>\n",
"</div>\n",
"\n",
" <div id=\"id_1918a6b0-5b55-45d7-9c14-ee29641610d9\">\n",
" <style>\n",
" .colab-df-generate {\n",
" background-color: #E8F0FE;\n",
" border: none;\n",
" border-radius: 50%;\n",
" cursor: pointer;\n",
" display: none;\n",
" fill: #1967D2;\n",
" height: 32px;\n",
" padding: 0 0 0 0;\n",
" width: 32px;\n",
" }\n",
"\n",
" .colab-df-generate:hover {\n",
" background-color: #E2EBFA;\n",
" box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
" fill: #174EA6;\n",
" }\n",
"\n",
" [theme=dark] .colab-df-generate {\n",
" background-color: #3B4455;\n",
" fill: #D2E3FC;\n",
" }\n",
"\n",
" [theme=dark] .colab-df-generate:hover {\n",
" background-color: #434B5C;\n",
" box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
" filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
" fill: #FFFFFF;\n",
" }\n",
" </style>\n",
" <button class=\"colab-df-generate\" onclick=\"generateWithVariable('Resumeranking')\"\n",
" title=\"Generate code using this dataframe.\"\n",
" style=\"display:none;\">\n",
"\n",
" <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
" width=\"24px\">\n",
" <path d=\"M7,19H8.4L18.45,9,17,7.55,7,17.6ZM5,21V16.75L18.45,3.32a2,2,0,0,1,2.83,0l1.4,1.43a1.91,1.91,0,0,1,.58,1.4,1.91,1.91,0,0,1-.58,1.4L9.25,21ZM18.45,9,17,7.55Zm-12,3A5.31,5.31,0,0,0,4.9,8.1,5.31,5.31,0,0,0,1,6.5,5.31,5.31,0,0,0,4.9,4.9,5.31,5.31,0,0,0,6.5,1,5.31,5.31,0,0,0,8.1,4.9,5.31,5.31,0,0,0,12,6.5,5.46,5.46,0,0,0,6.5,12Z\"/>\n",
" </svg>\n",
" </button>\n",
" <script>\n",
" (() => {\n",
" const buttonEl =\n",
" document.querySelector('#id_1918a6b0-5b55-45d7-9c14-ee29641610d9 button.colab-df-generate');\n",
" buttonEl.style.display =\n",
" google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
"\n",
" buttonEl.onclick = () => {\n",
" google.colab.notebook.generateWithVariable('Resumeranking');\n",
" }\n",
" })();\n",
" </script>\n",
" </div>\n",
"\n",
" </div>\n",
" </div>\n"
]
},
"metadata": {},
"execution_count": 203
}
]
},
{
"cell_type": "code",
"source": [
"Resumeranking['Resumes'][0]"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 174
},
"id": "q3iJMfuAudia",
"outputId": "457f5aa8-b1ea-4d12-9701-5bfdf7e69585"
},
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"'First Last Advertising Copy Writer Bay Area California +1234456789 professionalemailresumewordedcom linkedincominusername Advertising Copy Writer with eight years experience working with art directors to craft meaningful content for marketing and sales campaigns for over 75 clients to meet their advertising goals Supervised up to 10 junior copywriters and interns to assist in sharpening their writing skills to create content that delights its readers Acquired the Most Impactful Omnichannel Campaign Award for creating a crossplatform campaign concept that garnered over two million YouTube views and increased the clients customer base by 47 RELEVANT WORK EXPERIENCE Resume Worded New York NY 2015 Present Advertising Copy Writer 2017 Present Ranked number one in the top quartile of 50 copywriters for productivity metrics The metrics included the number of ads completed as per the brief within the scheduled timeframe with the least rewrites Consulted with eight department leads including Art Buying Merchandising Print Production and Social Media Management regarding print and graphic techniques to be considered when crafting the content Developed a $3M display for professionalgrade telescopes that increased category revenue by 50 Advertising Copy Writer 2015 2017 Developed copy for 10 omnichannel advertising campaigns for an international client while working remotely with a creative director and art director in London Collaborated with an art director on five awardwinning print advertisements that resulted in a 35 increase in client revenue and secured two new creative projects Growthsi San Francisco CA 2013 2015 Junior Copywriter Created social media strategies and rolled out 32 social media posts for four clients monthly which resulted in increased views likes and shares Optimized dated content across three websites to make it SEOfriendly by using the correct keywords and prioritizing highquality inbound and outbound links Resume Worded Exciting Company San Francisco CA 2011 2013 Copywriting Intern Started a weekly knowledgesharing Meetup for the companys 30 copywriting interns which resulted in 50 of the cohort being permanently employed Managed social media platforms for an advertising agency using TikTok Pinterest Facebook Instagram and Twitter and successfully increased engagement by 65 Collaborated with the other creative interns to brainstorm pitch ideas for dream clients which included names logos media content etc which resulted in two successful client pitches EDUCATION Resume Worded University New York NY Bachelor of Arts Journalism and Media Studies SKILLS Technical Skills Social Media WordPress Digital Marketing Search Engine Optimization SEO Languages English Native Portuguese Fluent Arabic Conversational'"
],
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
}
},
"metadata": {},
"execution_count": 204
}
]
},
{
"cell_type": "code",
"source": [
"Resumeranking['Resumes'][1]"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 261
},
"id": "etbBaUe3udjz",
"outputId": "44b96e1a-4b77-4b79-f1fa-d3d8a5db3cfe"
},
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"'BENTLI FALLA CAREER OBJECTIVE Creative and witty media mind with 3 years in professional social Social Media Content media roles Looking to use my knowledgebase of platforms and Creator trends which have generated trending posts with over 2M+ views to create captivating content for a company like Blueland = bentlifallaemailcom 123 4567890 o 125 WORK EXPERIENCE Q Las Vegas NV ff LinkedIn Social Media Content Moderator Teleperformance September 2018 current Las Vegas NV EDUCATION e Navigated 5+ social media platforms posting and engaging with content to increase followers by 22 since 2019 BS Maintained strong grasp of English utilizing grammatically Communication accurate sentences to answer 100+ questions per shift University of Nevada Analyzed media inquiries and determined how to address August 2014 May 2018 customer issues within 2 hours of posting Updated knowledge of software systems including Office Achieved 55 WPM responding to chats in 45 seconds Las Vegas NV Social Media Manager Intern Blue Ocean Digital Partners May 2018 September 2018 Las Vegas NV e Developed skills in SEO content creation KPIs and trend predictions Made engagement strategies presenting to 40+ colleagues Worked with Social Media Manager to boast lead generation creating 3 funnels resulting in a 7 increase in contact form submissions Generated social media presence on TikTok in 2018 rooting the company in the app before it was trending Maintained trending knowledgebase and strong understanding of 8 social media platforms including YouTube Facebook and TikTok SKILLS Instagram Twitter Facebook Pinterest YouTube TikTok Google Analytics SEO Paid social media advertising Attention to Detail'"
],
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
}
},
"metadata": {},
"execution_count": 199
}
]
},
{
"cell_type": "code",
"source": [
"Resumeranking['Resumes'][2]"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 400
},
"id": "LGl_LxhEudnm",
"outputId": "353c6ac5-f8de-47ae-e798-513b960c2a93"
},
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"'CESAR CABAL Financial Analyst ccabal43emailcom 123 4567890 Atlanta GA LinkedIn EDUCATION Masters Business Administration University of Georgia 2014 2016 Atlanta GA Bachelor of Science Finance University of Georgia 2010 2014 Atlanta GA SKILLS MS Excel Original Research Budget Development Project Management Data Analysis MA CAREER OBJECTIVE Detailoriented financial analyst with 6 years in quantitative statistical analysis budgeting accounting and forecasting Leveraging strong analytical skills to support operations through robust modeling to facilitate executivelevel decisionmaking and increase company revenue Quickly adapt to new technologies and attaining CPA licensure to become an indispensable asset to Logistics Property WORK EXPERIENCE Financial Analyst King Spalding October 2018 current Atlanta GA Update daily cash position through analysis investigation and reporting on key movements and trends in the PL lines Provide financial guidance to BusinessFunctions and assist in decisionmaking contributing to a 13 growth trend by developing strategic longrange planning recommendations for management Monitor regulatory developments and industry trends to facilitate incorporation into the firms AML program Perform a comprehensive analysis of financial issues debt and in depth market share and industry report that increased market share by 19 thereby increasing revenue by $12M Managed 3 financial statements with advanced layering of discounted cash flow analysis and internal planning models linked to automation tools that decreased manual admin tasks by 48 Financial Analyst Barnum Financial Group May 2016 October 2018 Atlanta GA Designed and created weekly and monthly comprehensive spending reports abstracts and charts to present data and guide investment strategies and performed adhoc analysis and reporting Improved operational efficiency of finance systems by 11 through implementation of streamlined datamanagement procedures Coordinated with underwriters lenders and loan managers to manage portfolios for multimilliondollar accounts Monitored the fund and equity investments including inflows outflows valuations risk ratings and record maintenance Established new forecasting tracking and management reporting system to improve availability and accuracy of financial data triggering a 14 increase in accuracy Financial Analysis Intern RaceTrac January 2016 April 2016 Atlanta GA Improved reporting process time by 20 with ad hoc analyses Created financial models and contributed findings to management to support initiatives for internal customers'"
],
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
}
},
"metadata": {},
"execution_count": 200
}
]
},
{
"cell_type": "code",
"source": [
"Resumeranking['Resumes'][4]"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 313
},
"id": "EbJ-XIMXudpM",
"outputId": "66f0d93b-3385-471c-8f64-8bb2a3f92822"
},
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"'CHELSEY DEGA Marketing Manager chelseydegaemailcom 123 4567890 Brooklyn NY LinkedIn EDUCATION BS Marketing University of Pittsburgh September 2010 April 2014 Pittsburgh PA SKILLS HubSpot Salesforce Microsoft Excel Word PowerPoint Paid Ads Facebook Google LinkedIn retargeting AB testing audience segmentation Google Analytics SEO WORK EXPERIENCE Marketing Manager HADASSAH May 2018 current New York NY Directed the launch of a campaign for a new platform resulting in revenue of $53M in the first year Created a holistic paid acquisition strategy ultimately leading to an ROI of 41 for every dollar spent Built out a culture of robust data collection and AB testing to iteratively improve campaign performance leading to an average improvement of 64 from campaign start to end Developed partnerships with higher education institutions in the US resulting in an incremental $74M in revenue Exceeded sales targets by 32 for the full year in 2019 Identified vendors who were underperforming leading to a reduction in costs of $425000 while exceeding revenue targets Oversaw a team of 5 fulltime marketers and 4 paid contractors Marketing Manager Fora Financial August 2016 May 2018 New York NY Developed a comprehensive paid acquisition strategy across Google Facebook and industry newsletters resulting in new leads that generated $18M in 2017 Built a robust brand awareness campaign through conferences and speaking engagements leading to an increase in inbound leads of 68 year over year Led the implementation of realtime reporting on marketing spend to adjust bid strategy leading to an improvement of ROI by 22 Exceeded growth targets every quarter by 23 on average Managed a team of 4 fulltime marketing associates Marketing Analyst Insight Global August 2014 August 2016 Washington DC Created AB testing plan for Facebook ad copy leading to an improvement in ROI of 12 Built key reports in Tableau for executive team around KPIs such as marketing spend new leads revenue generates and ROI saving 9 hours of manual reporting each week'"
],
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
}
},
"metadata": {},
"execution_count": 201
}
]
},
{
"cell_type": "code",
"source": [
"Resumeranking['Resumes'][8]"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 278
},
"id": "B6MH8RmjHEjE",
"outputId": "cb5aebaf-76b5-45ec-f482-52f9ad507a7a"
},
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"'OBJECTIVE To impart my knowledge in Veterinary medicine and provide quality healthcare to animals My aim is to sustain animal life by administering immunization to guard them against diseases PERSONAL INFORMATION Brian Avelar 322 Dogwood Lane Tucson AZ 85712 7778844221 bavelarsampleresumenet Date of Birth May 6 1979 Place of Birth PA Citizenship American Gender Male PROFILE SUMMARY Knowledgeable in toxicology and laboratory animal medicines Great skills in interpreting animal behavior Pathology EDUCATION Doctor of Veterinary Medicine 2009 Polytechnic Institute of New York University Brooklyn BS in Biology 2006 Polytechnic Institute of New York University Brooklyn EMPLOYMENT HISTORY Pharmaceutical Veterinarian 2007 Present AstraZeneca Pharmaceuticals LP Wilmington DE Responsibilities Administered immunization to animals to protect them from diseases Studied cause of animal diseases Reviewed the list of raw materials to be used and mixed in the vaccine Tested efficacy and effectiveness of vaccines to dying animals Inspected the meat products given to animals as food Developed vaccines for animals City Veterinarian 2006 2007 Private Practice Responsibilities Prescribed medicines for animals Provided daily menu for sick animals Immunized the cattle in MAGV Farm Educated the pet owners on proper animal bathing and feeding Demonstrated to clients the administration of vaccine to their pets RESEARCH Journey to Animal Life TRAININGCERTIFICATION Certificate in Animal Pathology AWARD EnvironmentFriendly Research PROFESSIONAL MEMBERSHIP American Animal Hospital Association American Veterinary Medical Association SKILLS Great communication skills Strong familiarity with animal diseases Ability to tame uncooperative animals'"
],
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
}
},
"metadata": {},
"execution_count": 205
}
]
},
{
"cell_type": "code",
"source": [],
"metadata": {
"id": "PxzWAz19HF6j"
},
"execution_count": null,
"outputs": []
}
]
} |