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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
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
WEBVTT

00:00:03.879 --> 00:00:07.480
cool um so this time I'm going to talk

00:00:05.480 --> 00:00:08.880
about word representation and text

00:00:07.480 --> 00:00:11.480
classifiers these are kind of the

00:00:08.880 --> 00:00:14.080
foundations that you need to know uh in

00:00:11.480 --> 00:00:15.640
order to move on to the more complex

00:00:14.080 --> 00:00:17.920
things that we'll be talking in future

00:00:15.640 --> 00:00:19.640
classes uh but actually the in

00:00:17.920 --> 00:00:22.760
particular the word representation part

00:00:19.640 --> 00:00:25.439
is pretty important it's a major uh

00:00:22.760 --> 00:00:31.800
thing that we need to do for all NLP

00:00:25.439 --> 00:00:34.239
models so uh let's go into it

00:00:31.800 --> 00:00:38.200
so last class I talked about the bag of

00:00:34.239 --> 00:00:40.239
words model um and just to review this

00:00:38.200 --> 00:00:43.920
was a model where basically we take each

00:00:40.239 --> 00:00:45.520
word we represent it as a one hot Vector

00:00:43.920 --> 00:00:48.760
uh like

00:00:45.520 --> 00:00:51.120
this and we add all of these vectors

00:00:48.760 --> 00:00:53.160
together we multiply the resulting

00:00:51.120 --> 00:00:55.160
frequency vector by some weights and we

00:00:53.160 --> 00:00:57.239
get a score out of this and we can use

00:00:55.160 --> 00:00:58.559
this score for binary classification or

00:00:57.239 --> 00:01:00.239
if we want to do multiclass

00:00:58.559 --> 00:01:02.519
classification we get you know multiple

00:01:00.239 --> 00:01:05.720
scores for each

00:01:02.519 --> 00:01:08.040
class and the features F were just based

00:01:05.720 --> 00:01:08.920
on our word identities and the weights

00:01:08.040 --> 00:01:12.159
were

00:01:08.920 --> 00:01:14.680
learned and um if we look at what's

00:01:12.159 --> 00:01:17.520
missing in bag of words

00:01:14.680 --> 00:01:19.600
models um we talked about handling of

00:01:17.520 --> 00:01:23.280
conjugated or compound

00:01:19.600 --> 00:01:25.439
words we talked about handling of word

00:01:23.280 --> 00:01:27.880
similarity and we talked about handling

00:01:25.439 --> 00:01:30.240
of combination features and handling of

00:01:27.880 --> 00:01:33.280
sentence structure and so all of these

00:01:30.240 --> 00:01:35.000
are are tricky problems uh we saw that

00:01:33.280 --> 00:01:37.000
you know creating a rule-based system to

00:01:35.000 --> 00:01:39.000
solve these problems is non-trivial and

00:01:37.000 --> 00:01:41.399
at the very least would take a lot of

00:01:39.000 --> 00:01:44.079
time and so now I want to talk about

00:01:41.399 --> 00:01:47.119
some solutions to the problems in this

00:01:44.079 --> 00:01:49.280
class so the first the solution to the

00:01:47.119 --> 00:01:52.240
first problem or a solution to the first

00:01:49.280 --> 00:01:54.880
problem is uh subword or character based

00:01:52.240 --> 00:01:57.520
models and that's what I'll talk about

00:01:54.880 --> 00:02:00.719
first handling of word similarity this

00:01:57.520 --> 00:02:02.960
can be handled uh using Word edings

00:02:00.719 --> 00:02:05.079
and the word embeddings uh will be

00:02:02.960 --> 00:02:07.159
another thing we'll talk about this time

00:02:05.079 --> 00:02:08.879
handling of combination features uh we

00:02:07.159 --> 00:02:11.039
can handle through neural networks which

00:02:08.879 --> 00:02:14.040
we'll also talk about this time and then

00:02:11.039 --> 00:02:15.560
handling of sentence structure uh the

00:02:14.040 --> 00:02:17.720
kind of standard way of handling this

00:02:15.560 --> 00:02:20.120
now is through sequence-based models and

00:02:17.720 --> 00:02:24.879
that will be uh starting in a few

00:02:20.120 --> 00:02:28.080
classes so uh let's jump into

00:02:24.879 --> 00:02:30.000
it so subword models uh as I mentioned

00:02:28.080 --> 00:02:31.840
this is a really really important part

00:02:30.000 --> 00:02:33.360
all of the models that we're building

00:02:31.840 --> 00:02:35.480
nowadays including you know

00:02:33.360 --> 00:02:38.239
state-of-the-art language models and and

00:02:35.480 --> 00:02:42.200
things like this and the basic idea

00:02:38.239 --> 00:02:44.720
behind this is that we want to split uh

00:02:42.200 --> 00:02:48.040
in particular split less common words up

00:02:44.720 --> 00:02:50.200
into multiple subboard tokens so to give

00:02:48.040 --> 00:02:52.200
an example of this uh if we have

00:02:50.200 --> 00:02:55.040
something like the companies are

00:02:52.200 --> 00:02:57.000
expanding uh it might split companies

00:02:55.040 --> 00:03:02.120
into compan

00:02:57.000 --> 00:03:05.000
e and expand in like this and there are

00:03:02.120 --> 00:03:08.480
a few benefits of this uh the first

00:03:05.000 --> 00:03:10.760
benefit is that this allows you to

00:03:08.480 --> 00:03:13.360
parameters between word varieties or

00:03:10.760 --> 00:03:15.200
compound words and the other one is to

00:03:13.360 --> 00:03:17.400
reduce parameter size and save compute

00:03:15.200 --> 00:03:19.720
and meming and both of these are kind of

00:03:17.400 --> 00:03:23.239
like equally important things that we

00:03:19.720 --> 00:03:25.519
need to be uh we need to be considering

00:03:23.239 --> 00:03:26.440
so does anyone know how many words there

00:03:25.519 --> 00:03:28.680
are in

00:03:26.440 --> 00:03:31.680
English any

00:03:28.680 --> 00:03:31.680
ideas

00:03:36.799 --> 00:03:43.400
yeah two

00:03:38.599 --> 00:03:45.560
million pretty good um any other

00:03:43.400 --> 00:03:47.159
ideas

00:03:45.560 --> 00:03:50.360
yeah

00:03:47.159 --> 00:03:53.599
60,000 some models use 60,000 I I think

00:03:50.360 --> 00:03:56.200
60,000 is probably these subword models

00:03:53.599 --> 00:03:58.079
uh when you're talking about this so

00:03:56.200 --> 00:03:59.319
they can use sub models to take the 2

00:03:58.079 --> 00:04:03.480
million which I think is a reasonable

00:03:59.319 --> 00:04:07.400
guess to 6 60,000 any other

00:04:03.480 --> 00:04:08.840
ideas 700,000 okay pretty good um so

00:04:07.400 --> 00:04:11.799
this was a per question it doesn't

00:04:08.840 --> 00:04:14.760
really have a good answer um but two 200

00:04:11.799 --> 00:04:17.479
million's probably pretty good six uh

00:04:14.760 --> 00:04:19.160
700,000 is pretty good the reason why

00:04:17.479 --> 00:04:21.360
this is a trick question is because are

00:04:19.160 --> 00:04:24.440
company and companies different

00:04:21.360 --> 00:04:26.840
words uh maybe maybe not right because

00:04:24.440 --> 00:04:30.120
if we know the word company we can you

00:04:26.840 --> 00:04:32.520
know guess what the word companies means

00:04:30.120 --> 00:04:35.720
um what about automobile is that a

00:04:32.520 --> 00:04:37.400
different word well maybe if we know

00:04:35.720 --> 00:04:39.400
Auto and mobile we can kind of guess

00:04:37.400 --> 00:04:41.160
what automobile means but not really so

00:04:39.400 --> 00:04:43.479
maybe that's a different word there's

00:04:41.160 --> 00:04:45.960
all kinds of Shades of Gray there and

00:04:43.479 --> 00:04:48.120
also we have really frequent words that

00:04:45.960 --> 00:04:50.360
everybody can probably acknowledge our

00:04:48.120 --> 00:04:52.320
words like

00:04:50.360 --> 00:04:55.639
the and

00:04:52.320 --> 00:04:58.520
a and um maybe

00:04:55.639 --> 00:05:00.680
car and then we have words down here

00:04:58.520 --> 00:05:02.320
which are like Miss spellings or

00:05:00.680 --> 00:05:04.160
something like that misspellings of

00:05:02.320 --> 00:05:06.520
actual correct words or

00:05:04.160 --> 00:05:09.199
slay uh or other things like that and

00:05:06.520 --> 00:05:12.520
then it's questionable whether those are

00:05:09.199 --> 00:05:17.199
actual words or not so um there's a

00:05:12.520 --> 00:05:19.520
famous uh law called Zip's

00:05:17.199 --> 00:05:21.280
law um which probably a lot of people

00:05:19.520 --> 00:05:23.360
have heard of it's also the source of

00:05:21.280 --> 00:05:26.919
your zip

00:05:23.360 --> 00:05:30.160
file um which is using Zip's law to

00:05:26.919 --> 00:05:32.400
compress uh compress output by making

00:05:30.160 --> 00:05:34.880
the uh more frequent words have shorter

00:05:32.400 --> 00:05:37.520
bite strings and less frequent words

00:05:34.880 --> 00:05:38.800
have uh you know less frequent bite

00:05:37.520 --> 00:05:43.120
strings but basically like we're going

00:05:38.800 --> 00:05:45.120
to have an infinite number of words or

00:05:43.120 --> 00:05:46.360
at least strings that are separated by

00:05:45.120 --> 00:05:49.280
white space so we need to handle this

00:05:46.360 --> 00:05:53.199
somehow and that's what subword units

00:05:49.280 --> 00:05:54.560
do so um 60,000 was a good guess for the

00:05:53.199 --> 00:05:57.160
number of subword units you might use in

00:05:54.560 --> 00:06:00.759
a model and so uh by using subw units we

00:05:57.160 --> 00:06:04.840
can limit to about that much

00:06:00.759 --> 00:06:08.160
so there's a couple of common uh ways to

00:06:04.840 --> 00:06:10.440
create these subword units and basically

00:06:08.160 --> 00:06:14.560
all of them rely on the fact that you

00:06:10.440 --> 00:06:16.039
want more common strings to become

00:06:14.560 --> 00:06:19.599
subword

00:06:16.039 --> 00:06:22.199
units um or actually sorry I realize

00:06:19.599 --> 00:06:24.280
maybe before doing that I could explain

00:06:22.199 --> 00:06:26.360
an alternative to creating subword units

00:06:24.280 --> 00:06:29.639
so the alternative to creating subword

00:06:26.360 --> 00:06:33.560
units is to treat every character or

00:06:29.639 --> 00:06:36.919
maybe every bite in a string as a single

00:06:33.560 --> 00:06:38.560
thing that you encode in forent so in

00:06:36.919 --> 00:06:42.520
other words instead of trying to model

00:06:38.560 --> 00:06:47.919
the companies are expanding we Model T h

00:06:42.520 --> 00:06:50.199
e space c o m uh etc etc can anyone

00:06:47.919 --> 00:06:53.199
think of any downsides of

00:06:50.199 --> 00:06:53.199
this

00:06:57.039 --> 00:07:01.879
yeah yeah the set of these will be very

00:07:00.080 --> 00:07:05.000
will be very small but that's not

00:07:01.879 --> 00:07:05.000
necessarily a problem

00:07:08.560 --> 00:07:15.599
right yeah um and any other

00:07:12.599 --> 00:07:15.599
ideas

00:07:19.520 --> 00:07:24.360
yeah yeah the resulting sequences will

00:07:22.080 --> 00:07:25.520
be very long um and when you say

00:07:24.360 --> 00:07:27.160
difficult to use it could be difficult

00:07:25.520 --> 00:07:29.560
to use for a couple of reasons there's

00:07:27.160 --> 00:07:31.840
mainly two reasons actually any any IDE

00:07:29.560 --> 00:07:31.840
about

00:07:33.479 --> 00:07:37.800
this any

00:07:46.280 --> 00:07:50.599
yeah yeah that's a little bit of a

00:07:49.000 --> 00:07:52.319
separate problem than the character

00:07:50.599 --> 00:07:53.919
based model so let me get back to that

00:07:52.319 --> 00:07:56.400
but uh let let's finish the discussion

00:07:53.919 --> 00:07:58.360
of the character based models so if it's

00:07:56.400 --> 00:08:00.120
really if it's really long maybe a

00:07:58.360 --> 00:08:01.879
simple thing like uh let's say you have

00:08:00.120 --> 00:08:06.560
a big neural network and it's processing

00:08:01.879 --> 00:08:06.560
a really long sequence any ideas what

00:08:06.919 --> 00:08:10.879
happens basically you run out of memory

00:08:09.280 --> 00:08:13.440
or it takes a really long time right so

00:08:10.879 --> 00:08:16.840
you have computational problems another

00:08:13.440 --> 00:08:18.479
reason why is um think of what a bag of

00:08:16.840 --> 00:08:21.400
words model would look like if it was a

00:08:18.479 --> 00:08:21.400
bag of characters

00:08:21.800 --> 00:08:25.919
model it wouldn't be very informative

00:08:24.199 --> 00:08:27.599
about whether like a sentence is

00:08:25.919 --> 00:08:30.919
positive sentiment or negative sentiment

00:08:27.599 --> 00:08:32.959
right because instead of having uh go o

00:08:30.919 --> 00:08:35.039
you would have uh instead of having good

00:08:32.959 --> 00:08:36.360
you would have go o and that doesn't

00:08:35.039 --> 00:08:38.560
really directly tell you whether it's

00:08:36.360 --> 00:08:41.719
positive sentiment or not so those are

00:08:38.560 --> 00:08:43.680
basically the two problems um compute

