Spaces:
Running
Running
File size: 182,342 Bytes
b82f276 | 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 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 | {
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "75d0658c-fb24-420f-9031-118d0041def9",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Collecting PyPDF2\n",
" Downloading pypdf2-3.0.1-py3-none-any.whl.metadata (6.8 kB)\n",
"Downloading pypdf2-3.0.1-py3-none-any.whl (232 kB)\n",
"Installing collected packages: PyPDF2\n",
"Successfully installed PyPDF2-3.0.1\n",
"Note: you may need to restart the kernel to use updated packages.\n"
]
}
],
"source": [
"pip install PyPDF2 transformers==4.46.0 faiss-cpu"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "4cd61927-a7bb-4585-b566-f6dbf5311b90",
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"os.environ[\"KMP_DUPLICATE_LIB_OK\"] = \"TRUE\" # Temporary fix\n",
"os.environ[\"FAISS_NO_OPENMP\"] = \"1\" # Prevent FAISS from using OpenMP"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "55f1b6a7-9dac-4750-80bc-2a56f269673c",
"metadata": {},
"outputs": [],
"source": [
"from PyPDF2 import PdfReader\n",
"from tqdm import tqdm"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "5f05891d-1467-428d-b837-696a05b4ee73",
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"path = \"../../volumes/pdfs/2023050195.pdf\"\n",
"\n",
"pdf_content = PdfReader(path)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "f552d64a-006a-47cf-98a2-a859eaeb6c42",
"metadata": {},
"outputs": [],
"source": [
"def get_pdf_texts(pdf_path):\n",
" pdf_text_dict = {}\n",
" for page_no, page in enumerate(tqdm(pdf_content.pages), start=1):\n",
" text = page.extract_text()\n",
" pdf_text_dict[page_no] = text\n",
" return pdf_text_dict"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "bcc8fa60-b3cd-4749-b7d9-0fe794655a28",
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"# pdf_texts = []\n",
"# for page in tqdm(pdf_content.pages):\n",
"# text = page.extract_text()\n",
"# pdf_texts.append(text)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "b79753e3-d19c-4fb9-a7f6-609ce654aaab",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"100%|████████████████████████████████████████████████████████████████████████████████| 404/404 [00:30<00:00, 13.30it/s]\n"
]
}
],
"source": [
"pdf_text_dict = get_pdf_texts(path)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "70bcacf8-5c08-4258-9a2b-4bcbe29d2a00",
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"THE CONSTITUTION OF INDIA \n",
"(Appendix I) \n",
" 368\n",
"1 2 3 4 5 6 \n",
"43. (i) Chhit Nalgram Sitalkuchi Patgarm 66 49.5 \n",
" (ii) Chhit Nalgram \n",
"(Fragment) Sitalkuchi Patgarm 66 \n",
"44. (i) Batrigachh Dinhata Kaliganj 81 577.37 \n",
" (ii) Batrigachh \n",
"(Fragment) Dinhata Kaliganj 81 \n",
" (iii) Batrigachh \n",
"(Fragment) Dinhata Phulbari 9 \n",
"45. (i) Karala Dinhata Phulbari 9 269.91 \n",
" (ii) Karala (fragment) Dinhata Phulbari 9 \n",
" (iii) Karala (fragment) Dinhata Phulbari 8 \n",
"46. (i) Sipprasad Mustati Dinhata Phulbari 8 373.2 \n",
" (ii) Sipprasad Mustati \n",
"(Fragment) Dinhata Phulbari 6 \n",
"47. (i) Dakshin \n",
"Masaldanga Dinhata Bhurungamari 6 571.38 \n",
" (ii) Dakshin \n",
"Masaldanga \n",
"(Fragment) Dinhata Bhurungamari 6 \n",
" (iii) Dakshin \n",
"Masaldanga \n",
"(Fragment) Dinhata Bhurungamari 6 \n",
" (iv) Dakshin \n",
"Masaldanga \n",
"(Fragment) Dinhata Bhurungamari 6 \n",
" (v) Dakshin \n",
"Masaldanga \n",
"(Fragment) Dinhata Bhurungamari 6 \n",
" (vi) Dakshin \n",
"Masaldanga \n",
"(Fragment) Dinhata Bhurungamari 6 \n"
]
}
],
"source": [
"print(pdf_text_dict[401])"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "dd8940af-9978-4b7d-927d-e2f217b1d0fc",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"' \\n \\n \\n \\n \\n THE CONSTITUTION OF INDIA \\n[As on May , 2022] \\n2022 \\n '"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pdf_text_dict[1]"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "801757f0-8321-43cd-99ef-1655acb37e7c",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"' \\n \\nPREFACE \\n \\nThis is the fifth pocket size edition of the Constitution of \\nIndia in the diglot form. In this edition, the text of the \\nConstitution of India has been brought up-to-date by \\nincorporating therein all the amendments up to the Constitution \\n(One Hundred and Fifth Amendment) Act, 2021. The foot notes \\nbelow the text indicate the Constitution Amendment Acts by \\nwhich such amendments have been made. \\nThe Constitution (One Hundredth Amendment) Act, 2015 \\ncontaining details of acquired and transferred territories \\nbetween the Governments of India and Bangladesh has been \\nprovided in APPENDIX I. \\nThe Constitution (Application to Jammu and Kashmir) \\nOrder, 2019 and the declaration under article 370(3) of the \\nConstitution have been provided respectively in Appendix II and \\nAppendix III for reference. \\n \\n \\nNew Delhi; Dr. Reeta Vasishta, \\n Secretary to the Government of India. \\n \\n '"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pdf_text_dict[2]"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "448d302c-4def-4c3a-a707-6d85ebe6f1c9",
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"THE CONSTITUTION OF INDIA \n",
"(Part XII. —Finance, Property, Contracts and Suits) \n",
" 169\n",
"Provided that any property which at the date when it would have so \n",
"accrued to His Majesty or to the Ruler of an Indian State was in the possession \n",
"or under the control of the Government of India or the Government of a State \n",
"shall, according as the purposes for which it was then used or held were \n",
"purposes of the Union or of a State, vest in the Union or in that State. \n",
"Explanation.— In this article, the expressions “Ruler” and “Indian State” \n",
"have the same meanings as in article 363. \n",
"1[297. Things of value within territorial waters or continental shelf \n",
"and resources of the exclusive economic zone to vest in the Union .—(1) All \n",
"lands, minerals and other things of value underlying the ocean within the \n",
"territorial waters, or the continental shelf, or the exclusive economic zone, of \n",
"India shall vest in the Union and be held for the purposes of the Union. \n",
"(2) All other resources of the exclusive economic zone of India shall also \n",
"vest in the Union and be held for the purposes of the Union. \n",
"(3) The limits of the territorial waters, the continental shelf, the exclusive \n",
"economic zone, and other maritime zones, of India shall be such as may be \n",
"specified, from time to time, by or under any law made by Parliament.] \n",
"2[298. Power to carry on trade, etc. —The executive power of the \n",
"Union and of each State shall extend to the carrying on of any trade or business \n",
"and to the acquisition, holding and disposal of property and the making of \n",
"contracts for any purpose: \n",
"Provided that— \n",
"(a) the said executive power of the Union shall, in so far as such \n",
"trade or business or such purpose is not one with respect to which \n",
"Parliament may make laws, be subject in each State to legislation by the \n",
"State; and \n",
"(b) the said executive power of each State shall, in so far as such \n",
"trade or business or such purpose is not one with respect to which the \n",
"State Legislature may make laws, be subject to legislation by \n",
"Parliament.] \n",
"______________________________________________ \n",
"1. Subs. by the Constitution (Fortieth Amendment) Act, 1976, s. 2 (w.e.f. 27-5-1976). \n",
"2. Subs. by the Constitution (Seventh Amendment) Act, 1956, s. 20 (w.e.f. 1-11-1956). \n"
]
}
],
"source": [
"print(pdf_text_dict[200])"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "74dee5b1-f158-48b4-ae79-0e2aaf54dadd",
"metadata": {},
"outputs": [],
"source": [
"metadata = {}\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0d3bebdb-38f8-4933-b7a9-87effb9cc4c4",
"metadata": {},
"outputs": [],
"source": [
"for page_no,text in pdf_text_dict.items()"
]
},
{
"cell_type": "code",
"execution_count": 30,
"id": "91aeb2b4-af4f-43d6-bdff-5fa3bbd2e430",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" \n",
" \n",
" \n",
" \n",
" \n",
" THE CONSTITUTION OF INDIA \n",
"[As on May , 2022] \n",
"2022 \n",
" \n"
]
}
],
"source": [
"print(pdf_text_dict[1])"
]
},
{
"cell_type": "code",
"execution_count": 31,
"id": "4fb24b5d-13f2-4638-ab52-702ee9b6fc5c",
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" 371APPENDIX III \n",
"1DECLRATION UNDER ARTICLE 370(3) OF THE CONSTITUTION \n",
"C.O. 273 \n",
"In exercise of the powers conferred by clause (3) of article 370 read \n",
"with clause (1) of article 370 of the Constitution of India, the President, on the \n",
"recommendation of Parliament, is pleased to declare that, as from the 6th \n",
"August, 2019, all clauses of the said article 370 shall cease to be operative \n",
"except the following which shall read as under, namely :— \n",
"“370. All provisions of this Constitution, as amended from time to \n",
"time, without any modifications or exceptions, shall apply to the State of \n",
"Jammu and Kashmir notwithstanding anything contrary contained in \n",
"article 152 or article 308 or any other article of this Constitution or any \n",
"other provision of the Constitution of Jammu and Kashmir or any law, \n",
"document, judgement, ordinance, order, by-law, rule, regulation, \n",
"notification, custom or usage having the force of law in the territory of \n",
"India, or any other instrument, treaty or agreement as envisaged under \n",
"article 363 or otherwise.”. \n",
"______________________________________________ \n",
"1.Published with the Ministry of Law and Justice, (Legislative Department) notification \n",
"No. G.S.R. 562(E), dated the 6th August, 2019, Gazette of India, Extraordinary, Part II, \n",
"Section 3, Sub-section (i). \n"
]
}
],
"source": [
"print(pdf_text_dict[404])"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "a58ca47b-8f28-451d-be5d-9756ff9440c9",
"metadata": {},
"outputs": [],
"source": [
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "fb03fafa-7ea8-473a-818e-0cf3deb0292c",
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.9341315\n"
]
}
],
"source": [
"from transformers import AutoModel\n",
"from numpy.linalg import norm\n",
"\n",
"cos_sim = lambda a,b: (a @ b.T) / (norm(a)*norm(b))\n",
"model = AutoModel.from_pretrained('../../volumes/models/jina-embeddings-v2-base-en/', trust_remote_code=True) # trust_remote_code is needed to use the encode method\n",
"embeddings = model.encode(['How is the weather today?', 'What is the current weather like today?'])\n",
"print(cos_sim(embeddings[0], embeddings[1]))"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "a1e608d8-74bb-41bb-beb8-33766e572c3a",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"768"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"len(embeddings[0])"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "877bb914-24dd-4775-a354-59dc363e4ee5",
"metadata": {},
"outputs": [],
"source": [
"def get_embeddings(text:list):\n",
" embeddings = model.encode(text)\n",
" normalized_embeddings = embeddings/norm(embeddings[0])\n",
" return normalized_embeddings"
]
},
{
"cell_type": "code",
"execution_count": 29,
"id": "3253b3f3-2861-4663-863a-94e1e5fa4959",
"metadata": {},
"outputs": [],
"source": [
"def batch_embeddings(texts, batch_size=5):\n",
" all_embeddings = []\n",
" for i in tqdm(range(0, len(texts), batch_size)):\n",
" batch = texts[i:i+batch_size]\n",
" embeddings = get_embeddings(batch)\n",
" all_embeddings.extend(embeddings.tolist())\n",
" return np.array(all_embeddings)"
]
},
{
"cell_type": "code",
"execution_count": 28,
"id": "2af58cef-d457-4282-85a6-e158b4c536b4",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"100%|████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:18<00:00, 9.26s/it]\n"
]
}
],
"source": [
"# res = batch_embeddings(list(pdf_text_dict.values())[0:10], batch_size=5)"
]
},
{
"cell_type": "code",
"execution_count": 31,
"id": "c11e61cc-401d-49c3-93a9-79b945ba9ceb",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"100%|██████████████████████████████████████████████████████████████████████████████████| 81/81 [16:37<00:00, 12.31s/it]\n"
]
}
],
"source": [
"result_embeddings = batch_embeddings(list(pdf_text_dict.values()), batch_size=5)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "5103f001-6a77-4381-af8b-22f1e35049ed",
"metadata": {},
"outputs": [],
"source": [
"# import pickle\n",
"\n",
"# with open(\"embeddings.pkl\", \"wb\") as p:\n",
"# pickle.dump(result_embeddings, p)"
]
},
{
"cell_type": "code",
"execution_count": 24,
"id": "0fd12d04-9ed7-4909-95d9-852c016bdfa7",
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": [
"[' \\n \\n \\n \\n \\n THE CONSTITUTION OF INDIA \\n[As on May , 2022] \\n2022 \\n ',\n",
" ' \\n \\nPREFACE \\n \\nThis is the fifth pocket size edition of the Constitution of \\nIndia in the diglot form. In this edition, the text of the \\nConstitution of India has been brought up-to-date by \\nincorporating therein all the amendments up to the Constitution \\n(One Hundred and Fifth Amendment) Act, 2021. The foot notes \\nbelow the text indicate the Constitution Amendment Acts by \\nwhich such amendments have been made. \\nThe Constitution (One Hundredth Amendment) Act, 2015 \\ncontaining details of acquired and transferred territories \\nbetween the Governments of India and Bangladesh has been \\nprovided in APPENDIX I. \\nThe Constitution (Application to Jammu and Kashmir) \\nOrder, 2019 and the declaration under article 370(3) of the \\nConstitution have been provided respectively in Appendix II and \\nAppendix III for reference. \\n \\n \\nNew Delhi; Dr. Reeta Vasishta, \\n Secretary to the Government of India. \\n \\n ',\n",
" ' \\nLIST OF ABBREVIATIONS USED \\n \\n \\nArt., arts. ........................................................ for Article, articles. \\nCl., cls. ........................................................ ″ Clause, clauses. \\nC.O. ........................................................ ″ Constitution Order. \\nIns. ........................................................ ″ Inserted. \\nP., pp. ........................................................ ″ Page, pages. \\nPt. ........................................................ ″ Part. \\nRep. ........................................................ ″ Repealed. \\nSs., ss. .......................................................... ″ Section, sections. \\nSch. ......................................................... ″ Schedule. \\nSubs. ........................................................ ″ Substituted. \\nw.e.f. ......................................................... ″ with effect from. \\nw.r.e.f. ...................................................... ″ with retrospective effect \\nfrom. \\n ',\n",
" 'THE CONSTITUTION OF INDIA \\n____________ \\n \\nCONTENTS \\n__________ \\n \\n \\nPREAMBLE \\nPART I \\nTHE UNION AND ITS TERRITORY \\nARTICLES \\n 1. Name and territory of the Union. \\n 2. Admission or establishment of new States. \\n[2A. Sikkim to be associated with the Union. —Omitted.] \\n 3. Formation of new States and alteration of areas, boundaries or \\nnames of existing States. \\n 4. Laws made under articles 2 and 3 to provide for the amendment of \\nthe First and the Fourth Schedules and supplemental, incidental \\nand consequential matters. \\nPART II \\nCITIZENSHIP \\n 5. Citizenship at the commencement of the Constitution. \\n6. Rights of citizenship of certain persons who have migrated to \\nIndia from Pakistan. \\n 7. Rights of citizenship of certain migrants to Pakistan. \\n8. Rights of citizenship of certain persons of Indian origin residing \\noutside India. \\n9. Persons voluntarily acquiring citizenship of a foreign State not to \\nbe citizens. \\n10. Continuance of the rights of citizenship. \\n11. Parliament to regulate the right of citizenship by law. ',\n",
" 'Contents \\n \\n ARTICLES (ii)\\nPART III \\nFUNDAMENTAL RIGHTS \\nGeneral \\n12. Definition. \\n13. Laws inconsistent with or in derogation of the fundamental \\nrights. \\n Right to Equality \\n14. Equality before law. \\n15. Prohibition of discrimination on grounds of religion, race, caste, \\nsex or place of birth. \\n16. Equality of opportunity in matters of public employment. \\n17. Abolition of Untouchability. \\n18. Abolition of titles. \\n Right to Freedom \\n19. Protection of certain rights regarding freedom of speech, etc. \\n20. Protection in respect of conviction for offences. \\n21. Protection of life and personal liberty. \\n21A. Right to education. \\n22. Protection against arrest and detention in certain cases. \\n Right against Exploitation \\n23. Prohibition of traffic in human beings and forced labour. \\n24. Prohibition of employment of children in factories, etc. \\n Right to Freedom of Religion \\n25. Freedom of conscience and free profession, practice and \\npropagation of religion. \\n26. Freedom to manage religious affairs. \\n27. Freedom as to payment of taxes for promotion of any particular \\nreligion. \\n28. Freedom as to attendance at religious instruction or religious \\nworship in certain educational institutions. ',\n",
" 'Contents \\n \\n ARTICLES (iii) \\n Cultural and Educational Rights \\n29. Protection of interests of minorities. \\n30. Right of minorities to establish and administer educational \\ninstitutions. \\n[31. Compulsory acquisition of property . —Omitted.] \\n Saving of Certain Laws \\n31A. Saving of Laws providing for acquisition of estates, etc. \\n31B. Validation of certain Acts and Regulations. \\n31C. Saving of laws giving effect to certain directive principles. \\n[31D. Saving of laws in respect of anti-national activities. —Omitted.] \\n Right to Constitutional Remedies \\n 32. Remedies for enforcement of rights conferred by this Part. \\n[32A. Constitutional validity of State laws not to be considered in \\nproceedings under article 32. —Omitted.] \\n 33. Power of Parliament to modify the rights conferred by this Part \\nin their application to Forces, etc. \\n 34. Restriction on rights conferred by this Part while martial law is \\nin force in any area. \\n 35. Legislation to give effect to the provisions of this Part. \\n PART IV \\nDIRECTIVE PRINCIPLES OF STATE POLICY \\n 36. Definition. \\n 37. Application of the principles contained in this Part. \\n38. State to secure a social order for the promotion of welfare of the \\npeople. \\n 39. Certain principles of policy to be followed by the State. \\n39A. Equal justice and free legal aid. ',\n",
" 'Contents \\n \\n ARTICLES (iv)\\n 40. Organisation of village panchayats. \\n 41. Right to work, to education and to public assistance in certain \\ncases. \\n 42. Provision for just and humane conditions of work and maternity \\nrelief. \\n 43. Living wage, etc., for workers. \\n43A. Participation of workers in management of Industries. \\n43B. Promotion of co-operative societies. \\n 44. Uniform civil code for the citizens. \\n 45. Provision for early childhood care and educat ion to children \\nbelow the age of six years. \\n 46. Promotion of educational and economic interests of Scheduled \\nCastes, Scheduled Tribes and other weaker sections. \\n 47. Duty of the State to raise the level of nutrition and the standard \\nof living and to improve public health. \\n 48. Organisation of agriculture and animal husbandry. \\n48A. Protection and improvement of environment and safeguarding of \\nforests and wild life. \\n 49. Protection of monuments and places and objects of national \\nimportance. \\n 50. Separation of judiciary from executive. \\n 51. Promotion of international peace and security. \\n PART IVA \\nFUNDAMENTAL DUTIES \\n51A. Fundamental duties. \\n \\n \\n \\n \\n PART V \\nTHE UNION \\nCHAPTER I.\\uf0beTHE EXECUTIVE \\nThe President and Vice-President \\n52. The President of India. \\n53. Executive power of the Union. \\n54. Election of President. ',\n",
" 'Contents \\n \\n ARTICLES (v) \\n55. Manner of election of President. \\n56. Term of office of President. \\n57. Eligibility for re-election. \\n58. Qualifications for election as President. \\n59. Conditions of President’s office. \\n60. Oath or affirmation by the President. \\n61. Procedure for impeachment of the President. \\n62. Time of holding election to fill vacancy in the office of President \\nand the term of office of person elected to fill casual vacancy. \\n63. The Vice-President of India. \\n64. The Vice-President to be ex officio Chairman of the Council of \\nStates. \\n65. The Vice-President to act as President or to discharge his \\nfunctions during casual vacancies in the office, or during the \\nabsence, of President. \\n66. Election of Vice-President. \\n67. Term of office of Vice-President. \\n68. Time of holding election to fill vacancy in the office of Vice-President \\nand the term of office of person elected to fill casual vacancy. \\n69. Oath or affirmation by the Vice-President. \\n70. Discharge of President’s functions in other contingencies. \\n71. Matters relating to, or connected with, the election of a President \\nor Vice-President. \\n72. Power of President to grant pardons, etc., and to suspend, remit \\nor commute sentences in certain cases. \\n73. Extent of executive power of the Union. \\n Council of Ministers \\n74. Council of Ministers to aid and advise President . \\n75. Other provisions as to Ministers. \\n The Attorney-General for India \\n76. Attorney-General for India. ',\n",
" 'Contents \\n \\n ARTICLES (vi)\\n Conduct of Government Business \\n77. Conduct of business of the Government of India. \\n78. Duties of Prime Minister as respects the furnishing of \\ninformation to the President, etc. \\n CHAPTER II. \\uf0bePARLIAMENT \\nGeneral \\n79. Constitution of Parliament. \\n80. Composition of the Council of States. \\n81. Composition of the House of the People. \\n82. Readjustment after each census. \\n83. Duration of Houses of Parliament. \\n84. Qualification for membership of Parliament. \\n85. Sessions of Parliament, prorogation and dissolution. \\n86. Right of President to address and send messages to Houses. \\n87. Special address by the President. \\n88. Rights of Ministers and Attorney-General as respects Houses. \\n \\nOfficers of Parliament \\n89. The Chairman and Deputy Chairman of the Council of States. \\n90. Vacation and resignation of, and removal from, the office of \\nDeputy Chairman. \\n91. Power of the Deputy Chairman or other person to perform the \\nduties of the office of, or to act as, Chairman. \\n92. The Chairman or the Deputy Chairman not to preside while a \\nresolution for his removal from office is under consideration. \\n93. The Speaker and Deputy Speaker of the House of the People. \\n94. Vacation and resignation of, and removal from, the offices of \\nSpeaker and Deputy Speaker. \\n95. Power of the Deputy Speaker or other person to perform the \\nduties of the office of, or to act as, Speaker. ',\n",
" 'Contents \\n \\n ARTICLES (vii)\\n96. The Speaker or the Deputy Speaker not to preside while a \\nresolution for his removal from office is under consideration. \\n97. Salaries and allowances of the Chairman and Deputy Chairman \\nand the Speaker and Deputy Speaker. \\n98. Secretariat of Parliament. \\n \\nConduct of Business \\n 99. Oath or affirmation by members. \\n100. Voting in Houses, power of Houses to act notwithstanding \\nvacancies and quorum. \\n \\nDisqualifications of Members \\n101. Vacation of seats. \\n102. Disqualifications for membership. \\n103. Decision on questions as to disqualifications of members. \\n104. Penalty for sitting and voting before making oath or affirmation \\nunder article 99 or when not qualified or when disqualified. \\n \\nPowers, Privileges and Immunities of Parliament and its \\nMembers \\n105. Powers, privileges, etc., of the Houses of Parliament and of the \\nmembers and committees thereof. \\n106. Salaries and allowances of members. \\n Legislative Procedure \\n107. Provisions as to introduction and passing of Bills. \\n108. Joint sitting of both Houses in certain cases. \\n109. Special procedure in respect of Money Bills. \\n110. Definition of “Money Bills”. \\n111. Assent to Bills. \\n Procedure in Financial Matters \\n112. Annual financial statement. \\n113. Procedure in Parliament with respect to estimates. \\n114. Appropriation Bills. ']"
]
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"list(pdf_text_dict.values())[0:10]"
]
},
{
"cell_type": "code",
"execution_count": 25,
"id": "1f63bb3a-c198-4c8a-8738-51eaba6e7de1",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"' \\n \\nPREFACE \\n \\nThis is the fifth pocket size edition of the Constitution of \\nIndia in the diglot form. In this edition, the text of the \\nConstitution of India has been brought up-to-date by \\nincorporating therein all the amendments up to the Constitution \\n(One Hundred and Fifth Amendment) Act, 2021. The foot notes \\nbelow the text indicate the Constitution Amendment Acts by \\nwhich such amendments have been made. \\nThe Constitution (One Hundredth Amendment) Act, 2015 \\ncontaining details of acquired and transferred territories \\nbetween the Governments of India and Bangladesh has been \\nprovided in APPENDIX I. \\nThe Constitution (Application to Jammu and Kashmir) \\nOrder, 2019 and the declaration under article 370(3) of the \\nConstitution have been provided respectively in Appendix II and \\nAppendix III for reference. \\n \\n \\nNew Delhi; Dr. Reeta Vasishta, \\n Secretary to the Government of India. \\n \\n '"
]
},
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"list(pdf_text_dict.values())[0:10][1]"
]
},
{
"cell_type": "code",
"execution_count": 26,
"id": "f1cdcbf2-89b4-4310-b255-824beda23ed7",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'THE CONSTITUTION OF INDIA \\n____________ \\n \\nCONTENTS \\n__________ \\n \\n \\nPREAMBLE \\nPART I \\nTHE UNION AND ITS TERRITORY \\nARTICLES \\n 1. Name and territory of the Union. \\n 2. Admission or establishment of new States. \\n[2A. Sikkim to be associated with the Union. —Omitted.] \\n 3. Formation of new States and alteration of areas, boundaries or \\nnames of existing States. \\n 4. Laws made under articles 2 and 3 to provide for the amendment of \\nthe First and the Fourth Schedules and supplemental, incidental \\nand consequential matters. \\nPART II \\nCITIZENSHIP \\n 5. Citizenship at the commencement of the Constitution. \\n6. Rights of citizenship of certain persons who have migrated to \\nIndia from Pakistan. \\n 7. Rights of citizenship of certain migrants to Pakistan. \\n8. Rights of citizenship of certain persons of Indian origin residing \\noutside India. \\n9. Persons voluntarily acquiring citizenship of a foreign State not to \\nbe citizens. \\n10. Continuance of the rights of citizenship. \\n11. Parliament to regulate the right of citizenship by law. '"
]
},
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"list(pdf_text_dict.values())[0:10][3]"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "dd1c8671-d49c-4b0f-8227-7e464f632baf",
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"res"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "2b991749-1219-447b-94eb-0dce9ceb9ce4",
"metadata": {},
"outputs": [],
"source": [
"import pickle\n",
"\n",
"with open(\"embeddings.pkl\", \"rb\") as p:\n",
" embeddings = pickle.load(p)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "79cdf6e5-e226-425e-b436-f724a62e5116",
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": [
"array([-2.57174131e-02, -4.15116362e-03, 1.00257555e-02, 7.95926899e-02,\n",
" -5.00002429e-02, -3.94614115e-02, 1.33040652e-03, 2.53507891e-03,\n",
" 3.81039083e-02, 6.45715967e-02, -3.22419666e-02, 2.89166835e-03,\n",
" -4.41535637e-02, 6.61504979e-04, -5.27535751e-02, 3.93252261e-02,\n",
" 2.10104175e-02, 7.21139321e-03, -1.50410482e-03, 1.66766183e-03,\n",
" -2.18644273e-02, 1.02400398e-02, -3.55437882e-02, -2.15868000e-03,\n",
" 2.28184578e-03, 1.63813438e-02, 1.12895691e-03, 7.70135522e-02,\n",
" 3.45573463e-02, 2.44991146e-02, -2.00111717e-02, 6.72883913e-03,\n",
" -2.55250596e-02, -5.63424500e-03, -7.87753426e-03, -3.85418697e-03,\n",
" -2.48634145e-02, -7.07174744e-03, 3.84833887e-02, 3.21004912e-02,\n",
" -2.16781627e-04, -2.28117988e-03, 1.99199300e-02, 4.85927574e-02,\n",
" -4.08204794e-02, 2.73830462e-02, -1.26146292e-02, -7.49849342e-03,\n",
" -4.45639668e-03, 1.89360857e-04, -2.24946439e-03, -3.31600965e-03,\n",
" -1.60166472e-02, -4.04273309e-02, -1.43064400e-02, 7.14589376e-03,\n",
" 5.04611582e-02, 2.84321122e-02, -3.95181105e-02, -8.68732517e-04,\n",
" -2.38176603e-02, 2.31797881e-02, 3.92579325e-02, 4.16808613e-02,\n",
" 3.38643230e-02, 1.28792981e-02, 9.27819684e-03, -7.97275975e-02,\n",
" -3.62305865e-02, 2.44509690e-02, 2.51307455e-03, 4.34498712e-02,\n",
" 1.60570405e-02, -1.33092497e-02, -9.81435552e-03, 5.10461740e-02,\n",
" -3.22855450e-02, -1.40512027e-02, -7.44149759e-02, -1.59587599e-02,\n",
" 2.51831021e-02, 1.58212669e-02, 4.97941598e-02, -3.26568261e-02,\n",
" -2.20435690e-02, 2.86261998e-02, -2.31538024e-02, -1.90641768e-02,\n",
" 4.00074311e-02, -1.61560122e-02, -3.14329937e-02, 6.27738088e-02,\n",
" -2.24409103e-02, 3.14719267e-02, 2.86239833e-02, 2.29620934e-02,\n",
" 1.44532863e-02, -5.51838502e-02, -2.88846418e-02, -4.62175580e-03,\n",
" 1.42100332e-02, 5.03641441e-02, -1.44368866e-02, 1.35967033e-02,\n",
" -1.18015390e-02, 2.06576474e-03, 1.52302766e-02, -2.91087516e-02,\n",
" -1.70847271e-02, 5.28466376e-03, -4.24599834e-02, -5.27886814e-03,\n",
" 3.86601617e-03, -4.36887257e-02, -1.96105447e-02, -3.98451649e-02,\n",
" -8.91261175e-03, -1.73474178e-02, 9.97464289e-04, 2.16768160e-02,\n",
" -3.74223106e-02, 4.30773124e-02, 1.28850238e-02, -9.29087326e-02,\n",
" 1.92922913e-02, 4.35058624e-02, 1.49308136e-02, 1.14250602e-03,\n",
" -2.46660896e-02, -5.55287255e-03, 3.18912715e-02, -2.60299258e-02,\n",
" 8.21265057e-02, -3.20272557e-02, -4.86789122e-02, 1.06412657e-02,\n",
" 3.98511738e-02, 1.11424178e-02, -9.69936256e-04, 6.70285448e-02,\n",
" -2.38062274e-02, -6.55766157e-03, 1.78289581e-02, -4.01245579e-02,\n",
" 2.62775505e-03, 3.77939045e-02, -4.85070348e-02, -2.35254504e-02,\n",
" -3.50936875e-02, 1.93835108e-03, 3.82161736e-02, -8.27286094e-02,\n",
" -2.75273547e-02, 3.61397304e-02, -2.14401968e-02, -4.95456764e-03,\n",
" -4.97811707e-04, -2.23175157e-03, 1.15858512e-02, 2.71322229e-03,\n",
" -2.63919011e-02, -1.70119721e-02, -2.30862983e-02, -4.39894572e-02,\n",
" 8.27744696e-03, 8.56813118e-02, 5.17081209e-02, 1.51095930e-02,\n",
" 1.18505927e-02, -6.92560226e-02, 2.08177138e-02, -2.48438437e-02,\n",
" -5.57903796e-02, 1.35288127e-02, 9.48630273e-03, 3.01143415e-02,\n",
" -2.14476660e-02, 6.19690605e-02, -6.08530045e-02, 3.01848315e-02,\n",
" -3.79563421e-02, 8.09773356e-02, 2.98364609e-02, 3.11936922e-02,\n",
" 8.36985186e-02, -1.94082968e-02, 3.28132696e-02, -1.39129777e-02,\n",
" 3.52161825e-02, 1.45578096e-02, -8.08469858e-03, -4.15643305e-02,\n",
" -6.27987692e-03, 3.87079939e-02, 4.05535921e-02, 2.17505591e-03,\n",
" 4.16704677e-02, -1.85360219e-02, -6.13073297e-02, 4.11122628e-02,\n",
" -2.94521283e-02, 2.53554173e-02, -4.13463509e-04, 1.24392090e-02,\n",
" 5.10037597e-03, -8.75441432e-02, -3.35522071e-02, -3.55749391e-02,\n",
" -3.74199525e-02, 3.92984822e-02, -1.36980480e-02, 3.84706073e-02,\n",
" -4.34904322e-02, 3.40716764e-02, -4.10234183e-02, -1.77299529e-02,\n",
" 1.07169664e-02, 7.71508552e-03, -1.33038471e-02, 4.69463877e-02,\n",
" 1.00914231e-02, -1.03330135e-01, -4.46362644e-02, -1.52932955e-02,\n",
" -6.22913288e-03, -3.76083292e-02, 9.37229581e-03, -1.44105330e-02,\n",
" 1.81969441e-02, 5.68255000e-02, -3.81160788e-02, 4.99916263e-02,\n",
" 3.55331115e-02, -5.53132333e-02, 4.30908613e-02, -8.75021890e-03,\n",
" 3.62314880e-02, -5.99500723e-02, -2.00973544e-02, -4.23832871e-02,\n",
" 1.48631181e-04, -3.31453537e-03, 4.87194513e-04, 6.86692726e-03,\n",
" -4.33841534e-02, -4.10430506e-02, 5.04185893e-02, -4.39018644e-02,\n",
" 4.79511991e-02, 7.12994207e-03, -1.65666137e-02, -1.23005453e-03,\n",
" -3.21396142e-02, -1.26902126e-02, 6.85491562e-02, 1.83431469e-02,\n",
" -4.26707454e-02, 4.98602390e-02, 8.39052871e-02, -9.85294953e-03,\n",
" 8.00013989e-02, -4.78869081e-02, 1.33880717e-03, -2.08081026e-03,\n",
" 1.29001196e-02, -5.54729849e-02, -2.85176355e-02, 2.61613596e-02,\n",
" -4.12822664e-02, 1.80716123e-02, 1.55945877e-02, -1.89834833e-02,\n",
" -3.57164219e-02, -1.74036268e-02, -3.76872998e-03, 2.76176017e-02,\n",
" -1.64445620e-02, 4.80964892e-02, 5.67719936e-02, 2.63716877e-02,\n",
" -3.05653866e-02, -7.99957588e-02, 2.77207308e-02, 8.93560424e-03,\n",
" -2.45386343e-02, 4.97584045e-02, -8.40527117e-02, -3.09794471e-02,\n",
" -5.38634509e-03, 7.81132886e-03, -8.46644025e-03, -3.17460448e-02,\n",
" 8.91395062e-02, -8.24773312e-03, 2.08232916e-04, -3.84259224e-02,\n",
" -2.60309372e-02, -2.58680284e-02, -9.59970336e-03, 2.90000089e-03,\n",
" 4.20159735e-02, -4.92865033e-03, -9.60522983e-03, -3.23424898e-02,\n",
" 3.46885994e-02, 4.42737192e-02, -9.42309201e-03, 6.07546279e-03,\n",
" -2.04809848e-03, -1.51178017e-02, 2.23173369e-02, -3.20781916e-02,\n",
" 1.50055997e-02, -2.52247248e-02, 1.61739476e-02, -4.06084396e-02,\n",
" -2.92415190e-02, 3.84871215e-02, -1.96853466e-02, -1.38590904e-02,\n",
" 6.11174777e-02, 4.71853018e-02, 1.21613629e-02, 3.03259287e-02,\n",
" 8.15545693e-02, -2.39564423e-02, 2.26027034e-02, -7.38728466e-03,\n",
" 2.18835250e-02, -3.52734514e-02, -6.87112138e-02, -5.37812039e-02,\n",
" 4.49983263e-03, -5.48941791e-02, 2.35720444e-02, 2.43920870e-02,\n",
" 2.60311761e-03, -3.54177244e-02, 2.39417087e-02, -3.02902274e-02,\n",
" 7.50474110e-02, 2.58429758e-02, 2.00601593e-02, 3.20557528e-03,\n",
" -3.02898772e-02, 1.30107952e-02, -5.12817642e-03, -3.27567197e-03,\n",
" -1.83725245e-02, 8.14397857e-02, -1.26546798e-02, 2.06452329e-02,\n",
" 4.48793452e-03, 5.35670370e-02, 1.71370078e-02, -1.42205236e-02,\n",
" 9.90118086e-03, 3.87974083e-02, -1.12237856e-02, -9.28443745e-02,\n",
" -1.61213917e-03, 5.09403422e-02, -4.10091691e-02, -2.40587331e-02,\n",
" -1.67168677e-02, -8.25436227e-03, 3.00410315e-02, -3.02776904e-03,\n",
" -6.56920895e-02, 1.08523667e-02, -6.01664782e-02, 3.51346321e-02,\n",
" 8.31364654e-03, -2.93967668e-02, -1.29347006e-02, -3.68301757e-02,\n",
" 1.74103808e-02, 8.80057830e-03, -1.67999063e-02, -1.05452416e-02,\n",
" -5.53115830e-02, 1.77454613e-02, -3.31044979e-02, -1.02671804e-02,\n",
" 9.23486054e-03, 4.48897704e-02, -1.33571625e-02, -4.63784002e-02,\n",
" 1.67843532e-02, 4.34448905e-02, -1.48189804e-02, -3.10456082e-02,\n",
" 1.77916475e-02, -4.07658145e-02, -9.48902499e-03, 5.06357923e-02,\n",
" -6.29982799e-02, -2.20906939e-02, -5.56349345e-02, -5.76249603e-03,\n",
" 3.26409154e-02, 1.10303722e-02, 6.41335547e-02, 4.63621244e-02,\n",
" -1.44787664e-02, 2.85407621e-02, 3.85229960e-02, -1.58771165e-02,\n",
" 5.23128211e-02, 3.16371135e-02, -1.93770379e-02, -8.31151009e-02,\n",
" 5.96538857e-02, 1.69710200e-02, -4.47052941e-02, 2.95169409e-02,\n",
" 9.96101741e-03, -7.08143264e-02, -6.08333163e-02, 5.24643855e-03,\n",
" -8.67547188e-03, -1.98073518e-02, -7.10181892e-03, -4.82533732e-03,\n",
" -3.42210606e-02, -6.62091821e-02, 6.86643529e-04, -3.11605888e-03,\n",
" -1.88093930e-02, -4.54276763e-02, 1.66178774e-02, -9.24200937e-03,\n",
" 5.04363403e-02, -2.69100834e-02, 1.21640610e-02, -3.79910320e-02,\n",
" 4.61157598e-02, 4.98860776e-02, 5.40914945e-02, -9.12549496e-02,\n",
" -4.24579270e-02, 1.80577394e-02, 6.82970416e-03, -4.85470816e-02,\n",
" -1.51658859e-02, 1.06326202e-02, 4.70561199e-02, 3.62257920e-02,\n",
" 6.07605278e-02, 5.40268002e-03, 5.89498058e-02, -6.06387146e-02,\n",
" 6.58009201e-02, -4.02346766e-03, -5.90549521e-02, 4.66582738e-02,\n",
" -2.19727624e-02, 7.63568701e-03, 3.38551775e-02, 2.51118299e-02,\n",
" 1.67633239e-02, -7.57379690e-03, -4.53396402e-02, -4.55261953e-02,\n",
" -1.29767805e-02, -1.11939721e-02, 4.74229865e-02, -7.96682760e-03,\n",
" 3.46547738e-02, -1.56249227e-02, 1.14434976e-02, -4.08555977e-02,\n",
" -3.93327847e-02, 8.71347077e-03, 3.25198402e-03, 7.20789796e-03,\n",
" -7.07184970e-02, 3.26750567e-03, -5.97659089e-02, 1.86769310e-02,\n",
" 3.20646800e-02, 4.63991277e-02, 1.44933881e-02, 2.05616876e-02,\n",
" -1.46729602e-02, 1.35006113e-02, 8.28524530e-02, 9.23626348e-02,\n",
" -3.67087424e-02, 2.18051486e-02, -4.95869573e-03, -4.41479124e-02,\n",
" 4.56103496e-03, 2.42516212e-02, 3.94829694e-05, -3.40070799e-02,\n",
" -5.38958097e-03, -1.73496694e-04, -2.03436632e-02, -3.21606882e-02,\n",
" 1.34499352e-02, 8.02154373e-03, -4.59527895e-02, -7.22823888e-02,\n",
" -5.73416986e-03, -2.32819538e-03, 4.25096639e-02, 2.81084422e-02,\n",
" 1.47780245e-02, -1.10051595e-03, -4.70580086e-02, 3.06684598e-02,\n",
" 8.43891781e-03, -2.89724376e-02, 1.08889192e-02, 7.62799010e-02,\n",
" 2.24546399e-02, -3.25210132e-02, 3.03014088e-02, -3.91665846e-03,\n",
" -6.56410307e-02, 1.23865018e-02, 1.15141831e-02, 2.53073722e-02,\n",
" -2.65552849e-03, -6.67901114e-02, 2.30800137e-02, -8.01113620e-03,\n",
" 1.19577367e-02, 2.12651268e-02, 1.04740600e-03, -1.57829765e-02,\n",
" -2.08491273e-03, -5.95473126e-02, -3.47732790e-02, 1.22981109e-02,\n",
" 1.06721595e-02, 5.90330996e-02, -3.01389974e-02, 1.69376973e-02,\n",
" -7.87201058e-03, 3.82638760e-02, 5.33554703e-03, 3.59303206e-02,\n",
" 1.50646353e-02, 8.82404968e-02, -4.65183333e-02, 3.05422116e-02,\n",
" 4.39457074e-02, -5.40589988e-02, -1.60491653e-02, -2.80300882e-02,\n",
" 2.44697258e-02, -6.21494614e-02, 2.62990221e-02, 8.80372524e-03,\n",
" 9.02920403e-03, 3.54958400e-02, -4.17020507e-02, -4.02663983e-02,\n",
" 6.77801222e-02, -9.44017246e-03, -3.44885662e-02, 2.63255667e-02,\n",
" 5.52932220e-03, -5.72426198e-03, 7.46076088e-03, -1.47854602e-02,\n",
" 5.22899702e-02, 7.51394406e-02, 2.11022329e-03, -7.83296824e-02,\n",
" -3.88271809e-02, -4.65840399e-02, -5.72163835e-02, 1.18325837e-02,\n",
" -4.14816551e-02, 7.46720955e-02, 3.25940140e-02, -7.07084639e-03,\n",
" 4.13522497e-02, 5.33461533e-02, -6.85378956e-03, 9.63330083e-03,\n",
" 4.37391847e-02, 6.41110018e-02, 2.76977010e-02, -3.89026180e-02,\n",
" 5.68633787e-02, -1.25569738e-02, 4.32890141e-03, 4.29894067e-02,\n",
" 6.14441372e-03, 4.32663560e-02, 6.76224083e-02, -4.22291160e-02,\n",
" -3.15231234e-02, 5.72597347e-02, -3.88096273e-02, 3.39227952e-02,\n",
" -1.68800971e-03, -1.19756786e-02, -1.84470788e-02, -3.40366624e-02,\n",
" -3.03276237e-02, 6.45805225e-02, -7.87456334e-03, 7.89515488e-03,\n",
" -8.29922035e-03, -1.41582796e-02, 9.94283613e-03, 6.83671907e-02,\n",
" -4.33024317e-02, 5.03238551e-02, -3.11147328e-03, -3.53818089e-02,\n",
" 2.36095767e-02, -1.79082900e-02, 1.64668970e-02, -2.64172014e-02,\n",
" -1.39206424e-02, 4.88296337e-03, 3.47088277e-02, -1.21132974e-02,\n",
" -5.42478561e-02, 7.91907087e-02, -2.03914233e-02, -5.02970181e-02,\n",
" -2.03962289e-02, 1.12735834e-02, -3.91431823e-02, -2.02119183e-02,\n",
" -3.52542824e-03, -2.08407342e-02, 1.86249875e-02, -2.87201889e-02,\n",
" -4.62423488e-02, 1.41155329e-02, -2.84677390e-02, 1.18444616e-03,\n",
" 8.76411889e-03, 1.97428302e-03, 2.39373022e-03, 4.31706980e-02,\n",
" 2.09482647e-02, 4.27652290e-03, 3.41798700e-02, -3.92067693e-02,\n",
" 4.06869762e-02, -2.80282907e-02, -3.85007784e-02, -6.52883723e-02,\n",
" 3.35024223e-02, -1.93925053e-02, -1.04146181e-02, 2.92182397e-02,\n",
" 8.47155750e-02, 5.39435931e-02, -3.32224853e-02, 3.28501128e-02,\n",
" -6.44694269e-02, 1.86609123e-02, -1.22591788e-02, 9.73810554e-02,\n",
" -6.55089542e-02, -3.54052931e-02, 5.99990450e-02, -4.45059650e-02,\n",
" -3.33516859e-02, 2.47762445e-02, -3.01544312e-02, -1.36626391e-02,\n",
" 5.10358959e-02, 4.19272594e-02, 1.67654604e-02, 1.54359555e-02,\n",
" 1.70950014e-02, -4.47353302e-03, -3.86933144e-03, 6.19440805e-03,\n",
" 4.24543545e-02, -5.20833442e-03, 4.19983380e-02, -1.19898049e-02,\n",
" 2.92801261e-02, -3.96090709e-02, -4.55748364e-02, -1.51574863e-02,\n",
" -7.18237534e-02, 1.37063820e-04, -1.96622610e-02, -1.96936242e-02,\n",
" 6.50710836e-02, 5.05920760e-02, -8.20037127e-02, -2.24901978e-02,\n",
" -1.91803798e-02, -2.80492386e-04, 4.05936167e-02, 1.58536131e-03,\n",
" 3.94752398e-02, 7.44592212e-03, -6.67359754e-02, -2.67490977e-03,\n",
" 3.05636209e-02, 2.60310457e-03, 2.86192051e-03, -3.07924058e-02,\n",
" -3.34362201e-02, 6.22385554e-03, 3.61801460e-02, 3.96534726e-02,\n",
" -4.80900556e-02, -3.77990194e-02, -5.96706904e-02, -3.05942800e-02,\n",
" 1.83355808e-02, 3.16484310e-02, 2.69839242e-02, 3.21686789e-02,\n",
" 5.26536740e-02, -6.51188428e-03, 1.55735351e-02, 1.61451381e-02,\n",
" 1.87562760e-02, 1.43227912e-02, 4.05485146e-02, 5.85826521e-04,\n",
" 1.07493647e-03, 2.27565388e-03, -4.96098772e-03, 5.04243039e-02,\n",
" 5.73003665e-02, -6.26097471e-02, -4.13594954e-02, 1.29982224e-02,\n",
" -1.18702397e-01, 6.81656040e-03, 3.30031961e-02, 3.82255837e-02,\n",
" -5.41785173e-02, -3.18652689e-02, -5.72521761e-02, 3.55881453e-02,\n",
" 1.90253754e-03, 3.53394672e-02, 1.71035007e-02, -4.14450616e-02,\n",
" -4.36440995e-03, -4.24259454e-02, 5.05301841e-02, -3.15273437e-03,\n",
" -4.80298959e-02, -4.68152650e-02, 2.08045412e-02, 1.52546295e-03,\n",
" 1.26549099e-02, 4.36554812e-02, -3.76826711e-02, 3.91826108e-02,\n",
" 1.85529906e-02, 1.80262085e-02, -2.83435956e-02, -1.07219657e-02,\n",
" -2.93594263e-02, 2.86445096e-02, -1.95666999e-02, -5.39201200e-02])"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"embeddings[0]"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "95bdfda2-1575-471e-8725-3f0900be9643",
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": [
"array([-1.43356454e-02, -2.16784477e-02, 3.21097896e-02, 2.72039808e-02,\n",
" -4.73676957e-02, -1.18169822e-02, -2.75448826e-03, -2.73635313e-02,\n",
" 2.27017626e-02, 7.22942054e-02, -3.79111543e-02, 2.92207138e-03,\n",
" -2.39777602e-02, 1.10094333e-02, -2.19638925e-02, 2.56774910e-02,\n",
" 1.94586087e-02, -1.32784937e-02, -4.69307834e-03, -2.03847066e-02,\n",
" -3.48538011e-02, -2.24664509e-02, -6.02852693e-03, 9.74042434e-03,\n",
" 8.85831658e-03, 4.31385264e-02, 2.20383871e-02, 5.08100763e-02,\n",
" 5.48611768e-02, 3.38501818e-02, -2.81725992e-02, 3.53083224e-03,\n",
" 7.75846944e-04, -1.82817597e-02, -1.83023009e-02, -3.09302025e-02,\n",
" -7.22549707e-02, 5.76679828e-03, 7.24002123e-02, 3.40825729e-02,\n",
" -4.33760975e-03, 1.72757935e-02, -5.63281029e-03, 7.27394000e-02,\n",
" -4.40556072e-02, -7.95468804e-04, -4.01170459e-03, -2.62629353e-02,\n",
" -2.25911066e-02, -1.19620198e-02, -9.47790034e-03, -2.43393853e-02,\n",
" 1.08281998e-02, -4.20785695e-02, 1.21216569e-02, -6.19425671e-03,\n",
" 4.87911515e-02, 1.80345513e-02, -3.02514657e-02, -2.77890693e-02,\n",
" -3.37241367e-02, 3.61536182e-02, -1.93439461e-02, 2.84802970e-02,\n",
" 1.13601284e-02, 3.97275835e-02, 6.80681987e-05, -8.40261802e-02,\n",
" -4.79498170e-02, -1.61925075e-03, -1.17525617e-02, 2.64808871e-02,\n",
" 1.22748120e-02, -9.20934137e-03, 6.83386670e-03, 5.15385866e-02,\n",
" -2.46887524e-02, -2.95052342e-02, -6.74237385e-02, -2.01902837e-02,\n",
" 5.67117780e-02, 2.98874802e-03, 4.15244102e-02, -3.93779427e-02,\n",
" -1.73047222e-02, -1.57598518e-02, -5.10301366e-02, -7.92580843e-03,\n",
" 4.25807275e-02, 2.39281505e-02, -3.71863209e-02, 3.48019972e-02,\n",
" -7.73385214e-03, 7.72475898e-02, 3.27461213e-02, 7.30556529e-03,\n",
" -1.45082911e-02, -5.52869849e-02, -3.20466384e-02, -5.49970241e-03,\n",
" 2.68832892e-02, 2.03074329e-02, 4.87453863e-03, 1.80150494e-02,\n",
" 2.45773625e-02, -4.11030799e-02, 2.72167623e-02, -2.47642267e-02,\n",
" 9.02612321e-03, 1.76703855e-02, -2.97775995e-02, -2.27024918e-03,\n",
" -6.13781717e-03, -4.55022752e-02, -4.76602837e-02, -2.83710100e-02,\n",
" 9.97630693e-03, -1.23663200e-02, -1.67159121e-02, 3.27480771e-02,\n",
" -2.59286966e-02, 4.96628545e-02, 4.19698209e-02, -7.26421922e-02,\n",
" 1.59672238e-02, 4.21368778e-02, 1.69072244e-02, 8.72177724e-03,\n",
" -1.84099749e-02, 2.12360751e-02, 1.58494115e-02, -3.99457887e-02,\n",
" 9.01012868e-02, -3.52990441e-02, -5.27740084e-02, 9.24822222e-03,\n",
" 2.54883599e-02, -3.33821191e-03, -2.00735647e-02, 4.36091647e-02,\n",
" -2.87584141e-02, 1.76400281e-02, -2.17234120e-02, -1.43929645e-02,\n",
" -1.04510412e-02, 2.99939625e-02, -4.78526168e-02, 7.80482357e-03,\n",
" 1.16777271e-02, -2.99124978e-02, 3.68478112e-02, -4.97667752e-02,\n",
" -3.07946280e-02, 1.47823589e-02, -6.85154274e-03, -6.66311290e-03,\n",
" 2.52754590e-03, 1.49103887e-02, 7.76185421e-03, 1.66614279e-02,\n",
" -2.46641729e-02, -2.75595225e-02, 2.84287729e-04, -1.30307758e-02,\n",
" 1.74694210e-02, 9.60071608e-02, 2.25315895e-02, 2.16462929e-02,\n",
" 2.11229902e-02, -5.51582687e-02, 1.14661148e-02, -3.58657017e-02,\n",
" -4.38515842e-02, -8.70466605e-03, -1.23946965e-02, -8.24343879e-04,\n",
" -5.31356223e-03, 4.21371013e-02, -4.32137400e-02, 4.81118187e-02,\n",
" -2.67899502e-02, 3.10538355e-02, 3.02620362e-02, 4.64070924e-02,\n",
" 6.43681586e-02, -2.03091502e-02, 3.12586389e-02, -3.14582256e-03,\n",
" 3.16670127e-02, -7.15507520e-03, -1.17462473e-02, -3.93999480e-02,\n",
" -1.83532648e-02, 5.91176525e-02, 3.53675485e-02, 1.51073067e-02,\n",
" 1.85176414e-02, -3.89634930e-02, -6.79877549e-02, -4.66686627e-03,\n",
" -3.25556397e-02, -1.43425716e-02, -1.45725086e-02, 2.59300950e-03,\n",
" -1.82467129e-03, -5.82063198e-02, -4.54162844e-02, -3.97027694e-02,\n",
" -2.43694261e-02, 2.81483904e-02, 5.77986706e-03, 5.01666851e-02,\n",
" 4.26249579e-03, 6.20526001e-02, -2.01431997e-02, -1.14133293e-02,\n",
" -2.35341955e-02, -1.98291205e-02, -6.24520238e-03, 3.05182990e-02,\n",
" 3.63235623e-02, -6.86552152e-02, -5.20008765e-02, 2.21570935e-02,\n",
" -2.72559002e-02, 4.67344839e-03, -3.03068329e-02, -2.93763410e-02,\n",
" -8.17541219e-03, 1.18294312e-02, -3.29147018e-02, 4.59467918e-02,\n",
" 1.38999932e-02, -4.40894328e-02, 1.54225696e-02, -2.64135189e-02,\n",
" 3.24939527e-02, -9.18254331e-02, -1.26724700e-02, -4.01807986e-02,\n",
" -2.84393411e-02, -2.08554845e-02, 3.08648106e-02, 2.75163483e-02,\n",
" -9.11746547e-03, -1.82168111e-02, 4.97947484e-02, -3.73658277e-02,\n",
" 1.03505170e-02, 8.32711533e-03, 1.21768573e-02, 4.65863571e-03,\n",
" -2.55952775e-02, -2.17309948e-02, 4.79184426e-02, 1.81876235e-02,\n",
" -4.95702401e-02, 2.97002494e-02, 4.65753078e-02, -1.96203333e-03,\n",
" 6.03826232e-02, -2.12521087e-02, -7.67061068e-03, -1.00150515e-04,\n",
" 2.00358685e-02, -4.53991257e-02, -4.30120453e-02, 1.71365570e-02,\n",
" -4.03556302e-02, 3.33747119e-02, 3.87933594e-03, 8.95243604e-03,\n",
" -1.63769536e-02, -3.35253961e-02, -1.55624859e-02, 2.98685227e-02,\n",
" -1.27790188e-02, 7.16392919e-02, 4.79074344e-02, 1.17973490e-02,\n",
" -4.02338728e-02, -5.64230718e-02, 1.91179868e-02, -1.59064252e-02,\n",
" -3.95533368e-02, 1.74548049e-02, -1.95572395e-02, -2.42102984e-02,\n",
" -4.36006999e-03, -9.87635553e-03, -2.86743417e-02, -3.05287968e-02,\n",
" 3.54571417e-02, -1.82824321e-02, 1.37955286e-02, -2.10614614e-02,\n",
" -2.69130641e-03, 1.11276163e-02, -1.24010555e-02, 1.21000139e-02,\n",
" 6.11438183e-04, 2.18445305e-02, -2.80352728e-03, -4.72295284e-02,\n",
" 2.41780821e-02, 5.12120537e-02, 1.73368491e-03, -9.49876197e-03,\n",
" 1.15235127e-03, -2.46519595e-02, 9.13993455e-03, -2.35368479e-02,\n",
" 7.84077216e-03, -3.09900492e-02, -1.83918432e-03, -3.89971323e-02,\n",
" -2.10007392e-02, 2.85647847e-02, -1.93565004e-02, 1.82900503e-02,\n",
" 5.51992990e-02, 3.07692513e-02, 8.35671090e-03, 8.42630211e-03,\n",
" 7.56582916e-02, 8.34543444e-03, 3.18184383e-02, -6.17384491e-03,\n",
" 3.95975113e-02, -5.76960593e-02, -3.24971490e-02, -7.34638870e-02,\n",
" 3.48458299e-03, -6.58036321e-02, -4.93258890e-03, -8.00156686e-03,\n",
" 1.77636128e-02, -1.19626066e-02, 2.96311900e-02, -3.68610471e-02,\n",
" 3.04197185e-02, 3.41972224e-02, 1.51116475e-02, 1.50926476e-02,\n",
" -2.50595133e-03, 8.46610032e-03, -1.03192646e-02, -1.24879116e-02,\n",
" -3.64704728e-02, 6.70251772e-02, -2.30552815e-02, 3.32635939e-02,\n",
" 3.69163342e-02, 6.18307963e-02, 5.80018647e-02, 3.14503768e-03,\n",
" -9.93550755e-03, 3.29794697e-02, 6.82878727e-03, -8.85960311e-02,\n",
" -1.05398204e-02, 3.91046852e-02, -4.30030152e-02, -6.79476466e-03,\n",
" -6.77599618e-03, -3.99581976e-02, 4.62521836e-02, 3.22874612e-03,\n",
" -5.26554808e-02, 1.18789608e-02, -6.97451755e-02, 3.71613540e-02,\n",
" 1.48126408e-02, -3.18970233e-02, -2.76949760e-02, -3.14699113e-02,\n",
" 2.77896840e-02, 6.64762035e-03, -6.78986870e-03, 1.00684566e-02,\n",
" -1.35084391e-02, 4.00617905e-02, -4.27942835e-02, 2.15417631e-02,\n",
" -7.82450847e-03, 2.10278947e-02, 4.30472791e-02, -1.75182745e-02,\n",
" 7.69843860e-03, 2.49529351e-02, -1.06957583e-02, -1.72273517e-02,\n",
" 2.17490103e-02, -4.46285978e-02, -1.73219312e-02, 3.80140282e-02,\n",
" -5.07725589e-02, -3.16404887e-02, -6.19173385e-02, -1.16405804e-02,\n",
" 1.40790930e-02, 2.30277553e-02, 2.19954625e-02, 3.79117392e-02,\n",
" -2.21302340e-04, 2.20077429e-02, 2.14128159e-02, -1.88946091e-02,\n",
" 5.32614700e-02, 1.13945324e-02, -2.02453090e-03, -4.07919809e-02,\n",
" 1.80551484e-02, 3.14011499e-02, -1.57663785e-02, 1.57475900e-02,\n",
" 7.68021774e-03, -5.41340373e-02, -2.64007263e-02, -4.56298739e-02,\n",
" 3.39080230e-03, -4.95149791e-02, 1.27100460e-02, -3.50248106e-02,\n",
" -9.98336589e-04, -6.38119727e-02, -3.44801806e-02, -2.87301955e-03,\n",
" -3.89779285e-02, 1.03416583e-02, 2.38427166e-02, 2.25749351e-02,\n",
" 7.72128627e-02, -5.37086986e-02, 3.14587951e-02, -3.51935923e-02,\n",
" 3.01207229e-02, 4.15530875e-02, 1.73200294e-02, -4.14097644e-02,\n",
" -4.39602584e-02, 4.54685837e-03, 1.61281810e-03, -4.10120338e-02,\n",
" -6.34772182e-02, -9.71158687e-03, 1.42328069e-02, 1.48562761e-02,\n",
" 1.25701465e-02, 1.54929506e-02, 8.14306214e-02, -3.25670354e-02,\n",
" 8.56895000e-02, -1.12816310e-02, -4.78333086e-02, 3.89531627e-02,\n",
" -2.81416792e-02, 2.40886100e-02, 1.08475313e-02, 5.59064094e-03,\n",
" 3.56553379e-03, -9.31885908e-04, -4.99715805e-02, -3.07415165e-02,\n",
" 1.84915271e-02, -1.08987372e-02, 3.73096168e-02, 2.27946211e-02,\n",
" 3.46989557e-02, -1.72329079e-02, -6.13656500e-03, -3.82609665e-02,\n",
" -1.62435696e-02, -1.75268855e-03, 1.83316856e-03, 3.31918374e-02,\n",
" -3.64066996e-02, -6.18439866e-03, -3.93752456e-02, 3.00032310e-02,\n",
" 2.72428449e-02, 3.88909318e-02, 5.45297340e-02, -7.42445746e-03,\n",
" 2.15397030e-03, 4.34139483e-02, 6.80388212e-02, 1.08292498e-01,\n",
" -1.34532712e-02, -2.40998492e-02, 1.45109359e-03, -6.32137656e-02,\n",
" -6.43583899e-03, 1.18305348e-02, 4.18519275e-03, -7.55299907e-03,\n",
" 4.05896455e-02, 2.10507307e-02, -1.00444211e-02, -1.44077539e-02,\n",
" 2.30744965e-02, -1.66961085e-03, -2.33662166e-02, -4.45226766e-02,\n",
" -9.86683276e-03, -6.08660700e-03, 2.40885708e-02, 3.08201816e-02,\n",
" 1.99116091e-03, 1.15672396e-02, -3.73707749e-02, 8.76458269e-03,\n",
" 1.30018257e-02, -9.70822014e-03, -7.35309767e-03, 4.23015803e-02,\n",
" 1.13304285e-02, -3.17659006e-02, 2.20693252e-03, -1.51280151e-03,\n",
" -3.56691331e-02, 2.18733102e-02, 1.38000110e-02, 2.83594504e-02,\n",
" -2.02801432e-02, -7.58651504e-03, 4.84225601e-02, 4.07872312e-02,\n",
" 3.12525034e-02, 4.98623103e-02, -2.59318184e-02, 1.06037902e-02,\n",
" -1.99769307e-02, -3.70448977e-02, -3.65997739e-02, -1.28400540e-02,\n",
" -2.31204871e-02, 3.12355477e-02, -3.18615772e-02, -2.66414043e-03,\n",
" 8.50921869e-03, 5.69071434e-02, -1.74142160e-02, 3.01150717e-02,\n",
" -5.62037015e-03, 6.25777692e-02, -3.54778245e-02, 3.51262242e-02,\n",
" 5.18167876e-02, -1.85311548e-02, -4.43077870e-02, -7.78170885e-04,\n",
" -5.95852453e-03, -2.20750161e-02, -1.37064734e-03, -1.84399150e-02,\n",
" 1.68244578e-02, 1.68296210e-02, -3.38036977e-02, -5.51353320e-02,\n",
" 6.69947937e-02, -1.65974591e-02, -1.94531567e-02, 3.75299528e-02,\n",
" 2.43492443e-02, 1.47429444e-02, 2.54110666e-03, -3.37374187e-03,\n",
" 3.83959636e-02, 5.41988537e-02, -1.53749324e-02, -5.23985177e-02,\n",
" -1.87369306e-02, -3.57736135e-03, -3.08538303e-02, 8.57393537e-03,\n",
" -3.60491723e-02, 7.14102760e-02, -2.09798254e-02, -1.43607045e-02,\n",
" 1.38038006e-02, 3.09171509e-02, 5.91962715e-04, 2.74400692e-03,\n",
" 2.48805992e-02, 3.70309874e-02, 4.71902303e-02, -2.15414427e-02,\n",
" 8.60447958e-02, -1.17662298e-02, 1.35909701e-02, 6.13169558e-02,\n",
" -2.75752191e-02, 4.96041253e-02, 4.03546989e-02, -4.98761237e-02,\n",
" 3.45155224e-02, 7.37943798e-02, 7.62486132e-03, 3.54964137e-02,\n",
" -7.65900873e-03, -2.44783256e-02, 3.14811477e-03, -6.01268606e-03,\n",
" -4.59896289e-02, 5.05298860e-02, 8.86735320e-03, 8.68058018e-03,\n",
" -2.92791463e-02, -3.10860071e-02, 6.98281452e-03, 2.56989412e-02,\n",
" -3.05922031e-02, 4.07252759e-02, -1.79703105e-02, -3.80843990e-02,\n",
" 2.50013713e-02, -1.45621719e-02, -6.65497361e-03, -3.38632576e-02,\n",
" -1.58141274e-02, -2.88456008e-02, 1.93242673e-02, -3.63971689e-03,\n",
" -3.93430404e-02, 4.50239927e-02, 8.99149291e-03, -2.13194322e-02,\n",
" -1.50523365e-05, 4.87163737e-02, -3.83192790e-03, -3.31537090e-02,\n",
" -2.27865279e-02, 2.66835280e-02, -3.13516334e-03, 3.38254706e-03,\n",
" -3.98263857e-02, 4.44598933e-04, -1.17501970e-02, -3.26845087e-02,\n",
" 1.52193720e-03, 1.74808558e-02, -1.71031076e-02, 1.74386706e-02,\n",
" 2.96904780e-02, 2.46194508e-02, 5.89949228e-02, -3.35624665e-02,\n",
" 2.61088405e-02, -5.50580062e-02, -5.40384762e-02, -4.65848297e-02,\n",
" 4.84881215e-02, -6.58584386e-02, -3.42320688e-02, 3.50068770e-02,\n",
" 2.91352943e-02, 3.93977724e-02, -2.06956677e-02, 6.16698898e-02,\n",
" -6.44478872e-02, 2.48006787e-02, 9.64339881e-04, 7.72104114e-02,\n",
" -5.83015606e-02, -2.44647395e-02, 2.40632612e-02, -4.77992967e-02,\n",
" -3.25150900e-02, 2.54701208e-02, -1.83726717e-02, 4.42709861e-04,\n",
" 6.06252290e-02, 3.01637053e-02, 6.20173709e-03, -1.76736561e-03,\n",
" 1.39037138e-02, 1.14818178e-02, -1.11023383e-02, 1.54927466e-03,\n",
" 2.43816245e-02, -3.69032025e-02, 1.43887503e-02, -5.68023287e-02,\n",
" 9.50496923e-03, 1.90070958e-03, -5.32673746e-02, -3.12984847e-02,\n",
" -5.48556000e-02, 3.69088631e-03, -1.23435631e-02, 4.68733022e-03,\n",
" 4.19523641e-02, 5.11015095e-02, -4.51871119e-02, -2.72006188e-02,\n",
" 6.59744674e-03, 8.66057537e-03, 1.12540713e-02, -5.09890914e-03,\n",
" 5.04220165e-02, 4.54485323e-03, -6.82729930e-02, 1.95662421e-03,\n",
" 3.04329898e-02, -2.34693172e-03, -1.37398043e-03, -3.53209936e-04,\n",
" -4.96427082e-02, 1.34285092e-02, 2.61487197e-02, 3.21481749e-02,\n",
" -4.97249775e-02, -3.57422270e-02, -2.98923347e-02, -1.42609132e-02,\n",
" -1.12756649e-02, 5.08668870e-02, -2.98765954e-02, 4.66655158e-02,\n",
" 4.49310951e-02, 2.53670420e-02, 9.36789718e-03, 1.36808278e-02,\n",
" 8.50078370e-03, -2.44636200e-02, 3.67989205e-02, -1.96039435e-02,\n",
" 7.59241823e-03, 2.50165574e-02, -6.03327528e-03, 4.61267866e-02,\n",
" 1.35313133e-02, -3.77288796e-02, -5.14320210e-02, 1.09182186e-02,\n",
" -1.05255470e-01, 4.06814693e-03, 5.25197200e-02, 4.45685256e-03,\n",
" -5.17143719e-02, -4.59787715e-03, -2.57198438e-02, 3.69616076e-02,\n",
" 2.12156083e-02, 2.93332636e-02, 5.23170717e-02, -1.31642222e-02,\n",
" 1.40874460e-02, -4.84576896e-02, 3.18079107e-02, -1.36526749e-02,\n",
" -7.40123838e-02, -1.70104075e-02, 2.65298821e-02, 1.72942714e-03,\n",
" 1.32380184e-02, 5.42758889e-02, -2.61124335e-02, 4.26517315e-02,\n",
" 1.73017047e-02, -3.98834702e-04, 1.36054317e-02, -6.38240203e-03,\n",
" -3.33479457e-02, 1.91155151e-02, -8.56664905e-04, -3.58897559e-02])"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"embeddings[1]"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "95038468-5fdc-406d-81f7-a99cd941e64f",
"metadata": {},
"outputs": [],
"source": [
"d = 128 # Dimension of vectors\n",
"nb = 1000 # Number of database vectors\n",
"np.random.seed(42)\n",
"data = np.random.random((nb, d)).astype('float32')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6d84ffe2-5376-455c-b28d-84a4b64cd6d9",
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"data"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "ca73fdd2-af22-4738-97cc-cd671e02b4b1",
"metadata": {},
"outputs": [],
"source": [
"import faiss\n",
"d = 768\n",
"index = faiss.IndexFlatL2(d)"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "e93311d5-d5ef-4974-9d3c-eacf912403da",
"metadata": {},
"outputs": [],
"source": [
"index.add(embeddings)"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "fa9059fc-773e-42c0-a414-5262089faa58",
"metadata": {},
"outputs": [],
"source": [
"faiss.write_index(index, \"../../volumes/indexes/law_corpus_index.bin\")"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "3dcff12e-23b9-40f1-aa8a-8c04232053c6",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"' \\n \\n \\n \\n \\n THE CONSTITUTION OF INDIA \\n[As on May , 2022] \\n2022 \\n '"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"list(pdf_text_dict.values())[0:10][0]"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "c35858d0-3211-4e3c-b0b4-1ddb8f527cd0",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"' \\n \\nPREFACE \\n \\nThis is the fifth pocket size edition of the Constitution of \\nIndia in the diglot form. In this edition, the text of the \\nConstitution of India has been brought up-to-date by \\nincorporating therein all the amendments up to the Constitution \\n(One Hundred and Fifth Amendment) Act, 2021. The foot notes \\nbelow the text indicate the Constitution Amendment Acts by \\nwhich such amendments have been made. \\nThe Constitution (One Hundredth Amendment) Act, 2015 \\ncontaining details of acquired and transferred territories \\nbetween the Governments of India and Bangladesh has been \\nprovided in APPENDIX I. \\nThe Constitution (Application to Jammu and Kashmir) \\nOrder, 2019 and the declaration under article 370(3) of the \\nConstitution have been provided respectively in Appendix II and \\nAppendix III for reference. \\n \\n \\nNew Delhi; Dr. Reeta Vasishta, \\n Secretary to the Government of India. \\n \\n '"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"list(pdf_text_dict.values())[0:10][1]"
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "b93d46dc-81ee-435b-82a5-1009700a12d3",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"' \\nLIST OF ABBREVIATIONS USED \\n \\n \\nArt., arts. ........................................................ for Article, articles. \\nCl., cls. ........................................................ ″ Clause, clauses. \\nC.O. ........................................................ ″ Constitution Order. \\nIns. ........................................................ ″ Inserted. \\nP., pp. ........................................................ ″ Page, pages. \\nPt. ........................................................ ″ Part. \\nRep. ........................................................ ″ Repealed. \\nSs., ss. .......................................................... ″ Section, sections. \\nSch. ......................................................... ″ Schedule. \\nSubs. ........................................................ ″ Substituted. \\nw.e.f. ......................................................... ″ with effect from. \\nw.r.e.f. ...................................................... ″ with retrospective effect \\nfrom. \\n '"
]
},
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"list(pdf_text_dict.values())[0:10][2]"
]
},
{
"cell_type": "code",
"execution_count": 23,
"id": "a8c8b023-f06a-4c12-ad4c-c4db7be95bef",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'Contents \\n \\n ARTICLES (iv)\\n 40. Organisation of village panchayats. \\n 41. Right to work, to education and to public assistance in certain \\ncases. \\n 42. Provision for just and humane conditions of work and maternity \\nrelief. \\n 43. Living wage, etc., for workers. \\n43A. Participation of workers in management of Industries. \\n43B. Promotion of co-operative societies. \\n 44. Uniform civil code for the citizens. \\n 45. Provision for early childhood care and educat ion to children \\nbelow the age of six years. \\n 46. Promotion of educational and economic interests of Scheduled \\nCastes, Scheduled Tribes and other weaker sections. \\n 47. Duty of the State to raise the level of nutrition and the standard \\nof living and to improve public health. \\n 48. Organisation of agriculture and animal husbandry. \\n48A. Protection and improvement of environment and safeguarding of \\nforests and wild life. \\n 49. Protection of monuments and places and objects of national \\nimportance. \\n 50. Separation of judiciary from executive. \\n 51. Promotion of international peace and security. \\n PART IVA \\nFUNDAMENTAL DUTIES \\n51A. Fundamental duties. \\n \\n \\n \\n \\n PART V \\nTHE UNION \\nCHAPTER I.\\uf0beTHE EXECUTIVE \\nThe President and Vice-President \\n52. The President of India. \\n53. Executive power of the Union. \\n54. Election of President. '"
]
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"list(pdf_text_dict.values())[0:10][6]"
]
},
{
"cell_type": "code",
"execution_count": 23,
"id": "49e5aed7-79dc-480e-a5a9-f75799eab328",
"metadata": {},
"outputs": [],
"source": [
"query = np.random.random((5, d)).astype('float32')"
]
},
{
"cell_type": "code",
"execution_count": 24,
"id": "a2ee4345-5a43-4ee6-9706-004d147328b2",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[0.04977802, 0.48656103, 0.28263223, ..., 0.9249028 , 0.49694043,\n",
" 0.6121883 ],\n",
" [0.02063165, 0.32649937, 0.5049617 , ..., 0.41199866, 0.43590757,\n",
" 0.20361727],\n",
" [0.37153634, 0.62894505, 0.84184766, ..., 0.6600337 , 0.12406218,\n",
" 0.18649617],\n",
" [0.00358555, 0.36700717, 0.8201504 , ..., 0.3835851 , 0.03757534,\n",
" 0.33080533],\n",
" [0.41282707, 0.23166862, 0.9693633 , ..., 0.92313445, 0.02211179,\n",
" 0.21810389]], dtype=float32)"
]
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"query"
]
},
{
"cell_type": "code",
"execution_count": 25,
"id": "5fe715db-5a9c-41c5-afb6-1d6b207c3e98",
"metadata": {},
"outputs": [],
"source": [
"faiss.write_index(index, \"faiss_test_index.bin\")\n",
"# print(\"Index saved successfully!\")"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "fec115ed-99a7-4e64-a411-b55e8bd85f6b",
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Index loaded successfully!\n",
"Number of vectors in the index: 10\n"
]
}
],
"source": [
"import faiss\n",
"index = faiss.read_index(\"faiss_test_index.bin\")\n",
"print(\"Index loaded successfully!\")\n",
"print(\"Number of vectors in the index:\", index.ntotal)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "de4cebf6-cd24-499b-b79a-f7dfe98fb807",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Index type: <class 'faiss.swigfaiss_avx2.IndexFlatL2'>\n",
"Is Trained: True\n",
"Number of vectors: 10\n"
]
}
],
"source": [
"print(\"Index type:\", type(index))\n",
"print(\"Is Trained:\", index.is_trained)\n",
"print(\"Number of vectors:\", index.ntotal)\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "c02455e6-b99e-4eff-bd7a-7cf4c05566a1",
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": [
"array([-4.33520480e-34, 1.96945212e-39, 1.63441963e-34, 7.23149259e-29,\n",
" 0.00000000e+00, 0.00000000e+00, 3.44876660e-28, 7.18866112e-43,\n",
" 1.71810193e+19, 7.14495034e+31, 5.44333404e-30, 7.18866112e-43,\n",
" 2.80259693e-45, 0.00000000e+00, -4.22660315e-38, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 6.38779203e-30, 7.18866112e-43,\n",
" 0.00000000e+00, 0.00000000e+00, 3.44716688e-28, 7.18866112e-43,\n",
" 1.71810193e+19, 7.14495034e+31, 5.44333404e-30, 7.18866112e-43,\n",
" 2.80259693e-45, 0.00000000e+00, 4.20622715e-38, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 6.38779203e-30, 7.18866112e-43,\n",
" 0.00000000e+00, 0.00000000e+00, 1.85896145e+34, 7.77666437e+31,\n",
" 1.71810666e+19, 7.14495034e+31, 1.57661930e-19, 1.94412705e+31,\n",
" 1.14918035e-38, 0.00000000e+00, 9.28516057e-39, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 6.38779203e-30, 7.18866112e-43,\n",
" 0.00000000e+00, 0.00000000e+00, 2.76294526e-27, 7.18866112e-43,\n",
" 1.71810666e+19, 7.14495034e+31, 5.44333404e-30, 7.18866112e-43,\n",
" 2.80259693e-45, 0.00000000e+00, -4.22660315e-38, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 6.38779203e-30, 7.18866112e-43,\n",
" 0.00000000e+00, 0.00000000e+00, 8.43042259e+11, 5.40934844e+04,\n",
" 1.71810193e+19, 7.14495034e+31, 5.44333404e-30, 7.18866112e-43,\n",
" 2.80259693e-45, 0.00000000e+00, 4.20672938e-38, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 6.38779203e-30, 7.18866112e-43,\n",
" 0.00000000e+00, 0.00000000e+00, 2.76339824e-27, 7.18866112e-43,\n",
" 1.71810193e+19, 7.14495034e+31, 5.44333404e-30, 7.18866112e-43,\n",
" 2.80259693e-45, 0.00000000e+00, -4.22660315e-38, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 6.38779203e-30, 7.18866112e-43,\n",
" 0.00000000e+00, 0.00000000e+00, 2.75243739e-27, 7.18866112e-43,\n",
" 1.71810193e+19, 7.14495034e+31, 5.44333404e-30, 7.18866112e-43,\n",
" 2.80259693e-45, 0.00000000e+00, -4.22660315e-38, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 6.38779203e-30, 7.18866112e-43,\n",
" 0.00000000e+00, 0.00000000e+00, 3.44882823e-28, 7.18866112e-43,\n",
" 1.71810193e+19, 7.14495034e+31, 5.44333404e-30, 7.18866112e-43,\n",
" 2.80259693e-45, 0.00000000e+00, -4.22660315e-38, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 6.38779203e-30, 7.18866112e-43,\n",
" 0.00000000e+00, 0.00000000e+00, 3.44716688e-28, 7.18866112e-43,\n",
" 1.71810193e+19, 7.14495034e+31, 5.44333404e-30, 7.18866112e-43,\n",
" 2.80259693e-45, 0.00000000e+00, 4.20622715e-38, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 6.38779203e-30, 7.18866112e-43,\n",
" 0.00000000e+00, 0.00000000e+00, 4.54700658e-27, 7.18866112e-43,\n",
" 1.71810193e+19, 7.14495034e+31, 5.44333404e-30, 7.18866112e-43,\n",
" 2.80259693e-45, 0.00000000e+00, -9.36731029e-39, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 6.38779203e-30, 7.18866112e-43,\n",
" 0.00000000e+00, 0.00000000e+00, 7.15600499e+22, 1.38195514e+31,\n",
" 3.03465913e+32, 8.80015436e-43, 5.44333404e-30, 7.18866112e-43,\n",
" 2.80259693e-45, 0.00000000e+00, 4.20701636e-38, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 6.87729688e+03, 2.48029828e-43,\n",
" 0.00000000e+00, 0.00000000e+00, 8.43042259e+11, 5.40934844e+04,\n",
" 3.03464869e+32, 8.80015436e-43, 5.44333404e-30, 7.18866112e-43,\n",
" 2.80259693e-45, 0.00000000e+00, 4.20672938e-38, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 6.87729688e+03, 2.48029828e-43,\n",
" 0.00000000e+00, 0.00000000e+00, 2.76300997e-27, 7.18866112e-43,\n",
" 3.03464869e+32, 8.80015436e-43, 5.44333404e-30, 7.18866112e-43,\n",
" 2.80259693e-45, 0.00000000e+00, -4.22660315e-38, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 6.87729688e+03, 2.48029828e-43,\n",
" 0.00000000e+00, 0.00000000e+00, 3.44710260e-28, 7.18866112e-43,\n",
" 3.03464869e+32, 8.80015436e-43, 5.44333404e-30, 7.18866112e-43,\n",
" 2.80259693e-45, 0.00000000e+00, -4.22660315e-38, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 6.87729688e+03, 2.48029828e-43,\n",
" 0.00000000e+00, 0.00000000e+00, 3.44888986e-28, 7.18866112e-43,\n",
" 3.03464869e+32, 8.80015436e-43, 5.44333404e-30, 7.18866112e-43,\n",
" 2.80259693e-45, 0.00000000e+00, -4.22660315e-38, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 6.87729688e+03, 2.48029828e-43,\n",
" 0.00000000e+00, 0.00000000e+00, 3.44716688e-28, 7.18866112e-43,\n",
" 3.03464869e+32, 8.80015436e-43, 5.44333404e-30, 7.18866112e-43,\n",
" 2.80259693e-45, 0.00000000e+00, 4.20622715e-38, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 6.87729688e+03, 2.48029828e-43,\n",
" 0.00000000e+00, 0.00000000e+00, 1.24288541e-28, 7.18866112e-43,\n",
" 3.03464869e+32, 8.80015436e-43, 5.44333404e-30, 7.18866112e-43,\n",
" 2.80259693e-45, 0.00000000e+00, -9.36731029e-39, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 6.87729688e+03, 2.48029828e-43,\n",
" 0.00000000e+00, 0.00000000e+00, 2.76339824e-27, 7.18866112e-43,\n",
" 1.12103877e-44, 0.00000000e+00, 5.44333404e-30, 7.18866112e-43,\n",
" 2.80259693e-45, 0.00000000e+00, -4.22660315e-38, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 6.38779203e-30, 7.18866112e-43,\n",
" 0.00000000e+00, 0.00000000e+00, 8.43042259e+11, 5.40934844e+04,\n",
" 8.68805048e-44, 0.00000000e+00, 5.44333404e-30, 7.18866112e-43,\n",
" 2.80259693e-45, 0.00000000e+00, 4.20672938e-38, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 6.38779203e-30, 7.18866112e-43,\n",
" 0.00000000e+00, 0.00000000e+00, 2.76311782e-27, 7.18866112e-43,\n",
" 8.68805048e-44, 0.00000000e+00, 5.44333404e-30, 7.18866112e-43,\n",
" 2.80259693e-45, 0.00000000e+00, -4.22660315e-38, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 6.38779203e-30, 7.18866112e-43,\n",
" 0.00000000e+00, 0.00000000e+00, 3.44839682e-28, 7.18866112e-43,\n",
" 8.68805048e-44, 0.00000000e+00, 5.44333404e-30, 7.18866112e-43,\n",
" 2.80259693e-45, 0.00000000e+00, -4.22660315e-38, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 6.38779203e-30, 7.18866112e-43,\n",
" 0.00000000e+00, 0.00000000e+00, 3.44747238e-28, 7.18866112e-43,\n",
" 8.68805048e-44, 0.00000000e+00, 5.44333404e-30, 7.18866112e-43,\n",
" 2.80259693e-45, 0.00000000e+00, -4.22660315e-38, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 6.38779203e-30, 7.18866112e-43,\n",
" 0.00000000e+00, 0.00000000e+00, 3.44716688e-28, 7.18866112e-43,\n",
" 8.68805048e-44, 0.00000000e+00, 5.44333404e-30, 7.18866112e-43,\n",
" 2.80259693e-45, 0.00000000e+00, 4.20622715e-38, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 6.38779203e-30, 7.18866112e-43,\n",
" 0.00000000e+00, 0.00000000e+00, 1.85896145e+34, 7.77666437e+31,\n",
" 1.71810666e+19, 7.14495034e+31, 1.57661930e-19, 1.10452625e+27,\n",
" 1.14917755e-38, 0.00000000e+00, 9.28516057e-39, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 6.38779203e-30, 7.18866112e-43,\n",
" 0.00000000e+00, 0.00000000e+00, 2.76300997e-27, 7.18866112e-43,\n",
" 1.71810666e+19, 7.14495034e+31, 5.44333404e-30, 7.18866112e-43,\n",
" 2.80259693e-45, 0.00000000e+00, -4.23615889e-38, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 6.38779203e-30, 7.18866112e-43,\n",
" 0.00000000e+00, 0.00000000e+00, 8.43042259e+11, 5.40934844e+04,\n",
" 1.71810193e+19, 7.14495034e+31, 5.44333404e-30, 7.18866112e-43,\n",
" 2.80259693e-45, 0.00000000e+00, 4.20674283e-38, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 6.38779203e-30, 7.18866112e-43,\n",
" 0.00000000e+00, 0.00000000e+00, 2.76346295e-27, 7.18866112e-43,\n",
" 1.71810193e+19, 7.14495034e+31, 5.44333404e-30, 7.18866112e-43,\n",
" 2.80259693e-45, 0.00000000e+00, -4.23615889e-38, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 6.38779203e-30, 7.18866112e-43,\n",
" 0.00000000e+00, 0.00000000e+00, 3.44882823e-28, 7.18866112e-43,\n",
" 1.71810193e+19, 7.14495034e+31, 5.44333404e-30, 7.18866112e-43,\n",
" 2.80259693e-45, 0.00000000e+00, -4.23615889e-38, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 6.38779203e-30, 7.18866112e-43,\n",
" 0.00000000e+00, 0.00000000e+00, 3.44778053e-28, 7.18866112e-43,\n",
" 1.71810193e+19, 7.14495034e+31, 5.44333404e-30, 7.18866112e-43,\n",
" 2.80259693e-45, 0.00000000e+00, -4.23615889e-38, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 6.38779203e-30, 7.18866112e-43,\n",
" 0.00000000e+00, 0.00000000e+00, 3.44716688e-28, 7.18866112e-43,\n",
" 1.71810193e+19, 7.14495034e+31, 5.44333404e-30, 7.18866112e-43,\n",
" 2.80259693e-45, 0.00000000e+00, 4.20624061e-38, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 6.38779203e-30, 7.18866112e-43,\n",
" 0.00000000e+00, 0.00000000e+00, 1.85896145e+34, 7.77666437e+31,\n",
" 1.71810666e+19, 7.14495034e+31, 1.57661930e-19, 1.94412705e+31,\n",
" 1.14918035e-38, 0.00000000e+00, 9.28522783e-39, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 6.38779203e-30, 7.18866112e-43,\n",
" 0.00000000e+00, 0.00000000e+00, 2.76341981e-27, 7.18866112e-43,\n",
" 1.71810666e+19, 7.14495034e+31, 5.44333404e-30, 7.18866112e-43,\n",
" 2.80259693e-45, 0.00000000e+00, -4.23615889e-38, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 6.38779203e-30, 7.18866112e-43,\n",
" 0.00000000e+00, 0.00000000e+00, 8.43042259e+11, 5.40934844e+04,\n",
" 1.71810193e+19, 7.14495034e+31, 5.44333404e-30, 7.18866112e-43,\n",
" 2.80259693e-45, 0.00000000e+00, 4.20674283e-38, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 6.38779203e-30, 7.18866112e-43,\n",
" 0.00000000e+00, 0.00000000e+00, 2.76294526e-27, 7.18866112e-43,\n",
" 1.71810193e+19, 7.14495034e+31, 5.44333404e-30, 7.18866112e-43,\n",
" 2.80259693e-45, 0.00000000e+00, -4.23615889e-38, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 6.38779203e-30, 7.18866112e-43,\n",
" 0.00000000e+00, 0.00000000e+00, 2.75243739e-27, 7.18866112e-43,\n",
" 1.71810193e+19, 7.14495034e+31, 5.44333404e-30, 7.18866112e-43,\n",
" 2.80259693e-45, 0.00000000e+00, -4.23615889e-38, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 6.38779203e-30, 7.18866112e-43,\n",
" 0.00000000e+00, 0.00000000e+00, 3.44734912e-28, 7.18866112e-43,\n",
" 1.71810193e+19, 7.14495034e+31, 5.44333404e-30, 7.18866112e-43,\n",
" 2.80259693e-45, 0.00000000e+00, -4.23615889e-38, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 6.38779203e-30, 7.18866112e-43,\n",
" 0.00000000e+00, 0.00000000e+00, 3.44716688e-28, 7.18866112e-43,\n",
" 1.71810193e+19, 7.14495034e+31, 5.44333404e-30, 7.18866112e-43,\n",
" 2.80259693e-45, 0.00000000e+00, 4.20624061e-38, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 6.38779203e-30, 7.18866112e-43,\n",
" 0.00000000e+00, 0.00000000e+00, 4.11713748e-28, 7.18866112e-43,\n",
" 1.71810193e+19, 7.14495034e+31, 5.44333404e-30, 7.18866112e-43,\n",
" 2.80259693e-45, 0.00000000e+00, -9.36737755e-39, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 6.38779203e-30, 7.18866112e-43,\n",
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 2.80259693e-45, 0.00000000e+00,\n",
" 1.19443525e-26, 7.18866112e-43, 0.00000000e+00, 0.00000000e+00,\n",
" 2.15268200e-26, 7.18866112e-43, 2.15268200e-26, 7.18866112e-43,\n",
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,\n",
" 2.15267076e-26, 7.18866112e-43, 2.15267076e-26, 7.18866112e-43,\n",
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 1.40129846e-45, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 4.59065377e-41,\n",
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,\n",
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n",
" dtype=float32)"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import numpy as np\n",
"vector_10 = np.zeros(768, dtype='float32')\n",
"index.reconstruct(10, vector_10) "
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "962695d9-9525-4ef2-9c5b-ea7c242ac5d5",
"metadata": {},
"outputs": [],
"source": [
"test_emb = index.reconstruct(10, vector_10) "
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "175af996-a07c-4e8e-832e-5d7410783e2a",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"768"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"len(test_emb)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "2af1ba86-d178-48b7-8a6e-09399bd984bb",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Index Type: <class 'faiss.swigfaiss_avx2.IndexFlatL2'>\n",
"Index Dimension: 768\n",
"Number of Vectors in Index: 10\n",
"Query Shape: (768,)\n",
"Is Index Trained: True\n"
]
}
],
"source": [
"print(\"Index Type:\", type(index))\n",
"print(\"Index Dimension:\", index.d)\n",
"print(\"Number of Vectors in Index:\", index.ntotal)\n",
"print(\"Query Shape:\", test_emb.shape)\n",
"print(\"Is Index Trained:\", index.is_trained)"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "70f97eaf-468d-4c1b-a042-276c8f0123ef",
"metadata": {},
"outputs": [],
"source": [
"query = \"which pocket size is this edition?\"\n",
"query_embeddings = model.encode([query])"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "fafd5f1c-9d42-45ec-84e6-e3dced2f9a52",
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": [
"array([[-3.73132437e-01, -2.49501050e-01, 5.96238971e-01,\n",
" 1.60232633e-01, -7.16607630e-01, -3.35337073e-01,\n",
" 2.09526420e-01, -5.55256248e-01, 6.18032277e-01,\n",
" 8.19526017e-01, -6.39822304e-01, 1.57655537e-01,\n",
" -2.45462924e-01, -1.64276659e-01, -2.11889967e-02,\n",
" 5.78294039e-01, 3.00301939e-01, -4.89581376e-02,\n",
" 5.43662719e-03, -2.26307601e-01, -6.92653283e-02,\n",
" -2.94720709e-01, -5.32017469e-01, -3.34114343e-01,\n",
" 2.40843698e-01, 1.39474165e+00, 8.41520846e-01,\n",
" 9.00752783e-01, 3.70669335e-01, 3.69088054e-01,\n",
" -2.56014347e-01, -3.89395177e-01, -4.00742084e-01,\n",
" -4.74080443e-01, 5.93443394e-01, -1.70544237e-01,\n",
" -7.75071025e-01, 6.44626856e-01, 7.97609329e-01,\n",
" 8.33190203e-01, 1.20621324e-02, 4.71046597e-01,\n",
" -3.30124229e-01, 1.22842538e+00, -7.82999873e-01,\n",
" -8.05311918e-01, 2.30400667e-01, 1.82415247e-01,\n",
" -2.73626685e-01, 2.95862228e-01, -2.96776861e-01,\n",
" 4.01828885e-01, 5.47554195e-01, -7.41805792e-01,\n",
" 6.52820528e-01, -2.80365616e-01, 5.87766767e-01,\n",
" -9.25101712e-02, -1.71328247e-01, -4.88722175e-01,\n",
" -6.11516654e-01, 8.54884803e-01, 6.13536574e-02,\n",
" 1.03063786e+00, 1.28858745e-01, 3.10793996e-01,\n",
" -9.51184779e-02, -1.10501099e+00, -6.18921220e-01,\n",
" 4.59839940e-01, 4.04549509e-01, 5.46272457e-01,\n",
" -4.80109006e-01, -3.37467492e-01, -2.01065853e-01,\n",
" 4.94460106e-01, -5.20232677e-01, -6.38742447e-01,\n",
" -6.71331465e-01, 1.15267292e-01, 8.12568665e-01,\n",
" -7.69091491e-03, 1.76295757e-01, -3.87636304e-01,\n",
" -2.75877208e-01, -5.07208779e-02, -9.28902864e-01,\n",
" -3.06568354e-01, 4.81325299e-01, 1.30671430e-02,\n",
" -2.72536874e-01, 3.41388918e-02, 3.54521304e-01,\n",
" 9.06797409e-01, 2.50232577e-01, -4.86936778e-01,\n",
" -4.14275318e-01, -7.26987123e-01, -6.16783917e-01,\n",
" 2.70495731e-02, 3.45965385e-01, 9.04193640e-01,\n",
" -2.00276956e-01, 2.49010026e-01, -2.13858709e-02,\n",
" -1.21312928e+00, 1.68583840e-01, -9.86288905e-01,\n",
" -3.84645879e-01, -1.94787923e-02, -5.11086226e-01,\n",
" 2.62719810e-01, 3.79847251e-02, -7.36862719e-01,\n",
" -5.68665743e-01, 3.88124317e-01, 1.63300022e-01,\n",
" -2.86569983e-01, -3.72056500e-03, 1.50334984e-01,\n",
" -4.81104314e-01, 1.73026845e-01, 5.45722723e-01,\n",
" -8.67989004e-01, 5.75004995e-01, 1.82515651e-01,\n",
" 9.60796356e-01, 9.23014641e-01, -8.13714638e-02,\n",
" -6.45711347e-02, 5.04627109e-01, -7.77863741e-01,\n",
" 1.08234835e+00, -3.77334476e-01, -1.57291222e+00,\n",
" -2.56048769e-01, 1.82667434e-01, -2.18309820e-01,\n",
" -4.18597072e-01, 3.87196004e-01, -1.32786959e-01,\n",
" -1.56175554e-01, -7.86275685e-01, 2.34808862e-01,\n",
" -1.37365952e-01, -1.35111615e-01, -4.24241722e-01,\n",
" 5.96258402e-01, 8.10592413e-01, -4.84668255e-01,\n",
" 4.53763366e-01, -4.93415564e-01, -2.01269567e-01,\n",
" 2.73051053e-01, 3.40254188e-01, -8.09984922e-01,\n",
" 5.26710093e-01, -9.40554962e-02, -1.18216380e-01,\n",
" -9.88251790e-02, -4.80686188e-01, -4.20976251e-01,\n",
" -2.63683915e-01, -5.48085630e-01, 2.88112044e-01,\n",
" 5.15181303e-01, 5.17866492e-01, 2.55876034e-01,\n",
" 1.74452350e-01, -8.66756022e-01, 1.28356129e-01,\n",
" 5.93110323e-01, -2.46795833e-01, -4.72101092e-01,\n",
" -9.51930806e-02, -3.32720965e-01, 2.77996790e-02,\n",
" 7.48720825e-01, -8.02123785e-01, -9.64421928e-02,\n",
" -2.64321007e-02, 5.29742241e-01, 5.07097185e-01,\n",
" 2.51757592e-01, 5.91747046e-01, -5.11173129e-01,\n",
" 2.94839919e-01, -3.23320031e-01, 1.38826823e+00,\n",
" -1.81692377e-01, -8.22013058e-03, -7.93573976e-01,\n",
" -6.65791273e-01, 7.07389593e-01, 6.87932596e-02,\n",
" 1.39326096e-01, 4.90396291e-01, -5.17733395e-01,\n",
" -1.08724594e+00, -1.31639168e-01, 2.29492158e-01,\n",
" -4.92301248e-02, -3.75349402e-01, -1.11997604e-01,\n",
" -5.58441617e-02, -6.61340579e-02, -1.48219085e+00,\n",
" -4.10615094e-03, -3.43739361e-01, 3.03971678e-01,\n",
" 9.24170196e-01, 3.64206761e-01, -3.11778784e-01,\n",
" 6.69572055e-01, -6.96559727e-01, -3.94165248e-01,\n",
" -6.09896004e-01, -2.76756316e-01, -7.65358359e-02,\n",
" 3.11748415e-01, 1.08360314e+00, -5.18168986e-01,\n",
" -9.83385503e-01, 2.48666689e-01, 2.65461743e-01,\n",
" -3.07810903e-02, -1.80236802e-01, -9.18660462e-02,\n",
" -1.05982646e-01, 1.97828472e-01, -2.54839603e-02,\n",
" 4.36863214e-01, 6.80076063e-01, -1.05401337e+00,\n",
" 1.80188343e-01, -9.56242800e-01, 5.97054809e-02,\n",
" -7.74244487e-01, -3.17614317e-01, 4.34077024e-01,\n",
" -7.36546636e-01, -2.82710582e-01, -2.38731354e-01,\n",
" 4.33760226e-01, -5.03278792e-01, 2.40366995e-01,\n",
" 4.17858779e-01, -1.14790308e+00, 3.63061996e-03,\n",
" 1.98579997e-01, 4.91681933e-01, 3.63510609e-01,\n",
" -1.64256126e-01, -4.82028008e-01, 1.30196822e+00,\n",
" -1.67734966e-01, -1.14694767e-01, 1.03191659e-01,\n",
" 3.11995834e-01, -4.81099747e-02, 6.84669852e-01,\n",
" -8.66782844e-01, 3.97845149e-01, 1.05078049e-01,\n",
" -1.91367771e-02, -2.31815398e-01, -4.98310983e-01,\n",
" -2.50129551e-01, -3.04200739e-01, 5.40039778e-01,\n",
" -3.92500944e-02, -2.26705179e-01, -5.00782847e-01,\n",
" -8.49243283e-01, -1.52281150e-01, 3.02840889e-01,\n",
" -8.38819087e-01, 7.79993415e-01, 6.30303144e-01,\n",
" -3.37795734e-01, -4.16197717e-01, -5.30447960e-01,\n",
" 3.10830384e-01, -1.88205227e-01, -5.94668686e-01,\n",
" 1.59734219e-01, -1.08995959e-01, -5.41627169e-01,\n",
" -2.38114670e-01, -6.63974524e-01, 2.36916468e-02,\n",
" -3.53694648e-01, 9.17128250e-02, -5.80827408e-02,\n",
" 1.95876032e-01, -1.01593681e-01, 1.69732177e-03,\n",
" 9.79008079e-02, 2.53847957e-01, 5.74670248e-02,\n",
" 3.34153295e-01, -2.72751749e-01, 6.36534452e-01,\n",
" -1.16707854e-01, 5.43213308e-01, 7.07452834e-01,\n",
" 3.99107561e-02, 3.24606478e-01, -6.17893934e-01,\n",
" -1.00787114e-02, -4.40084338e-01, -2.32265413e-01,\n",
" 2.95902163e-01, -5.53712606e-01, 4.01033670e-01,\n",
" -7.52838850e-01, 1.89499423e-01, 6.55153930e-01,\n",
" -2.22477034e-01, -7.49209076e-02, 3.15154910e-01,\n",
" -1.48034245e-01, 5.52035034e-01, 4.73529935e-01,\n",
" 8.73762369e-01, 1.08367449e-03, 5.38138390e-01,\n",
" -4.17241633e-01, 3.97459447e-01, -9.75983083e-01,\n",
" -5.30309439e-01, -5.86849988e-01, 1.68224990e-01,\n",
" 8.97852480e-02, -3.28494668e-01, 6.88293517e-01,\n",
" 6.28556967e-01, -7.58412123e-01, 4.54522401e-01,\n",
" -5.63978970e-01, 1.03677034e+00, 9.27480936e-01,\n",
" 7.03815997e-01, -7.34761581e-02, -6.18429720e-01,\n",
" 3.67733747e-01, 3.19563188e-02, -5.64858139e-01,\n",
" -7.86610365e-01, 1.15927947e+00, 2.88311422e-01,\n",
" 2.27986667e-02, 1.16840279e+00, 6.96775556e-01,\n",
" 4.12162632e-01, 1.42026365e-01, -7.81583369e-01,\n",
" 3.59356999e-01, -3.03264558e-01, -1.23299253e+00,\n",
" -2.07522169e-01, 7.18758404e-02, -8.33071828e-01,\n",
" 2.67476916e-01, -3.35263610e-01, -4.65342253e-01,\n",
" -4.42757085e-02, -1.95778117e-01, -4.73799497e-01,\n",
" 1.64555743e-01, -1.49801087e+00, 1.52146614e+00,\n",
" 1.92096204e-01, -5.09908497e-01, -2.74958666e-02,\n",
" -3.37128758e-01, 4.71870899e-01, 1.35582626e-01,\n",
" 1.01404175e-01, -2.10669041e-01, -4.76792127e-01,\n",
" 6.74312353e-01, -5.67972898e-01, 2.08251834e-01,\n",
" -1.22650824e-01, 4.15052265e-01, 2.92291105e-01,\n",
" 3.84335458e-01, 3.82747501e-01, 7.96951652e-01,\n",
" 2.45787919e-01, -5.12812495e-01, 5.99845231e-01,\n",
" -6.05813682e-01, -2.56353378e-01, 8.67983997e-01,\n",
" -6.69039071e-01, -1.16040623e+00, -8.17078352e-01,\n",
" -6.14573061e-01, 9.32083800e-02, 6.49191320e-01,\n",
" 6.45326793e-01, 1.19449282e+00, -3.89639467e-01,\n",
" 4.40224290e-01, 8.74099731e-01, -1.36296421e-01,\n",
" 9.04735982e-01, 3.27269793e-01, 9.31127742e-02,\n",
" -5.14510274e-01, 7.46768236e-01, 3.84369940e-01,\n",
" 1.30401716e-01, 2.02281713e-01, 9.07322466e-01,\n",
" -6.44040048e-01, -7.17496872e-01, -1.07841885e+00,\n",
" 3.94205689e-01, -4.85761285e-01, 1.00266829e-01,\n",
" -3.77025425e-01, -1.14991017e-01, -6.03294492e-01,\n",
" -5.45877039e-01, -2.83136576e-01, -5.13567448e-01,\n",
" -5.82447886e-01, 2.68453449e-01, 3.32528502e-01,\n",
" 1.24224198e+00, -6.67818129e-01, 9.05226171e-01,\n",
" -5.66123486e-01, -1.90349564e-01, 8.19898665e-01,\n",
" 1.97118804e-01, -9.68308747e-01, -3.20560634e-01,\n",
" 2.53744036e-01, -7.06153274e-01, -9.31951821e-01,\n",
" -1.64078271e+00, 3.15479875e-01, 1.42178342e-01,\n",
" 5.88349700e-02, 5.27518749e-01, 6.56938732e-01,\n",
" 2.79468894e-01, -4.10564542e-01, 9.62086380e-01,\n",
" 9.48429763e-01, -7.86864221e-01, 5.47595382e-01,\n",
" -7.86275983e-01, 7.61770785e-01, 5.87614894e-01,\n",
" 1.48882167e-02, -4.84432578e-01, 2.60001332e-01,\n",
" -1.50160336e+00, -6.95915163e-01, 5.42413652e-01,\n",
" -2.24143401e-01, 3.45107228e-01, 7.04570860e-02,\n",
" 5.93081042e-02, 1.59532160e-01, 1.38447762e-01,\n",
" -5.61178684e-01, -9.39185560e-01, -8.43761027e-01,\n",
" -4.81777310e-01, -2.88198024e-01, -9.24013674e-01,\n",
" -5.58189489e-02, -5.62792122e-01, 3.82276475e-01,\n",
" 1.37424067e-01, 7.60315895e-01, 5.82331598e-01,\n",
" 2.34126389e-01, 4.09395903e-01, 2.04976454e-01,\n",
" 1.22483075e+00, 1.28335214e+00, -8.90118599e-01,\n",
" 1.99793875e-01, 1.23221315e-01, -1.26057792e+00,\n",
" 2.64338050e-02, 2.98419356e-01, -1.39900632e-02,\n",
" 7.02696145e-02, 2.03694075e-01, 6.90980375e-01,\n",
" 2.89714545e-01, -5.54847181e-01, 8.55074942e-01,\n",
" -6.81426674e-02, -5.34121580e-02, -9.28871036e-01,\n",
" -1.99676026e-02, 7.34668002e-02, 1.31285846e-01,\n",
" 2.54347950e-01, 1.70441449e-01, 7.08350718e-01,\n",
" -6.22398257e-01, -7.84196556e-02, 5.66708684e-01,\n",
" -7.40765691e-01, -2.78145909e-01, 5.26153743e-01,\n",
" 4.23496008e-01, -6.95848703e-01, 1.36369213e-01,\n",
" -5.10521293e-01, -1.75267711e-01, -7.64884567e-03,\n",
" 9.14079428e-01, 5.20044208e-01, -2.23987743e-01,\n",
" 3.53826940e-01, 8.52507830e-01, 5.36109507e-01,\n",
" 4.82949048e-01, 3.01424444e-01, -4.79259759e-01,\n",
" -6.10692287e-03, 6.04810655e-01, -2.61711717e-01,\n",
" -5.65918505e-01, -5.64313531e-02, -5.63005209e-01,\n",
" -5.22360057e-02, -9.35905874e-01, -3.12182814e-01,\n",
" 1.18156619e-01, 1.01302695e+00, -1.42838508e-01,\n",
" 7.82134235e-02, -8.96130681e-01, 1.70163655e+00,\n",
" -1.46398842e-01, 1.10671282e+00, 8.45957100e-01,\n",
" 4.63032350e-02, -1.00434208e+00, -1.14734650e-01,\n",
" 2.96710730e-01, -5.72073817e-01, -2.12342575e-01,\n",
" -2.37710774e-01, 3.79127055e-01, -1.49838269e-01,\n",
" 1.90677255e-01, -9.28616405e-01, 7.70177543e-01,\n",
" 2.35295668e-01, -7.38796234e-01, 8.12511504e-01,\n",
" -4.67237413e-01, -4.24484372e-01, 1.36564776e-01,\n",
" -2.15696618e-02, 9.13881302e-01, 3.11742872e-01,\n",
" 7.86022991e-02, -8.72730196e-01, -7.89672911e-01,\n",
" -4.01746392e-01, -2.15047896e-01, 5.05439878e-01,\n",
" -1.36737025e+00, 6.40702546e-01, -6.57468557e-01,\n",
" 3.03122461e-01, 2.00641811e-01, 2.77454436e-01,\n",
" 4.26229477e-01, 8.42323452e-02, 4.92563128e-01,\n",
" 8.77941966e-01, 5.69560945e-01, -5.02784848e-01,\n",
" 1.58974600e+00, 1.30327821e-01, 2.26048499e-01,\n",
" 6.67626560e-01, 5.49613871e-02, 9.43626285e-01,\n",
" 1.06245506e+00, -5.50742388e-01, 5.56908190e-01,\n",
" 9.31764066e-01, 3.82145762e-01, 6.55513942e-01,\n",
" 2.44829385e-03, -8.68118703e-01, 2.79977143e-01,\n",
" 1.21336579e-01, -3.55989635e-01, 4.50310290e-01,\n",
" 1.79327637e-01, -1.72277451e-01, -3.34044784e-01,\n",
" -4.58468914e-01, -2.24370077e-01, 6.02882028e-01,\n",
" -9.83122110e-01, 6.39831007e-01, -5.64755946e-02,\n",
" -2.68326759e-01, -3.14345598e-01, 6.05972763e-03,\n",
" -6.35993928e-02, -8.61854672e-01, 3.42682093e-01,\n",
" -1.87066928e-01, 7.03457654e-01, 6.24295175e-01,\n",
" -6.78606808e-01, 4.04980153e-01, -1.16588630e-01,\n",
" -6.46906197e-01, 2.58253694e-01, 2.56113768e-01,\n",
" 7.04896092e-01, -8.82478118e-01, -3.24431896e-01,\n",
" -1.49077222e-01, -2.00304121e-01, 4.80519086e-01,\n",
" -8.77241135e-01, 9.28806737e-02, -2.77008176e-01,\n",
" -2.52063602e-01, 3.62312973e-01, 5.23445070e-01,\n",
" 6.17201477e-02, 3.06572258e-01, -2.11930275e-01,\n",
" 1.78940728e-01, 3.65689784e-01, -5.40046096e-01,\n",
" 2.63069421e-01, -4.92571503e-01, -1.09113395e+00,\n",
" -2.64382094e-01, 1.50071561e-01, -1.21670222e+00,\n",
" -1.27806652e+00, 7.23531783e-01, 1.07804430e+00,\n",
" 2.99413145e-01, -3.73375475e-01, 5.63707471e-01,\n",
" -3.84140350e-02, 3.85195851e-01, 7.45883882e-02,\n",
" 5.53500690e-02, -1.04585457e+00, -1.97465733e-01,\n",
" -8.30319058e-03, -7.37104416e-01, 4.16536480e-02,\n",
" 1.17034423e+00, -1.80100635e-01, -1.88495189e-01,\n",
" 5.19660592e-01, 2.14780048e-01, 3.36319059e-02,\n",
" 7.73143053e-01, 3.61136287e-01, -4.28402722e-01,\n",
" -8.84197876e-02, 6.89760685e-01, 4.01313961e-01,\n",
" -6.98327184e-01, 2.32672039e-02, -8.21807086e-01,\n",
" -3.07718366e-01, -4.05677371e-02, -8.12784433e-01,\n",
" -8.40686142e-01, -5.86191237e-01, -1.52433366e-01,\n",
" -3.29975456e-01, -6.76786900e-02, 1.36615014e+00,\n",
" 1.39413977e+00, -5.70796877e-02, -2.52656639e-01,\n",
" -4.51961011e-02, 3.77376556e-01, 3.74267623e-02,\n",
" -1.00905411e-01, 5.03461361e-01, 4.47633147e-01,\n",
" -8.03849757e-01, 3.12187463e-01, 7.82718778e-01,\n",
" 7.99427450e-01, 8.74587893e-02, -3.69026005e-01,\n",
" 4.00398403e-01, 2.46881902e-01, 4.02131408e-01,\n",
" 2.96504140e-01, -2.65133023e-01, -8.00934196e-01,\n",
" -1.27983302e-01, 3.69233519e-01, -3.53833318e-01,\n",
" 9.58463430e-01, 8.44675601e-02, 1.76893070e-01,\n",
" 9.15330946e-02, -6.18301369e-02, 7.27794826e-01,\n",
" -5.30644834e-01, 5.37168384e-01, -9.10579562e-01,\n",
" 9.74827886e-01, -1.29682362e-01, 8.54603410e-01,\n",
" 2.43808255e-02, -5.53768694e-01, 5.91500998e-01,\n",
" 5.04585087e-01, -8.32424283e-01, -1.12211466e+00,\n",
" -2.83660553e-02, -1.73512232e+00, -7.24534571e-01,\n",
" 7.96634674e-01, 4.31780487e-01, -1.12527800e+00,\n",
" -1.56593829e-01, -2.48527288e-01, -6.10543132e-01,\n",
" -3.87620851e-02, 2.72551537e-01, 7.81981230e-01,\n",
" 2.83847809e-01, -5.20967424e-01, -7.18649983e-01,\n",
" 2.10900754e-01, -8.37667227e-01, -5.51518202e-01,\n",
" 5.75399138e-02, 2.35412762e-01, 4.11376804e-01,\n",
" 1.39269143e-01, 8.81839573e-01, -1.53456211e-01,\n",
" 1.32611656e+00, 5.51057339e-01, -3.10137779e-01,\n",
" -3.27861547e-01, -5.78627765e-01, 2.88041979e-01,\n",
" -2.95859277e-02, 5.04428446e-01, -5.79054892e-01]], dtype=float32)"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"query_embeddings"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "1660cff8-b813-4f10-9621-408070bdb877",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Index loaded successfully!\n",
"Number of vectors in the index: 404\n"
]
}
],
"source": [
"from retriever import vector_db_retriever"
]
},
{
"cell_type": "code",
"execution_count": 25,
"id": "470d596e-4c67-4d14-adf8-f7c923d95f21",
"metadata": {},
"outputs": [],
"source": [
"query = \" explain Seventh Amendment Act\"\n",
"query_embeddings = model.encode([query])"
]
},
{
"cell_type": "code",
"execution_count": 26,
"id": "5431146f-86c4-4c5b-8cda-0753940dbe12",
"metadata": {},
"outputs": [],
"source": [
"result = vector_db_retriever(query_embeddings, 15)"
]
},
{
"cell_type": "code",
"execution_count": 27,
"id": "255a910b-aa83-4c3f-bc27-2eaa070a6135",
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"THE CONSTITUTION OF INDIA \n",
"(Part VI.—The States) 101\n",
"218. Application of certain provisions relating to Supreme Court to \n",
"High Courts .—The provisions of clauses (4) and (5) of article 124 shall apply \n",
"in relation to a High Court as they apply in relation to the Supreme Court with \n",
"the substitution of references to the High Court for references to the Supreme \n",
"Court. \n",
"219. Oath or affirmation by Judges of High Courts. —Every person \n",
"appointed to be a Judge of a High Court 1*** shall, before he enters upon his \n",
"office, make and subscribe before the Governor of the State, or some person \n",
"appointed in that behalf by him, an oath or affirmation according to the form \n",
"set out for the purpose in the Third Schedule. \n",
"2[220. Restriction on practice after being a permanent Judge .—No \n",
"person who, after the commencement of this Constitution, has held office as a \n",
"permanent Judge of a High Court shall plead or act in any court or before any \n",
"authority in India except the Supreme Court and the other High Courts. \n",
"Explanation.— In this article, the expression “High Court” does not \n",
"include a High Court for a State specified in Part B of the First Schedule as it \n",
"existed before the commencement3 of the Constitution (Seventh Amendment) \n",
"Act, 1956.] \n",
"221. Salaries, etc., of Judges. —4[(1) There shall be paid to the Judges \n",
"of each High Court such salaries as may be determined by Parliament by law \n",
"and, until provision in that behalf is so made, such salaries as are specified in \n",
"the Second Schedule.] \n",
"(2) Every Judge shall be entitled to such allowances and to such rights in \n",
"respect of leave of absence and pension as may from time to time be \n",
"determined by or under law made by Parliament and, until so determined, to \n",
"such allowances and rights as are specified in the Second Schedule: \n",
"Provided that neither the allowances of a Judge nor his rights in respect \n",
"to leave of absence or pension shall be varied to his disadvantage after his \n",
"appointment. \n",
"______________________________________________ \n",
"1. The words \"in a State\" omitted by the Constitution (Seventh Amendment) Act, 1956, \n",
"s. 29 and Sch. (w.e.f. 1-11-1956). \n",
"2. Subs. by s. 13, ibid. (w.e.f. 1-11-1956). \n",
"3. 1st November, 1956. \n",
"4. Subs. by the Constitution (Fifty-fourth Amendment) Act, 1986, s. 3, for clause (1) \n",
"(w.e.f. 1-4-1986). \n",
"==========================================================================\n",
"THE CONSTITUTION OF INDIA \n",
"(Part XXI. —Temporary, Transitional and Special Provisions) 246\n",
"(b) identification of posts or classes of posts under the State \n",
"Government and in any body or organisation under the control of the \n",
"State Government in the Hyderabad-Karnataka region and reservation of \n",
"a proportion of such posts for persons who belong to that region by birth \n",
"or by domicile and for appointment thereto by direct recruitment or by \n",
"promotion or in any other manner as may be specified in the order.] \n",
"372. Continuance in force of existing laws and their adaptation.— (1) \n",
"Notwithstanding the repeal by this Constitution of the enactments referred to in \n",
"article 395 but subject to the other provisions of this Constitution, all the law in \n",
"force in the territory of India immediately before the commencement of this \n",
"Constitution shall continue in force therein until altered or repealed or amended \n",
"by a competent Legislature or other competent authority. \n",
"(2) For the purpose of bringing the provisions of any law in force in the \n",
"territory of India into accord with the provisions of this Constitution, the \n",
"President may by order make such adaptations and modifications of such law, \n",
"whether by way of repeal or amendment, as may be necessary or expedient, and \n",
"provide that the law shall, as from such date as may be specified in the order, \n",
"have effect subject to the adaptations and modifications so made, and any such \n",
"adaptation or modification shall not be questioned in any court of law. \n",
"(3) Nothing in clause (2) shall be deemed— \n",
"(a) to empower the President to make any adaptation or \n",
"modification of any law after the expiration of 1[three years] from the \n",
"commencement of this Constitution; or \n",
"(b) to prevent any competent Legislature or other competent \n",
"authority from repealing or amending any law adapted or modified by \n",
"the President under the said clause. \n",
"______________________________________________ \n",
" See the Adaptation of Laws Order, 1950, dated the 26th January, 1950, Gazette of \n",
"India, Extraordinary, p. 449, as amended by notification No. S.R.O. 115, dated the 5th \n",
"June, 1950, Gazette of India, Extraordinary, Part II, Section 3, p. 51, notification No. \n",
"S.R.O. 870, dated the 4th November, 1950, Gazette of India, Extraordinary, Part II, \n",
"Section 3, p. 903, notification No. S.R.O. 508, dated the 4th April, 1951, Gazette of \n",
"India, Extraordinary, Part II, Section 3, p. 287, notification No. S.R.O. 1140B, dated \n",
"the 2nd July, 1952, Gazette of India, Extraordinary, Part II, Section 3, p. 616/1, and the \n",
"Adaptation of the Travancore-Cochin Land Acquisition Laws Order, 1952, dated the \n",
"20th November, 1952, Gazette of India, Extraordinary, Part II, Section 3, p. 923. \n",
"1. Subs. by the Constitution (First Amendment) Act, 1951, s. 12 for \"two years\" \n",
"(w.e.f. 18-6-1951). \n",
"==========================================================================\n",
"THE CONSTITUTION OF INDIA \n",
"(Part III.—Fundamental Rights) 10\n",
"(e) to reside and settle in any part of the territory of India; 1[and] \n",
"2[(f)* * * * *] \n",
"(g) to practise any profession, or to carry on any occupation, trade or \n",
"business. \n",
"3[(2) Nothing in sub-clause ( a) of clause (1) shall affect the operation of \n",
"any existing law, or prevent the State from making any law, in so far as such \n",
"law imposes reasonable restrictions on the exercise of the right conferred by the \n",
"said sub-clause in the interests of 4[the sovereignty and integrity of India], the \n",
"security of the State, friendly relations with foreign States, public order, \n",
"decency or morality, or in relation to contempt of court, defamation or \n",
"incitement to an offence.] \n",
"(3) Nothing in sub-clause ( b) of the said clause shall affect the operation \n",
"of any existing law in so far as it imposes, or prevent the State from making \n",
"any law imposing, in the interests of 4[the sovereignty and integrity of India or] \n",
"public order, reasonable restrictions on the exercise of the right conferred by \n",
"the said sub-clause. \n",
"(4) Nothing in sub-clause ( c) of the said clause shall affect the operation \n",
"of any existing law in so far as it imposes, or prevent the State from making \n",
"any law imposing, in the interests of 4[the sovereignty and integrity of India or] \n",
"public order or morality, reasonable restrictions on the exercise of the right \n",
"conferred by the said sub-clause. \n",
"(5) Nothing in 5[sub-clauses ( d) and (e)] of the said clause shall affect \n",
"the operation of any existing law in so far as it imposes, or prevent the State \n",
"from making any law imposing, reasonable restrictions on the exercise of any \n",
"of the rights conferred by the said sub-clauses either in the interests of the \n",
"general public or for the protection of the interests of any Scheduled Tribe. \n",
"______________________________________________ \n",
"1. Ins. by the Constitution (Forty-fourth Amendment) Act, 1978, s. 2 (w.e.f. 20-6-1979). \n",
"2. Sub-clause (f) o mitted by s.2, ibid. (w.e.f. 20-6-1979). \n",
"3. Subs. by the Constitution (First Amendment) Act, 1951, s. 3, for cl. (2) (with retrospective \n",
"effect). \n",
"4. Ins. by the Constitution (Sixteenth Amendment) Act, 1963, s. 2 (w.e.f. 5-10-1963). \n",
"5. Subs. by the Constitution (Forty-fourth Amendment) Act, 1978, s. 2, for \"sub-clauses \n",
"(d), (e) and ( f)\" (w.e.f. 20-6-1979). \n",
"==========================================================================\n",
" 228PART XX \n",
"AMENDMENT OF THE CONSTITUTION \n",
"368. 1[Power of Parliament to amend the Constitution and \n",
"procedure therefor].— 2[(1) Notwithstanding anything in this Constitution, \n",
"Parliament may in exercise of its constituent power amend by way of addition, \n",
"variation or repeal any provision of this Constitution in accordance with the \n",
"procedure laid down in this article.] \n",
"3[(2)] An amendment of this Constitution may be initiated only by the \n",
"introduction of a Bill for the purpose in either House of Parliament, and when \n",
"the Bill is passed in each House by a majority of the total membership of that \n",
"House and by a majority of not less than two-thirds of the members of that \n",
"House present and voting, 4[it shall be presented to the President who shall give \n",
"his assent to the Bill and thereupon] the Constitution shall stand amended in \n",
"accordance with the terms of the Bill: \n",
"Provided that if such amendment seeks to make any change in— \n",
" (a) article 54, article 55, article 73, 5[ article 162, article 241 or article \n",
"279A]; or \n",
" (b) Chapter IV of Part V, Chapter V of Part VI, or Chapter I of Part XI; or \n",
" (c) any of the Lists in the Seventh Schedule; or \n",
" (d) the representation of States in Parliament; or \n",
" (e) the provisions of this article, \n",
"______________________________________________ \n",
"1. Marginal heading subs. by the Constitution (Twenty-fourth Amendment) Act, 1971, s. 3, \n",
"for \"Procedure for amendment of the Constitution\" (w.e.f. 5-11-1971). \n",
"2. Ins. by s. 3, ibid. (w.e.f. 5-11-1971). \n",
"3. Art. 368 re-numbered as cl. (2) thereof by s. 3, ibid. (w.e.f. 5-11-1971). \n",
"4. Subs. by s. 3, ibid., (w.e.f. 5-11-1971). \n",
"5. Subs. by the Constitution (One Hundred and First Amendment) Act, 2016, s. 15, for the \n",
"words and figures \"article 162 or article 241\" (w.e.f. 16-9-2016). \n",
"==========================================================================\n",
"THE CONSTITUTION OF INDIA \n",
"(Part XXI. —Temporary, Transitional and Special Provisions) 240\n",
"(5) The Order of the Administrative Tribunal finally disposing of any \n",
"case shall become effective upon its confirmation by the State Government or \n",
"on the expiry of three months from the date on which the order is made, \n",
"whichever is earlier: \n",
"Provided that the State Government may, by special order made in \n",
"writing and for reasons to be specified therein, modify or annul any order of the \n",
"Administrative Tribunal before it becomes effective and in such a case, the \n",
"order of the Administrative Tribunal shall have effect only in such modified \n",
"form or be of no effect, as the case may be. \n",
"(6) Every special order made by the State Government under the proviso \n",
"to clause (5) shall be laid, as soon as may be after it is made, before both \n",
"Houses of the State Legislature. \n",
"(7) The High Court for the State shall not have any powers of \n",
"superintendence over the Administrative Tribunal and no court (other than the \n",
"Supreme Court) or tribunal shall exercise any jurisdiction, power or authority in \n",
"respect of any matter subject to the jurisdiction, power or authority of, or in \n",
"relation to, the Administrative Tribunal. \n",
"(8) If the President is satisfied that the continued existence of the \n",
"Administrative Tribunal is not necessary, the President may by order abolish \n",
"the Administrative Tribunal and make such provisions in such order as he may \n",
"deem fit for the transfer and disposal of cases pending before the Tribunal \n",
"immediately before such abolition. \n",
"(9) Notwithstanding any judgment, decree or order of any court, tribunal \n",
"or other authority,— \n",
"(a) no appointment, posting, promotion or transfer of any person— \n",
"(i) made before the 1st day of November, 1956, to any post \n",
"under the Government of, or any local authority within, the State \n",
"of Hyderabad as it existed before that date; or \n",
"(ii) made before the commencement of the Constitution \n",
"(Thirty-second Amendment) Act, 1973, to any post under the \n",
"Government of, or any local or other authority within, the State of \n",
"Andhra Pradesh; and \n",
"(b) no action taken or thing done by or before any person referred to \n",
"in sub-clause ( a), \n",
"______________________________________________ \n",
" In P. Sambamurthy and Others Vs. State of Andhra Pradesh and Others (1987) \n",
"1 S.C.C. 362, the Supreme Court declared cl. (5) of art. 371D along with the proviso to \n",
"be unconstitutional and vo id. \n",
" \n",
"==========================================================================\n",
"THE CONSTITUTION OF INDIA \n",
"(Seventh Schedule) \n",
" 314\n",
"64. Institutions for scientific or technical education financed by the \n",
"Government of India wholly or in part and declared by Parliament by law to be \n",
"institutions of national importance. \n",
"65. Union agencies and institutions for— \n",
"(a) professional, vocational or technical training, including the \n",
"training of police officers; or \n",
"(b) the promotion of special studies or research; or \n",
"(c) scientific or technical assistance in the investigation or detection \n",
"of crime. \n",
"66. Co-ordination and determination of standards in institutions for higher \n",
"education or research and scientific and technical institutions. \n",
"67. Ancient and historical monuments and records, and archaeological \n",
"sites and remains, 1[declared by or under law made by Parliament] to be of \n",
"national importance. \n",
"68. The Survey of India, the Geological, Botanical, Zoological and \n",
"Anthropological Surveys of India; Meteorological organisations. \n",
"69. Census. \n",
"70. Union Public Service; All-India Services; Union Public Service \n",
"Commission. \n",
"71. Union pensions, that is to say, pensions payable by the Government of \n",
"India or out of the Consolidated Fund of India. \n",
"72. Elections to Parliament, to the Legislatures of States and to the offices \n",
"of President and Vice-President; the Election Commission. \n",
"73. Salaries and allowances of members of Parliament, the Chairman and \n",
"Deputy Chairman of the Council of States and the Speaker and Deputy Speaker \n",
"of the House of the People. \n",
"74. Powers, privileges and immunities of each House of Parliament and of \n",
"the members and the Committees of each House; enforcement of attendance of \n",
"persons for giving evidence or producing documents before committees of \n",
"Parliament or commissions appointed by Parliament. \n",
"75. Emoluments, allowances, privileges, and rights in respect of leave of \n",
"absence, of the President and Governors; salaries and allowances of the \n",
"Ministers for the Union; the salaries, allowances, and rights in respect of leave \n",
"of absence and other conditions of service of the Comptroller and Auditor-\n",
"General of India. \n",
"______________________________________________ \n",
"1. Subs. by the Constitution (Seventh Amendment) Act, 1956, s. 27, for \"declared by \n",
"Parliament by law\" (w.e.f. 1-11-1956). \n",
"==========================================================================\n",
" 276FIFTH SCHEDULE \n",
"[Article 244(1)] \n",
"Provisions as to the Administration and Control of Scheduled Areas and \n",
"Scheduled Tribes \n",
"PART A \n",
"GENERAL \n",
"1. Interpretation .—In this Schedule, unless the context otherwise \n",
"requires, the expression “State” 1*** does not include the 2[States of Assam \n",
"3[, 4[Meghalaya, Tripura and Mizoram.]]] \n",
"2. Executive power of a State in Scheduled Areas.— Subject to the \n",
"provisions of this Schedule, the executive power of a State extends to the \n",
"Scheduled Areas therein. \n",
"3. Report by the Governor 5*** to the President regarding the \n",
"administration of Scheduled Areas.— The Governor 5*** of each State having \n",
"Scheduled Areas therein shall annually, or whenever so required by the President, \n",
"make a report to the President regarding the administration of the Scheduled \n",
"Areas in that State and the executive power of the Union shall extend to the \n",
"giving of directions to the State as to the administration of the said areas. \n",
"PART B \n",
"ADMINISTRATION AND CONTROL OF SCHEDULED AREAS AND \n",
"SCHEDULED TRIBES \n",
"4. Tribes Advisory Council.—( 1) There shall be established in each \n",
"State having Scheduled Areas therein and, if the President so directs, also in \n",
"any State having Scheduled Tribes but not Scheduled Areas therein, a Tribes \n",
"Advisory Council consisting of not more than twenty members of whom, as \n",
"nearly as may be, three-fourths shall be the representatives of the Scheduled \n",
"Tribes in the Legislative Assembly of the State: \n",
"______________________________________________ \n",
"1. The words and letters \"means a State specified in Part A or Part B of the First \n",
"Schedule but\" omitted by the Constitution (Seventh Amendment) Act, 1956, s. 29 and \n",
"Sch. (w.e.f. 1-11-1956). \n",
"2. Subs. by the North-Eastern Areas (Reorganisation) Act, 1971 (81 of 1971), s. 71, for \n",
"\"State of Assam\" (w.e.f. 21-1-1972). \n",
"3. Subs. by the Constitution (Forty-ninth Amendment) Act, 1984, s. 3, for \"and \n",
"Meghalaya\" (w.e.f. 1-4-1985). \n",
"4. Subs. by the State of Mizoram Act, 1986 (34 of 1986), s. 39, for \"Meghalaya and \n",
"Tripura\" (w.e.f. 20-2-1987). \n",
"5. The words \"or Rajpramukh\" omitted by the Constitution (Seventh Amendment) Act, \n",
"1956, s. 29 and Sch. (w.e.f. 1-11-1956). \n",
"==========================================================================\n",
"THE CONSTITUTION OF INDIA \n",
"(Fifth Schedule) 278\n",
"(c) regulate the carrying on of business as money-lender by \n",
"persons who lend money to members of the Scheduled Tribes in such \n",
"area. \n",
"(3) In making any such regulation as is referred to in sub-paragraph (2) \n",
"of this paragraph, the Governor 1*** may repeal or amend any Act of \n",
"Parliament or of the Legislature of the State or any existing law which is for the \n",
"time being applicable to the area in question. \n",
"(4) All regulations made under this paragraph shall be submitted \n",
"forthwith to the President and, until assented to by him, shall have no effect. \n",
"(5) No regulation shall be made under this paragraph unless the \n",
"Governor 1** making the regulation has, in the case where there is a Tribes \n",
"Advisory Council for the State, consulted such Council. \n",
"PART C \n",
"SCHEDULED AREAS \n",
"6. Scheduled Areas .—(1) In this Constitution, the expression \n",
"“Scheduled Areas” means such areas as the President may by order declare to \n",
"be Scheduled Areas. \n",
"(2) The President may at any time by order— \n",
"(a) direct that the whole or any specified part of a Scheduled Area \n",
"shall cease to be a Scheduled Area or a part of such an area; \n",
"2[(aa) increase the area of any Scheduled Area in a State after \n",
"consultation with the Governor of that State;] \n",
"(b) alter, but only by way of rectification of boundaries, any \n",
"Scheduled Area; \n",
"______________________________________________ \n",
"1. The words \"or Rajpramukh\" omitted by the Constitution (Seventh Amendment) Act, \n",
"1956, s. 29 and Sch. (w.e.f. 1-11-1956). \n",
" See the Scheduled Areas (Part A States) Order, 1950 (C.O. 9), the Scheduled Areas \n",
"(Part B States) Order, 1950 (C.O.26), the Scheduled Areas (Himachal Pradesh) Order, \n",
"1975 (C.O. 102) and the Scheduled Areas (States of Bihar, Gujarat, Madhya Pradesh \n",
"and Orissa) Order, 1977 (C.O. 109). \n",
" See the Madras Scheduled Areas (Cessor) Order, 1950 (C.O. 30) and the Andhra \n",
"Scheduled Areas (Cessor) Order, 1955 (C.O. 50). \n",
"2. Ins. by the Fifth Schedule to the Constitution (Amendment) Act, 1976 (101 of 1976), \n",
"s. 2 (w.e.f. 7-9-1976). \n",
"==========================================================================\n",
"THE CONSTITUTION OF INDIA \n",
"(Seventh Schedule) \n",
" 316\n",
"86. Taxes on the capital value of the assets, exclusive of agricultural land, \n",
"of individuals and companies; taxes on the capital of companies. \n",
"87. Estate duty in respect of property other than agricultural land. \n",
"88. Duties in respect of succession to property other than agricultural land. \n",
"89. Terminal taxes on goods or passengers, carried by railway, sea or air; \n",
"taxes on railway fares and freights. \n",
"90. Taxes other than stamp duties on transactions in stock exchanges and \n",
"futures markets. \n",
"91. Rates of stamp duty in respect of bills of exchange, cheques, \n",
"promissory notes, bills of lading, letters of credit, policies of insurance, transfer \n",
"of shares, debentures, proxies and receipts. \n",
"1[92. * * * * * *] \n",
"2[92A. Taxes on the sale or purchase of goods other than newspapers, \n",
"where such sale or purchase takes place in the course of inter-State trade or \n",
"commerce.] \n",
"3[92B. Taxes on the consignments of goods (whether the consignment is to \n",
"the person making it or to any other person), where such consignment takes \n",
"place in the course of inter-State trade or commerce.] \n",
"4[92C. * * * * * *] \n",
"93. Offences against laws with respect to any of the matters in this List. \n",
"94. Inquires, surveys and statistics for the purpose of any of the matters in \n",
"this List. \n",
"95. Jurisdiction and powers of all courts, except the Supreme Court, with \n",
"respect to any of the matters in this List; admiralty jurisdiction. \n",
"96. Fees in respect of any of the matters in this List, but not including fees \n",
"taken in any court. \n",
"97. Any other matter not enumerated in List II or List III including any tax \n",
"not mentioned in either of those Lists. \n",
"______________________________________________ \n",
"1. Entry 92 omitted by the Constitution (One Hundred and First Amendment) Act, 2016, \n",
"s. 17(a)(ii) (w.e.f. 16-9-2016). \n",
"2. Ins. by the Constitution (Sixth Amendment) Act, 1956, s. 2 (w.e.f. 11-9-1956). \n",
"3. Ins.by the Constitution (Forty-sixth Amendment) Act, 1982, s. 5 (w.e.f. 2-2-1983). \n",
"4. Entry 92C was ins. by the Constitution (Eighty-eighth Amendment) Act, 2003, s. 4 \n",
"(date not notified) and omitted by the Constitution (One Hundred and First \n",
"Amendment) Act, 2016, s. 17( a)(ii) (w.e.f. 16-9-2016). \n",
"==========================================================================\n",
"THE CONSTITUTION OF INDIA \n",
"(Part III.—Fundamental Rights) 7\n",
"(a) access to shops, public restaurants, hotels and places of public \n",
"entertainment; or \n",
"(b) the use of wells, tanks, bathing ghats, roads and places of \n",
"public resort maintained wholly or partly out of State funds or dedicated \n",
"to the use of the general public. \n",
"(3) Nothing in this article shall prevent the State from making any \n",
"special provision for women and children. \n",
"1[(4) Nothing in this article or in clause (2) of article 29 shall prevent the \n",
"State from making any special provision for the advancement of any socially \n",
"and educationally backward classes of citizens or for the Scheduled Castes and \n",
"the Scheduled Tribes.] \n",
"2[(5) Nothing in this article or in sub-clause ( g) of clause (1) of article 19 \n",
"shall prevent the State from making any special provision, by law, for the \n",
"advancement of any socially and educationally backward classes of citizens or \n",
"for the Scheduled Castes or the Scheduled Tribes in so far as such special \n",
"provisions relate to their admission to educational institutions including private \n",
"educational institutions, whether aided or unaided by the State, other than the \n",
"minority educational institutions referred to in clause (1) of article 30.] \n",
"3[(6) Nothing in this article or sub-clause ( g) of clause (1) of article 19 or \n",
"clause (2) of article 29 shall prevent the State from making,— \n",
"(a) any special provision for the advancement of any \n",
"economically weaker sections of citizens other than the classes \n",
"mentioned in clauses (4) and (5); and \n",
"(b) any special provision for the advancement of any \n",
"economically weaker sections of citizens other than the classes \n",
"mentioned in clauses (4) and (5) in so far as such special provisions \n",
"relate to their admission to educational institutions including private \n",
"educational institutions, whether aided or unaided by the State, other \n",
"than the minority educational institutions referred to in clause (1) of \n",
"article 30, which in the case of reservation would be in addition to the \n",
"existing reservations and subject to a maximum of ten per cent. of the \n",
"total seats in each category. \n",
"______________________________________________ \n",
"1. Added by the Constitution (First Amendment) Act, 1951, s. 2 (w.e.f. 18-6-1951). \n",
"2. Ins. by the Constitution (Ninety-third Amendment) Act, 2005, s. 2 (w.e.f. 20-1-2006). \n",
"3. Ins. by the Constitution (One Hundred and Third Amendment) Act, 2019, s. 2 \n",
"(w.e.f. 14-1-2019). \n",
"==========================================================================\n",
"THE CONSTITUTION OF INDIA \n",
"(Appendix I) \n",
" 369\n",
" \n",
"1 2 3 4 5 6 \n",
"48. (i) Paschim \n",
"Masaldanga Dinhata Bhurungamari 4 29.49 \n",
" (ii) Paschim \n",
"Masaldanga (Fragment) Dinhata Bhurungamari 4 \n",
"49. (i) Purba Chhit \n",
"Masaldanga Dinhata Bhurungamari 10 35.01 \n",
" (ii) Purba Chhit \n",
"Masaldanga (Fragment) Dinhata Bhurungamari 10 \n",
"50. (i) Purba Masaldanga Dinhata Bhurungamari 11 153.89 \n",
" (ii) Purba Masaldanga \n",
"(Fragment) Dinhata Bhurungamari 11 \n",
"51. (i) Uttar Dhaldanga Tufanganj Bhurungamari 14 24.98 \n",
" (ii) Uttar Dhaldanga \n",
"(Fragment) Tufanganj Bhurungamari 14 \n",
" (iii) Uttar Dhaldanga \n",
"(Fragment) Tufanganj Bhurungamari 14 \n",
" Total Area 7,110.02 \n",
" \n",
"The above given details of enclaves have been jointly compared and \n",
"reconciled with records held by India and Bangladesh during the Indo-\n",
"Bangladesh Conference held at Calcutta during 9th—12th October, 1996 as well as \n",
"during joint field inspection at Jalpaiguri (West Bengal) – Panchagarh (Bangladesh) \n",
"sector during 21—24 November, 1996. \n",
" \n",
"Brig. J.R. Peter \n",
"Director Land Records & Survey ( Ex \n",
"officio) West Bengal, India & Director, \n",
"Eastern Circle Survey of India, \n",
"Calcutta. Md. Shafi Uddin \n",
"Director General, Land Records \n",
"and Surveys, Bangladesh. \n",
" \n",
" \n",
"==========================================================================\n",
"THE CONSTITUTION OF INDIA \n",
"(Second Schedule) 266\n",
"Court under clause (1) of article 374, or \n",
"(b) was holding office as any other Judge of the Federal Court and \n",
"has on such commencement become a Judge (other than the Chief \n",
"Justice) of the Supreme Court under the said clause, \n",
"during the period he holds office as such Chief Justice or other Judge, and \n",
"every Judge who so becomes the Chief Justice or other Judge of the Supreme \n",
"Court shall, in respect of time spent on actual service as such Chief Justice or \n",
"other Judge, as the case may be, be entitled to receive in addition to the salary \n",
"specified in sub-paragraph (1) of this paragraph as special pay an amount \n",
"equivalent to the difference between the salary so specified and the salary \n",
"which he was drawing immediately before such commencement. \n",
"(4) Every Judge of the Supreme Court shall receive such reasonable \n",
"allowances to reimburse him for expenses incurred in travelling on duty within \n",
"the territory of India and shall be afforded such reasonable facilities in \n",
"connection with travelling as the President may from time to time prescribe. \n",
"(5) The rights in respect of leave of absence (including leave allowances) \n",
"and pension of the Judges of the Supreme Court shall be governed by the \n",
"provisions which, immediately before the commencement of this Constitution, \n",
"were applicable to the Judges of the Federal Court. \n",
"10. (1) 1[There shall be paid to the Judges of High Courts, in respect of time \n",
"spent on actual service, salary at the following rates per mensem, that is to say,— \n",
"The Chief Justice .. 2[9,000 rupees] \n",
"Any other Judge .. 3[8,000 rupees]: \n",
"Provided that if a Judge of a High Court at the time of his appointment is in \n",
"receipt of a pension (other than a disability or wound pension) in respect of any \n",
"______________________________________________ \n",
"1. Subs. by the Constitution (Seventh Amendment) Act, 1956, s. 25(c)(i), for sub-\n",
"paragraph (1) (w.e.f. 1-11-1956). \n",
"2. Subs. by the Constitution (Fifty-fourth Amendment) Act, 1986, s. 4, for \"4,000 rupees\" \n",
"(w.e.f. 1-4-1986). \n",
" Now two lakh fifty thousand rupees, vide the High Court and Supreme Court Judges \n",
"(Salaries and Conditions of Service) Amendment Act, 2018 (10 of 2018), s. 2 \n",
"(w.e.f. 1-1-2016). \n",
"3. Subs. by the Constitution (Fifty-fourth Amendment) Act, 1986, s. 4, for \"3,500 rupees\" \n",
"(w.e.f. 1-4-1986). \n",
" Now two lakh twenty-five thousand rupees, vide the High Court and Supreme Court \n",
"Judges (Salaries and Conditions of Service) Amendment Act, 2018 (10 of 2018), s. 2 \n",
"(w.e.f. 1-1-2016). \n",
"==========================================================================\n",
"THE CONSTITUTION OF INDIA \n",
"(Part XXI. —Temporary, Transitional and Special Provisions) 243\n",
"(i) the High Court functioning as such immediately before the \n",
"appointed day in the territories comprised in the State of Sikkim shall, on \n",
"and from the appointed day, be deemed to be the High Court for the \n",
"State of Sikkim; \n",
"(j) all courts of civil, criminal and revenue jurisdiction, all authorities and \n",
"all officers, judicial, executive and ministerial, throughout the territory of the \n",
"State of Sikkim shall continue on and from the appointed day to exercise \n",
"their respective functions subject to the provisions of this Constitution; \n",
"(k) all laws in force immediately before the appointed day in the \n",
"territories comprised in the State of Sikkim or any part thereof shall \n",
"continue to be in force therein until amended or repealed by a competent \n",
"Legislature or other competent authority; \n",
"(l) for the purpose of facilitating the application of any such law as is \n",
"referred to in clause ( k) in relation to the administration of the State of \n",
"Sikkim and for the purpose of bringing the provisions of any such law \n",
"into accord with the provisions of this Constitution, the President may, \n",
"within two years from the appointed day, by order, make such \n",
"adaptations and modifications of the law, whether by way of repeal or \n",
"amendment, as may be necessary or expedient, and thereupon, every \n",
"such law shall have effect subject to the adaptations and modifications so \n",
"made, and any such adaptation or modification shall not be questioned in \n",
"any court of law; \n",
"(m) neither the Supreme Court nor any other court shall have \n",
"jurisdiction in respect of any dispute or other matter arising out of any \n",
"treaty, agreement, engagement or other similar instrument relating to \n",
"Sikkim which was entered into or executed before the appointed day and \n",
"to which the Government of India or any of its predecessor Governments \n",
"was a party, but nothing in this clause shall be construed to derogate \n",
"from the provisions of article 143; \n",
"(n) the President may, by public notification, extend with such restrictions \n",
"or modifications as he thinks fit to the State of Sikkim any enactment which \n",
"is in force in a State in India at the date of the notification; \n",
"(o) if any difficulty arises in giving effect to any of the foregoing \n",
"provisions of this article, the President may, by order, do anything \n",
"(including any adaptation or modification of any other article) which \n",
"appears to him to be necessary for the purpose of removing that \n",
"difficulty: \n",
"______________________________________________ \n",
" See the Constitution (Removal of Difficulties) Order No. XI (C.O. 99). \n",
"==========================================================================\n",
"THE CONSTITUTION OF INDIA \n",
"(Fifth Schedule) 277\n",
"Provided that if the number of representatives of the Scheduled Tribes in \n",
"the Legislative Assembly of the State is less than the number of seats in the \n",
"Tribes Advisory Council to be filled by such representatives, the remaining \n",
"seats shall be filled by other members of those tribes. \n",
"(2) It shall be the duty of the Tribes Advisory Council to advise on such \n",
"matters pertaining to the welfare and advancement of the Scheduled Tribes in \n",
"the State as may be referred to them by the Governor 1***. \n",
"(3) The Governor 2*** may make rules prescribing or regulating, as the \n",
"case may be,— \n",
"(a) the number of members of the Council, the mode of their \n",
"appointment and the appointment of the Chairman of the Council and of \n",
"the officers and servants thereof; \n",
"(b) the conduct of its meetings and its procedure in general; and \n",
"(c) all other incidental matters. \n",
"5. Law applicable to Scheduled Areas. —(1) Notwithstanding anything \n",
"in this Constitution, the Governor 1*** may by public notification direct that \n",
"any particular Act of Parliament or of the Legislature of the State shall not \n",
"apply to a Scheduled Area or any part thereof in the State or shall apply to a \n",
"Scheduled Area or any part thereof in the State subject to such exceptions and \n",
"modifications as he may specify in the notification and any direction given \n",
"under this sub-paragraph may be given so as to have retrospective effect. \n",
"(2) The Governor may make regulations for the peace and good \n",
"government of any area in a State which is for the time being a Scheduled Area. \n",
"In particular and without prejudice to the generality of the foregoing \n",
"power, such regulations may— \n",
"(a) prohibit or restrict the transfer of land by or among members \n",
"of the Scheduled Tribes in such area; \n",
"(b) regulate the allotment of land to members of the Scheduled \n",
"Tribes in such area; \n",
"______________________________________________ \n",
"1. The words \"or Rajpramukh, as the case may be\" omitted by the Constitution (Seventh \n",
"Amendment) Act, 1956, s. 29 and Sch. (w.e.f. 1-11-1956). \n",
"2. The words \"or Rajpramukh\" omitted by s. 29 and Sch., ibid. (w.e.f. 1-11-1956). \n",
"==========================================================================\n",
"THE CONSTITUTION OF INDIA \n",
"(Part XIX.—M ISCELLANEOUS ) 227\n",
"(e) a tax on the supply of goods by any unincorporated \n",
"association or body of persons to a member thereof for cash, \n",
"deferred payment or other valuable consideration; \n",
"(f) a tax on the supply, by way of or as part of any service \n",
"or in any other manner whatsoever, of goods, being food or any \n",
"other article for human consumption or any drink (whether or not \n",
"intoxicating), where such supply or service, is for cash, deferred \n",
"payment or other valuable consideration, \n",
"and such transfer, delivery or supply of any goods shall be deemed to be \n",
"a sale of those goods by the person making the transfer, delivery or \n",
"supply and a purchase of those goods by the person to whom such \n",
"transfer, delivery or supply is made;] \n",
"1[(30) \"Union territory\" means any Union territory specified in the \n",
"First Schedule and includes any other territory comprised within the \n",
"territory of India but not specified in that Schedule.] \n",
"367. Interpretation. —(1) Unless the context otherwise requires, the \n",
"General Clauses Act, 1897, shall, subject to any adaptations and modifications \n",
"that may be made therein under article 372, apply for the interpretation of this \n",
"Constitution as it applies for the interpretation of an Act of the Legislature of \n",
"the Dominion of India. \n",
"(2) Any reference in this Constitution to Acts or laws of, or made by, \n",
"Parliament, or to Acts or laws of, or made by, the Legislature of a State 2***, \n",
"shall be construed as including a reference to an Ordinance made by the \n",
"President or, to an Ordinance made by a Governor 3***, as the case may be. \n",
"(3) For the purposes of this Constitution “foreign State” means any State \n",
"other than India: \n",
"Provided that, subject to the provisions of any law made by Parliament, \n",
"the President may by order4 declare any State not to be a foreign State for such \n",
"purposes as may be specified in the order. \n",
"5[(4) * * * *] \n",
"______________________________________________ \n",
"1. Subs. by the Constitution (Seventh Amendment) Act, 1956, s. 29 and Sch. for cl. (30) \n",
"(w.e.f. 1-11-1956). \n",
"2. The words and letters \"specified in Part A or Part B of the First Schedule\" omitted by \n",
"s. 29 and Sch., ibid. (w.e.f. 1-11-1956). \n",
"3. The words \"or Rajpramukh\" omitted by s. 29 and Sch., ibid. (w.e.f. 1-11-1956). \n",
"4. See the Constitution (Declaration as to Foreign States) Order, 1950 (C.O. 2). \n",
"5. Added by the Constitution (Application to Jammu and Kashmir) Order, 2019 \n",
"(C.O. 272)(w.e.f.5-8-2019). For the text of this C.O., s ee Appendix II. \n",
"==========================================================================\n"
]
}
],
"source": [
"for idx in result[0][0]:\n",
" print(pdf_text_dict[idx])\n",
" print(\"==========================================================================\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7eae8623-0b1d-4606-ba0c-e7d9b3db51f8",
"metadata": {},
"outputs": [],
"source": [
"index.search(query_embeddings, 5)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "b7431376-2ff8-4eab-bb71-467dce2d1032",
"metadata": {},
"outputs": [],
"source": [
"test_emb = test_emb.reshape(1, -1) # Reshape to (1, dimension)\n"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "c84de25d-194a-47c2-8481-801c8c64f320",
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": [
"array([[ 9.24338506e-41, 0.00000000e+00, -1.97645558e+34,\n",
" 1.11390840e-38, -6.25416305e-08, 7.09057023e-43,\n",
" -2.18818045e-16, 7.09057023e-43, 8.30269340e-42,\n",
" 0.00000000e+00, nan, nan,\n",
" 8.57594660e-43, 0.00000000e+00, 1.35631564e-19,\n",
" 1.35631564e-19, 1.65943575e-07, 6.86198462e-07,\n",
" 1.30291750e-11, 1.45852466e-19, 6.33692210e-10,\n",
" 6.40969056e-10, 5.20015877e+22, 2.50378429e-12,\n",
" 4.02852196e-11, 1.69701607e-07, 4.32033157e-05,\n",
" 1.66864609e-07, 2.33013520e-09, 4.12557526e-08,\n",
" 1.71538787e-07, 4.03717308e-08, 1.17036854e-19,\n",
" 1.35631564e-19, 2.57977081e-06, 1.68751939e-07,\n",
" 6.51968313e-10, 6.30808572e-10, 1.35671579e-19,\n",
" 1.68018843e-04, 6.66505962e-10, 1.30285106e-11,\n",
" 1.45859084e-19, 2.53488541e-09, 4.22524463e-05,\n",
" 5.34819389e+22, 2.58910536e-12, 4.16379153e-11,\n",
" 6.56483280e-07, 4.14877057e-08, 4.19508019e-08,\n",
" 1.35558927e-19, 1.35631564e-19, 4.05010470e-11,\n",
" 4.31995759e-05, 4.28928786e-08, 1.06798007e-05,\n",
" 9.32054078e-09, 4.12548431e-08, 1.76624264e-04,\n",
" 1.61487023e-07, 1.35671476e-19, 4.27199520e-05,\n",
" 6.44607367e-10, 1.30296269e-11, 1.45868997e-19,\n",
" 1.01393027e-08, 1.08015292e-05, 5.31902588e+22,\n",
" 2.50400677e-12, 1.35631280e-19, 1.35631564e-19,\n",
" 6.33692210e-10, 6.40969056e-10, 5.20015877e+22,\n",
" 2.50378429e-12, 4.00462996e-11, 6.40969056e-10,\n",
" 6.40969056e-10, 6.40900943e-10, 5.82533799e-10,\n",
" 6.40968945e-10, 6.40969056e-10, 6.23532337e-10,\n",
" 1.35671476e-19, 6.40940634e-10, 6.40969056e-10,\n",
" 8.14240168e-13, 8.29056182e-33, 1.35631564e-19,\n",
" 1.35631564e-19, 4.17187032e-08, 1.66900264e-07,\n",
" 1.30289547e-11, 1.45878884e-19, 1.01411217e-08,\n",
" 4.27246123e-05, 5.37724977e+22, 2.51821762e-12,\n",
" 4.00462996e-11, 6.40969056e-10, 6.40969056e-10,\n",
" 6.40900943e-10, 2.33013520e-09, 2.67057794e-06,\n",
" 1.70894768e-04, 1.61486980e-07, 1.17036751e-19,\n",
" 1.35631564e-19, 9.32053013e-09, 6.60092041e-07,\n",
" 1.07996684e-05, 4.03717486e-08, 1.35671566e-19,\n",
" 2.59286659e-09, 1.07405240e-05, 1.30280647e-11,\n",
" 1.45875615e-19, 6.33734842e-10, 4.34435824e-05,\n",
" 5.34808175e+22, 2.51810660e-12, 4.02736733e-11,\n",
" 1.65033981e-07, 6.82502446e-07, 1.05605914e-05,\n",
" 1.35558927e-19, 1.35631564e-19, 4.20926627e-11,\n",
" 2.63669331e-09, 1.68748372e-07, 2.62192512e-09,\n",
" 5.82533799e-10, 6.40968945e-10, 6.40969056e-10,\n",
" 6.23532337e-10, 1.35671476e-19, 1.05011759e-05,\n",
" 2.62259658e-09, 1.30298411e-11, 1.45875576e-19,\n",
" 4.05599394e-08, 2.56427413e-09, 5.43719988e+22,\n",
" 2.57500553e-12, 1.35631280e-19, 1.35631564e-19,\n",
" 1.62239758e-07, 1.07400574e-05, 5.43696930e+22,\n",
" 2.56073873e-12, 4.02736733e-11, 1.03137161e-08,\n",
" 2.68548160e-06, 6.71212831e-07, 5.82533799e-10,\n",
" 6.40968945e-10, 6.40969056e-10, 6.23532337e-10,\n",
" 1.35671476e-19, 6.40940634e-10, 6.40969056e-10,\n",
" 8.14240168e-13, 8.29056182e-33, 1.35631564e-19,\n",
" 1.35631564e-19, 6.40940634e-10, 6.40969056e-10,\n",
" 8.14240168e-13, 1.45849106e-19, 2.53488253e-09,\n",
" 4.39185569e-05, 5.28962953e+22, 2.60342724e-12,\n",
" 4.14105417e-11, 1.75685418e-04, 1.73755718e-04,\n",
" 4.27192026e-05, 2.33013520e-09, 2.56410315e-09,\n",
" 1.71571429e-07, 1.61487009e-07, 1.17036816e-19,\n",
" 1.35631564e-19, 1.52707566e-04, 4.28855671e-08,\n",
" 2.75975367e-06, 1.61486952e-07, 9.10475948e-12,\n",
" 4.34352005e-05, 2.64054370e-06, 8.14268412e-13,\n",
" 1.45855749e-19, 1.01393027e-08, 1.05032668e-05,\n",
" 5.31925736e+22, 2.50389575e-12, 4.05010470e-11,\n",
" 1.72798304e-04, 1.07225366e-08, 1.06798007e-05,\n",
" 1.35558927e-19, 1.35631564e-19, 4.05010470e-11,\n",
" 1.75659326e-04, 2.62552680e-06, 1.06798007e-05,\n",
" 9.32054078e-09, 4.24843092e-05, 4.39223113e-05,\n",
" 4.03717344e-08, 1.35671566e-19, 6.86125759e-07,\n",
" 4.22487028e-05, 1.30285132e-11, 1.45875615e-19,\n",
" 1.01397575e-08, 6.62910837e-10, 5.20050555e+22,\n",
" 2.58904985e-12, 1.35631280e-19, 1.35631564e-19,\n",
" 2.59566445e-06, 2.62219935e-09, 5.26022868e+22,\n",
" 2.53231702e-12, 4.02736733e-11, 4.12576107e-08,\n",
" 2.69535527e-09, 1.68969462e-04, 9.32054078e-09,\n",
" 6.60092041e-07, 4.34436115e-05, 4.03717380e-08,\n",
" 1.35671566e-19, 2.57831489e-09, 2.71481827e-06,\n",
" 1.30291819e-11, 8.29188058e-33, 1.35631564e-19,\n",
" 1.35631564e-19, 2.59286659e-09, 2.65544509e-06,\n",
" 1.30296217e-11, 1.45875615e-19, 2.53505306e-09,\n",
" 2.73012688e-06, 5.43697020e+22, 2.57483900e-12,\n",
" 4.07284206e-11, 2.56438781e-09, 6.86169244e-07,\n",
" 4.22423655e-05, 9.32054078e-09, 6.60092041e-07,\n",
" 1.72473747e-07, 4.03717415e-08, 1.17036841e-19,\n",
" 1.35631564e-19, 9.32053013e-09, 1.04883338e-08,\n",
" 6.86213070e-07, 1.61487009e-07, 1.35671476e-19,\n",
" 2.57831489e-09, 6.56483564e-07, 1.30289590e-11,\n",
" 1.45872306e-19, 1.01393027e-08, 1.71852080e-04,\n",
" 5.28882204e+22, 2.61763809e-12, 4.09557943e-11,\n",
" 2.62231326e-09, 2.75998696e-06, 1.05605914e-05,\n",
" 1.35558927e-19, 1.35631564e-19, 4.02736733e-11,\n",
" 1.68744691e-07, 1.05025701e-05, 2.66995016e-06,\n",
" 2.33013520e-09, 2.56410315e-09, 1.71571429e-07,\n",
" 1.61487009e-07, 1.35671540e-19, 2.57831489e-09,\n",
" 1.75685462e-04, 1.30285158e-11, 1.45872306e-19,\n",
" 6.33720632e-10, 4.10274907e-08, 5.46671648e+22,\n",
" 2.50400677e-12, 1.35631280e-19, 1.35631564e-19,\n",
" 4.05590299e-08, 2.56421906e-09, 5.43731473e+22,\n",
" 2.58921638e-12, 4.02736733e-11, 2.60776001e-09,\n",
" 4.32023808e-05, 6.55481280e-10, 5.82533799e-10,\n",
" 6.40968945e-10, 6.40969056e-10, 6.23532337e-10,\n",
" 1.35671476e-19, 6.40940634e-10, 6.40969056e-10,\n",
" 8.14240168e-13, 8.29056182e-33, 1.35631564e-19,\n",
" 1.35631564e-19, 6.40940634e-10, 6.40969056e-10,\n",
" 8.14240168e-13, 1.45849106e-19, 6.33692210e-10,\n",
" 6.40969056e-10, 5.20015877e+22, 2.50378429e-12,\n",
" 4.18652890e-11, 6.62839950e-10, 4.32061024e-05,\n",
" 1.64077917e-07, 1.52707740e-04, 4.19551540e-08,\n",
" 6.59272803e-10, 1.61487009e-07, 1.17036764e-19,\n",
" 1.35631564e-19, 5.82533133e-10, 6.40968945e-10,\n",
" 6.40969056e-10, 6.23532337e-10, 1.35671476e-19,\n",
" 4.28828493e-08, 4.14940686e-08, 1.30287387e-11,\n",
" 1.45849158e-19, 2.53488253e-09, 6.73781975e-10,\n",
" 5.34854202e+22, 2.60342724e-12, 4.02736733e-11,\n",
" 6.67542849e-07, 1.09805751e-05, 4.27192026e-05,\n",
" 1.35558927e-19, 1.35631564e-19, 4.16379153e-11,\n",
" 2.62546951e-06, 4.17259969e-08, 2.64014784e-06,\n",
" 3.81769350e-05, 2.67051973e-06, 6.86198291e-07,\n",
" 6.30808739e-10, 1.35671527e-19, 2.60742028e-09,\n",
" 2.60758992e-09, 1.30287352e-11, 1.45852466e-19,\n",
" 6.33692210e-10, 6.40969056e-10, 5.20015877e+22,\n",
" 2.50378429e-12, 1.35631280e-19, 1.35631564e-19,\n",
" 4.05572109e-08, 1.06047535e-08, 5.20073838e+22,\n",
" 2.53220643e-12, 4.09557943e-11, 6.66435074e-10,\n",
" 4.39148316e-05, 6.67487541e-07, 3.72821631e-08,\n",
" 1.06804491e-05, 6.59187760e-10, 3.99060731e-08,\n",
" 1.35671540e-19, 6.55492605e-10, 4.41541815e-05,\n",
" 1.30291784e-11, 8.29150516e-33, 1.35631564e-19,\n",
" 1.35631564e-19, 6.40940634e-10, 6.40969056e-10,\n",
" 8.14240168e-13, 1.45849106e-19, 6.33692210e-10,\n",
" 6.40969056e-10, 5.20015877e+22, 2.50378429e-12,\n",
" 4.00462996e-11, 6.40969056e-10, 6.40969056e-10,\n",
" 6.40900943e-10, 9.32054078e-09, 6.60092041e-07,\n",
" 4.41597949e-05, 4.03717415e-08, 1.17036841e-19,\n",
" 1.35631564e-19, 2.38605571e-06, 6.73739176e-10,\n",
" 2.62214117e-09, 4.03717415e-08, 1.35671579e-19,\n",
" 6.55492605e-10, 4.41541815e-05, 1.30291784e-11,\n",
" 1.45865701e-19, 2.53528043e-09, 1.68755719e-07,\n",
" 5.25988416e+22, 2.51821762e-12, 4.14105417e-11,\n",
" 4.10238563e-08, 4.10247551e-08, 1.70876810e-04,\n",
" 1.35558927e-19, 1.35631564e-19, 4.07284206e-11,\n",
" 1.04897007e-08, 4.21898356e-08, 6.60036960e-07,\n",
" 9.32054078e-09, 6.60092041e-07, 1.72473747e-07,\n",
" 4.03717415e-08, 1.35671566e-19, 2.57831489e-09,\n",
" 4.20084398e-05, 1.30287317e-11, 1.45872306e-19,\n",
" 6.33706421e-10, 4.27273917e-05, 5.31856741e+22,\n",
" 2.58921638e-12, 1.35631280e-19, 1.35631564e-19,\n",
" 1.62228844e-07, 1.69937266e-04, 5.37771229e+22,\n",
" 2.57506104e-12, 4.05010470e-11, 4.31995759e-05,\n",
" 4.28928786e-08, 1.06798007e-05, 9.32054078e-09,\n",
" 6.62796817e-10, 2.63709121e-09, 1.61487037e-07,\n",
" 1.35671476e-19, 4.27199520e-05, 6.44607367e-10,\n",
" 1.30296269e-11, 8.29169250e-33, 1.35631564e-19,\n",
" 1.35631564e-19, 1.06799862e-05, 4.19606216e-08,\n",
" 1.30293979e-11, 1.45849158e-19, 6.33692210e-10,\n",
" 6.40969056e-10, 5.20015877e+22, 2.50378429e-12,\n",
" 4.00462996e-11, 6.40969056e-10, 6.40969056e-10,\n",
" 6.40900943e-10, 5.82533799e-10, 6.40968945e-10,\n",
" 6.40969056e-10, 6.23532337e-10, 1.17036751e-19,\n",
" 1.35631564e-19, 5.82533133e-10, 6.40968945e-10,\n",
" 6.40969056e-10, 6.23532337e-10, 1.35671476e-19,\n",
" 4.14858690e-08, 6.63861442e-07, 1.30296260e-11,\n",
" 1.45852415e-19, 1.01411217e-08, 4.27246123e-05,\n",
" 5.37724977e+22, 2.51821762e-12, 4.00462996e-11,\n",
" 6.40969056e-10, 6.40969056e-10, 6.40900943e-10,\n",
" 1.35558927e-19, 1.35631564e-19, 4.02736733e-11,\n",
" 1.08599706e-05, 1.72480924e-07, 6.55481280e-10,\n",
" 9.32054078e-09, 6.60092041e-07, 1.07996684e-05,\n",
" 4.03717486e-08, 1.35671566e-19, 2.59286659e-09,\n",
" 4.12612273e-08, 1.30293996e-11, 1.45875615e-19,\n",
" 6.33720632e-10, 4.12594048e-08, 5.20096807e+22,\n",
" 2.54647280e-12, 1.35631280e-19, 1.35631564e-19,\n",
" 6.33706421e-10, 1.04894724e-08, 5.40676411e+22,\n",
" 2.58921638e-12, 4.02736733e-11, 1.03137161e-08,\n",
" 2.68548160e-06, 6.71212831e-07, 9.32054078e-09,\n",
" 6.60092041e-07, 4.41597949e-05, 4.03717415e-08,\n",
" 1.35671566e-19, 2.62529329e-06, 1.72813292e-04,\n",
" 1.30285158e-11, 8.29056476e-33, 1.35631564e-19,\n",
" 1.35631564e-19, 4.27199520e-05, 6.44607367e-10,\n",
" 1.30296269e-11, 1.45868997e-19, 4.05572109e-08,\n",
" 1.69002335e-04, 5.40722437e+22, 2.50400677e-12,\n",
" 4.00462996e-11, 6.40969056e-10, 6.40969056e-10,\n",
" 6.40900943e-10, 5.82533799e-10, 6.40968945e-10,\n",
" 6.40969056e-10, 6.23532337e-10, 1.17036751e-19,\n",
" 1.35631564e-19, 5.82533133e-10, 6.40968945e-10,\n",
" 6.40969056e-10, 6.23532337e-10, 1.35671476e-19,\n",
" 6.40940634e-10, 6.40969056e-10, 8.14240168e-13,\n",
" 1.45849106e-19, 6.48944479e-07, 4.24908612e-05,\n",
" 5.20062039e+22, 2.50378429e-12, 4.20926627e-11,\n",
" 4.17241566e-08, 2.62570211e-06, 2.62192512e-09,\n",
" 1.35558927e-19, 1.35631564e-19, 4.00462996e-11,\n",
" 6.40969056e-10, 6.40969056e-10, 6.40900943e-10,\n",
" 2.33013520e-09, 2.67057794e-06, 1.70894768e-04,\n",
" 1.61486980e-07, 1.35671476e-19, 2.57831489e-09,\n",
" 6.56483564e-07, 1.30289590e-11, 1.45872306e-19,\n",
" 1.01393027e-08, 4.36782757e-05, 5.22979111e+22,\n",
" 2.61763809e-12, 1.35631280e-19, 1.35631564e-19,\n",
" 1.01397575e-08, 2.59298094e-09, 5.25930680e+22,\n",
" 2.53226194e-12, 4.18652890e-11, 6.62839950e-10,\n",
" 4.32061024e-05, 1.64077917e-07, 1.52707740e-04,\n",
" 6.60121145e-07, 6.60121316e-07, 1.61486980e-07,\n",
" 1.35671489e-19, 6.40940634e-10, 6.40969056e-10,\n",
" 8.14240168e-13, 8.29056182e-33, 1.35631564e-19,\n",
" 1.35631564e-19, 6.71224655e-07, 6.59187371e-10,\n",
" 8.14295788e-13, 1.45852415e-19, 4.05599394e-08,\n",
" 2.56427413e-09, 5.43719988e+22, 2.57500553e-12,\n",
" 4.09673406e-11, 4.12548644e-08, 6.56440079e-07,\n",
" 6.67487541e-07, 2.33013520e-09, 2.56410315e-09,\n",
" 1.71571429e-07, 1.61487009e-07, 1.17036816e-19,\n",
" 1.35631564e-19, 5.82533133e-10, 6.40968945e-10,\n",
" 6.40969056e-10, 6.23532337e-10, 1.35671476e-19,\n",
" 6.40940634e-10, 6.40969056e-10, 8.14240168e-13,\n",
" 1.45849106e-19, 6.33692210e-10, 6.40969056e-10,\n",
" 5.20015877e+22, 2.50378429e-12, 4.05010470e-11,\n",
" 4.31995759e-05, 4.28928786e-08, 1.06798007e-05,\n",
" 1.35558927e-19, 1.35631564e-19, 4.14105417e-11,\n",
" 6.44735043e-10, 1.68044920e-04, 4.27192026e-05,\n",
" 2.33013520e-09, 2.56410315e-09, 1.71571429e-07,\n",
" 1.61487009e-07, 1.35671540e-19, 4.22431367e-05,\n",
" 1.71859559e-04, 1.30282920e-11, 1.45852466e-19,\n",
" 6.48988134e-07, 1.04301296e-08, 5.28870449e+22,\n",
" 2.63184895e-12, 1.35631280e-19, 1.35631564e-19,\n",
" 1.01393027e-08, 4.20121687e-05, 5.34865776e+22,\n",
" 2.51805109e-12, 4.05010470e-11, 1.72798304e-04,\n",
" 4.19615311e-08, 1.06798007e-05, 9.32054078e-09,\n",
" 4.22458907e-05, 6.63875937e-07, 4.03717380e-08,\n",
" 1.35671566e-19, 6.40940689e-10, 4.39167125e-05,\n",
" 1.30287335e-11, 8.29169250e-33, 1.35631564e-19,\n",
" 1.35631564e-19, 6.55492605e-10, 4.41541815e-05,\n",
" 1.30291784e-11, 1.45865701e-19, 2.53488253e-09,\n",
" 4.39185569e-05, 5.28962953e+22, 2.60342724e-12,\n",
" 4.05010470e-11, 1.69009669e-04, 4.12630357e-08,\n",
" 6.55481280e-10, 3.72821631e-08, 2.74479271e-06,\n",
" 1.68029917e-04, 4.03717593e-08, 1.17036828e-19,\n",
" 1.35631564e-19, 2.33013253e-09, 1.65033924e-07,\n",
" 6.44735376e-10, 1.61487009e-07, 1.35671476e-19,\n",
" 6.40940634e-10, 6.40969056e-10, 8.14240168e-13,\n",
" 1.45849106e-19, 6.33692210e-10, 6.40969056e-10,\n",
" 5.20015877e+22, 2.50378429e-12, 4.00462996e-11,\n",
" 6.40969056e-10, 6.40969056e-10, 6.40900943e-10,\n",
" 1.35558927e-19, 1.35631564e-19, 4.00462996e-11,\n",
" 6.40969056e-10, 6.40969056e-10, 6.40900943e-10,\n",
" 1.52707740e-04, 6.62811028e-10, 4.10220338e-08,\n",
" 6.23532836e-10, 1.35671502e-19, 1.65943575e-07,\n",
" 6.86198462e-07, 1.30291750e-11, 1.45852466e-19,\n",
" 6.33692210e-10, 6.40969056e-10, 5.20015877e+22,\n",
" 2.50378429e-12, 1.35631280e-19, 1.35631564e-19,\n",
" 4.15305840e-05, 1.06643254e-08, 5.31925691e+22,\n",
" 2.50400677e-12, 4.05010470e-11, 1.72798304e-04,\n",
" 6.82502105e-07, 1.06798007e-05, 2.33013520e-09,\n",
" 4.12566621e-08, 2.74473700e-06, 4.03717308e-08,\n",
" 1.35671579e-19, 1.69926207e-04, 6.75109959e-07,\n",
" 1.30285158e-11, 8.29056256e-33, 1.35631564e-19,\n",
" 1.35631564e-19, 4.26500435e-08, 4.27218256e-05]], dtype=float32)"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"test_emb"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "048937c2-24a7-4116-8012-35809e1a9ca2",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Index Type: <class 'faiss.swigfaiss_avx2.IndexFlatL2'>\n",
"Index Dimension: 768\n",
"Number of Vectors in Index: 10\n",
"Query Shape: (1, 768)\n",
"Is Index Trained: True\n"
]
}
],
"source": [
"print(\"Index Type:\", type(index))\n",
"print(\"Index Dimension:\", index.d)\n",
"print(\"Number of Vectors in Index:\", index.ntotal)\n",
"print(\"Query Shape:\", test_emb.shape)\n",
"print(\"Is Index Trained:\", index.is_trained)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c764fbe2-b63e-4f54-8482-2a7a4663b1fe",
"metadata": {},
"outputs": [],
"source": [
"import faiss\n",
"import numpy as np\n",
"\n",
"# Set the embedding dimension\n",
"dimension = 768 \n",
"num_vectors = 10 \n",
"\n",
"# Create random embeddings\n",
"np.random.seed(42)\n",
"embeddings = np.random.random((num_vectors, dimension)).astype('float32')\n",
"\n",
"# Create a FAISS index\n",
"index = faiss.IndexFlatL2(dimension)\n",
"index.add(embeddings)\n",
"\n",
"# Create a random query vector\n",
"query_vector = np.random.random((1, dimension)).astype('float32')\n",
"\n",
"# Search in the index\n",
"distances, indices = index.search(query_vector, 5)\n",
"\n",
"# Print results\n",
"print(\"Search successful!\")\n",
"print(\"Nearest Neighbors:\", indices)\n",
"print(\"Distances:\", distances)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9ac633d0-2683-4c9c-9cf0-ed48acc3c529",
"metadata": {},
"outputs": [],
"source": [
"index.search(test_emb, 5)"
]
},
{
"cell_type": "code",
"execution_count": 102,
"id": "3f73cab7-8937-4b35-9f97-73f2188675d9",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"tensor([0.8617])"
]
},
"execution_count": 102,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import torch\n",
"\n",
"torch.nn.functional.cosine_similarity(torch.tensor(temp_1[0]).unsqueeze(0), torch.tensor(temp_1[1]).unsqueeze(0))"
]
},
{
"cell_type": "code",
"execution_count": 103,
"id": "fdef611d-38fc-45e7-bf91-cb7856dd9ad7",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"tensor([0.8617])"
]
},
"execution_count": 103,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import torch\n",
"\n",
"torch.nn.functional.cosine_similarity(torch.tensor(temp_2[0]).unsqueeze(0), torch.tensor(temp_2[1]).unsqueeze(0))"
]
},
{
"cell_type": "code",
"execution_count": 77,
"id": "736151bb-9546-4909-b92c-04dbcd541a02",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"13.994422"
]
},
"execution_count": 77,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import numpy as np\n",
"\n",
"np.linalg.norm(embeddings[0])"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ec3251c7-3a81-47b7-8e56-66851784b84f",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "7dd5610f-aafa-492d-9300-8eb8db72092d",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "8f89f401-f7c3-4e23-87e2-424d661a7fc5",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
|