00:08:41.719 --> 00:08:45.320
and lack of expressiveness in the

00:08:43.680 --> 00:08:50.720
underlying representations so you need

00:08:45.320 --> 00:08:52.080
to handle both of those yes so if we uh

00:08:50.720 --> 00:08:54.480
move from

00:08:52.080 --> 00:08:56.440
character better expressiveness and we

00:08:54.480 --> 00:08:58.920
assume that if we just get the bigger

00:08:56.440 --> 00:09:00.120
and bigger paragraphs we'll get even

00:08:58.920 --> 00:09:02.760
better

00:09:00.120 --> 00:09:05.120
yeah so a very good question I'll repeat

00:09:02.760 --> 00:09:06.560
it um and actually this also goes back

00:09:05.120 --> 00:09:08.040
to the other question you asked about

00:09:06.560 --> 00:09:09.519
words that look the same but are

00:09:08.040 --> 00:09:12.160
pronounced differently or have different

00:09:09.519 --> 00:09:14.360
meanings and so like let's say we just

00:09:12.160 --> 00:09:15.920
remembered this whole sentence right the

00:09:14.360 --> 00:09:18.279
companies are

00:09:15.920 --> 00:09:21.600
expanding um and that was like a single

00:09:18.279 --> 00:09:22.680
embedding and we somehow embedded it the

00:09:21.600 --> 00:09:25.720
problem would be we're never going to

00:09:22.680 --> 00:09:27.120
see that sentence again um or if we go

00:09:25.720 --> 00:09:29.480
to longer sentences we're never going to

00:09:27.120 --> 00:09:31.839
see the longer sentences again so it

00:09:29.480 --> 00:09:34.320
becomes too sparse so there's kind of a

00:09:31.839 --> 00:09:37.240
sweet spot between

00:09:34.320 --> 00:09:40.279
like long enough to be expressive and

00:09:37.240 --> 00:09:42.480
short enough to occur many times so that

00:09:40.279 --> 00:09:43.959
you can learn appropriately and that's

00:09:42.480 --> 00:09:47.120
kind of what subword models are aiming

00:09:43.959 --> 00:09:48.360
for and if you get longer subwords then

00:09:47.120 --> 00:09:50.200
you'll get things that are more

00:09:48.360 --> 00:09:52.959
expressive but more sparse in shorter

00:09:50.200 --> 00:09:55.440
subwords you'll get things that are like

00:09:52.959 --> 00:09:57.279
uh less expressive but less spice so you

00:09:55.440 --> 00:09:59.120
need to balance between them and then

00:09:57.279 --> 00:10:00.600
once we get into sequence modeling they

00:09:59.120 --> 00:10:02.600
start being able to model like which

00:10:00.600 --> 00:10:04.120
words are next to each other uh which

00:10:02.600 --> 00:10:06.040
tokens are next to each other and stuff

00:10:04.120 --> 00:10:07.800
like that so even if they are less

00:10:06.040 --> 00:10:11.279
expressive the combination between them

00:10:07.800 --> 00:10:12.600
can be expressive so um yeah that's kind

00:10:11.279 --> 00:10:13.440
of a preview of what we're going to be

00:10:12.600 --> 00:10:17.320
doing

00:10:13.440 --> 00:10:19.279
next okay so um let's assume that we

00:10:17.320 --> 00:10:21.320
want to have some subwords that are

00:10:19.279 --> 00:10:23.000
longer than characters but shorter than

00:10:21.320 --> 00:10:26.240
tokens how do we make these in a

00:10:23.000 --> 00:10:28.680
consistent way there's two major ways of

00:10:26.240 --> 00:10:31.480
doing this uh the first one is bite pair

00:10:28.680 --> 00:10:32.839
encoding and this is uh very very simple

00:10:31.480 --> 00:10:35.839
in fact it's so

00:10:32.839 --> 00:10:35.839
simple

00:10:36.600 --> 00:10:40.839
that we can implement

00:10:41.839 --> 00:10:47.240
it in this notebook here which you can

00:10:44.600 --> 00:10:51.720
click through to on the

00:10:47.240 --> 00:10:55.440
slides and it's uh

00:10:51.720 --> 00:10:58.040
about 10 lines of code um and so

00:10:55.440 --> 00:11:01.040
basically what B pair encoding

00:10:58.040 --> 00:11:01.040
does

00:11:04.600 --> 00:11:09.560
is that you start out with um all of the

00:11:07.000 --> 00:11:14.360
vocabulary that you want to process

00:11:09.560 --> 00:11:17.560
where each vocabulary item is split into

00:11:14.360 --> 00:11:21.240
uh the characters and an end of word

00:11:17.560 --> 00:11:23.360
symbol and you have a corresponding

00:11:21.240 --> 00:11:27.519
frequency of

00:11:23.360 --> 00:11:31.120
this you then uh get statistics about

00:11:27.519 --> 00:11:33.279
the most common pairs of tokens that

00:11:31.120 --> 00:11:34.880
occur next to each other and so here the

00:11:33.279 --> 00:11:38.240
most common pairs of tokens that occur

00:11:34.880 --> 00:11:41.920
next to each other are e s because it

00:11:38.240 --> 00:11:46.560
occurs nine times because it occurs in

00:11:41.920 --> 00:11:48.279
newest and wildest also s and t w

00:11:46.560 --> 00:11:51.440
because those occur there too and then

00:11:48.279 --> 00:11:53.519
you have we and other things like that

00:11:51.440 --> 00:11:56.000
so out of all the most frequent ones you

00:11:53.519 --> 00:11:59.920
just merge them together and that gives

00:11:56.000 --> 00:12:02.720
you uh new s new

00:11:59.920 --> 00:12:05.200
EST and wide

00:12:02.720 --> 00:12:09.360
EST and then you do the same thing this

00:12:05.200 --> 00:12:12.519
time now you get EST so now you get this

00:12:09.360 --> 00:12:14.279
uh suffix EST and that looks pretty

00:12:12.519 --> 00:12:16.399
reasonable for English right you know

00:12:14.279 --> 00:12:19.040
EST is a common suffix that we use it

00:12:16.399 --> 00:12:22.399
seems like it should be a single token

00:12:19.040 --> 00:12:25.880
and um so you just do this over and over

00:12:22.399 --> 00:12:29.279
again if you want a vocabulary of 60,000

00:12:25.880 --> 00:12:31.120
for example you would do um 60,000 minus

00:12:29.279 --> 00:12:33.079
number of characters merge operations

00:12:31.120 --> 00:12:37.160
and eventually you would get a B of

00:12:33.079 --> 00:12:41.920
60,000 um and yeah very very simple

00:12:37.160 --> 00:12:41.920
method to do this um any questions about

00:12:43.160 --> 00:12:46.160
that

00:12:57.839 --> 00:13:00.839
yeah

00:13:15.600 --> 00:13:20.959
yeah so uh just to repeat the the

00:13:18.040 --> 00:13:23.560
comment uh this seems like a greedy

00:13:20.959 --> 00:13:25.320
version of Huffman encoding which is a

00:13:23.560 --> 00:13:28.839
you know similar to what you're using in

00:13:25.320 --> 00:13:32.000
your zip file a way to shorten things by

00:13:28.839 --> 00:13:36.560
getting longer uh more frequent things

00:13:32.000 --> 00:13:39.120
being inced as a single token um I think

00:13:36.560 --> 00:13:40.760
B pair encoding did originally start

00:13:39.120 --> 00:13:43.720
like that that's part of the reason why

00:13:40.760 --> 00:13:45.760
the encoding uh thing is here I think it

00:13:43.720 --> 00:13:47.360
originally started there I haven't read

00:13:45.760 --> 00:13:49.360
really deeply into this but I can talk

00:13:47.360 --> 00:13:53.240
more about how the next one corresponds

00:13:49.360 --> 00:13:54.440
to information Theory and Tuesday I'm

00:13:53.240 --> 00:13:55.720
going to talk even more about how

00:13:54.440 --> 00:13:57.720
language models correspond to

00:13:55.720 --> 00:14:00.040
information theories so we can uh we can

00:13:57.720 --> 00:14:04.519
discuss maybe in more detail

00:14:00.040 --> 00:14:07.639
to um so the the alternative option is

00:14:04.519 --> 00:14:10.000
to use unigram models and unigram models

00:14:07.639 --> 00:14:12.240
are the simplest type of language model

00:14:10.000 --> 00:14:15.079
I'm going to talk more in detail about

00:14:12.240 --> 00:14:18.279
them next time but basically uh the way

00:14:15.079 --> 00:14:20.759
it works is you create a model that

00:14:18.279 --> 00:14:23.600
generates all word uh words in the

00:14:20.759 --> 00:14:26.199
sequence independently sorry I thought I

00:14:23.600 --> 00:14:26.199
had a

00:14:26.320 --> 00:14:31.800
um I thought I had an equation but

00:14:28.800 --> 00:14:31.800
basically the

00:14:32.240 --> 00:14:35.759
equation looks

00:14:38.079 --> 00:14:41.079
like

00:14:47.720 --> 00:14:52.120
this so you say the probability of the

00:14:50.360 --> 00:14:53.440
sequence is the product of the

00:14:52.120 --> 00:14:54.279
probabilities of each of the words in

00:14:53.440 --> 00:14:55.959
the

00:14:54.279 --> 00:15:00.079
sequence

00:14:55.959 --> 00:15:04.079
and uh then you try to pick a vocabulary

00:15:00.079 --> 00:15:06.839
that maximizes the probability of the

00:15:04.079 --> 00:15:09.320
Corpus given a fixed vocabulary size so

00:15:06.839 --> 00:15:10.320
you try to say okay you get a vocabulary

00:15:09.320 --> 00:15:14.440
size of

00:15:10.320 --> 00:15:16.920
60,000 how do you um how do you pick the

00:15:14.440 --> 00:15:19.680
best 60,000 vocabulary to maximize the

00:15:16.920 --> 00:15:22.440
probability of the the Corpus and that

00:15:19.680 --> 00:15:25.959
will result in something very similar uh

00:15:22.440 --> 00:15:27.920
it will also try to give longer uh

00:15:25.959 --> 00:15:29.880
vocabulary uh sorry more common

00:15:27.920 --> 00:15:32.240
vocabulary long sequences because that

00:15:29.880 --> 00:15:35.560
allows you to to maximize this

00:15:32.240 --> 00:15:36.959
objective um the optimization for this

00:15:35.560 --> 00:15:40.040
is performed using something called the

00:15:36.959 --> 00:15:44.440
EM algorithm where basically you uh

00:15:40.040 --> 00:15:48.560
predict the uh the probability of each

00:15:44.440 --> 00:15:51.600
token showing up and uh then select the

00:15:48.560 --> 00:15:53.279
most common tokens and then trim off the

00:15:51.600 --> 00:15:54.759
ones that are less common and then just

00:15:53.279 --> 00:15:58.120
do this over and over again until you

00:15:54.759 --> 00:15:59.839
drop down to the 60,000 token lat so the

00:15:58.120 --> 00:16:02.040
details for this are not important for

00:15:59.839 --> 00:16:04.160
most people in this class uh because

00:16:02.040 --> 00:16:07.480
you're going to just be using a toolkit

00:16:04.160 --> 00:16:08.880
that implements this for you um but if

00:16:07.480 --> 00:16:10.759
you're interested in this I'm happy to

00:16:08.880 --> 00:16:14.199
talk to you about it

00:16:10.759 --> 00:16:14.199
yeah is there

00:16:14.680 --> 00:16:18.959
problem Oh in unigram models there's a

00:16:17.199 --> 00:16:20.959
huge problem with assuming Independence

00:16:18.959 --> 00:16:22.720
in language models because then you

00:16:20.959 --> 00:16:25.120
could rearrange the order of words in

00:16:22.720 --> 00:16:26.600
sentences um that that's something we're

00:16:25.120 --> 00:16:27.519
going to talk about in language model

00:16:26.600 --> 00:16:30.560
next

00:16:27.519 --> 00:16:32.839
time but the the good thing about this

00:16:30.560 --> 00:16:34.519
is the EM algorithm requires dynamic

00:16:32.839 --> 00:16:36.079
programming in this case and you can't

00:16:34.519 --> 00:16:37.800
easily do dynamic programming if you

00:16:36.079 --> 00:16:40.160
don't make that

00:16:37.800 --> 00:16:41.880
assumptions um and then finally after

00:16:40.160 --> 00:16:43.560
you've picked your vocabulary and you've

00:16:41.880 --> 00:16:45.720
assigned a probability to each word in

00:16:43.560 --> 00:16:47.800
the vocabulary you then find a

00:16:45.720 --> 00:16:49.639
segmentation of the input that maximizes

00:16:47.800 --> 00:16:52.600
the unigram

00:16:49.639 --> 00:16:54.880
probabilities um so this is basically

00:16:52.600 --> 00:16:56.519
the idea of what's going on here um I'm

00:16:54.880 --> 00:16:58.120
not going to go into a lot of detail

00:16:56.519 --> 00:17:00.560
about this because most people are just

00:16:58.120 --> 00:17:02.279
going to be users of this algorithm so

00:17:00.560 --> 00:17:06.240
it's not super super

00:17:02.279 --> 00:17:09.400
important um the one important thing

00:17:06.240 --> 00:17:11.240
about this is that there's a library

00:17:09.400 --> 00:17:15.520
called sentence piece that's used very

00:17:11.240 --> 00:17:19.199
widely in order to build these um in

00:17:15.520 --> 00:17:22.000
order to build these subword units and

00:17:19.199 --> 00:17:23.720
uh basically what you do is you run the

00:17:22.000 --> 00:17:27.600
sentence piece

00:17:23.720 --> 00:17:30.200
train uh model or sorry uh program and

00:17:27.600 --> 00:17:32.640
that gives you uh you select your vocab

00:17:30.200 --> 00:17:34.240
size uh this also this character

00:17:32.640 --> 00:17:36.120
coverage is basically how well do you

00:17:34.240 --> 00:17:39.760
need to cover all of the characters in

00:17:36.120 --> 00:17:41.840
your vocabulary or in your input text um

00:17:39.760 --> 00:17:45.240
what model type do you use and then you

00:17:41.840 --> 00:17:48.640
run this uh sentence piece en code file

00:17:45.240 --> 00:17:51.039
uh to uh encode the output and split the

00:17:48.640 --> 00:17:54.799
output and there's also python bindings

00:17:51.039 --> 00:17:56.240
available for this and by the one thing

00:17:54.799 --> 00:17:57.919
that you should know is by default it

00:17:56.240 --> 00:18:00.600
uses the unigram model but it also

00:17:57.919 --> 00:18:01.960
supports EP in my experience it doesn't

00:18:00.600 --> 00:18:05.159
make a huge difference about which one

00:18:01.960 --> 00:18:07.640
you use the bigger thing is how um how

00:18:05.159 --> 00:18:10.159
big is your vocabulary size and if your

00:18:07.640 --> 00:18:11.880
vocabulary size is smaller then things

00:18:10.159 --> 00:18:13.760
will be more efficient but less

00:18:11.880 --> 00:18:17.480
expressive if your vocabulary size is

00:18:13.760 --> 00:18:21.280
bigger things will be um will

00:18:17.480 --> 00:18:23.240
be more expressive but less efficient

00:18:21.280 --> 00:18:25.360
and A good rule of thumb is like

00:18:23.240 --> 00:18:26.960
something like 60,000 to 80,000 is

00:18:25.360 --> 00:18:29.120
pretty reasonable if you're only doing

00:18:26.960 --> 00:18:31.320
English if you're spreading out to

00:18:29.120 --> 00:18:32.600
things that do other languages um which

00:18:31.320 --> 00:18:35.960
I'll talk about in a second then you

00:18:32.600 --> 00:18:38.720
need a much bigger B regular

00:18:35.960 --> 00:18:40.559
say so there's two considerations here

00:18:38.720 --> 00:18:42.440
two important considerations when using

00:18:40.559 --> 00:18:46.320
these models uh the first is

00:18:42.440 --> 00:18:48.760
multilinguality as I said so when you're

00:18:46.320 --> 00:18:50.760
using um subword

00:18:48.760 --> 00:18:54.710
models they're hard to use

00:18:50.760 --> 00:18:55.840
multilingually because as I said before

00:18:54.710 --> 00:18:59.799
[Music]

00:18:55.840 --> 00:19:03.799
they give longer strings to more

00:18:59.799 --> 00:19:06.520
frequent strings basically so then

00:19:03.799 --> 00:19:09.559
imagine what happens if 50% of your

00:19:06.520 --> 00:19:11.919
Corpus is English another 30% of your

00:19:09.559 --> 00:19:15.400
Corpus is

00:19:11.919 --> 00:19:17.200
other languages written in Latin script

00:19:15.400 --> 00:19:21.720
10% is

00:19:17.200 --> 00:19:25.480
Chinese uh 5% is cerlic script languages

00:19:21.720 --> 00:19:27.240
four 4% is 3% is Japanese and then you

00:19:25.480 --> 00:19:31.080
have like

00:19:27.240 --> 00:19:33.320
0.01% written in like burmes or

00:19:31.080 --> 00:19:35.520
something like that suddenly burmes just

00:19:33.320 --> 00:19:37.400
gets chunked up really really tiny

00:19:35.520 --> 00:19:38.360
really long sequences and it doesn't

00:19:37.400 --> 00:19:45.559
work as

00:19:38.360 --> 00:19:45.559
well um so one way that people fix this

00:19:45.919 --> 00:19:50.520
um and actually there's a really nice uh

00:19:48.760 --> 00:19:52.600
blog post about this called exploring

00:19:50.520 --> 00:19:53.760
B's vocabulary which I referenced here

00:19:52.600 --> 00:19:58.039
if you're interested in learning more

00:19:53.760 --> 00:20:02.960
about that um but one way that people

00:19:58.039 --> 00:20:05.240
were around this is if your

00:20:02.960 --> 00:20:07.960
actual uh data

00:20:05.240 --> 00:20:11.559
distribution looks like this like

00:20:07.960 --> 00:20:11.559
English uh

00:20:17.039 --> 00:20:23.159
Ty we actually sorry I took out the

00:20:19.280 --> 00:20:23.159
Indian languages in my example

00:20:24.960 --> 00:20:30.159
apologies

00:20:27.159 --> 00:20:30.159
so

00:20:30.400 --> 00:20:35.919
um what you do is you essentially create

00:20:33.640 --> 00:20:40.000
a different distribution that like

00:20:35.919 --> 00:20:43.559
downweights English a little bit and up

00:20:40.000 --> 00:20:47.000
weights up weights all of the other

00:20:43.559 --> 00:20:49.480
languages um so that you get more of

00:20:47.000 --> 00:20:53.159
other languages when creating so this is

00:20:49.480 --> 00:20:53.159
a common work around that you can do for

00:20:54.200 --> 00:20:59.960
this um the

00:20:56.799 --> 00:21:03.000
second problem with these is

00:20:59.960 --> 00:21:08.000
arbitrariness so as you saw in my

00:21:03.000 --> 00:21:11.240
example with bpe e s s and t and of

00:21:08.000 --> 00:21:13.520
board symbol all have the same probabil

00:21:11.240 --> 00:21:16.960
or have the same frequency right so if

00:21:13.520 --> 00:21:21.520
we get to that point do we segment es or

00:21:16.960 --> 00:21:25.039
do we seg uh EST or do we segment e

00:21:21.520 --> 00:21:26.559
s and so this is also a problem and it

00:21:25.039 --> 00:21:29.000
actually can affect your results

00:21:26.559 --> 00:21:30.480
especially if you like don't have a

00:21:29.000 --> 00:21:31.760
really strong vocabulary for the

00:21:30.480 --> 00:21:33.279
language you're working in or you're

00:21:31.760 --> 00:21:37.200
working in a new

00:21:33.279 --> 00:21:40.159
domain and so there's a few workarounds

00:21:37.200 --> 00:21:41.520
for this uh one workaround for this is

00:21:40.159 --> 00:21:44.000
uh called subword

00:21:41.520 --> 00:21:46.279
regularization and the way it works is

00:21:44.000 --> 00:21:49.400
instead

00:21:46.279 --> 00:21:51.640
of just having a single segmentation and

00:21:49.400 --> 00:21:54.679
getting the kind of

00:21:51.640 --> 00:21:56.200
maximally probable segmentation or the

00:21:54.679 --> 00:21:58.480
one the greedy one that you get out of

00:21:56.200 --> 00:22:01.360
BP instead you sample different

00:21:58.480 --> 00:22:03.000
segmentations in training time and use

00:22:01.360 --> 00:22:05.720
the different segmentations and that

00:22:03.000 --> 00:22:09.200
makes your model more robust to this

00:22:05.720 --> 00:22:10.840
kind of variation and that's also

00:22:09.200 --> 00:22:15.679
actually the reason why sentence piece

00:22:10.840 --> 00:22:17.919
was released was through this um subword

00:22:15.679 --> 00:22:19.559
regularization paper so that's also

00:22:17.919 --> 00:22:22.720
implemented in sentence piece if that's

00:22:19.559 --> 00:22:22.720
something you're interested in

00:22:24.919 --> 00:22:32.520
trying cool um are there any questions

00:22:28.480 --> 00:22:32.520
or discussions about this

00:22:53.279 --> 00:22:56.279
yeah

00:22:56.960 --> 00:22:59.960
already

00:23:06.799 --> 00:23:11.080
yeah so this is a good question um just

00:23:08.960 --> 00:23:12.760
to repeat the question it was like let's

00:23:11.080 --> 00:23:16.080
say we have a big

00:23:12.760 --> 00:23:19.640
multilingual um subword

00:23:16.080 --> 00:23:23.440
model and we want to add a new language

00:23:19.640 --> 00:23:26.240
in some way uh how can we reuse the

00:23:23.440 --> 00:23:28.880
existing model but add a new

00:23:26.240 --> 00:23:31.080
language it's a good question if you're

00:23:28.880 --> 00:23:33.679
only using it for subord

00:23:31.080 --> 00:23:36.320
segmentation um one one nice thing about

00:23:33.679 --> 00:23:36.320
the unigram

00:23:36.400 --> 00:23:41.799
model here is this is kind of a

00:23:38.880 --> 00:23:43.679
probabilistic model so it's very easy to

00:23:41.799 --> 00:23:46.360
do the kind of standard things that we

00:23:43.679 --> 00:23:48.240
do with probabilistic models which is

00:23:46.360 --> 00:23:50.559
like let's say we had an

00:23:48.240 --> 00:23:53.919
old uh an

00:23:50.559 --> 00:23:56.880
old vocabulary for

00:23:53.919 --> 00:23:59.880
this um we could just

00:23:56.880 --> 00:23:59.880
interpolate

00:24:07.159 --> 00:24:12.320
um we could interpolate like this and

00:24:09.559 --> 00:24:13.840
just you know uh combine the

00:24:12.320 --> 00:24:17.080
probabilities of the two and then use

00:24:13.840 --> 00:24:19.520
that combine probability in order to

00:24:17.080 --> 00:24:21.320
segment the new language um things like

00:24:19.520 --> 00:24:24.159
this have been uh done before but I

00:24:21.320 --> 00:24:26.159
don't remember the exact preferences uh

00:24:24.159 --> 00:24:30.440
for them but that that's what I would do

00:24:26.159 --> 00:24:31.960
here another interesting thing is um

00:24:30.440 --> 00:24:35.399
this might be getting a little ahead of

00:24:31.960 --> 00:24:35.399
myself but there's

00:24:48.559 --> 00:24:58.279
a there's a paper that talks about um

00:24:55.360 --> 00:25:00.159
how you can take things that or trained

00:24:58.279 --> 00:25:03.360
with another

00:25:00.159 --> 00:25:05.480
vocabulary and basically the idea is um

00:25:03.360 --> 00:25:09.320
you pre-train on whatever languages you

00:25:05.480 --> 00:25:10.679
have and then uh you learn embeddings in

00:25:09.320 --> 00:25:11.880
the new language you freeze the body of

00:25:10.679 --> 00:25:14.360
the model and learn embeddings in the

00:25:11.880 --> 00:25:15.880
new language so that's another uh method

00:25:14.360 --> 00:25:19.080
that's used it's called on the cross

00:25:15.880 --> 00:25:19.080
lingual printability

00:25:21.840 --> 00:25:26.159
representations and I'll probably talk

00:25:23.840 --> 00:25:28.480
about that in the last class of this uh

00:25:26.159 --> 00:25:30.720
thing so you can remember that

00:25:28.480 --> 00:25:33.720
then cool any other

00:25:30.720 --> 00:25:33.720
questions

00:25:38.480 --> 00:25:42.640
yeah is bag of words a first step to

00:25:41.039 --> 00:25:46.640
process your data if you want to do

00:25:42.640 --> 00:25:49.919
Generation Um do you mean like

00:25:46.640 --> 00:25:52.440
uh a word based model or a subword based

00:25:49.919 --> 00:25:52.440
model

00:25:56.679 --> 00:26:00.480
or like is

00:26:02.360 --> 00:26:08.000
this so the subword segmentation is the

00:26:05.919 --> 00:26:10.640
first step of creating just about any

00:26:08.000 --> 00:26:13.080
model nowadays like every model every

00:26:10.640 --> 00:26:16.600
model uses this and they usually use

00:26:13.080 --> 00:26:21.520
this either to segment characters or

00:26:16.600 --> 00:26:23.559
byes um characters are like Unicode code

00:26:21.520 --> 00:26:25.799
points so they actually correspond to an

00:26:23.559 --> 00:26:28.279
actual visual character and then bites

00:26:25.799 --> 00:26:31.120
are many unicode characters are like

00:26:28.279 --> 00:26:35.000
three by like a Chinese character is

00:26:31.120 --> 00:26:37.159
three byes if I remember correctly so um

00:26:35.000 --> 00:26:38.640
the bbased segmentation is nice because

00:26:37.159 --> 00:26:41.240
you don't even need to worry about unic

00:26:38.640 --> 00:26:43.880
code you can just do the like you can

00:26:41.240 --> 00:26:45.640
just segment the pile like literally as

00:26:43.880 --> 00:26:49.440
is and so a lot of people do it that way

00:26:45.640 --> 00:26:53.279
too uh llama as far as I know is

00:26:49.440 --> 00:26:55.720
bites I believe GPT is also bites um but

00:26:53.279 --> 00:26:58.799
pre previous to like three or four years

00:26:55.720 --> 00:27:02.799
ago people used SCS I

00:26:58.799 --> 00:27:05.000
cool um okay so this is really really

00:27:02.799 --> 00:27:05.919
important it's not like super complex

00:27:05.000 --> 00:27:09.760
and

00:27:05.919 --> 00:27:13.039
practically uh you will just maybe maybe

00:27:09.760 --> 00:27:15.840
train or maybe just use a tokenizer um

00:27:13.039 --> 00:27:18.559
but uh that that's an important thing to

00:27:15.840 --> 00:27:20.760
me cool uh next I'd like to move on to

00:27:18.559 --> 00:27:24.399
continuous word eddings

00:27:20.760 --> 00:27:26.720
so the basic idea is that previously we

00:27:24.399 --> 00:27:28.240
represented words with a sparse Vector

00:27:26.720 --> 00:27:30.120
uh with a single one

00:27:28.240 --> 00:27:31.960
also known as one poot Vector so it

00:27:30.120 --> 00:27:35.720
looked a little bit like

00:27:31.960 --> 00:27:37.640
this and instead what continuous word

00:27:35.720 --> 00:27:39.640
embeddings do is they look up a dense

00:27:37.640 --> 00:27:42.320
vector and so you get a dense

00:27:39.640 --> 00:27:45.760
representation where the entire Vector

00:27:42.320 --> 00:27:45.760
has continuous values in

00:27:46.000 --> 00:27:51.919
it and I talked about a bag of words

00:27:49.200 --> 00:27:54.320
model but we could also create a

00:27:51.919 --> 00:27:58.360
continuous bag of words model and the

00:27:54.320 --> 00:28:01.159
way this works is you look up the

00:27:58.360 --> 00:28:03.720
values of each Vector the embeddings of

00:28:01.159 --> 00:28:06.320
each Vector this gives you an embedding

00:28:03.720 --> 00:28:08.440
Vector for the entire sequence and then

00:28:06.320 --> 00:28:15.120
you multiply this by a weight

00:28:08.440 --> 00:28:17.559
Matrix uh where the so this is column so

00:28:15.120 --> 00:28:19.960
the rows of the weight Matrix uh

00:28:17.559 --> 00:28:22.919
correspond to to the size of this

00:28:19.960 --> 00:28:24.760
continuous embedding and The Columns of

00:28:22.919 --> 00:28:28.320
the weight Matrix would correspond to

00:28:24.760 --> 00:28:30.919
the uh overall um

00:28:28.320 --> 00:28:32.559
to the overall uh number of labels that

00:28:30.919 --> 00:28:36.919
you would have here and then that would

00:28:32.559 --> 00:28:40.120
give you sces and so this uh basically

00:28:36.919 --> 00:28:41.679
what this is saying is each Vector now

00:28:40.120 --> 00:28:43.440
instead of having a single thing that

00:28:41.679 --> 00:28:46.799
represents which vocabulary item you're

00:28:43.440 --> 00:28:48.679
looking at uh you would kind of hope

00:28:46.799 --> 00:28:52.120
that you would get vectors where words

00:28:48.679 --> 00:28:54.919
that are similar uh by some mention of

00:28:52.120 --> 00:28:57.760
by some concept of similar like syntatic

00:28:54.919 --> 00:28:59.679
uh syntax semantics whether they're in

00:28:57.760 --> 00:29:03.120
the same language or not are close in

00:28:59.679 --> 00:29:06.679
the vector space and each Vector element

00:29:03.120 --> 00:29:09.399
is a feature uh so for example each

00:29:06.679 --> 00:29:11.519
Vector element corresponds to is this an

00:29:09.399 --> 00:29:14.960
animate object or is this a positive

00:29:11.519 --> 00:29:17.399
word or other Vector other things like

00:29:14.960 --> 00:29:19.399
that so just to give an example here

00:29:17.399 --> 00:29:21.760
this is totally made up I just made it

00:29:19.399 --> 00:29:24.360
in keynote so it's not natural Vector

00:29:21.760 --> 00:29:26.279
space but to Ill illustrate the concept

00:29:24.360 --> 00:29:27.960
I showed here what if we had a

00:29:26.279 --> 00:29:30.240
two-dimensional vector

00:29:27.960 --> 00:29:33.399
space where the two-dimensional Vector

00:29:30.240 --> 00:29:36.240
space the xais here is corresponding to

00:29:33.399 --> 00:29:38.679
whether it's animate or not and the the

00:29:36.240 --> 00:29:41.480
Y AIS here is corresponding to whether

00:29:38.679 --> 00:29:44.080
it's like positive sentiment or not and

00:29:41.480 --> 00:29:46.399
so this is kind of like our ideal uh

00:29:44.080 --> 00:29:49.799
goal

00:29:46.399 --> 00:29:52.279
here um so why would we want to do this

00:29:49.799 --> 00:29:52.279
yeah sorry

00:29:56.320 --> 00:30:03.399
guys what do the like in the one it's

00:30:00.919 --> 00:30:06.399
one

00:30:03.399 --> 00:30:06.399
yep

00:30:07.200 --> 00:30:12.519
like so what would the four entries do

00:30:09.880 --> 00:30:14.799
here the four entries here are learned

00:30:12.519 --> 00:30:17.039
so they are um they're learned just

00:30:14.799 --> 00:30:18.519
together with the model um and I'm going

00:30:17.039 --> 00:30:22.120
to talk about exactly how we learn them

00:30:18.519 --> 00:30:24.000
soon but the the final goal is that

00:30:22.120 --> 00:30:25.399
after learning has happened they look

00:30:24.000 --> 00:30:26.799
they have these two properties like

00:30:25.399 --> 00:30:28.600
similar words are close together in the

00:30:26.799 --> 00:30:30.080
vectorace

00:30:28.600 --> 00:30:32.640
and

00:30:30.080 --> 00:30:35.679
um that's like number one that's the

00:30:32.640 --> 00:30:37.600
most important and then number two is

00:30:35.679 --> 00:30:39.279
ideally these uh features would have

00:30:37.600 --> 00:30:41.200
some meaning uh maybe human

00:30:39.279 --> 00:30:44.720
interpretable meaning maybe not human

00:30:41.200 --> 00:30:47.880
interpretable meaning but

00:30:44.720 --> 00:30:50.880
yeah so um one thing that I should

00:30:47.880 --> 00:30:53.159
mention is I I showed a contrast between

00:30:50.880 --> 00:30:55.159
the bag of words uh the one hot

00:30:53.159 --> 00:30:57.000
representations here and the dense

00:30:55.159 --> 00:31:00.880
representations here and I used this

00:30:57.000 --> 00:31:03.880
look look up operation for both of them

00:31:00.880 --> 00:31:07.399
and this this lookup

00:31:03.880 --> 00:31:09.559
operation actually um can be viewed as

00:31:07.399 --> 00:31:11.799
grabbing a single Vector from a big

00:31:09.559 --> 00:31:14.919
Matrix of word

00:31:11.799 --> 00:31:17.760
embeddings and

00:31:14.919 --> 00:31:19.760
so the way it can work is like we have

00:31:17.760 --> 00:31:22.919
this big vector and then we look up word

00:31:19.760 --> 00:31:25.919
number two in a zero index Matrix and it

00:31:22.919 --> 00:31:27.799
would just grab this out of that Matrix

00:31:25.919 --> 00:31:29.880
and that's practically what most like

00:31:27.799 --> 00:31:32.240
deep learning libraries or or whatever

00:31:29.880 --> 00:31:35.840
Library you use are going to be

00:31:32.240 --> 00:31:38.000
doing but another uh way you can view it

00:31:35.840 --> 00:31:40.880
is you can view it as multiplying by a

00:31:38.000 --> 00:31:43.880
one hot vector and so you have this

00:31:40.880 --> 00:31:48.679
Vector uh exactly the same Matrix uh but

00:31:43.880 --> 00:31:50.799
you just multiply by a vector uh 0 1 z z

00:31:48.679 --> 00:31:55.720
and that gives you exactly the same

00:31:50.799 --> 00:31:58.200
things um so the Practical imple

00:31:55.720 --> 00:31:59.720
implementations of this uh uh tend to be

00:31:58.200 --> 00:32:01.279
the first one because the first one's a

00:31:59.720 --> 00:32:04.679
lot faster to implement you don't need

00:32:01.279 --> 00:32:06.760
to multiply like this big thing by a

00:32:04.679 --> 00:32:11.000
huge Vector but there

00:32:06.760 --> 00:32:13.880
are advantages of knowing the second one

00:32:11.000 --> 00:32:15.519
uh just to give an example what if you

00:32:13.880 --> 00:32:19.600
for whatever reason you came up with

00:32:15.519 --> 00:32:21.440
like an a crazy model that predicts a

00:32:19.600 --> 00:32:24.120
probability distribution over words

00:32:21.440 --> 00:32:25.720
instead of just words maybe it's a

00:32:24.120 --> 00:32:27.679
language model that has an idea of what

00:32:25.720 --> 00:32:30.200
the next word is going to look like

00:32:27.679 --> 00:32:32.159
and maybe your um maybe your model

00:32:30.200 --> 00:32:35.279
thinks the next word has a 50%

00:32:32.159 --> 00:32:36.600
probability of being capped 30%

00:32:35.279 --> 00:32:42.279
probability of being

00:32:36.600 --> 00:32:44.960
dog and uh 2% probability uh sorry uh

00:32:42.279 --> 00:32:47.200
20% probability being

00:32:44.960 --> 00:32:50.000
bir you can take this vector and

00:32:47.200 --> 00:32:51.480
multiply it by The Matrix and get like a

00:32:50.000 --> 00:32:53.639
word embedding that's kind of a mix of

00:32:51.480 --> 00:32:55.639
all of those word which might be

00:32:53.639 --> 00:32:57.960
interesting and let you do creative

00:32:55.639 --> 00:33:02.120
things so um knowing that these two

00:32:57.960 --> 00:33:05.360
things are the same are the same is kind

00:33:02.120 --> 00:33:05.360
of useful for that kind of

00:33:05.919 --> 00:33:11.480
thing um any any questions about this

00:33:09.120 --> 00:33:13.919
I'm G to talk about how we train next so

00:33:11.480 --> 00:33:18.159
maybe maybe I can goow into

00:33:13.919 --> 00:33:23.159
that okay cool so how do we get the

00:33:18.159 --> 00:33:25.840
vectors uh like the question uh so up

00:33:23.159 --> 00:33:27.519
until now we trained a bag of words

00:33:25.840 --> 00:33:29.080
model and the way we trained a bag of

00:33:27.519 --> 00:33:31.159
words model was using the structured

00:33:29.080 --> 00:33:35.440
perceptron algorithm where if the model

00:33:31.159 --> 00:33:39.639
got the answer wrong we would either

00:33:35.440 --> 00:33:42.799
increment or decrement the embeddings

00:33:39.639 --> 00:33:45.080
based on whether uh whether the label

00:33:42.799 --> 00:33:46.559
was positive or negative right so I

00:33:45.080 --> 00:33:48.919
showed an example of this very simple

00:33:46.559 --> 00:33:51.039
algorithm you don't even uh need to

00:33:48.919 --> 00:33:52.480
write any like numpy or anything like

00:33:51.039 --> 00:33:55.919
that to implement that

00:33:52.480 --> 00:33:59.559
algorithm uh so here here it is so we

00:33:55.919 --> 00:34:02.320
have like 4X why in uh data we extract

00:33:59.559 --> 00:34:04.639
the features we run the classifier uh we

00:34:02.320 --> 00:34:07.440
have the predicted why and then we

00:34:04.639 --> 00:34:09.480
increment or decrement

00:34:07.440 --> 00:34:12.679
features but how do we train more

00:34:09.480 --> 00:34:15.599
complex models so I think most people

00:34:12.679 --> 00:34:17.079
here have taken a uh machine learning

00:34:15.599 --> 00:34:19.159
class of some kind so this will be

00:34:17.079 --> 00:34:21.079
reviewed for a lot of people uh but

00:34:19.159 --> 00:34:22.280
basically we do this uh by doing

00:34:21.079 --> 00:34:24.839
gradient

00:34:22.280 --> 00:34:27.240
descent and in order to do so we write

00:34:24.839 --> 00:34:29.919
down a loss function calculate the

00:34:27.240 --> 00:34:30.919
derivatives of the L function with

00:34:29.919 --> 00:34:35.079
respect to the

00:34:30.919 --> 00:34:37.320
parameters and move uh the parameters in

00:34:35.079 --> 00:34:40.839
the direction that reduces the loss

00:34:37.320 --> 00:34:42.720
mtion and so specifically for this bag

00:34:40.839 --> 00:34:45.560
of words or continuous bag of words

00:34:42.720 --> 00:34:48.240
model um we want this loss of function

00:34:45.560 --> 00:34:50.839
to be a loss function that gets lower as

00:34:48.240 --> 00:34:52.240
the model gets better and I'm going to

00:34:50.839 --> 00:34:54.000
give two examples from binary

00:34:52.240 --> 00:34:57.400
classification both of these are used in

00:34:54.000 --> 00:34:58.839
NLP models uh reasonably frequently

00:34:57.400 --> 00:35:01.440
uh there's a bunch of other loss

00:34:58.839 --> 00:35:02.800
functions but these are kind of the two

00:35:01.440 --> 00:35:05.480
major

00:35:02.800 --> 00:35:08.160
ones so the first one um which is

00:35:05.480 --> 00:35:10.160
actually less frequent is the hinge loss

00:35:08.160 --> 00:35:13.400
and then the second one is taking a

00:35:10.160 --> 00:35:15.800
sigmoid and then doing negative log

00:35:13.400 --> 00:35:19.760
likelyhood so the hinge loss basically

00:35:15.800 --> 00:35:22.760
what we do is we uh take the max of the

00:35:19.760 --> 00:35:26.119
label times the score that is output by

00:35:22.760 --> 00:35:29.200
the model and zero and what this looks

00:35:26.119 --> 00:35:33.480
like is we have a hinged loss uh where

00:35:29.200 --> 00:35:36.880
if Y is equal to one the loss if Y is

00:35:33.480 --> 00:35:39.520
greater than zero is zero so as long as

00:35:36.880 --> 00:35:42.680
we get basically as long as we get the

00:35:39.520 --> 00:35:45.079
answer right there's no loss um as the

00:35:42.680 --> 00:35:47.400
answer gets more wrong the loss gets

00:35:45.079 --> 00:35:49.880
worse like this and then similarly if

00:35:47.400 --> 00:35:53.160
the label is negative if we get a

00:35:49.880 --> 00:35:54.839
negative score uh then we get zero loss

00:35:53.160 --> 00:35:55.800
and the loss increases if we have a

00:35:54.839 --> 00:35:58.800
positive

00:35:55.800 --> 00:36:00.800
score so the sigmoid plus negative log

00:35:58.800 --> 00:36:05.440
likelihood the way this works is you

00:36:00.800 --> 00:36:07.400
multiply y * the score here and um then

00:36:05.440 --> 00:36:09.960
we have the sigmoid function which is

00:36:07.400 --> 00:36:14.079
just kind of a nice function that looks

00:36:09.960 --> 00:36:15.440
like this with zero and one centered

00:36:14.079 --> 00:36:19.480
around

00:36:15.440 --> 00:36:21.240
zero and then we take the negative log

00:36:19.480 --> 00:36:22.319
of this sigmoid function or the negative

00:36:21.240 --> 00:36:27.160
log

00:36:22.319 --> 00:36:28.520
likelihood and that gives us a uh L that

00:36:27.160 --> 00:36:30.440
looks a little bit like this so

00:36:28.520 --> 00:36:32.640
basically you can see that these look

00:36:30.440 --> 00:36:36.040
very similar right the difference being

00:36:32.640 --> 00:36:37.760
that the hinge loss is uh sharp and we

00:36:36.040 --> 00:36:41.119
get exactly a zero loss if we get the

00:36:37.760 --> 00:36:44.319
answer right and the sigmoid is smooth

00:36:41.119 --> 00:36:48.440
uh and we never get a zero

00:36:44.319 --> 00:36:50.680
loss um so does anyone have an idea of

00:36:48.440 --> 00:36:53.119
the benefits and disadvantages of

00:36:50.680 --> 00:36:55.680
these I kind of flashed one on the

00:36:53.119 --> 00:36:57.599
screen already

00:36:55.680 --> 00:36:59.400
but

00:36:57.599 --> 00:37:01.359
so I flash that on the screen so I'll

00:36:59.400 --> 00:37:03.680
give this one and then I can have a quiz

00:37:01.359 --> 00:37:06.319
about the sign but the the hinge glass

00:37:03.680 --> 00:37:07.720
is more closely linked to accuracy and

00:37:06.319 --> 00:37:10.400
the reason why it's more closely linked

00:37:07.720 --> 00:37:13.640
to accuracy is because basically we will

00:37:10.400 --> 00:37:16.079
get a zero loss if the model gets the

00:37:13.640 --> 00:37:18.319
answer right so when the model gets all

00:37:16.079 --> 00:37:20.240
of the answers right we will just stop

00:37:18.319 --> 00:37:22.760
updating our model whatsoever because we

00:37:20.240 --> 00:37:25.440
never we don't have any loss whatsoever

00:37:22.760 --> 00:37:27.720
and the gradient of the loss is zero um

00:37:25.440 --> 00:37:29.960
what about the sigmoid uh a negative log

00:37:27.720 --> 00:37:33.160
likelihood uh there there's kind of two

00:37:29.960 --> 00:37:36.160
major advantages of this anyone want to

00:37:33.160 --> 00:37:36.160
review their machine learning

00:37:38.240 --> 00:37:41.800
test sorry what was

00:37:43.800 --> 00:37:49.960
that for for R uh yeah maybe there's a

00:37:48.200 --> 00:37:51.319
more direct I think I know what you're

00:37:49.960 --> 00:37:54.560
saying but maybe there's a more direct

00:37:51.319 --> 00:37:54.560
way to say that um

00:37:54.839 --> 00:38:00.760
yeah yeah so the gradient is nonzero

00:37:57.560 --> 00:38:04.240
everywhere and uh the gradient also kind

00:38:00.760 --> 00:38:05.839
of increases as your score gets worse so

00:38:04.240 --> 00:38:08.440
those are that's one advantage it makes

00:38:05.839 --> 00:38:11.240
it easier to optimize models um another

00:38:08.440 --> 00:38:13.839
one linked to the ROC score but maybe we

00:38:11.240 --> 00:38:13.839
could say it more

00:38:16.119 --> 00:38:19.400
directly any

00:38:20.040 --> 00:38:26.920
ideas okay um basically the sigmoid can

00:38:23.240 --> 00:38:30.160
be interpreted as a probability so um if

00:38:26.920 --> 00:38:32.839
the the sigmoid is between Zer and one

00:38:30.160 --> 00:38:34.640
uh and because it's between zero and one

00:38:32.839 --> 00:38:36.720
we can say the sigmoid is a

00:38:34.640 --> 00:38:38.640
probability um and that can be useful

00:38:36.720 --> 00:38:40.119
for various things like if we want a

00:38:38.640 --> 00:38:41.960
downstream model or if we want a

00:38:40.119 --> 00:38:45.480
confidence prediction out of the model

00:38:41.960 --> 00:38:48.200
so those are two uh advantages of using

00:38:45.480 --> 00:38:49.920
a s plus negative log likelihood there's

00:38:48.200 --> 00:38:53.160
no probabilistic interpretation to

00:38:49.920 --> 00:38:56.560
something transing theas

00:38:53.160 --> 00:38:59.200
basically cool um so the next thing that

00:38:56.560 --> 00:39:01.240
that we do is we calculate derivatives

00:38:59.200 --> 00:39:04.040
and we calculate the derivative of the

00:39:01.240 --> 00:39:05.920
parameter given the loss function um to

00:39:04.040 --> 00:39:09.839
give an example of the bag of words

00:39:05.920 --> 00:39:13.480
model and the hinge loss um the hinge

00:39:09.839 --> 00:39:16.480
loss as I said is the max of the score

00:39:13.480 --> 00:39:19.359
and times y in the bag of words model

00:39:16.480 --> 00:39:22.640
the score was the frequency of that

00:39:19.359 --> 00:39:25.880
vocabulary item in the input multiplied

00:39:22.640 --> 00:39:27.680
by the weight here and so if we this is

00:39:25.880 --> 00:39:29.520
a simple a function that I can just do

00:39:27.680 --> 00:39:34.440
the derivative by hand and if I do the

00:39:29.520 --> 00:39:36.920
deriva by hand what comes out is if y *

00:39:34.440 --> 00:39:39.319
this value is greater than zero so in

00:39:36.920 --> 00:39:44.640
other words if this Max uh picks this

00:39:39.319 --> 00:39:48.319
instead of this then the derivative is y

00:39:44.640 --> 00:39:52.359
* stre and otherwise uh it

00:39:48.319 --> 00:39:52.359
is in the opposite

00:39:55.400 --> 00:40:00.160
direction

00:39:56.920 --> 00:40:02.839
then uh optimizing gradients uh we do

00:40:00.160 --> 00:40:06.200
standard uh in standard stochastic

00:40:02.839 --> 00:40:07.839
gradient descent uh which is the most

00:40:06.200 --> 00:40:10.920
standard optimization algorithm for

00:40:07.839 --> 00:40:14.440
these models uh we basically have a

00:40:10.920 --> 00:40:17.440
gradient over uh you take the gradient

00:40:14.440 --> 00:40:20.040
over the parameter of the loss function

00:40:17.440 --> 00:40:22.480
and we call it GT so here um sorry I

00:40:20.040 --> 00:40:25.599
switched my terminology between W and

00:40:22.480 --> 00:40:28.280
Theta so this could be W uh the previous

00:40:25.599 --> 00:40:31.000
value of w

00:40:28.280 --> 00:40:35.440
um and this is the gradient of the loss

00:40:31.000 --> 00:40:37.040
and then uh we take the previous value

00:40:35.440 --> 00:40:39.680
and then we subtract out the learning

00:40:37.040 --> 00:40:39.680
rate times the

00:40:40.680 --> 00:40:45.720
gradient and uh there are many many

00:40:43.200 --> 00:40:47.280
other optimization options uh I'll cover

00:40:45.720 --> 00:40:50.960
the more frequent one called Adam at the

00:40:47.280 --> 00:40:54.319
end of this uh this lecture but um this

00:40:50.960 --> 00:40:57.160
is the basic way of optimizing the

00:40:54.319 --> 00:41:00.599
model so

00:40:57.160 --> 00:41:03.359
then my question now is what is this

00:41:00.599 --> 00:41:07.000
algorithm with respect

00:41:03.359 --> 00:41:10.119
to this is an algorithm that is

00:41:07.000 --> 00:41:12.280
taking that has a loss function it's

00:41:10.119 --> 00:41:14.079
calculating derivatives and it's

00:41:12.280 --> 00:41:17.240
optimizing gradients using stochastic

00:41:14.079 --> 00:41:18.839
gradient descent so does anyone have a

00:41:17.240 --> 00:41:20.960
guess about what the loss function is

00:41:18.839 --> 00:41:23.520
here and maybe what is the learning rate

00:41:20.960 --> 00:41:23.520
of stas

00:41:24.319 --> 00:41:29.480
gradient I kind of gave you a hint about

00:41:26.599 --> 00:41:29.480
the L one

00:41:31.640 --> 00:41:37.839
actually and just to recap what this is

00:41:34.440 --> 00:41:41.440
doing here it's um if predicted Y is

00:41:37.839 --> 00:41:44.560
equal to Y then it is moving the uh the

00:41:41.440 --> 00:41:48.240
future weights in the direction of Y

00:41:44.560 --> 00:41:48.240
times the frequency

00:41:52.599 --> 00:41:56.960
Vector

00:41:55.240 --> 00:41:59.079
yeah

00:41:56.960 --> 00:42:01.640
yeah exactly so the loss function is

00:41:59.079 --> 00:42:05.800
hinge loss and the learning rate is one

00:42:01.640 --> 00:42:07.880
um and just to show how that you know

00:42:05.800 --> 00:42:12.359
corresponds we have this if statement

00:42:07.880 --> 00:42:12.359
here and we have the increment of the

00:42:12.960 --> 00:42:20.240
features and this is what the um what

00:42:16.920 --> 00:42:21.599
the L sorry the derivative looked like

00:42:20.240 --> 00:42:24.240
so we have

00:42:21.599 --> 00:42:26.920
if this is moving in the right direction

00:42:24.240 --> 00:42:29.520
for the label uh then we increment

00:42:26.920 --> 00:42:31.599
otherwise we do nothing so

00:42:29.520 --> 00:42:33.559
basically you can see that even this

00:42:31.599 --> 00:42:35.200
really simple algorithm that I you know

00:42:33.559 --> 00:42:37.480
implemented with a few lines of python

00:42:35.200 --> 00:42:38.839
is essentially equivalent to this uh

00:42:37.480 --> 00:42:40.760
stochastic gradient descent that we

00:42:38.839 --> 00:42:44.559
doing

00:42:40.760 --> 00:42:46.359
models so the good news about this is

00:42:44.559 --> 00:42:48.359
you know this this is really simple but

00:42:46.359 --> 00:42:50.599
it only really works forit like a bag of

00:42:48.359 --> 00:42:55.400
words model or a simple feature based

00:42:50.599 --> 00:42:57.200
model uh but it opens up a lot of uh new

00:42:55.400 --> 00:43:00.440
possibilities for how we can optimize

00:42:57.200 --> 00:43:01.599
models and in particular I mentioned uh

00:43:00.440 --> 00:43:04.839
that there was a problem with

00:43:01.599 --> 00:43:08.200
combination features last class like

00:43:04.839 --> 00:43:11.200
don't hate and don't love are not just

00:43:08.200 --> 00:43:12.760
you know hate plus don't and love plus

00:43:11.200 --> 00:43:14.119
don't it's actually the combination of

00:43:12.760 --> 00:43:17.680
the two is really

00:43:14.119 --> 00:43:20.160
important and so um yeah just to give an

00:43:17.680 --> 00:43:23.440
example we have don't love is maybe bad

00:43:20.160 --> 00:43:26.960
uh nothing I don't love is very

00:43:23.440 --> 00:43:30.960
good and so in order

00:43:26.960 --> 00:43:34.040
to solve this problem we turn to neural

00:43:30.960 --> 00:43:37.160
networks and the way we do this is we

00:43:34.040 --> 00:43:39.119
have a lookup of dense embeddings sorry

00:43:37.160 --> 00:43:41.839
I actually I just realized my coloring

00:43:39.119 --> 00:43:44.119
is off I was using red to indicate dense

00:43:41.839 --> 00:43:46.480
embeddings so this should be maybe red

00:43:44.119 --> 00:43:49.319
instead of blue but um we take these

00:43:46.480 --> 00:43:51.200
stents embeddings and then we create

00:43:49.319 --> 00:43:53.720
some complicated function to extract

00:43:51.200 --> 00:43:55.079
combination features um and then use

00:43:53.720 --> 00:43:57.359
those to calculate

00:43:55.079 --> 00:44:02.200
scores

00:43:57.359 --> 00:44:04.480
um and so we calculate these combination

00:44:02.200 --> 00:44:08.240
features and what we want to do is we

00:44:04.480 --> 00:44:12.880
want to extract vectors from the input

00:44:08.240 --> 00:44:12.880
where each Vector has features

00:44:15.839 --> 00:44:21.040
um sorry this is in the wrong order so

00:44:18.240 --> 00:44:22.559
I'll I'll get back to this um so this

00:44:21.040 --> 00:44:25.319
this was talking about the The

00:44:22.559 --> 00:44:27.200
Continuous bag of words features so the

00:44:25.319 --> 00:44:30.960
problem with the continuous bag of words

00:44:27.200 --> 00:44:30.960
features was we were extracting

00:44:31.359 --> 00:44:36.359
features

00:44:33.079 --> 00:44:36.359
um like

00:44:36.839 --> 00:44:41.400
this but then we were directly using the

00:44:39.760 --> 00:44:43.359
the feature the dense features that we

00:44:41.400 --> 00:44:45.559
extracted to make predictions without

00:44:43.359 --> 00:44:48.839
actually allowing for any interactions

00:44:45.559 --> 00:44:51.839
between the features um and

00:44:48.839 --> 00:44:55.160
so uh neural networks the way we fix

00:44:51.839 --> 00:44:57.079
this is we first extract these features

00:44:55.160 --> 00:44:59.440
uh we take these these features of each

00:44:57.079 --> 00:45:04.000
word embedding and then we run them

00:44:59.440 --> 00:45:07.240
through uh kind of linear transforms in

00:45:04.000 --> 00:45:09.880
nonlinear uh like linear multiplications

00:45:07.240 --> 00:45:10.880
and then nonlinear transforms to extract

00:45:09.880 --> 00:45:13.920
additional

00:45:10.880 --> 00:45:15.839
features and uh finally run this through

00:45:13.920 --> 00:45:18.640
several layers and then use the

00:45:15.839 --> 00:45:21.119
resulting features to make our

00:45:18.640 --> 00:45:23.200
predictions and when we do this this

00:45:21.119 --> 00:45:25.319
allows us to do more uh interesting

00:45:23.200 --> 00:45:28.319
things so like for example we could

00:45:25.319 --> 00:45:30.000
learn feature combination a node in the

00:45:28.319 --> 00:45:32.599
second layer might be feature one and

00:45:30.000 --> 00:45:35.240
feature five are active so that could be

00:45:32.599 --> 00:45:38.680
like feature one corresponds to negative

00:45:35.240 --> 00:45:43.640
sentiment words like hate

00:45:38.680 --> 00:45:45.839
despise um and other things like that so

00:45:43.640 --> 00:45:50.079
for hate and despise feature one would

00:45:45.839 --> 00:45:53.119
have a high value like 8.0 and then

00:45:50.079 --> 00:45:55.480
7.2 and then we also have negation words

00:45:53.119 --> 00:45:57.040
like don't or not or something like that

00:45:55.480 --> 00:46:00.040
and those would

00:45:57.040 --> 00:46:00.040
have

00:46:03.720 --> 00:46:08.640
don't would have a high value for like 2

00:46:11.880 --> 00:46:15.839
five and so these would be the word

00:46:14.200 --> 00:46:18.040
embeddings where each word embedding

00:46:15.839 --> 00:46:20.599
corresponded to you know features of the

00:46:18.040 --> 00:46:23.480
words and

00:46:20.599 --> 00:46:25.480
then um after that we would extract

00:46:23.480 --> 00:46:29.319
feature combinations in this second

00:46:25.480 --> 00:46:32.079
layer that say oh we see at least one

00:46:29.319 --> 00:46:33.760
word where the first feature is active

00:46:32.079 --> 00:46:36.359
and we see at least one word where the

00:46:33.760 --> 00:46:37.920
fifth feature is active so now that

00:46:36.359 --> 00:46:40.640
allows us to capture the fact that we

00:46:37.920 --> 00:46:42.319
saw like don't hate or don't despise or

00:46:40.640 --> 00:46:44.559
not hate or not despise or something

00:46:42.319 --> 00:46:44.559
like

00:46:45.079 --> 00:46:51.760
that so this is the way uh kind of this

00:46:49.680 --> 00:46:54.839
is a deep uh continuous bag of words

00:46:51.760 --> 00:46:56.839
model um this actually was proposed in

00:46:54.839 --> 00:46:58.119
205 15 I don't think I have the

00:46:56.839 --> 00:47:02.599
reference on the slide but I think it's

00:46:58.119 --> 00:47:05.040
in the notes um on the website and

00:47:02.599 --> 00:47:07.200
actually at that point in time they

00:47:05.040 --> 00:47:09.200
demon there were several interesting

00:47:07.200 --> 00:47:11.960
results that showed that even this like

00:47:09.200 --> 00:47:13.960
really simple model did really well uh

00:47:11.960 --> 00:47:16.319
at text classification and other simple

00:47:13.960 --> 00:47:18.640
tasks like that because it was able to

00:47:16.319 --> 00:47:21.720
you know share features of the words and

00:47:18.640 --> 00:47:23.800
then extract combinations to the

00:47:21.720 --> 00:47:28.200
features

00:47:23.800 --> 00:47:29.760
so um in order order to learn these we

00:47:28.200 --> 00:47:30.920
need to start turning to neural networks

00:47:29.760 --> 00:47:34.400
and the reason why we need to start

00:47:30.920 --> 00:47:38.040
turning to neural networks is

00:47:34.400 --> 00:47:41.920
because while I can calculate the loss

00:47:38.040 --> 00:47:43.280
function of the while I can calculate

00:47:41.920 --> 00:47:44.839
the loss function of the hinged loss for

00:47:43.280 --> 00:47:47.720
a bag of words model by hand I

00:47:44.839 --> 00:47:49.359
definitely don't I probably could but

00:47:47.720 --> 00:47:51.240
don't want to do it for a model that

00:47:49.359 --> 00:47:53.200
starts become as complicated as this

00:47:51.240 --> 00:47:57.440
with multiple Matrix multiplications

00:47:53.200 --> 00:48:00.520
Andes and stuff like that so the way we

00:47:57.440 --> 00:48:05.000
do this just a very brief uh coverage of

00:48:00.520 --> 00:48:06.200
this uh for because um I think probably

00:48:05.000 --> 00:48:08.400
a lot of people have dealt with neural

00:48:06.200 --> 00:48:10.200
networks before um the original

00:48:08.400 --> 00:48:12.880
motivation was that we had neurons in

00:48:10.200 --> 00:48:16.160
the brain uh where

00:48:12.880 --> 00:48:18.839
the each of the neuron synapses took in

00:48:16.160 --> 00:48:21.480
an electrical signal and once they got

00:48:18.839 --> 00:48:24.079
enough electrical signal they would fire

00:48:21.480 --> 00:48:25.960
um but now the current conception of

00:48:24.079 --> 00:48:28.160
neural networks or deep learning models

00:48:25.960 --> 00:48:30.440
is basically computation

00:48:28.160 --> 00:48:32.400
graphs and the way a computation graph

00:48:30.440 --> 00:48:34.760
Works um and I'm especially going to

00:48:32.400 --> 00:48:36.240
talk about the way it works in natural

00:48:34.760 --> 00:48:38.119
language processing which might be a

00:48:36.240 --> 00:48:42.319
contrast to the way it works in computer

00:48:38.119 --> 00:48:43.960
vision is um we have an expression uh

00:48:42.319 --> 00:48:46.480
that looks like this and maybe maybe

00:48:43.960 --> 00:48:47.640
it's the expression X corresponding to

00:48:46.480 --> 00:48:51.880
uh a

00:48:47.640 --> 00:48:53.400
scal um and each node corresponds to

00:48:51.880 --> 00:48:55.599
something like a tensor a matrix a

00:48:53.400 --> 00:48:57.599
vector a scalar so scaler is uh kind

00:48:55.599 --> 00:49:00.480
kind of Zero Dimensional it's a single

00:48:57.599 --> 00:49:01.720
value one dimensional two dimensional or

00:49:00.480 --> 00:49:04.200
arbitrary

00:49:01.720 --> 00:49:06.040
dimensional um and then we also have

00:49:04.200 --> 00:49:08.000
nodes that correspond to the result of

00:49:06.040 --> 00:49:11.480
function applications so if we have X be

00:49:08.000 --> 00:49:14.079
a vector uh we take the vector transpose

00:49:11.480 --> 00:49:18.160
and so each Edge represents a function

00:49:14.079 --> 00:49:20.559
argument and also a data

00:49:18.160 --> 00:49:23.960
dependency and a node with an incoming

00:49:20.559 --> 00:49:27.000
Edge is a function of that Edge's tail

00:49:23.960 --> 00:49:29.040
node and importantly each node knows how

00:49:27.000 --> 00:49:30.640
to compute its value and the value of

00:49:29.040 --> 00:49:32.640
its derivative with respect to each

00:49:30.640 --> 00:49:34.440
argument times the derivative of an

00:49:32.640 --> 00:49:37.920
arbitrary

00:49:34.440 --> 00:49:41.000
input and functions could be basically

00:49:37.920 --> 00:49:45.400
arbitrary functions it can be unary Nary

00:49:41.000 --> 00:49:49.440
unary binary Nary often unary or binary

00:49:45.400 --> 00:49:52.400
and computation graphs are directed in

00:49:49.440 --> 00:49:57.040
cyclic and um one important thing to

00:49:52.400 --> 00:50:00.640
note is that you can um have multiple

00:49:57.040 --> 00:50:02.559
ways of expressing the same function so

00:50:00.640 --> 00:50:04.839
this is actually really important as you

00:50:02.559 --> 00:50:06.920
start implementing things and the reason

00:50:04.839 --> 00:50:09.359
why is the left graph and the right

00:50:06.920 --> 00:50:12.960
graph both express the same thing the

00:50:09.359 --> 00:50:18.640
left graph expresses X

00:50:12.960 --> 00:50:22.559
transpose time A Time X where is whereas

00:50:18.640 --> 00:50:27.160
this one has x a and then it puts it

00:50:22.559 --> 00:50:28.760
into a node that is X transpose a x

00:50:27.160 --> 00:50:30.319
and so these Express exactly the same

00:50:28.760 --> 00:50:32.319
thing but the graph on the left is

00:50:30.319 --> 00:50:33.760
larger and the reason why this is

00:50:32.319 --> 00:50:38.920
important is for practical

00:50:33.760 --> 00:50:40.359
implementation of neural networks um you

00:50:38.920 --> 00:50:43.200
the larger graphs are going to take more

00:50:40.359 --> 00:50:46.799
memory and going to be slower usually

00:50:43.200 --> 00:50:48.200
and so often um in a neural network we

00:50:46.799 --> 00:50:49.559
look at like pipe part which we're going

00:50:48.200 --> 00:50:52.160
to look at in a

00:50:49.559 --> 00:50:55.520
second

00:50:52.160 --> 00:50:57.920
um you will have something you will be

00:50:55.520 --> 00:50:57.920
able to

00:50:58.680 --> 00:51:01.680
do

00:51:03.079 --> 00:51:07.880
this or you'll be able to do

00:51:18.760 --> 00:51:22.880
like

00:51:20.359 --> 00:51:24.839
this so these are two different options

00:51:22.880 --> 00:51:26.920
this one is using more operations and

00:51:24.839 --> 00:51:29.559
this one is using using less operations

00:51:26.920 --> 00:51:31.000
and this is going to be faster because

00:51:29.559 --> 00:51:33.119
basically the implementation within

00:51:31.000 --> 00:51:34.799
Pythor will have been optimized for you

00:51:33.119 --> 00:51:36.799
it will only require one graph node

00:51:34.799 --> 00:51:37.880
instead of multiple graph nodes and

00:51:36.799 --> 00:51:39.799
that's even more important when you

00:51:37.880 --> 00:51:41.040
start talking about like attention or

00:51:39.799 --> 00:51:43.920
something like that which we're going to

00:51:41.040 --> 00:51:46.079
be covering very soon um attention is a

00:51:43.920 --> 00:51:47.359
very multi-head attention or something

00:51:46.079 --> 00:51:49.839
like that is a very complicated

00:51:47.359 --> 00:51:52.079
operation so you want to make sure that

00:51:49.839 --> 00:51:54.359
you're using the operators that are

00:51:52.079 --> 00:51:57.359
available to you to make this more

00:51:54.359 --> 00:51:57.359
efficient

00:51:57.440 --> 00:52:00.760
um and then finally we could like add

00:51:59.280 --> 00:52:01.920
all of these together at the end we

00:52:00.760 --> 00:52:04.000
could add a

00:52:01.920 --> 00:52:05.880
constant um and then we get this

00:52:04.000 --> 00:52:09.520
expression here which gives us kind of a

00:52:05.880 --> 00:52:09.520
polinomial polom

00:52:09.680 --> 00:52:15.760
expression um also another thing to note

00:52:13.480 --> 00:52:17.599
is within a neural network computation

00:52:15.760 --> 00:52:21.920
graph variable names are just labelings

00:52:17.599 --> 00:52:25.359
of nodes and so if you're using a a

00:52:21.920 --> 00:52:27.680
computation graph like this you might

00:52:25.359 --> 00:52:29.240
only be declaring one variable here but

00:52:27.680 --> 00:52:30.839
actually there's a whole bunch of stuff

00:52:29.240 --> 00:52:32.359
going on behind the scenes and all of

00:52:30.839 --> 00:52:34.240
that will take memory and computation

00:52:32.359 --> 00:52:35.440
time and stuff like that so it's

00:52:34.240 --> 00:52:37.119
important to be aware of that if you

00:52:35.440 --> 00:52:40.400
want to make your implementations more

00:52:37.119 --> 00:52:40.400
efficient than other other

00:52:41.119 --> 00:52:46.680
things so we have several algorithms

00:52:44.480 --> 00:52:49.079
that go into implementing neural nuts um

00:52:46.680 --> 00:52:50.760
the first one is graph construction uh

00:52:49.079 --> 00:52:53.480
the second one is forward

00:52:50.760 --> 00:52:54.839
propagation uh and graph construction is

00:52:53.480 --> 00:52:56.359
basically constructing the graph

00:52:54.839 --> 00:52:58.680
declaring ing all the variables stuff

00:52:56.359 --> 00:53:01.520
like this the second one is forward

00:52:58.680 --> 00:53:03.880
propagation and um the way you do this

00:53:01.520 --> 00:53:06.480
is in topological order uh you compute

00:53:03.880 --> 00:53:08.280
the value of a node given its inputs and

00:53:06.480 --> 00:53:11.000
so basically you start out with all of

00:53:08.280 --> 00:53:12.680
the nodes that you give is input and

00:53:11.000 --> 00:53:16.040
then you find any node in the graph

00:53:12.680 --> 00:53:17.799
where all of its uh all of its tail

00:53:16.040 --> 00:53:20.280
nodes or all of its children have been

00:53:17.799 --> 00:53:22.119
calculated so in this case that would be

00:53:20.280 --> 00:53:24.640
these two nodes and then in arbitrary

00:53:22.119 --> 00:53:27.000
order or even in parallel you calculate

00:53:24.640 --> 00:53:28.280
the value of all of the satisfied nodes

00:53:27.000 --> 00:53:31.799
until you get to the

00:53:28.280 --> 00:53:34.280
end and then uh the remaining algorithms

00:53:31.799 --> 00:53:36.200
are back propagation and parameter

00:53:34.280 --> 00:53:38.240
update I already talked about parameter

00:53:36.200 --> 00:53:40.799
update uh using stochastic gradient

00:53:38.240 --> 00:53:42.760
descent but for back propagation we then

00:53:40.799 --> 00:53:45.400
process examples in Reverse topological

00:53:42.760 --> 00:53:47.640
order uh calculate derivatives of

00:53:45.400 --> 00:53:50.400
parameters with respect to final

00:53:47.640 --> 00:53:52.319
value and so we start out with the very

00:53:50.400 --> 00:53:54.200
final value usually this is your loss

00:53:52.319 --> 00:53:56.200
function and then you just step

00:53:54.200 --> 00:54:00.440
backwards in top ological order to

00:53:56.200 --> 00:54:04.160
calculate the derivatives of all these

00:54:00.440 --> 00:54:05.920
so um this is pretty simple I think a

00:54:04.160 --> 00:54:08.040
lot of people may have seen this already

00:54:05.920 --> 00:54:09.920
but keeping this in mind as you're

00:54:08.040 --> 00:54:12.480
implementing NLP models especially

00:54:09.920 --> 00:54:14.240
models that are really memory intensive

00:54:12.480 --> 00:54:16.559
or things like that is pretty important

00:54:14.240 --> 00:54:19.040
because if you accidentally like for

00:54:16.559 --> 00:54:21.799
example calculate the same thing twice

00:54:19.040 --> 00:54:23.559
or accidentally create a graph that is

00:54:21.799 --> 00:54:25.720
manipulating very large tensors and

00:54:23.559 --> 00:54:27.319
creating very large intermediate States

00:54:25.720 --> 00:54:29.720
that can kill your memory and and cause

00:54:27.319 --> 00:54:31.839
big problems so it's an important thing

00:54:29.720 --> 00:54:31.839
to

00:54:34.359 --> 00:54:38.880
be um cool any any questions about

00:54:39.040 --> 00:54:44.440
this okay if not I will go on to the

00:54:41.680 --> 00:54:45.680
next one so neural network Frameworks

00:54:44.440 --> 00:54:48.920
there's several neural network

00:54:45.680 --> 00:54:52.880
Frameworks but in NLP nowadays I really

00:54:48.920 --> 00:54:55.079
only see two and mostly only see one um

00:54:52.880 --> 00:54:57.960
so that one that almost everybody us

00:54:55.079 --> 00:55:01.240
uses is pie torch um and I would

00:54:57.960 --> 00:55:04.559
recommend using it unless you uh you

00:55:01.240 --> 00:55:07.480
know if you're a fan of like rust or you

00:55:04.559 --> 00:55:09.200
know esoteric uh not esoteric but like

00:55:07.480 --> 00:55:11.960
unusual programming languages and you

00:55:09.200 --> 00:55:14.720
like Beauty and things like this another

00:55:11.960 --> 00:55:15.799
option might be Jacks uh so I'll explain

00:55:14.720 --> 00:55:18.440
a little bit about the difference

00:55:15.799 --> 00:55:19.960
between them uh and you can pick

00:55:18.440 --> 00:55:23.559
accordingly

00:55:19.960 --> 00:55:25.359
um first uh both of these Frameworks uh

00:55:23.559 --> 00:55:26.839
are developed by big companies and they

00:55:25.359 --> 00:55:28.520
have a lot of engineering support behind

00:55:26.839 --> 00:55:29.720
them that's kind of an important thing

00:55:28.520 --> 00:55:31.280
to think about when you're deciding

00:55:29.720 --> 00:55:32.599
which framework to use because you know

00:55:31.280 --> 00:55:36.000
it'll be well

00:55:32.599 --> 00:55:38.039
supported um pytorch is definitely most

00:55:36.000 --> 00:55:40.400
widely used in NLP especially NLP

00:55:38.039 --> 00:55:44.240
research um and it's used in some NLP

00:55:40.400 --> 00:55:47.359
project J is used in some NLP

00:55:44.240 --> 00:55:49.960
projects um pytorch favors Dynamic

00:55:47.359 --> 00:55:53.760
execution so what dynamic execution

00:55:49.960 --> 00:55:55.880
means is um you basically create a

00:55:53.760 --> 00:55:59.760
computation graph and and then execute

00:55:55.880 --> 00:56:02.760
it uh every time you process an input uh

00:55:59.760 --> 00:56:04.680
in contrast there's also you define the

00:56:02.760 --> 00:56:07.200
computation graph first and then execute

00:56:04.680 --> 00:56:09.280
it over and over again so in other words

00:56:07.200 --> 00:56:10.680
the graph construction step only happens

00:56:09.280 --> 00:56:13.119
once kind of at the beginning of

00:56:10.680 --> 00:56:16.799
computation and then you compile it

00:56:13.119 --> 00:56:20.039
afterwards and it's actually pytorch

00:56:16.799 --> 00:56:23.359
supports kind of defining and compiling

00:56:20.039 --> 00:56:27.480
and Jax supports more Dynamic things but

00:56:23.359 --> 00:56:30.160
the way they were designed is uh is kind

00:56:27.480 --> 00:56:32.960
of favoring Dynamic execution or

00:56:30.160 --> 00:56:37.079
favoring definition in population

00:56:32.960 --> 00:56:39.200
and the difference between these two is

00:56:37.079 --> 00:56:41.760
this one gives you more flexibility this

00:56:39.200 --> 00:56:45.440
one gives you better optimization in wor

00:56:41.760 --> 00:56:49.760
speed if you want to if you want to do

00:56:45.440 --> 00:56:52.400
that um another thing about Jax is um

00:56:49.760 --> 00:56:55.200
it's kind of very close to numpy in a

00:56:52.400 --> 00:56:57.440
way like it uses a very num something

00:56:55.200 --> 00:56:59.960
that's kind of close to numpy it's very

00:56:57.440 --> 00:57:02.359
heavily based on tensors and so because

00:56:59.960 --> 00:57:04.640
of this you can kind of easily do some

00:57:02.359 --> 00:57:06.640
interesting things like okay I want to

00:57:04.640 --> 00:57:11.319
take this tensor and I want to split it

00:57:06.640 --> 00:57:14.000
over two gpus um and this is good if

00:57:11.319 --> 00:57:17.119
you're training like a very large model

00:57:14.000 --> 00:57:20.920
and you want to put kind

00:57:17.119 --> 00:57:20.920
of this part of the

00:57:22.119 --> 00:57:26.520
model uh you want to put this part of

00:57:24.119 --> 00:57:30.079
the model on GP 1 this on gpu2 this on

00:57:26.520 --> 00:57:31.599
GPU 3 this on GPU it's slightly simpler

00:57:30.079 --> 00:57:34.400
conceptually to do in Jacks but it's

00:57:31.599 --> 00:57:37.160
also possible to do in

00:57:34.400 --> 00:57:39.119
p and pytorch by far has the most

00:57:37.160 --> 00:57:41.640
vibrant ecosystem so like as I said

00:57:39.119 --> 00:57:44.200
pytorch is a good default choice but you

00:57:41.640 --> 00:57:47.480
can consider using Jack if you uh if you

00:57:44.200 --> 00:57:47.480
like new

00:57:48.079 --> 00:57:55.480
things cool um yeah actually I already

00:57:51.599 --> 00:57:58.079
talked about that so in the interest of

00:57:55.480 --> 00:58:02.119
time I may not go into these very deeply

00:57:58.079 --> 00:58:05.799
but it's important to note that we have

00:58:02.119 --> 00:58:05.799
examples of all of

00:58:06.920 --> 00:58:12.520
the models that I talked about in the

00:58:09.359 --> 00:58:16.720
class today these are created for

00:58:12.520 --> 00:58:17.520
Simplicity not for Speed or efficiency

00:58:16.720 --> 00:58:20.480
of

00:58:17.520 --> 00:58:24.920
implementation um so these are kind of

00:58:20.480 --> 00:58:27.760
torch P torch based uh examples uh where

00:58:24.920 --> 00:58:31.599
you can create the bag of words

00:58:27.760 --> 00:58:36.440
Model A continuous bag of words

00:58:31.599 --> 00:58:39.640
model um and

00:58:36.440 --> 00:58:41.640
a deep continuous bag of wordss

00:58:39.640 --> 00:58:44.359
model

00:58:41.640 --> 00:58:46.039
and all of these I believe are

00:58:44.359 --> 00:58:48.760
implemented in

00:58:46.039 --> 00:58:51.960
model.py and the most important thing is

00:58:48.760 --> 00:58:54.960
where you define the forward pass and

00:58:51.960 --> 00:58:57.319
maybe I can just give a a simple example

00:58:54.960 --> 00:58:58.200
this but here this is where you do the

00:58:57.319 --> 00:59:01.839
word

00:58:58.200 --> 00:59:04.400
embedding this is where you sum up all

00:59:01.839 --> 00:59:08.119
of the embeddings and add a

00:59:04.400 --> 00:59:10.200
bias um and then this is uh where you

00:59:08.119 --> 00:59:13.960
return the the

00:59:10.200 --> 00:59:13.960
score and then oh

00:59:14.799 --> 00:59:19.119
sorry the continuous bag of words model

00:59:17.520 --> 00:59:22.160
sums up some

00:59:19.119 --> 00:59:23.640
embeddings uh or gets the embeddings

00:59:22.160 --> 00:59:25.799
sums up some

00:59:23.640 --> 00:59:28.079
embeddings

00:59:25.799 --> 00:59:30.599
uh gets the score here and then runs it

00:59:28.079 --> 00:59:33.200
through a linear or changes the view

00:59:30.599 --> 00:59:35.119
runs it through a linear layer and then

00:59:33.200 --> 00:59:38.319
the Deep continuous bag of words model

00:59:35.119 --> 00:59:41.160
also adds a few layers of uh like linear

00:59:38.319 --> 00:59:43.119
transformations in Dage so you should be

00:59:41.160 --> 00:59:44.640
able to see that these correspond pretty

00:59:43.119 --> 00:59:47.440
closely to the things that I had on the

00:59:44.640 --> 00:59:49.280
slides so um hopefully that's a good

00:59:47.440 --> 00:59:51.839
start if you're not very familiar with

00:59:49.280 --> 00:59:51.839
implementing

00:59:53.119 --> 00:59:58.440
model oh and yes the recitation uh will

00:59:56.599 --> 00:59:59.799
be about playing around with sentence

00:59:58.440 --> 01:00:01.200
piece and playing around with these so

00:59:59.799 --> 01:00:02.839
if you have any look at them have any

01:00:01.200 --> 01:00:05.000
questions you're welcome to show up

01:00:02.839 --> 01:00:09.880
where I walk

01:00:05.000 --> 01:00:09.880
through cool um any any questions about

01:00:12.839 --> 01:00:19.720
these okay so a few more final important

01:00:16.720 --> 01:00:21.720
Concepts um another concept that you

01:00:19.720 --> 01:00:25.440
should definitely be aware of is the

01:00:21.720 --> 01:00:27.280
atom Optimizer uh so there's lots of uh

01:00:25.440 --> 01:00:30.559
optimizers that you could be using but

01:00:27.280 --> 01:00:32.200
almost all research in NLP uses some uh

01:00:30.559 --> 01:00:38.440
variety of the atom

01:00:32.200 --> 01:00:40.839
Optimizer and the U the way this works

01:00:38.440 --> 01:00:42.559
is it

01:00:40.839 --> 01:00:45.640
optimizes

01:00:42.559 --> 01:00:48.480
the um it optimizes model considering

01:00:45.640 --> 01:00:49.359
the rolling average of the gradient and

01:00:48.480 --> 01:00:53.160
uh

01:00:49.359 --> 01:00:55.920
momentum and the way it works is here we

01:00:53.160 --> 01:00:58.839
have a gradient here we have

01:00:55.920 --> 01:01:04.000
momentum and what you can see is

01:00:58.839 --> 01:01:06.680
happening here is we add a little bit of

01:01:04.000 --> 01:01:09.200
the gradient in uh how much you add in

01:01:06.680 --> 01:01:12.720
is with respect to the size of this beta

01:01:09.200 --> 01:01:16.000
1 parameter and you add it into uh the

01:01:12.720 --> 01:01:18.640
momentum term so this momentum term like

01:01:16.000 --> 01:01:20.440
gradually increases and decreases so in

01:01:18.640 --> 01:01:23.440
contrast to standard gradient percent

01:01:20.440 --> 01:01:25.839
which could be

01:01:23.440 --> 01:01:28.440
updating

01:01:25.839 --> 01:01:31.440
uh each parameter kind of like very

01:01:28.440 --> 01:01:33.359
differently on each time step this will

01:01:31.440 --> 01:01:35.680
make the momentum kind of transition

01:01:33.359 --> 01:01:37.240
more smoothly by taking the rolling

01:01:35.680 --> 01:01:39.880
average of the

01:01:37.240 --> 01:01:43.400
gradient and then the the second thing

01:01:39.880 --> 01:01:47.640
is um by taking the momentum this is the

01:01:43.400 --> 01:01:51.000
rolling average of the I guess gradient

01:01:47.640 --> 01:01:54.440
uh variance sorry I this should be

01:01:51.000 --> 01:01:58.079
variance and the reason why you need

01:01:54.440 --> 01:02:01.319
need to keep track of the variance is

01:01:58.079 --> 01:02:03.319
some uh some parameters will have very

01:02:01.319 --> 01:02:06.559
large variance in their gradients and

01:02:03.319 --> 01:02:11.480
might fluctuate very uh strongly and

01:02:06.559 --> 01:02:13.039
others might have a smaller uh chain

01:02:11.480 --> 01:02:15.240
variant in their gradients and not

01:02:13.039 --> 01:02:18.240
fluctuate very much but we want to make

01:02:15.240 --> 01:02:20.200
sure that we update the ones we still

01:02:18.240 --> 01:02:22.240
update the ones that have a very small

01:02:20.200 --> 01:02:25.760
uh change of their variance and the

01:02:22.240 --> 01:02:27.440
reason why is kind of let's say you have

01:02:25.760 --> 01:02:30.440
a

01:02:27.440 --> 01:02:30.440
multi-layer

01:02:32.480 --> 01:02:38.720
network

01:02:34.480 --> 01:02:41.240
um or actually sorry a better

01:02:38.720 --> 01:02:44.319
um a better example is like let's say we

01:02:41.240 --> 01:02:47.559
have a big word embedding Matrix and

01:02:44.319 --> 01:02:53.359
over here we have like really frequent

01:02:47.559 --> 01:02:56.279
words and then over here we have uh

01:02:53.359 --> 01:02:59.319
gradi

01:02:56.279 --> 01:03:00.880
no we have like less frequent words we

01:02:59.319 --> 01:03:02.799
want to make sure that all of these get

01:03:00.880 --> 01:03:06.160
updated appropriately all of these get

01:03:02.799 --> 01:03:08.640
like enough updates and so over here

01:03:06.160 --> 01:03:10.760
this one will have lots of updates and

01:03:08.640 --> 01:03:13.680
so uh kind of

01:03:10.760 --> 01:03:16.599
the amount that we

01:03:13.680 --> 01:03:20.039
update or the the amount that we update

01:03:16.599 --> 01:03:21.799
the uh this will be relatively large

01:03:20.039 --> 01:03:23.119
whereas over here this will not have

01:03:21.799 --> 01:03:24.880
very many updates we'll have lots of

01:03:23.119 --> 01:03:26.480
zero updates also

01:03:24.880 --> 01:03:29.160
and so the amount that we update this

01:03:26.480 --> 01:03:32.520
will be relatively small and so this

01:03:29.160 --> 01:03:36.119
kind of squared to gradient here will uh

01:03:32.520 --> 01:03:38.400
be smaller for the values over here and

01:03:36.119 --> 01:03:41.359
what that allows us to do is it allows

01:03:38.400 --> 01:03:44.200
us to maybe I can just go to the bottom

01:03:41.359 --> 01:03:46.039
we end up uh dividing by the square root

01:03:44.200 --> 01:03:47.599
of this and because we divide by the

01:03:46.039 --> 01:03:51.000
square root of this if this is really

01:03:47.599 --> 01:03:55.680
large like 50 and 70 and then this over

01:03:51.000 --> 01:03:59.480
here is like one 0.5

01:03:55.680 --> 01:04:01.920
uh or something we will be upgrading the

01:03:59.480 --> 01:04:03.920
ones that have like less Square

01:04:01.920 --> 01:04:06.880
gradients so it will it allows you to

01:04:03.920 --> 01:04:08.760
upweight the less common gradients more

01:04:06.880 --> 01:04:10.440
frequently and then there's also some

01:04:08.760 --> 01:04:13.400
terms for correcting bias early in

01:04:10.440 --> 01:04:16.440
training because these momentum in uh in

01:04:13.400 --> 01:04:19.559
variance or momentum in squared gradient

01:04:16.440 --> 01:04:23.119
terms are not going to be like well

01:04:19.559 --> 01:04:24.839
calibrated yet so it prevents them from

01:04:23.119 --> 01:04:28.880
going very three wire beginning of

01:04:24.839 --> 01:04:30.839
training so this is uh the details of

01:04:28.880 --> 01:04:33.640
this again are not like super super

01:04:30.839 --> 01:04:37.359
important um another thing that I didn't

01:04:33.640 --> 01:04:40.200
write on the slides is uh now in

01:04:37.359 --> 01:04:43.920
Transformers it's also super common to

01:04:40.200 --> 01:04:47.400
have an overall learning rate schle so

01:04:43.920 --> 01:04:50.520
even um Even Adam has this uh Ada

01:04:47.400 --> 01:04:53.440
learning rate parameter here and we what

01:04:50.520 --> 01:04:55.240
we often do is we adjust this so we

01:04:53.440 --> 01:04:57.839
start at low

01:04:55.240 --> 01:04:59.640
we raise it up and then we have a Decay

01:04:57.839 --> 01:05:03.039
uh at the end and exactly how much you

01:04:59.640 --> 01:05:04.440
do this kind of depends on um you know

01:05:03.039 --> 01:05:06.160
how big your model is how much data

01:05:04.440 --> 01:05:09.160
you're tring on eventually and the

01:05:06.160 --> 01:05:12.440
reason why we do this is transformers

01:05:09.160 --> 01:05:13.839
are unfortunately super sensitive to

01:05:12.440 --> 01:05:15.359
having a high learning rate right at the

01:05:13.839 --> 01:05:16.559
very beginning so if you update them

01:05:15.359 --> 01:05:17.920
with a high learning rate right at the

01:05:16.559 --> 01:05:22.920
very beginning they go haywire and you

01:05:17.920 --> 01:05:24.400
get a really weird model um and but you

01:05:22.920 --> 01:05:26.760
want to raise it eventually so your

01:05:24.400 --> 01:05:28.920
model is learning appropriately and then

01:05:26.760 --> 01:05:30.400
in all stochastic gradient descent no

01:05:28.920 --> 01:05:31.680
matter whether you're using atom or

01:05:30.400 --> 01:05:33.400
anything else it's a good idea to

01:05:31.680 --> 01:05:36.200
gradually decrease the learning rate at

01:05:33.400 --> 01:05:38.119
the end to prevent the model from

01:05:36.200 --> 01:05:40.480
continuing to fluctuate and getting it

01:05:38.119 --> 01:05:42.760
to a stable point that gives you good

01:05:40.480 --> 01:05:45.559
accuracy over a large part of data so

01:05:42.760 --> 01:05:47.480
this is often included like if you look

01:05:45.559 --> 01:05:51.000
at any standard Transformer training

01:05:47.480 --> 01:05:53.079
recipe it will have that this so that's

01:05:51.000 --> 01:05:54.799
kind of the the go-to

01:05:53.079 --> 01:05:58.960
optimizer

01:05:54.799 --> 01:06:01.039
um are there any questions or

01:05:58.960 --> 01:06:02.599
discussion there's also tricky things

01:06:01.039 --> 01:06:04.000
like cyclic learning rates where you

01:06:02.599 --> 01:06:06.599
decrease the learning rate increase it

01:06:04.000 --> 01:06:08.559
and stuff like that but I won't go into

01:06:06.599 --> 01:06:11.000
that and don't actually use it that

01:06:08.559 --> 01:06:12.760
much second thing is visualization of

01:06:11.000 --> 01:06:15.400
embeddings so normally when we have word

01:06:12.760 --> 01:06:19.760
embeddings usually they're kind of large

01:06:15.400 --> 01:06:21.559
um and they can be like 512 or 1024

01:06:19.760 --> 01:06:25.079
dimensions

01:06:21.559 --> 01:06:28.720
and so one thing that we can do is we

01:06:25.079 --> 01:06:31.079
can down weight them or sorry down uh

01:06:28.720 --> 01:06:34.400
like reduce the dimensions or perform

01:06:31.079 --> 01:06:35.880
dimensionality reduction and put them in

01:06:34.400 --> 01:06:37.680
like two or three dimensions which are

01:06:35.880 --> 01:06:40.200
easy for humans to

01:06:37.680 --> 01:06:42.000
visualize this is an example using

01:06:40.200 --> 01:06:44.839
principal component analysis which is a

01:06:42.000 --> 01:06:48.279
linear Dimension reduction technique and

01:06:44.839 --> 01:06:50.680
this is uh an example from 10 years ago

01:06:48.279 --> 01:06:52.359
now uh one of the first major word

01:06:50.680 --> 01:06:55.240
embedding papers where they demonstrated

01:06:52.359 --> 01:06:57.720
that if you do this sort of linear

01:06:55.240 --> 01:06:59.440
Dimension reduction uh you get actually

01:06:57.720 --> 01:07:01.279
some interesting things where you can

01:06:59.440 --> 01:07:03.240
draw a vector that's almost the same

01:07:01.279 --> 01:07:06.400
direction between like countries and

01:07:03.240 --> 01:07:09.319
their uh countries and their capitals

01:07:06.400 --> 01:07:13.720
for example so this is a good thing to

01:07:09.319 --> 01:07:16.559
do but actually PCA uh doesn't give

01:07:13.720 --> 01:07:20.760
you in some cases PCA doesn't give you

01:07:16.559 --> 01:07:22.920
super great uh visualizations sorry yeah

01:07:20.760 --> 01:07:25.920
well for like if it's

01:07:22.920 --> 01:07:25.920
like

01:07:29.880 --> 01:07:35.039
um for things like this I think you

01:07:33.119 --> 01:07:37.359
probably would still see vectors in the

01:07:35.039 --> 01:07:38.760
same direction but I don't think it like

01:07:37.359 --> 01:07:40.920
there's a reason why I'm introducing

01:07:38.760 --> 01:07:44.279
nonlinear projections next because the

01:07:40.920 --> 01:07:46.799
more standard way to do this is uh

01:07:44.279 --> 01:07:50.640
nonlinear projections in in particular a

01:07:46.799 --> 01:07:54.880
method called tisne and the way um they

01:07:50.640 --> 01:07:56.880
do this is they try to group

01:07:54.880 --> 01:07:59.000
things that are close together in high

01:07:56.880 --> 01:08:01.240
dimensional space so that they're also

01:07:59.000 --> 01:08:04.440
close together in low dimensional space

01:08:01.240 --> 01:08:08.520
but they remove the Restriction that

01:08:04.440 --> 01:08:10.799
this is uh that this is linear so this

01:08:08.520 --> 01:08:15.480
is an example of just grouping together

01:08:10.799 --> 01:08:18.040
some digits uh from the memus data

01:08:15.480 --> 01:08:20.279
set or sorry reducing the dimension of

01:08:18.040 --> 01:08:23.640
digits from the mest data

01:08:20.279 --> 01:08:25.640
set according to PCA and you can see it

01:08:23.640 --> 01:08:28.000
gives these kind of blobs that overlap

01:08:25.640 --> 01:08:29.799
with each other and stuff like this but

01:08:28.000 --> 01:08:31.679
if you do it with tney this is

01:08:29.799 --> 01:08:34.799
completely unsupervised actually it's

01:08:31.679 --> 01:08:37.080
not training any model for labeling the

01:08:34.799 --> 01:08:39.239
labels are just used to draw the colors

01:08:37.080 --> 01:08:42.520
and you can see that it gets pretty

01:08:39.239 --> 01:08:44.520
coherent um clusters that correspond to

01:08:42.520 --> 01:08:48.120
like what the actual digits

01:08:44.520 --> 01:08:50.120
are um however uh one problem with

01:08:48.120 --> 01:08:53.159
titney I I still think it's better than

01:08:50.120 --> 01:08:55.000
PCA for a large number of uh

01:08:53.159 --> 01:08:59.199
applications

01:08:55.000 --> 01:09:01.040
but settings of tisy matter and tisy has

01:08:59.199 --> 01:09:02.920
a few settings kind of the most

01:09:01.040 --> 01:09:04.120
important ones are the overall

01:09:02.920 --> 01:09:06.560
perplexity

01:09:04.120 --> 01:09:09.040
hyperparameter and uh the number of

01:09:06.560 --> 01:09:12.319
steps that you perform and there's a

01:09:09.040 --> 01:09:14.920
nice example uh of a paper or kind of

01:09:12.319 --> 01:09:16.359
like online post uh that demonstrates

01:09:14.920 --> 01:09:18.560
how if you change these parameters you

01:09:16.359 --> 01:09:22.279
can get very different things so if this

01:09:18.560 --> 01:09:24.080
is the original data you run tisy and it

01:09:22.279 --> 01:09:26.640
gives you very different things based on

01:09:24.080 --> 01:09:29.279
the hyper parameters that you change um

01:09:26.640 --> 01:09:32.880
and here's another example uh you have

01:09:29.279 --> 01:09:36.960
two linear uh things like this and so

01:09:32.880 --> 01:09:40.839
PCA no matter how you ran PCA you would

01:09:36.960 --> 01:09:44.080
still get a linear output from this so

01:09:40.839 --> 01:09:45.960
normally uh you know it might change the

01:09:44.080 --> 01:09:49.239
order it might squash it a little bit or

01:09:45.960 --> 01:09:51.239
something like this but um if you run

01:09:49.239 --> 01:09:53.400
tisy it gives you crazy things it even

01:09:51.239 --> 01:09:56.040
gives you like DNA and other stuff like

01:09:53.400 --> 01:09:58.040
that so so um you do need to be a little

01:09:56.040 --> 01:10:00.600
bit careful that uh this is not

01:09:58.040 --> 01:10:02.320
necessarily going to tell you nice

01:10:00.600 --> 01:10:04.400
linear correlations like this so like

01:10:02.320 --> 01:10:06.159
let's say this correlation existed if

01:10:04.400 --> 01:10:09.199
you use tisy it might not necessarily

01:10:06.159 --> 01:10:09.199
come out to

01:10:09.320 --> 01:10:14.880
TIY

01:10:11.800 --> 01:10:16.920
cool yep uh that that's my final thing

01:10:14.880 --> 01:10:18.520
actually I talked said sequence models

01:10:16.920 --> 01:10:19.679
in the next class but it's in the class

01:10:18.520 --> 01:10:21.440
after this I'm going to be talking about

01:10:19.679 --> 01:10:24.199
language

01:10:21.440 --> 01:10:27.159
modeling uh cool any any questions

01:10:24.199 --> 01:10:27.159
or