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 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
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
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
1
00:00:00,040 --> 00:00:03,880
so today I'm going to talk about

2
00:00:01,319 --> 00:00:06,680
retrieval and retrieval augmented

3
00:00:03,880 --> 00:00:09,040
generation so if we look at our standard

4
00:00:06,680 --> 00:00:10,880
prompting flow normally what we do is we

5
00:00:09,040 --> 00:00:14,160
combine together a prompt template with

6
00:00:10,880 --> 00:00:16,600
an input so if we say please answer this

7
00:00:14,160 --> 00:00:18,720
question I think Vin Diesel has been a

8
00:00:16,600 --> 00:00:21,000
voice actor for several pictors in TV

9
00:00:18,720 --> 00:00:24,000
series do you know what their names

10
00:00:21,000 --> 00:00:25,400
are we could get a response from a

11
00:00:24,000 --> 00:00:26,840
language model but there are several

12
00:00:25,400 --> 00:00:30,840
problems with

13
00:00:26,840 --> 00:00:33,680
this the first is accuracy issues

14
00:00:30,840 --> 00:00:36,160
the models generally have a knowledge

15
00:00:33,680 --> 00:00:38,879
cut off so the parameters are usually

16
00:00:36,160 --> 00:00:41,120
only updated to a particular time so for

17
00:00:38,879 --> 00:00:43,200
example if a new Vin Diesel TV series

18
00:00:41,120 --> 00:00:44,960
comes out then the model that was

19
00:00:43,200 --> 00:00:47,440
trained up to a certain time Point won't

20
00:00:44,960 --> 00:00:51,000
be able to know anything about

21
00:00:47,440 --> 00:00:53,600
it there's also issues of private data

22
00:00:51,000 --> 00:00:55,320
so data stored in private text or data

23
00:00:53,600 --> 00:00:57,840
repositories is not suitable for

24
00:00:55,320 --> 00:01:02,600
training for a number of reasons number

25
00:00:57,840 --> 00:01:05,199
one it's not available to to particular

26
00:01:02,600 --> 00:01:07,799
language model training providers such

27
00:01:05,199 --> 00:01:10,720
as you know open AI or Google or anybody

28
00:01:07,799 --> 00:01:13,840
else like this the second thing is

29
00:01:10,720 --> 00:01:16,799
Access Control issues so even if you're

30
00:01:13,840 --> 00:01:17,840
within an organization that has lots of

31
00:01:16,799 --> 00:01:20,799
private data and you can train a

32
00:01:17,840 --> 00:01:22,600
language model on that certain people in

33
00:01:20,799 --> 00:01:24,200
the organization may have access to

34
00:01:22,600 --> 00:01:27,640
certain varieties of data and other

35
00:01:24,200 --> 00:01:29,400
people may not so it's not just solely

36
00:01:27,640 --> 00:01:31,520
an issue of third party providers it's

37
00:01:29,400 --> 00:01:33,840
an issue of organization level Access

38
00:01:31,520 --> 00:01:36,159
Control in

39
00:01:33,840 --> 00:01:38,920
general in addition there are learning

40
00:01:36,159 --> 00:01:40,320
failures so even for data that the model

41
00:01:38,920 --> 00:01:42,640
was trained on it might not be

42
00:01:40,320 --> 00:01:44,399
sufficient to get the right answer and

43
00:01:42,640 --> 00:01:47,799
this is particularly the case for very

44
00:01:44,399 --> 00:01:52,320
very large uh training data sets and

45
00:01:47,799 --> 00:01:53,920
models that are you know modestly sized

46
00:01:52,320 --> 00:01:55,880
because the models very often won't be

47
00:01:53,920 --> 00:01:58,360
able to learn from a single look at a

48
00:01:55,880 --> 00:02:02,039
particular fact or or whatever else like

49
00:01:58,360 --> 00:02:02,039
this especially if iter early in

50
00:02:02,159 --> 00:02:08,160
training another thing is even if the

51
00:02:05,240 --> 00:02:10,599
answer is correct it might not be

52
00:02:08,160 --> 00:02:13,440
verifiable so you might want to be very

53
00:02:10,599 --> 00:02:15,000
sure that the model is not making any

54
00:02:13,440 --> 00:02:17,640
accuracy

55
00:02:15,000 --> 00:02:19,040
problems and so in order to do that very

56
00:02:17,640 --> 00:02:21,879
often a human will want to go back to

57
00:02:19,040 --> 00:02:21,879
the source of the

58
00:02:22,200 --> 00:02:27,319
data so to solve this there's a method

59
00:02:25,480 --> 00:02:29,200
called retrieval augmented generation

60
00:02:27,319 --> 00:02:30,280
which will also be the topic of our

61
00:02:29,200 --> 00:02:32,599
second assignment

62
00:02:30,280 --> 00:02:35,680
here and the way it works is you

63
00:02:32,599 --> 00:02:38,319
retrieve relevant passages

64
00:02:35,680 --> 00:02:40,680
efficiently ones that kind of entail the

65
00:02:38,319 --> 00:02:42,480
answer to a question and then read the

66
00:02:40,680 --> 00:02:46,080
passages to answer the

67
00:02:42,480 --> 00:02:48,599
query so we have documents like this we

68
00:02:46,080 --> 00:02:52,360
have a query based on the query we form

69
00:02:48,599 --> 00:02:55,360
retrieval we get a whole bunch of uh

70
00:02:52,360 --> 00:02:57,560
passages we do reading and then we get

71
00:02:55,360 --> 00:02:57,560
the

72
00:02:58,280 --> 00:03:04,440
answer so this is in fact implemented in

73
00:03:01,720 --> 00:03:07,599
many or even most uh language modeling

74
00:03:04,440 --> 00:03:09,840
providers including open AI so to give

75
00:03:07,599 --> 00:03:11,480
an example I asked the question that I

76
00:03:09,840 --> 00:03:12,879
just said about Vin Diesel's voice

77
00:03:11,480 --> 00:03:16,599
acting and TV

78
00:03:12,879 --> 00:03:19,760
series and Chad GPT gave me an answer

79
00:03:16,599 --> 00:03:22,440
and you can see that J gpt's answer

80
00:03:19,760 --> 00:03:24,720
includes several places with quotes um

81
00:03:22,440 --> 00:03:28,159
they the little blue quotes

82
00:03:24,720 --> 00:03:30,760
there and if you click on the quote it

83
00:03:28,159 --> 00:03:33,120
tells you where the information Source

84
00:03:30,760 --> 00:03:35,000
came from and so this one says behind

85
00:03:33,120 --> 00:03:37,760
the voice actors been

86
00:03:35,000 --> 00:03:39,920
Diesel and behind the voice actors TV

87
00:03:37,760 --> 00:03:42,959
shows Big Mouth V

88
00:03:39,920 --> 00:03:45,640
diesel now if we look

89
00:03:42,959 --> 00:03:48,640
closer into this answer we'll see that

90
00:03:45,640 --> 00:03:49,959
it's not perfect even though it is uh

91
00:03:48,640 --> 00:03:52,519
performing retrieval augmented

92
00:03:49,959 --> 00:03:54,840
Generations so for example I only asked

93
00:03:52,519 --> 00:03:57,200
about TV series but it's giving me lots

94
00:03:54,840 --> 00:03:59,680
of things about movies where it says

95
00:03:57,200 --> 00:04:01,319
Groot in Guardians of the Galaxy volume

96
00:03:59,680 --> 00:04:04,480
3 2023

97
00:04:01,319 --> 00:04:07,200
movie and in fact uh Vin Diesel was not

98
00:04:04,480 --> 00:04:10,920
even voicing a character named gut here

99
00:04:07,200 --> 00:04:13,480
so that's definitely an accuracy

100
00:04:10,920 --> 00:04:15,079
mistake and separately there's a place

101
00:04:13,480 --> 00:04:17,639
where it says additionally though the

102
00:04:15,079 --> 00:04:19,959
website for big mouthless Vin Diesel it

103
00:04:17,639 --> 00:04:22,040
appears to be a misunderstanding or err

104
00:04:19,959 --> 00:04:25,360
as Nick croll is credited as the voice

105
00:04:22,040 --> 00:04:27,800
of Vin Diesel in that show so there

106
00:04:25,360 --> 00:04:30,039
actually Nick croll was acting as V

107
00:04:27,800 --> 00:04:32,800
diesel but that's um kind of a

108
00:04:30,039 --> 00:04:34,600
misunderstanding of the reader model but

109
00:04:32,800 --> 00:04:36,600
anyway you can get the general idea here

110
00:04:34,600 --> 00:04:40,199
you can also see that it's not perfect

111
00:04:36,600 --> 00:04:42,720
even for very strong models like GPD

112
00:04:40,199 --> 00:04:44,800
4 so now I'd like to go into the actual

113
00:04:42,720 --> 00:04:46,759
methodology that we use for this uh we

114
00:04:44,800 --> 00:04:50,360
have retrieval

115
00:04:46,759 --> 00:04:53,160
methods and for the retrieval methods we

116
00:04:50,360 --> 00:04:55,160
have uh quite a few different options

117
00:04:53,160 --> 00:04:57,960
I'm going to go through each one of them

118
00:04:55,160 --> 00:05:00,960
at a time so sparse retrieval document

119
00:04:57,960 --> 00:05:04,240
level dense retrieval token level DSE

120
00:05:00,960 --> 00:05:08,039
retrieval cross- encoder reranking and

121
00:05:04,240 --> 00:05:09,320
blackbox retrieval so blackbox retrieval

122
00:05:08,039 --> 00:05:11,280
I'm not really going to go into it a

123
00:05:09,320 --> 00:05:16,000
whole lot basically this is just asking

124
00:05:11,280 --> 00:05:17,560
a blackbox search engine to retrieve uh

125
00:05:16,000 --> 00:05:20,000
you know the relevant context and

126
00:05:17,560 --> 00:05:22,560
getting the top several results

127
00:05:20,000 --> 00:05:24,039
nonetheless this is a pretty you know

128
00:05:22,560 --> 00:05:26,800
reasonable method to do it if you want

129
00:05:24,039 --> 00:05:29,080
to do search over you know lots of data

130
00:05:26,800 --> 00:05:32,759
that exists on the internet already and

131
00:05:29,080 --> 00:05:36,600
that in is what chat jpt does it looks

132
00:05:32,759 --> 00:05:39,240
up on Bing by generating a query to

133
00:05:36,600 --> 00:05:41,560
Bing so anyway let's go into the actual

134
00:05:39,240 --> 00:05:43,840
methods that you develop and control

135
00:05:41,560 --> 00:05:46,600
yourself so the first one is sparse

136
00:05:43,840 --> 00:05:48,479
retrieval and the way this works is you

137
00:05:46,600 --> 00:05:50,440
express the query and document as a

138
00:05:48,479 --> 00:05:53,680
sparse word frequency Vector usually

139
00:05:50,440 --> 00:05:58,759
normalized by length and so if I ask uh

140
00:05:53,680 --> 00:06:01,720
query what is NLP we get a vector where

141
00:05:58,759 --> 00:06:04,120
each row the vector corresponds to a

142
00:06:01,720 --> 00:06:07,919
different

143
00:06:04,120 --> 00:06:12,960
token and we asked what is

144
00:06:07,919 --> 00:06:16,360
NLP and so uh the places for what NLP

145
00:06:12,960 --> 00:06:18,199
and is will all have a non-zero value

146
00:06:16,360 --> 00:06:20,199
and everything else will have a zero

147
00:06:18,199 --> 00:06:21,720
value and we also normalize by the

148
00:06:20,199 --> 00:06:24,120
length of vectors so we get something

149
00:06:21,720 --> 00:06:24,120
like

150
00:06:24,840 --> 00:06:28,440
333333 then we have a whole bunch of

151
00:06:26,759 --> 00:06:30,720
documents so the first document says

152
00:06:28,440 --> 00:06:31,759
what is life can is life someone really

153
00:06:30,720 --> 00:06:33,960
likes

154
00:06:31,759 --> 00:06:36,000
candy we also have another one that says

155
00:06:33,960 --> 00:06:38,360
NLP as an acronym for natural language

156
00:06:36,000 --> 00:06:39,479
processing so this is a pretty good uh

157
00:06:38,360 --> 00:06:42,479
you

158
00:06:39,479 --> 00:06:44,840
know answer to our

159
00:06:42,479 --> 00:06:48,039
question then we also have I like to do

160
00:06:44,840 --> 00:06:49,360
good research on NLP which is you know a

161
00:06:48,039 --> 00:06:51,360
nice sentiment but not a very good

162
00:06:49,360 --> 00:06:54,400
answer to our question I

163
00:06:51,360 --> 00:06:59,479
guess so if we look at the vectors here

164
00:06:54,400 --> 00:07:03,280
we have uh what and candy and is have uh

165
00:06:59,479 --> 00:07:07,120
a fairly high

166
00:07:03,280 --> 00:07:12,520
score and we have here NLP and is have a

167
00:07:07,120 --> 00:07:16,479
high score and NLP has a a nonzero

168
00:07:12,520 --> 00:07:18,400
score So based on this um we find the

169
00:07:16,479 --> 00:07:20,560
document similarity with the highest

170
00:07:18,400 --> 00:07:22,039
inner product or cosine similarity in

171
00:07:20,560 --> 00:07:24,360
the document

172
00:07:22,039 --> 00:07:27,000
collection and so if we take the inner

173
00:07:24,360 --> 00:07:28,759
product between these vectors we

174
00:07:27,000 --> 00:07:31,280
actually see that the first one got the

175
00:07:28,759 --> 00:07:34,479
highest score because of its

176
00:07:31,280 --> 00:07:37,440
relatively High values for the words

177
00:07:34,479 --> 00:07:37,440
what and

178
00:07:38,160 --> 00:07:43,759
is

179
00:07:40,199 --> 00:07:46,720
so as you can see common words like what

180
00:07:43,759 --> 00:07:49,000
and is can get a high score kind of

181
00:07:46,720 --> 00:07:51,800
regardless of whether a document is very

182
00:07:49,000 --> 00:07:53,919
relevant and so one way we can fix this

183
00:07:51,800 --> 00:07:55,960
is through something called term

184
00:07:53,919 --> 00:07:59,479
waiting and the way that term waiting

185
00:07:55,960 --> 00:08:02,680
works is in addition to having this

186
00:07:59,479 --> 00:08:04,599
Vector that

187
00:08:02,680 --> 00:08:07,680
calculates

188
00:08:04,599 --> 00:08:10,680
the frequency within a particular

189
00:08:07,680 --> 00:08:13,639
document we also have an upweighting

190
00:08:10,680 --> 00:08:15,599
term that gives higher weight to low

191
00:08:13,639 --> 00:08:18,199
frequency words because low frequency

192
00:08:15,599 --> 00:08:20,280
words like NLP tend to be more

193
00:08:18,199 --> 00:08:22,759
informative about whether the document

194
00:08:20,280 --> 00:08:25,240
is relevant than high frequency words

195
00:08:22,759 --> 00:08:27,080
like what it is because these high

196
00:08:25,240 --> 00:08:31,320
frequency words like what and is Could

197
00:08:27,080 --> 00:08:34,279
Happen kind of regardless of whether

198
00:08:31,320 --> 00:08:36,680
the you know document is relevant the

199
00:08:34,279 --> 00:08:41,800
particular terms the person is asking

200
00:08:36,680 --> 00:08:44,000
about so one well used and easy to

201
00:08:41,800 --> 00:08:46,560
understand version of this is uh tfidf

202
00:08:44,000 --> 00:08:48,839
or term frequency indument

203
00:08:46,560 --> 00:08:51,200
frequency so the way we Define term

204
00:08:48,839 --> 00:08:52,959
frequency is exactly what I talked about

205
00:08:51,200 --> 00:08:56,959
before so it's basically the frequency

206
00:08:52,959 --> 00:08:59,839
of the term uh T in the document d

207
00:08:56,959 --> 00:09:01,640
normalized by the total term frequency

208
00:08:59,839 --> 00:09:03,680
within the document so that that's what

209
00:09:01,640 --> 00:09:06,800
I already showed in the previous

210
00:09:03,680 --> 00:09:09,360
slide and then indument frequency is a

211
00:09:06,800 --> 00:09:13,760
little bit more involved but basically

212
00:09:09,360 --> 00:09:15,760
the way this works is we have log of the

213
00:09:13,760 --> 00:09:18,160
total number of documents in the

214
00:09:15,760 --> 00:09:24,040
collection divided

215
00:09:18,160 --> 00:09:26,760
by the total number of uh times this

216
00:09:24,040 --> 00:09:30,279
term appeared in any particular

217
00:09:26,760 --> 00:09:33,360
document and so if a term appears many

218
00:09:30,279 --> 00:09:36,120
times in any particular document it will

219
00:09:33,360 --> 00:09:39,240
have a low IDF score uh one that's close

220
00:09:36,120 --> 00:09:41,519
to zero but if it rarely appears it will

221
00:09:39,240 --> 00:09:44,120
have a high IDF score so basically this

222
00:09:41,519 --> 00:09:45,040
is upweighting our frequent terms and

223
00:09:44,120 --> 00:09:47,560
then for

224
00:09:45,040 --> 00:09:51,320
tfidf uh we basically multiply these two

225
00:09:47,560 --> 00:09:53,120
terms together and we upweight the low

226
00:09:51,320 --> 00:09:55,640
frequency

227
00:09:53,120 --> 00:10:00,519
words there's another version of this

228
00:09:55,640 --> 00:10:03,640
called bm25 that is uh widely used used

229
00:10:00,519 --> 00:10:05,800
um this is more involved so I'm not

230
00:10:03,640 --> 00:10:08,120
going to go into all of the details but

231
00:10:05,800 --> 00:10:12,399
basically if you remember back to the

232
00:10:08,120 --> 00:10:13,720
lecture on count-based language models

233
00:10:12,399 --> 00:10:14,880
there were a bunch of smoothing

234
00:10:13,720 --> 00:10:18,839
techniques for these count-based

235
00:10:14,880 --> 00:10:21,839
language models and this uses uh kind of

236
00:10:18,839 --> 00:10:25,839
a m multiplicative additive smoothing

237
00:10:21,839 --> 00:10:27,160
term to upway things instead of using

238
00:10:25,839 --> 00:10:30,200
the term

239
00:10:27,160 --> 00:10:33,399
frequency and uh the actual formula is

240
00:10:30,200 --> 00:10:37,240
here K and B are kind of

241
00:10:33,399 --> 00:10:39,360
hyperparameters and um average DL is

242
00:10:37,240 --> 00:10:40,639
average document length the details of

243
00:10:39,360 --> 00:10:42,120
this are not really important but

244
00:10:40,639 --> 00:10:43,800
basically what you should know is that

245
00:10:42,120 --> 00:10:45,639
this is doing some smoothing on the term

246
00:10:43,800 --> 00:10:48,240
frequencies and you can look in more

247
00:10:45,639 --> 00:10:48,240
detail if you're

248
00:10:49,160 --> 00:10:54,920
interested so now that we have this sort

249
00:10:52,880 --> 00:10:57,959
of term

250
00:10:54,920 --> 00:11:00,320
based uh sparse Vector we would like to

251
00:10:57,959 --> 00:11:03,320
use this to look up relevant documents

252
00:11:00,320 --> 00:11:06,000
in a collection very quickly because you

253
00:11:03,320 --> 00:11:08,000
know we might have a collection that's

254
00:11:06,000 --> 00:11:09,720
extremely large like as large as the

255
00:11:08,000 --> 00:11:12,320
entire internet like what Google is

256
00:11:09,720 --> 00:11:14,160
doing when it searches and so in order

257
00:11:12,320 --> 00:11:16,240
to solve this we need a data structure

258
00:11:14,160 --> 00:11:17,279
that allows for efficient sparse lookup

259
00:11:16,240 --> 00:11:19,480
of

260
00:11:17,279 --> 00:11:23,720
vectors and so we have all of these

261
00:11:19,480 --> 00:11:27,279
sparse vectors like this

262
00:11:23,720 --> 00:11:31,240
and we uh basically turn this into an

263
00:11:27,279 --> 00:11:34,720
index where we have something like a you

264
00:11:31,240 --> 00:11:37,920
know python style dictionary or map that

265
00:11:34,720 --> 00:11:41,079
has it's the key each uh word we would

266
00:11:37,920 --> 00:11:45,000
look like to look up and is the vector

267
00:11:41,079 --> 00:11:48,480
the corresponding um index of that

268
00:11:45,000 --> 00:11:50,480
document so for example what in our case

269
00:11:48,480 --> 00:11:54,200
here only appears in document one so it

270
00:11:50,480 --> 00:11:56,279
would point to document one candy uh

271
00:11:54,200 --> 00:11:58,560
also appears in document one NLP appears

272
00:11:56,279 --> 00:11:59,839
in two and three and so you can create

273
00:11:58,560 --> 00:12:02,760
this index IND like this and this is

274
00:11:59,839 --> 00:12:02,760
called an inverted

275
00:12:03,079 --> 00:12:08,760
Index this is an important application

276
00:12:06,000 --> 00:12:11,600
of course so there's lots of software

277
00:12:08,760 --> 00:12:14,920
the most kind of pical software for this

278
00:12:11,600 --> 00:12:18,760
is Apache Lucine so if you want to build

279
00:12:14,920 --> 00:12:21,639
a big index uh to look up vectors using

280
00:12:18,760 --> 00:12:24,160
this sparse index like this you can uh

281
00:12:21,639 --> 00:12:24,160
take a look at

282
00:12:26,160 --> 00:12:30,880
Lucy so the next thing I'd like to talk

283
00:12:28,399 --> 00:12:33,199
about is dense retrieval and the way

284
00:12:30,880 --> 00:12:36,000
dense retrieval works is you encode the

285
00:12:33,199 --> 00:12:37,240
document in query into a dense factor

286
00:12:36,000 --> 00:12:40,240
and find the nearest

287
00:12:37,240 --> 00:12:42,160
neighbor in order to do this encoding

288
00:12:40,240 --> 00:12:44,639
you can use a number of things you can

289
00:12:42,160 --> 00:12:47,440
use out of the box embeddings or you can

290
00:12:44,639 --> 00:12:49,959
use learned embeddings specifically

291
00:12:47,440 --> 00:12:53,519
created for the purpose of

292
00:12:49,959 --> 00:12:56,240
retrieving and so what we do is we take

293
00:12:53,519 --> 00:12:57,920
all of these uh documents here we

294
00:12:56,240 --> 00:12:59,920
convert them into embeddings using

295
00:12:57,920 --> 00:13:04,040
whatever embedding method that we want

296
00:12:59,920 --> 00:13:05,920
to use we then have a query and we take

297
00:13:04,040 --> 00:13:07,720
that query and we match it and find the

298
00:13:05,920 --> 00:13:10,040
nearest neighbor

299
00:13:07,720 --> 00:13:13,120
here so if you're just using out of the

300
00:13:10,040 --> 00:13:14,839
box embeddings you don't need to um you

301
00:13:13,120 --> 00:13:15,880
know do anything special for retrieval

302
00:13:14,839 --> 00:13:18,440
you can just take your favorite

303
00:13:15,880 --> 00:13:22,800
embeddings like the sentence BT

304
00:13:18,440 --> 00:13:25,639
embeddings or the open AI uh Adda

305
00:13:22,800 --> 00:13:27,240
embeddings or something like this but

306
00:13:25,639 --> 00:13:29,519
actually the type of embeddings you need

307
00:13:27,240 --> 00:13:32,040
for retrieval are kind of

308
00:13:29,519 --> 00:13:33,519
very special and because of that it's

309
00:13:32,040 --> 00:13:36,160
important

310
00:13:33,519 --> 00:13:38,600
to if you're very serious about doing a

311
00:13:36,160 --> 00:13:39,800
good job of retal it's important to use

312
00:13:38,600 --> 00:13:41,360
embeddings that were specifically

313
00:13:39,800 --> 00:13:45,040
tailored for

314
00:13:41,360 --> 00:13:47,680
retrieval and the reason why it is

315
00:13:45,040 --> 00:13:50,079
important to do this is severalfold but

316
00:13:47,680 --> 00:13:53,800
the most intuitive way to think about it

317
00:13:50,079 --> 00:13:57,600
is if we think about uh the things that

318
00:13:53,800 --> 00:13:59,440
tfidf does tfidf is giving a very high

319
00:13:57,600 --> 00:14:03,000
weight to

320
00:13:59,440 --> 00:14:04,959
contentful words and rare words and

321
00:14:03,000 --> 00:14:06,639
we're not guaranteed that any random

322
00:14:04,959 --> 00:14:10,600
embedding that we get is going to do

323
00:14:06,639 --> 00:14:13,800
that so for example if we just take the

324
00:14:10,600 --> 00:14:16,160
average word embeddings of every word in

325
00:14:13,800 --> 00:14:20,160
a sequence it's going to give the same

326
00:14:16,160 --> 00:14:22,320
weight to all of the words um in the

327
00:14:20,160 --> 00:14:24,680
output and in fact common words tend to

328
00:14:22,320 --> 00:14:27,959
have slightly higher Norms than

329
00:14:24,680 --> 00:14:29,639
infrequent words and so that would

330
00:14:27,959 --> 00:14:31,880
actually upli common wordss which is

331
00:14:29,639 --> 00:14:34,639
kind of exactly the opposite thing we

332
00:14:31,880 --> 00:14:36,480
want so how do we learn retrieval

333
00:14:34,639 --> 00:14:39,160
oriented

334
00:14:36,480 --> 00:14:40,920
embeddings the normal way we do this is

335
00:14:39,160 --> 00:14:43,399
we select positive and negative

336
00:14:40,920 --> 00:14:46,839
documents and then train using a

337
00:14:43,399 --> 00:14:50,240
contrastive loss and so an example of

338
00:14:46,839 --> 00:14:52,519
this is we have a query and then we have

339
00:14:50,240 --> 00:14:55,519
negative documents for that query and we

340
00:14:52,519 --> 00:14:58,199
have positive documents for that query

341
00:14:55,519 --> 00:15:00,079
and uh we form formulate a hinge loss or

342
00:14:58,199 --> 00:15:04,000
maybe some sort of probabilistic loss

343
00:15:00,079 --> 00:15:06,560
similar to the Hench loss and uh do fine

344
00:15:04,000 --> 00:15:06,560
tuning of the

345
00:15:07,160 --> 00:15:13,440
embeddings so if

346
00:15:09,399 --> 00:15:16,320
you have gold standard positive

347
00:15:13,440 --> 00:15:18,800
documents then this is relatively easy

348
00:15:16,320 --> 00:15:21,040
to train uh because you just need the

349
00:15:18,800 --> 00:15:23,800
positive documents and then you can get

350
00:15:21,040 --> 00:15:25,959
Negative documents in a number of ways

351
00:15:23,800 --> 00:15:29,279
one common way of getting negative

352
00:15:25,959 --> 00:15:32,279
documents is you just form a batch of

353
00:15:29,279 --> 00:15:34,560
data and given that batch of data you

354
00:15:32,279 --> 00:15:37,480
take all of the other documents in the

355
00:15:34,560 --> 00:15:39,480
batch um all of the documents in the

356
00:15:37,480 --> 00:15:42,839
batch that are positive for some other

357
00:15:39,480 --> 00:15:46,399
query and you use those as negative

358
00:15:42,839 --> 00:15:49,000
documents so you sample 32 query

359
00:15:46,399 --> 00:15:50,759
document pairs you use the aligned ones

360
00:15:49,000 --> 00:15:53,759
as positive documents and then use the

361
00:15:50,759 --> 00:15:57,440
31 other ones as negative documents and

362
00:15:53,759 --> 00:16:00,279
this is both effective and efficient

363
00:15:57,440 --> 00:16:02,000
because you can kind of learned from the

364
00:16:00,279 --> 00:16:05,079
query document pairs all at the same

365
00:16:02,000 --> 00:16:05,079
time in an efficient

366
00:16:05,680 --> 00:16:13,680
implementation however this is not

367
00:16:09,160 --> 00:16:16,279
enough in many cases because that will

368
00:16:13,680 --> 00:16:19,040
end up having lots of very kind of

369
00:16:16,279 --> 00:16:20,440
obviously wrong documents because you

370
00:16:19,040 --> 00:16:23,120
know

371
00:16:20,440 --> 00:16:25,360
they're documents that are relevant for

372
00:16:23,120 --> 00:16:27,880
a completely different query and it's

373
00:16:25,360 --> 00:16:29,880
kind of easy to distinguish uh between

374
00:16:27,880 --> 00:16:32,319
those you can just at superficial word

375
00:16:29,880 --> 00:16:34,519
overlap so another common thing to do

376
00:16:32,319 --> 00:16:35,759
when you're training these models is to

377
00:16:34,519 --> 00:16:38,160
get hard

378
00:16:35,759 --> 00:16:40,680
negatives so hard negatives are

379
00:16:38,160 --> 00:16:44,360
basically negative examples that look

380
00:16:40,680 --> 00:16:49,399
plausible but are actually wrong and

381
00:16:44,360 --> 00:16:53,199
so here uh this famous method called DPR

382
00:16:49,399 --> 00:16:55,880
is it basically learns the uh encoders

383
00:16:53,199 --> 00:16:57,759
based on both inbatch negatives like I

384
00:16:55,880 --> 00:17:00,160
mentioned before and hard negatives that

385
00:16:57,759 --> 00:17:01,360
were created by looking up documents

386
00:17:00,160 --> 00:17:03,839
with

387
00:17:01,360 --> 00:17:06,039
bm25 and so the ones that were looked up

388
00:17:03,839 --> 00:17:07,640
by bm25 you know kind of look very

389
00:17:06,039 --> 00:17:10,039
similar superficially but they might

390
00:17:07,640 --> 00:17:12,400
have you know subtle errors in them for

391
00:17:10,039 --> 00:17:12,400
why they're

392
00:17:12,799 --> 00:17:17,160
inappropriate there's also methods to

393
00:17:15,679 --> 00:17:20,000
learn these

394
00:17:17,160 --> 00:17:23,199
retrievers based on kind of not

395
00:17:20,000 --> 00:17:26,199
supervised data so one major bottleneck

396
00:17:23,199 --> 00:17:29,000
if you're taking the positive documents

397
00:17:26,199 --> 00:17:30,440
from Human annotations of whether

398
00:17:29,000 --> 00:17:33,440
something is correct or not or human

399
00:17:30,440 --> 00:17:37,880
clickthrough logs or other things like

400
00:17:33,440 --> 00:17:40,640
this is that you need that data in order

401
00:17:37,880 --> 00:17:44,440
to start training a bottle so uh

402
00:17:40,640 --> 00:17:47,880
contriver is another method that uses

403
00:17:44,440 --> 00:17:51,520
two random spans within a document is a

404
00:17:47,880 --> 00:17:54,440
positive pair and random spans from

405
00:17:51,520 --> 00:17:56,559
across documents is negative Pairs and

406
00:17:54,440 --> 00:17:58,960
so this can be used for you know very

407
00:17:56,559 --> 00:18:00,039
very large scale initial pre-training of

408
00:17:58,960 --> 00:18:02,280
the

409
00:18:00,039 --> 00:18:04,520
models and then after you've done that

410
00:18:02,280 --> 00:18:06,840
large scale initial pre-training you can

411
00:18:04,520 --> 00:18:10,799
then go in and fine-tune it on you know

412
00:18:06,840 --> 00:18:10,799
actually annotate the data to improve it

413
00:18:12,120 --> 00:18:18,799
further Okay so we've talked about

414
00:18:15,159 --> 00:18:21,559
training uh these dense product uh

415
00:18:18,799 --> 00:18:24,559
models these uh models that look at

416
00:18:21,559 --> 00:18:27,720
dense embedding overlap for nearest

417
00:18:24,559 --> 00:18:28,919
neighbors but the problem is in order to

418
00:18:27,720 --> 00:18:30,919
calculate this you would need to

419
00:18:28,919 --> 00:18:35,159
calculate it over a very very large

420
00:18:30,919 --> 00:18:37,960
document base and just taking a product

421
00:18:35,159 --> 00:18:40,480
between the query and all of the other

422
00:18:37,960 --> 00:18:42,400
documents in the document base is

423
00:18:40,480 --> 00:18:46,080
extremely

424
00:18:42,400 --> 00:18:48,080
costly and so in order to fix this there

425
00:18:46,080 --> 00:18:49,080
are methods for approximate nearest

426
00:18:48,080 --> 00:18:52,280
neighbor

427
00:18:49,080 --> 00:18:54,200
search and these are methods that allow

428
00:18:52,280 --> 00:18:57,360
you to retrieve embeddings that have the

429
00:18:54,200 --> 00:19:00,280
maximum inner product between them in

430
00:18:57,360 --> 00:19:02,520
sublinear time and because you're doing

431
00:19:00,280 --> 00:19:03,960
the maximum inner product this is also

432
00:19:02,520 --> 00:19:06,600
often called maximum inner product

433
00:19:03,960 --> 00:19:06,600
search or

434
00:19:06,679 --> 00:19:12,360
myips so I'm going to introduce on a

435
00:19:09,440 --> 00:19:15,360
very high level two common methods to do

436
00:19:12,360 --> 00:19:19,320
this the first one is locality sensitive

437
00:19:15,360 --> 00:19:22,440
hashen um or this can also be called

438
00:19:19,320 --> 00:19:24,799
kind of inverted index as well and what

439
00:19:22,440 --> 00:19:26,840
you do is you make partitions in

440
00:19:24,799 --> 00:19:29,320
continuous space and then you use it

441
00:19:26,840 --> 00:19:31,240
like an inverted index

442
00:19:29,320 --> 00:19:33,679
so let's say we have a whole bunch of

443
00:19:31,240 --> 00:19:34,919
embeddings uh I demonstrated two

444
00:19:33,679 --> 00:19:36,640
dimensional embeddings here but in

445
00:19:34,919 --> 00:19:38,440
reality this would be you know as large

446
00:19:36,640 --> 00:19:41,159
as your word

447
00:19:38,440 --> 00:19:42,880
embedding your query and document

448
00:19:41,159 --> 00:19:47,120
embedding space so this would be you

449
00:19:42,880 --> 00:19:49,760
know 512 or 1024 or something like that

450
00:19:47,120 --> 00:19:53,480
and what you do is you define a whole

451
00:19:49,760 --> 00:19:56,720
bunch of planes that separate these

452
00:19:53,480 --> 00:19:59,320
points into two spaces so if this is our

453
00:19:56,720 --> 00:20:02,520
first plane all the points above the

454
00:19:59,320 --> 00:20:04,280
plane will get a one for this partition

455
00:20:02,520 --> 00:20:06,799
and all the points below the plane will

456
00:20:04,280 --> 00:20:08,840
get a zero for this partition and we do

457
00:20:06,799 --> 00:20:12,400
it similarly we we create a whole bunch

458
00:20:08,840 --> 00:20:15,840
of them and then based on this we can

459
00:20:12,400 --> 00:20:18,440
now assign sparse vectors depending on

460
00:20:15,840 --> 00:20:21,520
each of these planes so we have uh for

461
00:20:18,440 --> 00:20:24,000
example the top one uh one0 0 because

462
00:20:21,520 --> 00:20:26,400
it's on the right side of the blue plane

463
00:20:24,000 --> 00:20:28,760
and the um wrong side of the red and the

464
00:20:26,400 --> 00:20:30,679
green planes and then for the top right

465
00:20:28,760 --> 00:20:32,799
we have one1 because it's on the right

466
00:20:30,679 --> 00:20:37,159
side of the blueing the green planes and

467
00:20:32,799 --> 00:20:39,440
the wrong side of the red plane and So

468
00:20:37,159 --> 00:20:41,000
based on this now we have a sparse

469
00:20:39,440 --> 00:20:42,600
vector and we already know what to do

470
00:20:41,000 --> 00:20:44,640
with a sparse Vector right we look it up

471
00:20:42,600 --> 00:20:49,039
in an inverted index just like we did

472
00:20:44,640 --> 00:20:51,520
for a sparse um you know sparse lookup

473
00:20:49,039 --> 00:20:54,520
table so that's one

474
00:20:51,520 --> 00:20:57,799
method another method uses a graph-based

475
00:20:54,520 --> 00:21:01,320
search and the basic idea behind this is

476
00:20:57,799 --> 00:21:02,480
that we create hubs uh and these hubs

477
00:21:01,320 --> 00:21:05,200
are kind

478
00:21:02,480 --> 00:21:07,960
of a small number of points that are

479
00:21:05,200 --> 00:21:09,440
close to other points in the space and

480
00:21:07,960 --> 00:21:10,880
so we create some hubs and then we

481
00:21:09,440 --> 00:21:12,200
search from there so if we have a

482
00:21:10,880 --> 00:21:16,880
similar

483
00:21:12,200 --> 00:21:19,159
looking uh set of points in the space we

484
00:21:16,880 --> 00:21:21,520
find these hubs which are something like

485
00:21:19,159 --> 00:21:24,880
cluster centroids and then based on the

486
00:21:21,520 --> 00:21:28,559
cluster centroids we then rule down or

487
00:21:24,880 --> 00:21:31,200
we greatly reduce the number of

488
00:21:28,559 --> 00:21:33,400
points that we need to be looking at and

489
00:21:31,200 --> 00:21:36,960
then we search through only those points

490
00:21:33,400 --> 00:21:38,600
in a more kind of extensive Manner and

491
00:21:36,960 --> 00:21:41,840
you can even turn this into a tree where

492
00:21:38,600 --> 00:21:43,760
you have hubs and then you have uh kind

493
00:21:41,840 --> 00:21:46,600
of mini hubs and then you have all the

494
00:21:43,760 --> 00:21:50,200
points so this allows you to do a kind

495
00:21:46,600 --> 00:21:50,200
of tree based or graph based

496
00:21:50,600 --> 00:21:55,840
search so obviously unless you're really

497
00:21:54,159 --> 00:21:57,039
excited about these algorithms this is

498
00:21:55,840 --> 00:22:00,080
something that you probably don't want

499
00:21:57,039 --> 00:22:01,440
to be implementing yourself um and the

500
00:22:00,080 --> 00:22:03,000
good news is there's lots of very good

501
00:22:01,440 --> 00:22:04,480
libraries that help you do this in fact

502
00:22:03,000 --> 00:22:08,799
there are so many libraries it's hard to

503
00:22:04,480 --> 00:22:11,960
manage them but some libraries that

504
00:22:08,799 --> 00:22:13,799
people very commonly use I I think face

505
00:22:11,960 --> 00:22:17,320
uh FIS

506
00:22:13,799 --> 00:22:20,200
SS is a widely used one created by uh

507
00:22:17,320 --> 00:22:23,760
fair and meta and chroma DB is a

508
00:22:20,200 --> 00:22:27,720
separate one uh that is kind of an AI

509
00:22:23,760 --> 00:22:30,720
native uh embedding search database so

510
00:22:27,720 --> 00:22:30,720
both those are good

511
00:22:32,960 --> 00:22:41,120
options even with intelligent training

512
00:22:37,880 --> 00:22:42,640
of dense embeddings however there still

513
00:22:41,120 --> 00:22:45,600
are

514
00:22:42,640 --> 00:22:48,240
problems and the biggest

515
00:22:45,600 --> 00:22:51,720
problem that you face when you're

516
00:22:48,240 --> 00:22:54,000
looking at something like uh cross

517
00:22:51,720 --> 00:22:56,880
encoders um that sorry when you're

518
00:22:54,000 --> 00:23:00,240
looking at dense embeddings is that in

519
00:22:56,880 --> 00:23:02,159
order to form a good dense embedding you

520
00:23:00,240 --> 00:23:03,840
need to kind of know in advance what

521
00:23:02,159 --> 00:23:05,799
you're looking for right because you're

522
00:23:03,840 --> 00:23:09,120
taking a long document you're condensing

523
00:23:05,799 --> 00:23:10,679
it down into a single embedding and or a

524
00:23:09,120 --> 00:23:13,320
long passage and you're condensing it

525
00:23:10,679 --> 00:23:16,200
down to a single embedding and so if

526
00:23:13,320 --> 00:23:19,520
that during that condensation process

527
00:23:16,200 --> 00:23:21,240
actually there's other information that

528
00:23:19,520 --> 00:23:23,159
is relevant to a query but you have to

529
00:23:21,240 --> 00:23:27,600
throw out because of the limited

530
00:23:23,159 --> 00:23:30,600
embedding capacity this causes you to

531
00:23:27,600 --> 00:23:32,320
you know essentially fail at um doing

532
00:23:30,600 --> 00:23:34,840
retrieval

533
00:23:32,320 --> 00:23:38,159
appropriately so there's a couple

534
00:23:34,840 --> 00:23:40,880
methods that can be used to fix this so

535
00:23:38,159 --> 00:23:42,279
the first method is in contrast to the

536
00:23:40,880 --> 00:23:44,159
buy encoder which is what I've been

537
00:23:42,279 --> 00:23:47,000
talking out about at this point where

538
00:23:44,159 --> 00:23:48,520
you kind of do full encoding of queries

539
00:23:47,000 --> 00:23:52,120
full encoding of documents and then do

540
00:23:48,520 --> 00:23:53,840
inner product search for a score uh you

541
00:23:52,120 --> 00:23:56,760
can use a cross encoder and the way the

542
00:23:53,840 --> 00:23:58,559
cross- encoder works is you append the

543
00:23:56,760 --> 00:24:00,799
query and document and then you run them

544
00:23:58,559 --> 00:24:03,400
through a model like a Transformer model

545
00:24:00,799 --> 00:24:07,840
and you calculate the output

546
00:24:03,400 --> 00:24:09,880
score so the problem with this um so

547
00:24:07,840 --> 00:24:12,480
this this is great uh because it gives

548
00:24:09,880 --> 00:24:15,799
you maximum flexibility um Transformer

549
00:24:12,480 --> 00:24:18,799
models are powerful you can uh assess

550
00:24:15,799 --> 00:24:20,520
relevance very well the problem with

551
00:24:18,799 --> 00:24:22,200
this is this precludes approximate

552
00:24:20,520 --> 00:24:23,720
nearest neighbor lookup because now

553
00:24:22,200 --> 00:24:25,799
you're running through you know many

554
00:24:23,720 --> 00:24:28,880
many nonlinearities

555
00:24:25,799 --> 00:24:32,760
here so this is can only be used for

556
00:24:28,880 --> 00:24:34,360
reranking documents um or if even if

557
00:24:32,760 --> 00:24:36,880
you're doing retrieval doing retrieval

558
00:24:34,360 --> 00:24:39,679
over a very very small number of

559
00:24:36,880 --> 00:24:41,960
documents but if you really want maximal

560
00:24:39,679 --> 00:24:44,080
accuracy I definitely would recommend uh

561
00:24:41,960 --> 00:24:45,720
doing something like this because it can

562
00:24:44,080 --> 00:24:47,960
allow you to do kind of a second pass

563
00:24:45,720 --> 00:24:49,360
filtering over the most relevant looking

564
00:24:47,960 --> 00:24:52,399
documents to identify the ones you

565
00:24:49,360 --> 00:24:52,399
really want to add to your

566
00:24:54,240 --> 00:24:58,240
context so then there are also

567
00:24:56,760 --> 00:25:01,360
approaches that are kind kind of in the

568
00:24:58,240 --> 00:25:02,159
middle of these two uh the most famous

569
00:25:01,360 --> 00:25:05,880
one is

570
00:25:02,159 --> 00:25:08,320
Kar and the I called this token level

571
00:25:05,880 --> 00:25:10,840
dense retrieval it's also called uh late

572
00:25:08,320 --> 00:25:12,720
interaction in the coold bear paper but

573
00:25:10,840 --> 00:25:14,919
the way it works is you use

574
00:25:12,720 --> 00:25:18,440
contextualized representations of all

575
00:25:14,919 --> 00:25:19,440
query and document tokens to compute a

576
00:25:18,440 --> 00:25:23,559
retrieval

577
00:25:19,440 --> 00:25:26,919
score and so you do offline indexing of

578
00:25:23,559 --> 00:25:29,159
every token in the document and then

579
00:25:26,919 --> 00:25:31,399
based on this offline X indexing of

580
00:25:29,159 --> 00:25:35,320
every token in the document you then

581
00:25:31,399 --> 00:25:38,760
have a query encoder and you do matching

582
00:25:35,320 --> 00:25:41,799
between each token in the query and the

583
00:25:38,760 --> 00:25:43,399
highest scoring tokens in each

584
00:25:41,799 --> 00:25:46,320
document

585
00:25:43,399 --> 00:25:48,399
and the reason why this is good is it

586
00:25:46,320 --> 00:25:49,600
still allows you to encode all of the

587
00:25:48,399 --> 00:25:52,120
tokens in the

588
00:25:49,600 --> 00:25:55,440
document and but each of these

589
00:25:52,120 --> 00:25:59,679
similarity searches is still just

590
00:25:55,440 --> 00:26:03,559
a kind of maximum product search and

591
00:25:59,679 --> 00:26:06,279
because of this this allows you to do

592
00:26:03,559 --> 00:26:07,960
each of these searches efficiently and

593
00:26:06,279 --> 00:26:09,840
doesn't preclude you from running it

594
00:26:07,960 --> 00:26:12,919
over an entire

595
00:26:09,840 --> 00:26:16,399
database the downside to this method uh

596
00:26:12,919 --> 00:26:19,120
may already be obvious but in the

597
00:26:16,399 --> 00:26:22,200
traditional bu encoder we have a single

598
00:26:19,120 --> 00:26:26,880
Vector for each document but here we

599
00:26:22,200 --> 00:26:29,320
have one vector for um each token in the

600
00:26:26,880 --> 00:26:31,880
document so BAS basically your vector

601
00:26:29,320 --> 00:26:34,399
database gets n times larger where n is

602
00:26:31,880 --> 00:26:36,679
the number of tokens in the document and

603
00:26:34,399 --> 00:26:38,080
there are certain methods to make this

604
00:26:36,679 --> 00:26:41,559
better like you can compress each

605
00:26:38,080 --> 00:26:42,960
document to a smaller number of n uh but

606
00:26:41,559 --> 00:26:45,880
still this is definitely going to be

607
00:26:42,960 --> 00:26:48,399
more costly than looking up each uh

608
00:26:45,880 --> 00:26:50,360
token so this is definitely something to

609
00:26:48,399 --> 00:26:53,520
consider if you want to get you know

610
00:26:50,360 --> 00:26:55,159
very good scores and Co bear is a good

611
00:26:53,520 --> 00:26:59,600
implementation of that to start with if

612
00:26:55,159 --> 00:26:59,600
you're interested in trying it out

613
00:27:00,480 --> 00:27:07,000
so this is a final thing this is uh

614
00:27:03,080 --> 00:27:08,679
something that is a little bit uh

615
00:27:07,000 --> 00:27:10,080
different than all the other things I I

616
00:27:08,679 --> 00:27:12,399
talked about before but I've used it

617
00:27:10,080 --> 00:27:15,840
myself and it actually can be pretty

618
00:27:12,399 --> 00:27:18,799
effective um it was also made at CMU so

619
00:27:15,840 --> 00:27:24,399
by Lal so I would like to promote our

620
00:27:18,799 --> 00:27:26,880
CMU work of course but um the HP idea

621
00:27:24,399 --> 00:27:28,080
between behind a hypothetical document

622
00:27:26,880 --> 00:27:30,320
embedding

623
00:27:28,080 --> 00:27:33,440
is that it's actually somewhat difficult

624
00:27:30,320 --> 00:27:36,200
to match a query and a document right

625
00:27:33,440 --> 00:27:38,919
because a query is a very short possibly

626
00:27:36,200 --> 00:27:42,240
ungrammatical output that's asking a

627
00:27:38,919 --> 00:27:44,799
question and then a document is a very

628
00:27:42,240 --> 00:27:49,440
long output that's written in a

629
00:27:44,799 --> 00:27:50,799
different proos style and you you know

630
00:27:49,440 --> 00:27:53,159
it might have lots of irrelevant

631
00:27:50,799 --> 00:27:54,519
information or or boiler plate or fluff

632
00:27:53,159 --> 00:27:57,640
or something like

633
00:27:54,519 --> 00:28:00,640
that so the idea behind a hypothetical

634
00:27:57,640 --> 00:28:03,120
document embedding is that it's e easier

635
00:28:00,640 --> 00:28:05,279
to match a document in a document than

636
00:28:03,120 --> 00:28:08,159
it is to match a query in a

637
00:28:05,279 --> 00:28:10,159
document but the input to our model is a

638
00:28:08,159 --> 00:28:14,360
query right so what do we

639
00:28:10,159 --> 00:28:17,919
do and so essentially what we do is we

640
00:28:14,360 --> 00:28:20,399
then take a large language model we feed

641
00:28:17,919 --> 00:28:23,320
it in a query in a prompt and say

642
00:28:20,399 --> 00:28:25,399
generate a document that looks like it

643
00:28:23,320 --> 00:28:30,080
should be the answer to this

644
00:28:25,399 --> 00:28:32,120
query and so so then the llm goes in and

645
00:28:30,080 --> 00:28:34,440
it generates a document and hopefully

646
00:28:32,120 --> 00:28:38,440
this document looks more similar to the

647
00:28:34,440 --> 00:28:41,440
documents you want to retrieve than the

648
00:28:38,440 --> 00:28:44,039
um than the original query does and I've

649
00:28:41,440 --> 00:28:47,240
actually found this to be relatively

650
00:28:44,039 --> 00:28:51,880
effective at improving accuracy

651
00:28:47,240 --> 00:28:53,200
on kind of difficult uh tasks especially

652
00:28:51,880 --> 00:28:55,840
ones that are out of domain from the

653
00:28:53,200 --> 00:28:58,000
trend models that I'm

654
00:28:55,840 --> 00:29:01,880
using so I've gone through a whole bunch

655
00:28:58,000 --> 00:29:04,039
of methods and I would like to finish up

656
00:29:01,880 --> 00:29:05,679
this section by giving some insight

657
00:29:04,039 --> 00:29:11,399
about which one you should be

658
00:29:05,679 --> 00:29:14,559
using so my impression right now is

659
00:29:11,399 --> 00:29:17,760
that a good basine to start out with is

660
00:29:14,559 --> 00:29:20,679
something like bm25 it's very easy to

661
00:29:17,760 --> 00:29:23,080
start out and compared to embedding

662
00:29:20,679 --> 00:29:26,120
based models it tends to be relatively

663
00:29:23,080 --> 00:29:28,279
robust to new domains so if you have a

664
00:29:26,120 --> 00:29:30,559
new domain you're more less guaranteed

665
00:29:28,279 --> 00:29:32,240
that bm25 will give you some performance

666
00:29:30,559 --> 00:29:35,320
whereas embeddings may be really good

667
00:29:32,240 --> 00:29:38,399
but they may be really bad uh depending

668
00:29:35,320 --> 00:29:40,880
on how out of domain that is compared to

669
00:29:38,399 --> 00:29:42,799
your underlying embedding

670
00:29:40,880 --> 00:29:44,760
model

671
00:29:42,799 --> 00:29:48,039
so however if you want to get the

672
00:29:44,760 --> 00:29:51,080
highest accuracy definitely tuned models

673
00:29:48,039 --> 00:29:53,200
are going to be better and if you're not

674
00:29:51,080 --> 00:29:56,039
worried about computation efficiency

675
00:29:53,200 --> 00:29:58,480
using something like P bear um with kind

676
00:29:56,039 --> 00:30:01,320
of the token level retrieval will

677
00:29:58,480 --> 00:30:05,559
definitely give you uh good accuracy

678
00:30:01,320 --> 00:30:08,559
here however there's better support for

679
00:30:05,559 --> 00:30:12,159
bu encoder style models um in kind of

680
00:30:08,559 --> 00:30:15,240
standard Vector databases like feice and

681
00:30:12,159 --> 00:30:17,519
uh chroma and other things like that so

682
00:30:15,240 --> 00:30:19,799
if you want a kind of easier method to

683
00:30:17,519 --> 00:30:23,279
get started very quickly then using a bu

684
00:30:19,799 --> 00:30:23,279
encoder is probably the best way to

685
00:30:25,080 --> 00:30:31,080
go okay so now moving on to actual

686
00:30:28,279 --> 00:30:33,159
retrieval augmented generation models we

687
00:30:31,080 --> 00:30:38,360
have uh retriever reader

688
00:30:33,159 --> 00:30:40,880
models and the way these work is you

689
00:30:38,360 --> 00:30:43,279
basically the simplest way they can work

690
00:30:40,880 --> 00:30:45,799
is you basically just chain retrieval

691
00:30:43,279 --> 00:30:47,640
and reading together so you use an outof

692
00:30:45,799 --> 00:30:52,519
thebox Retriever and an outof thebox

693
00:30:47,640 --> 00:30:54,039
reader model and you have your query uh

694
00:30:52,519 --> 00:30:56,159
you could for example look something up

695
00:30:54,039 --> 00:30:58,039
on Google get a whole bunch of passages

696
00:30:56,159 --> 00:30:59,760
and then feed them into a GP key model

697
00:30:58,039 --> 00:31:03,919
and get an

698
00:30:59,760 --> 00:31:06,960
answer this overall is quite effective

699
00:31:03,919 --> 00:31:09,159
um you it's easy to implement and it

700
00:31:06,960 --> 00:31:10,600
will give you decent results so

701
00:31:09,159 --> 00:31:15,480
definitely it's something to be worth

702
00:31:10,600 --> 00:31:20,720
thinking about uh for assignment two in

703
00:31:15,480 --> 00:31:24,799
the um in the class you're required to

704
00:31:20,720 --> 00:31:26,679
only use uh kind of public models or

705
00:31:24,799 --> 00:31:29,760
open source implementations so you could

706
00:31:26,679 --> 00:31:34,360
still replace that with Apachi Lucine

707
00:31:29,760 --> 00:31:36,360
and then um you know any standard llm

708
00:31:34,360 --> 00:31:39,159
and that could be you know llama llama

709
00:31:36,360 --> 00:31:41,600
Chad or M mistol or mixol or something

710
00:31:39,159 --> 00:31:45,360
like that so uh you could definitely

711
00:31:41,600 --> 00:31:48,120
feel feel free to do something like

712
00:31:45,360 --> 00:31:51,559
that um of course the passages are

713
00:31:48,120 --> 00:31:53,200
concatenated to the context and so

714
00:31:51,559 --> 00:31:54,799
because the passages are concatenated to

715
00:31:53,200 --> 00:31:56,679
context the contacts can get relatively

716
00:31:54,799 --> 00:31:58,399
long and expensive and other things like

717
00:31:56,679 --> 00:32:01,960
that but it's just something you have to

718
00:31:58,399 --> 00:32:01,960
deal with when you're using

719
00:32:02,600 --> 00:32:07,480
R there are methods also for Retriever

720
00:32:05,799 --> 00:32:11,600
and Generator endtoend

721
00:32:07,480 --> 00:32:14,720
training so this is the paper actually

722
00:32:11,600 --> 00:32:17,600
where the name rag came from and I'll

723
00:32:14,720 --> 00:32:20,200
use that as an example here uh but

724
00:32:17,600 --> 00:32:21,600
basically um there are several methods

725
00:32:20,200 --> 00:32:23,399
that propos to train the Retriever and

726
00:32:21,600 --> 00:32:27,440
reader to improve

727
00:32:23,399 --> 00:32:31,240
accuracy and specifically the rag p by

728
00:32:27,440 --> 00:32:33,200
Lewis at all the way it trained the um

729
00:32:31,240 --> 00:32:35,639
reader was to maximize generation

730
00:32:33,200 --> 00:32:38,600
likelihood given a single retrieved

731
00:32:35,639 --> 00:32:40,279
document and for the retriever it

732
00:32:38,600 --> 00:32:41,880
maximized overall likelihood by

733
00:32:40,279 --> 00:32:44,480
optimizing the mixture weight over

734
00:32:41,880 --> 00:32:46,559
documents so here's kind of a a

735
00:32:44,480 --> 00:32:50,480
schematic uh which is you have your

736
00:32:46,559 --> 00:32:54,039
query encoder um you run the Retriever

737
00:32:50,480 --> 00:32:57,760
with uh maximum inner product search it

738
00:32:54,039 --> 00:33:00,919
gives you several documents and each

739
00:32:57,760 --> 00:33:05,880
document has a score and then based on

740
00:33:00,919 --> 00:33:09,399
the documents and the scores you

741
00:33:05,880 --> 00:33:11,200
generate uh with each document in the

742
00:33:09,399 --> 00:33:15,360
context and

743
00:33:11,200 --> 00:33:17,080
then sum together the probabilities

744
00:33:15,360 --> 00:33:18,639
multiplied by the weights and I have the

745
00:33:17,080 --> 00:33:20,320
actual equations here because I think

746
00:33:18,639 --> 00:33:23,039
it'll be a little bit easier to

747
00:33:20,320 --> 00:33:25,760
understand after looking at the

748
00:33:23,039 --> 00:33:28,360
equations so generation is a mixture

749
00:33:25,760 --> 00:33:31,440
model and you pick a document and

750
00:33:28,360 --> 00:33:36,519
generate from the document this

751
00:33:31,440 --> 00:33:40,080
p z given X is the probability of

752
00:33:36,519 --> 00:33:44,679
picking that document given the query X

753
00:33:40,080 --> 00:33:48,880
and then this P Theta x z and all of the

754
00:33:44,679 --> 00:33:51,480
previous tokens is basically the uh

755
00:33:48,880 --> 00:33:54,840
probability of the next token given that

756
00:33:51,480 --> 00:33:56,559
you have this particular document so you

757
00:33:54,840 --> 00:34:00,840
can see that this is basically linearly

758
00:33:56,559 --> 00:34:00,840
interpr ating between the multiple

759
00:34:01,559 --> 00:34:05,760
documents and if we look this can be

760
00:34:04,600 --> 00:34:09,039
considered the Retriever and the

761
00:34:05,760 --> 00:34:09,039
generator the Retriever and the

762
00:34:10,839 --> 00:34:16,119
reader one really important thing here

763
00:34:13,639 --> 00:34:17,760
uh that enables endtoend training is

764
00:34:16,119 --> 00:34:19,639
they have this probability of the

765
00:34:17,760 --> 00:34:22,919
retriever be based on

766
00:34:19,639 --> 00:34:25,480
embeddings and so here we have the

767
00:34:22,919 --> 00:34:29,040
document embedding and the query

768
00:34:25,480 --> 00:34:31,440
embedding and the probability is

769
00:34:29,040 --> 00:34:33,320
proportional to the inner product of

770
00:34:31,440 --> 00:34:36,599
these exponentiated so you're basically

771
00:34:33,320 --> 00:34:38,839
taking a soft Max over uh the inner

772
00:34:36,599 --> 00:34:40,599
product between the

773
00:34:38,839 --> 00:34:44,200
two

774
00:34:40,599 --> 00:34:47,919
and this adjusts the retriever to give

775
00:34:44,200 --> 00:34:49,560
higher similarities to helpful

776
00:34:47,919 --> 00:34:52,560
documents

777
00:34:49,560 --> 00:34:52,560
and

778
00:34:54,040 --> 00:35:02,800
so because the prob probability of the

779
00:34:59,800 --> 00:35:04,839
retriever model here is included in the

780
00:35:02,800 --> 00:35:07,160
endtoend probability you don't actually

781
00:35:04,839 --> 00:35:10,680
need any annotations

782
00:35:07,160 --> 00:35:12,839
about which documents are useful you can

783
00:35:10,680 --> 00:35:16,680
just train all of this end to end and

784
00:35:12,839 --> 00:35:19,480
let backrop do its thing to update the

785
00:35:16,680 --> 00:35:22,640
uh the retriever as

786
00:35:19,480 --> 00:35:25,000
well one important issue when training

787
00:35:22,640 --> 00:35:27,480
models like this is that the search

788
00:35:25,000 --> 00:35:30,400
index will become stale so what do I

789
00:35:27,480 --> 00:35:34,760
mean by this if we go back to our

790
00:35:30,400 --> 00:35:34,760
previous uh thing about dense

791
00:35:35,480 --> 00:35:43,560
models creating this blue search index

792
00:35:39,800 --> 00:35:45,400
on the right side of the figure here is

793
00:35:43,560 --> 00:35:48,680
very costly so like let's say you want

794
00:35:45,400 --> 00:35:50,520
to embed a million documents or a

795
00:35:48,680 --> 00:35:55,240
billion documents if you're a big search

796
00:35:50,520 --> 00:35:58,200
engine company so doing this is very

797
00:35:55,240 --> 00:36:00,599
slow and

798
00:35:58,200 --> 00:36:01,920
in contrast doing lookup with kind of

799
00:36:00,599 --> 00:36:04,160
these approximate nearest neighbor

800
00:36:01,920 --> 00:36:05,440
searches is sublinear time or even you

801
00:36:04,160 --> 00:36:08,119
know log time so you can do it

802
00:36:05,440 --> 00:36:12,319
relatively quickly

803
00:36:08,119 --> 00:36:15,680
so it's fine to do lookup over this big

804
00:36:12,319 --> 00:36:17,520
index but if you start updating this

805
00:36:15,680 --> 00:36:19,920
document embedding you need to recreate

806
00:36:17,520 --> 00:36:23,760
the entire index and that would be you

807
00:36:19,920 --> 00:36:27,240
know very computationally costly so the

808
00:36:23,760 --> 00:36:30,119
solution to this proposed in this rag

809
00:36:27,240 --> 00:36:33,640
paper by Lewis at all is uh we only

810
00:36:30,119 --> 00:36:35,640
train the query embeddings and we keep

811
00:36:33,640 --> 00:36:39,640
the document embedding

812
00:36:35,640 --> 00:36:41,920
swix there's other Alternatives like um

813
00:36:39,640 --> 00:36:45,000
there was a paper called realm uh from

814
00:36:41,920 --> 00:36:48,040
early in retrieval base modeling and in

815
00:36:45,000 --> 00:36:50,040
that in that method they basically had

816
00:36:48,040 --> 00:36:51,520
an asynchronous process that was going

817
00:36:50,040 --> 00:36:55,760
through and using the most recent

818
00:36:51,520 --> 00:36:59,960
document in better to re-update the

819
00:36:55,760 --> 00:37:03,359
search index during training but that is

820
00:36:59,960 --> 00:37:05,960
uh you know kind of a very onerous

821
00:37:03,359 --> 00:37:07,800
process so I think it's quite common to

822
00:37:05,960 --> 00:37:11,000
use kind of a fixed document embedding

823
00:37:07,800 --> 00:37:11,000
in update only the

824
00:37:12,079 --> 00:37:17,720
queries another thing to think about is

825
00:37:14,359 --> 00:37:21,160
when do we do retrieval um so there's a

826
00:37:17,720 --> 00:37:23,079
bunch of different methods the rag paper

827
00:37:21,160 --> 00:37:24,440
that I mentioned before did this only

828
00:37:23,079 --> 00:37:26,359
once right at the very beginning of

829
00:37:24,440 --> 00:37:29,400
generation it grabbed a single document

830
00:37:26,359 --> 00:37:32,560
and generated the entire output this is

831
00:37:29,400 --> 00:37:34,800
the default method used by most

832
00:37:32,560 --> 00:37:37,240
systems however there's other options as

833
00:37:34,800 --> 00:37:39,640
well you can retrieve uh several times

834
00:37:37,240 --> 00:37:43,040
during generation as

835
00:37:39,640 --> 00:37:44,480
necessary and the way this works uh we

836
00:37:43,040 --> 00:37:46,280
can do this either by generating a

837
00:37:44,480 --> 00:37:48,480
search token uh saying that we should

838
00:37:46,280 --> 00:37:50,200
start searching or searching when the

839
00:37:48,480 --> 00:37:52,640
model is

840
00:37:50,200 --> 00:37:55,920
uncertain and another way is to do this

841
00:37:52,640 --> 00:37:58,079
every token so we can do this by finding

842
00:37:55,920 --> 00:37:59,760
similar final embeddings and using this

843
00:37:58,079 --> 00:38:02,240
to influence the

844
00:37:59,760 --> 00:38:04,720
probabilities or approximating attention

845
00:38:02,240 --> 00:38:06,440
with nearest neighbors so I'm going to

846
00:38:04,720 --> 00:38:08,920
explain about each of these in a bit

847
00:38:06,440 --> 00:38:12,480
more detail

848
00:38:08,920 --> 00:38:16,119
in so triggering retrieval with token

849
00:38:12,480 --> 00:38:19,720
embeddings is um was proposed by Tool

850
00:38:16,119 --> 00:38:22,119
forer shik all and the way it works is

851
00:38:19,720 --> 00:38:25,000
you generate tokens that Tri trigger

852
00:38:22,119 --> 00:38:27,880
retrieval or other tools so in this

853
00:38:25,000 --> 00:38:30,079
particular method it uh had several

854
00:38:27,880 --> 00:38:32,000
tools including asking a QA model or

855
00:38:30,079 --> 00:38:34,800
getting a calculator or having a machine

856
00:38:32,000 --> 00:38:37,200
translation system but with respect to

857
00:38:34,800 --> 00:38:40,000
retrieval augmented generation it had

858
00:38:37,200 --> 00:38:41,560
this essentially Wiki search

859
00:38:40,000 --> 00:38:43,680
functionality that would look up

860
00:38:41,560 --> 00:38:46,680
something in Wikipedia and then use that

861
00:38:43,680 --> 00:38:46,680
to influence the final

862
00:38:46,760 --> 00:38:52,200
probabilities

863
00:38:48,800 --> 00:38:55,160
and the way this was trained is training

864
00:38:52,200 --> 00:38:59,800
was done in an inative manner where it

865
00:38:55,160 --> 00:38:59,800
basically generated uh kind

866
00:39:00,000 --> 00:39:05,680
of examples of tools being useful and

867
00:39:04,359 --> 00:39:09,560
when the

868
00:39:05,680 --> 00:39:14,160
tools improve the probability of the

869
00:39:09,560 --> 00:39:16,119
following output then that would be kind

870
00:39:14,160 --> 00:39:19,560
of treated as a positive example and

871
00:39:16,119 --> 00:39:21,520
used to further train the model so this

872
00:39:19,560 --> 00:39:23,400
was really influential and in fact this

873
00:39:21,520 --> 00:39:27,000
is how things are implemented in chat

874
00:39:23,400 --> 00:39:29,319
GPT nowadays not only for um doing

875
00:39:27,000 --> 00:39:33,400
retrieval but also doing other tools

876
00:39:29,319 --> 00:39:35,200
like um for example uh generating code

877
00:39:33,400 --> 00:39:37,440
or generating images or other things

878
00:39:35,200 --> 00:39:37,440
like

879
00:39:38,200 --> 00:39:45,079
this another option is to trigger

880
00:39:40,920 --> 00:39:48,240
retrieval uh with uncertainty estimates

881
00:39:45,079 --> 00:39:52,280
so flare this is a paper by my student

882
00:39:48,240 --> 00:39:55,160
Jang bang um where we try to generate

883
00:39:52,280 --> 00:39:58,560
content and then do retrieval if the

884
00:39:55,160 --> 00:40:01,800
language model certainty is low so

885
00:39:58,560 --> 00:40:05,599
here's a schematic of how this works but

886
00:40:01,800 --> 00:40:09,160
basically um if we have

887
00:40:05,599 --> 00:40:13,440
some uh retrieved documents we can say

888
00:40:09,160 --> 00:40:16,560
generate a a summary about Joe Biden and

889
00:40:13,440 --> 00:40:19,560
when it generates a summary maybe for

890
00:40:16,560 --> 00:40:20,960
the first output um the language model

891
00:40:19,560 --> 00:40:22,960
has high

892
00:40:20,960 --> 00:40:24,240
confidence and because the language

893
00:40:22,960 --> 00:40:25,359
model has high confidence we just

894
00:40:24,240 --> 00:40:27,520
generate the

895
00:40:25,359 --> 00:40:29,599
output

896
00:40:27,520 --> 00:40:31,839
however in the next step if it might

897
00:40:29,599 --> 00:40:33,599
generate something like saying Joe Biden

898
00:40:31,839 --> 00:40:35,680
attended the University of Pennsylvania

899
00:40:33,599 --> 00:40:37,160
where he earned a law degree but the

900
00:40:35,680 --> 00:40:39,000
model might not be very certain about

901
00:40:37,160 --> 00:40:41,560
this it might have a low probability of

902
00:40:39,000 --> 00:40:45,839
certain important entities and So based

903
00:40:41,560 --> 00:40:48,839
on this uh we then form a a query where

904
00:40:45,839 --> 00:40:52,119
what we do is essentially we blank out

905
00:40:48,839 --> 00:40:55,079
the low probability parts of this and we

906
00:40:52,119 --> 00:40:57,200
do a search and so this is also a little

907
00:40:55,079 --> 00:41:00,240
bit like the hypothetical

908
00:40:57,200 --> 00:41:02,520
edings method where we basically create

909
00:41:00,240 --> 00:41:04,040
a document that we think will look

910
00:41:02,520 --> 00:41:07,119
similar to the document that we want to

911
00:41:04,040 --> 00:41:09,480
find we use that to create search

912
00:41:07,119 --> 00:41:11,359
results and then we generate the output

913
00:41:09,480 --> 00:41:13,880
and then we continue doing that and

914
00:41:11,359 --> 00:41:15,960
whenever we have a high confidence

915
00:41:13,880 --> 00:41:18,800
output like the one here we don't do any

916
00:41:15,960 --> 00:41:20,040
retrieval we just you know generate uh

917
00:41:18,800 --> 00:41:21,880
directly from the parameters of the

918
00:41:20,040 --> 00:41:23,960
model but whenever we have low

919
00:41:21,880 --> 00:41:27,400
confidence outputs we do the retrieval

920
00:41:23,960 --> 00:41:30,400
and base the output on this and so I I

921
00:41:27,400 --> 00:41:33,119
think this is uh you know a nice method

922
00:41:30,400 --> 00:41:35,000
that could potentially be uh used the

923
00:41:33,119 --> 00:41:36,920
downside to that is you might sometimes

924
00:41:35,000 --> 00:41:38,920
need to generate twice because you would

925
00:41:36,920 --> 00:41:40,480
generate the output once and then find

926
00:41:38,920 --> 00:41:42,720
the low confidence parts and generate

927
00:41:40,480 --> 00:41:45,400
again but you know if you really care

928
00:41:42,720 --> 00:41:47,319
about the uh kind of quality of the

929
00:41:45,400 --> 00:41:49,640
output this is I think a reasonable

930
00:41:47,319 --> 00:41:49,640
thing to

931
00:41:50,160 --> 00:41:54,920
do okay so now moving on to the Token by

932
00:41:53,000 --> 00:41:59,800
token retrieval

933
00:41:54,920 --> 00:42:03,560
methods the kind of original or one of

934
00:41:59,800 --> 00:42:05,200
the methods that popularized this idea

935
00:42:03,560 --> 00:42:08,720
of token by token retrieval is something

936
00:42:05,200 --> 00:42:10,760
called K&N LM and the way it works is it

937
00:42:08,720 --> 00:42:13,839
retrieves similar

938
00:42:10,760 --> 00:42:16,680
examples and then uses the following

939
00:42:13,839 --> 00:42:20,880
tokens from these

940
00:42:16,680 --> 00:42:23,800
examples and this is kind of like a very

941
00:42:20,880 --> 00:42:25,839
powerful count-based byr model in a way

942
00:42:23,800 --> 00:42:28,440
so if you remember back to when we were

943
00:42:25,839 --> 00:42:32,920
talking about count based Pam models

944
00:42:28,440 --> 00:42:36,440
what we would do is we would take the

945
00:42:32,920 --> 00:42:39,400
previous token and we would calculate

946
00:42:36,440 --> 00:42:41,319
the probability of the next token by

947
00:42:39,400 --> 00:42:43,040
summing up together all of the next

948
00:42:41,319 --> 00:42:44,800
tokens and dividing by the total number

949
00:42:43,040 --> 00:42:49,240
of times that previous token

950
00:42:44,800 --> 00:42:52,720
occurred and so given that background uh

951
00:42:49,240 --> 00:42:56,760
we can talk about how the KLM

952
00:42:52,720 --> 00:43:00,319
works so we have the text context X

953
00:42:56,760 --> 00:43:02,240
and we want to generate a Target output

954
00:43:00,319 --> 00:43:04,839
separately from this we have all of the

955
00:43:02,240 --> 00:43:06,440
training contexts so this is all of the

956
00:43:04,839 --> 00:43:09,920
contexts that appeared in our training

957
00:43:06,440 --> 00:43:13,520
data and we encode all of these training

958
00:43:09,920 --> 00:43:15,720
contexts specifically by calculating the

959
00:43:13,520 --> 00:43:18,559
representation of the final layer or

960
00:43:15,720 --> 00:43:21,119
near the final layer of the model and so

961
00:43:18,559 --> 00:43:23,200
we encode that as

962
00:43:21,119 --> 00:43:25,240
representations separately from that we

963
00:43:23,200 --> 00:43:27,920
remember the next word that appeared

964
00:43:25,240 --> 00:43:29,720
after this Contex

965
00:43:27,920 --> 00:43:32,920
so now we have a data store consisting

966
00:43:29,720 --> 00:43:35,040
of representations in next words we then

967
00:43:32,920 --> 00:43:38,440
take the representation of the current

968
00:43:35,040 --> 00:43:40,880
context and we calculate the distance

969
00:43:38,440 --> 00:43:43,400
between the current context and all of

970
00:43:40,880 --> 00:43:47,119
the other similar context in the

971
00:43:43,400 --> 00:43:49,839
database we take the nearest K so we

972
00:43:47,119 --> 00:43:52,440
take the top uh K examples here which

973
00:43:49,839 --> 00:43:55,240
would be Hawaii Illinois and

974
00:43:52,440 --> 00:43:57,520
Hawaii we then do uh some sort of

975
00:43:55,240 --> 00:44:01,440
normalization based on the

976
00:43:57,520 --> 00:44:05,200
distance and this gives us a probability

977
00:44:01,440 --> 00:44:06,680
distribution over all of the next tokens

978
00:44:05,200 --> 00:44:10,599
sometimes these tokens are duplicated

979
00:44:06,680 --> 00:44:13,599
multiple times and so we aggregate all

980
00:44:10,599 --> 00:44:15,800
of these counts to be Hawaii for example

981
00:44:13,599 --> 00:44:18,839
0.8 and Illinois

982
00:44:15,800 --> 00:44:21,839
0.2 and then we interpolate this with

983
00:44:18,839 --> 00:44:24,040
the probability given by the standard

984
00:44:21,839 --> 00:44:26,440
language model using an interpolation

985
00:44:24,040 --> 00:44:28,400
coefficient Lambda and this gives us our

986
00:44:26,440 --> 00:44:31,000
final

987
00:44:28,400 --> 00:44:34,559
probability so the nice thing about this

988
00:44:31,000 --> 00:44:38,000
is this allows us to explicitly ground

989
00:44:34,559 --> 00:44:42,079
our outputs in individual

990
00:44:38,000 --> 00:44:45,319
examples uh and it's a pretty effective

991
00:44:42,079 --> 00:44:48,760
way to improve the probability of models

992
00:44:45,319 --> 00:44:53,839
improve translation and other stuff like

993
00:44:48,760 --> 00:44:56,119
this the disadvantage of doing this is

994
00:44:53,839 --> 00:44:59,319
that it provides it it kind of ADD add

995
00:44:56,119 --> 00:45:01,800
an extra component of the model it adds

996
00:44:59,319 --> 00:45:05,440
extra

997
00:45:01,800 --> 00:45:08,520
um kind of hyperparameters like Lambda

998
00:45:05,440 --> 00:45:11,680
and things like this so it is a little

999
00:45:08,520 --> 00:45:16,960
bit finicky and it doesn't work in all

1000
00:45:11,680 --> 00:45:21,440
situations and so another method that we

1001
00:45:16,960 --> 00:45:23,559
uh proposed or by Manda Birch who gave

1002
00:45:21,440 --> 00:45:26,920
the uh previous lecture on generation in

1003
00:45:23,559 --> 00:45:29,240
this class is unlimi forer and basically

1004
00:45:26,920 --> 00:45:32,680
what unlimi forer does is it notes that

1005
00:45:29,240 --> 00:45:36,079
attention itself is an in inner product

1006
00:45:32,680 --> 00:45:40,440
search and it does topk

1007
00:45:36,079 --> 00:45:42,680
attention and the way we do this is we

1008
00:45:40,440 --> 00:45:45,160
first process the input with a sliding

1009
00:45:42,680 --> 00:45:47,480
window and then perform attention using

1010
00:45:45,160 --> 00:45:49,960
a vector index so if we have a really

1011
00:45:47,480 --> 00:45:54,280
long input that we want to encode what

1012
00:45:49,960 --> 00:45:56,559
we do is we first encode chunks so we

1013
00:45:54,280 --> 00:46:01,960
encode for example AB

1014
00:45:56,559 --> 00:46:03,839
then we encode CD and we encode EF we

1015
00:46:01,960 --> 00:46:06,240
concatenate them together into a big

1016
00:46:03,839 --> 00:46:07,800
index of one long input so in a way that

1017
00:46:06,240 --> 00:46:10,920
this is similar to what they did in the

1018
00:46:07,800 --> 00:46:12,720
KLM you know concatenate all of these

1019
00:46:10,920 --> 00:46:16,520
embeddings into a single

1020
00:46:12,720 --> 00:46:18,680
input but the difference is that this is

1021
00:46:16,520 --> 00:46:21,640
done with

1022
00:46:18,680 --> 00:46:24,280
um the values that we are attending to

1023
00:46:21,640 --> 00:46:27,559
as opposed to just the final

1024
00:46:24,280 --> 00:46:30,079
layer and

1025
00:46:27,559 --> 00:46:33,680
the interesting thing about this is now

1026
00:46:30,079 --> 00:46:36,200
we have an index of one long input and

1027
00:46:33,680 --> 00:46:39,800
when we want to do our next version of

1028
00:46:36,200 --> 00:46:42,240
attention we do KNN search from the

1029
00:46:39,800 --> 00:46:44,280
query we take the retrieved hidden

1030
00:46:42,240 --> 00:46:47,880
States and then we just do attention

1031
00:46:44,280 --> 00:46:50,440
over them so the nice thing about this

1032
00:46:47,880 --> 00:46:53,079
is in the extreme case this makes no

1033
00:46:50,440 --> 00:46:55,240
changes to the model what I mean by this

1034
00:46:53,079 --> 00:46:57,520
is let's say our input was small enough

1035
00:46:55,240 --> 00:47:02,240
that we could coded in only a single

1036
00:46:57,520 --> 00:47:06,400
chunk and for KNN search we also did KNN

1037
00:47:02,240 --> 00:47:09,559
search um we did you know exact Canon

1038
00:47:06,400 --> 00:47:12,400
search over all of the embeddings in the

1039
00:47:09,559 --> 00:47:14,680
trunk in that case this would just be

1040
00:47:12,400 --> 00:47:16,520
normal attention it's exactly the same

1041
00:47:14,680 --> 00:47:18,640
as normal

1042
00:47:16,520 --> 00:47:20,160
attention however there are some

1043
00:47:18,640 --> 00:47:21,760
approximations that go into here like

1044
00:47:20,160 --> 00:47:24,000
when we encode chunks they might not be

1045
00:47:21,760 --> 00:47:26,359
exactly the same as if we encoded the

1046
00:47:24,000 --> 00:47:29,839
entire thing together and we're also

1047
00:47:26,359 --> 00:47:33,640
chopping off some of the values with

1048
00:47:29,839 --> 00:47:35,800
very low um kind of inner products and

1049
00:47:33,640 --> 00:47:37,400
so because of this there are some

1050
00:47:35,800 --> 00:47:38,760
approximations being made but in the

1051
00:47:37,400 --> 00:47:40,160
extreme case if we made no

1052
00:47:38,760 --> 00:47:41,880
approximations this would just be

1053
00:47:40,160 --> 00:47:44,359
exactly the same model as we were using

1054
00:47:41,880 --> 00:47:46,160
before so I find this pretty attractive

1055
00:47:44,359 --> 00:47:48,760
and uh you know empirically it gives

1056
00:47:46,160 --> 00:47:51,720
very good results over long

1057
00:47:48,760 --> 00:47:53,440
distances and you know we can always

1058
00:47:51,720 --> 00:47:56,240
make our approximations better and

1059
00:47:53,440 --> 00:47:57,680
improve this model as well so I I think

1060
00:47:56,240 --> 00:48:00,960
this is a attractive method that you

1061
00:47:57,680 --> 00:48:00,960
might be interested in taking a look

1062
00:48:02,240 --> 00:48:06,200
at okay for the final part of this I'd

1063
00:48:04,559 --> 00:48:08,079
like to talk about long context

1064
00:48:06,200 --> 00:48:12,400
Transformers and these are models that

1065
00:48:08,079 --> 00:48:15,119
are explicitly trained in a way that

1066
00:48:12,400 --> 00:48:16,920
allows you to attend to longer contexts

1067
00:48:15,119 --> 00:48:18,839
in an efficient

1068
00:48:16,920 --> 00:48:21,960
manner

1069
00:48:18,839 --> 00:48:23,680
so one way that we can train over longer

1070
00:48:21,960 --> 00:48:25,880
context is just append all of the

1071
00:48:23,680 --> 00:48:28,040
context together and in fact shortly

1072
00:48:25,880 --> 00:48:32,200
after Transformers came out uh this

1073
00:48:28,040 --> 00:48:34,280
paper by VOA at all demonstrated that um

1074
00:48:32,200 --> 00:48:36,160
it doing this can learn you know

1075
00:48:34,280 --> 00:48:38,119
interesting document level phenomena so

1076
00:48:36,160 --> 00:48:40,440
it can identify when

1077
00:48:38,119 --> 00:48:42,480
multiple uh words refer to the same

1078
00:48:40,440 --> 00:48:43,680
thing or co-reference and other things

1079
00:48:42,480 --> 00:48:45,640
like

1080
00:48:43,680 --> 00:48:47,720
this however the problem with

1081
00:48:45,640 --> 00:48:51,119
Transformers is that computation is

1082
00:48:47,720 --> 00:48:52,799
quadratic in the sentence length because

1083
00:48:51,119 --> 00:48:54,599
you're multiplying all of the query

1084
00:48:52,799 --> 00:48:56,799
vectors by all of the key

1085
00:48:54,599 --> 00:48:59,480
vectors

1086
00:48:56,799 --> 00:49:02,799
and that basically causes a big problem

1087
00:48:59,480 --> 00:49:02,799
if your sequences become very

1088
00:49:03,480 --> 00:49:09,760
long so if we go back to what we did in

1089
00:49:07,480 --> 00:49:12,400
rnns uh from the very beginning of the

1090
00:49:09,760 --> 00:49:14,359
class in rnns they don't have this

1091
00:49:12,400 --> 00:49:16,280
problem because computation is linear in

1092
00:49:14,359 --> 00:49:20,440
the length of the sequence you just pass

1093
00:49:16,280 --> 00:49:22,200
along the RNN State and every single

1094
00:49:20,440 --> 00:49:23,839
time you do the same computation over it

1095
00:49:22,200 --> 00:49:26,559
so there's no quadratic term in

1096
00:49:23,839 --> 00:49:32,400
calculating rnns

1097
00:49:26,559 --> 00:49:34,880
another thing is that when doing rnns

1098
00:49:32,400 --> 00:49:37,680
you can actually P State infinitely

1099
00:49:34,880 --> 00:49:39,040
during the forward pass by just

1100
00:49:37,680 --> 00:49:40,240
calculating the hidden State and then

1101
00:49:39,040 --> 00:49:42,119
throwing away the rest of the

1102
00:49:40,240 --> 00:49:43,359
computation graph that was used in

1103
00:49:42,119 --> 00:49:45,160
calculating that hidden State and

1104
00:49:43,359 --> 00:49:48,319
there's no approximation that goes on

1105
00:49:45,160 --> 00:49:49,680
there so unlike on in un liform that I

1106
00:49:48,319 --> 00:49:51,640
was talking about before where we needed

1107
00:49:49,680 --> 00:49:54,119
to make approximations none need to be

1108
00:49:51,640 --> 00:49:56,400
made in this

1109
00:49:54,119 --> 00:50:00,200
case however there is a problem with

1110
00:49:56,400 --> 00:50:02,040
doing back propop uh because in order to

1111
00:50:00,200 --> 00:50:05,839
do back propop normally you maintain the

1112
00:50:02,040 --> 00:50:09,720
entire you know state of the computation

1113
00:50:05,839 --> 00:50:12,400
graph and so there a common method to

1114
00:50:09,720 --> 00:50:15,280
fix this is basically you pass along the

1115
00:50:12,400 --> 00:50:16,920
RNN state from the previous sentence but

1116
00:50:15,280 --> 00:50:19,240
you just don't do backdrop into the

1117
00:50:16,920 --> 00:50:21,200
previous sentence and this is called

1118
00:50:19,240 --> 00:50:24,040
truncated backrop or truncated back

1119
00:50:21,200 --> 00:50:27,280
propagation through time and this allows

1120
00:50:24,040 --> 00:50:30,160
you to essentially train models with

1121
00:50:27,280 --> 00:50:32,319
infinite context um or at least models

1122
00:50:30,160 --> 00:50:33,720
that can pass along context infinitely

1123
00:50:32,319 --> 00:50:36,359
even if you're not back propping into

1124
00:50:33,720 --> 00:50:36,359
they Cod ear

1125
00:50:37,480 --> 00:50:43,520
there so of course a problem with this

1126
00:50:40,720 --> 00:50:45,880
over long contexts is recurrents uh

1127
00:50:43,520 --> 00:50:47,520
recurrent models can be slow due to the

1128
00:50:45,880 --> 00:50:51,400
kind of sequential dependence they're

1129
00:50:47,520 --> 00:50:54,280
not ideal for um you know running on

1130
00:50:51,400 --> 00:50:57,359
gpus or things like that and this is

1131
00:50:54,280 --> 00:51:01,960
improved by recent architectures like

1132
00:50:57,359 --> 00:51:05,359
Mamba and RW KV which are more conducive

1133
00:51:01,960 --> 00:51:07,079
to GPU Based training um while still

1134
00:51:05,359 --> 00:51:08,599
maintaining linear time complexity and

1135
00:51:07,079 --> 00:51:11,480
so I'm looking forward to talking about

1136
00:51:08,599 --> 00:51:11,480
that more in a future

1137
00:51:13,000 --> 00:51:17,559
class so actually if we take this idea

1138
00:51:15,880 --> 00:51:20,440
of truncated back propagation through

1139
00:51:17,559 --> 00:51:22,359
time this can also be applied to

1140
00:51:20,440 --> 00:51:25,440
Transformers and there's a really nice

1141
00:51:22,359 --> 00:51:27,880
paper Transformer XEL also created by

1142
00:51:25,440 --> 00:51:31,119
kungai who was formerly at

1143
00:51:27,880 --> 00:51:33,119
CMU and what this does is this attempts

1144
00:51:31,119 --> 00:51:35,760
to fix vectors from the previous

1145
00:51:33,119 --> 00:51:39,440
sentence so if we have a standard

1146
00:51:35,760 --> 00:51:40,720
Transformer uh in a Transformer XL

1147
00:51:39,440 --> 00:51:44,640
normally what we do in the standard

1148
00:51:40,720 --> 00:51:48,480
Transformer is each Vector attends back

1149
00:51:44,640 --> 00:51:50,920
to all the other vectors in the current

1150
00:51:48,480 --> 00:51:53,839
context what Transformer XEL does

1151
00:51:50,920 --> 00:51:56,359
instead is when you have a new segment

1152
00:51:53,839 --> 00:51:58,960
that you want to do backrop

1153
00:51:56,359 --> 00:52:01,200
into um you have a new segment that you

1154
00:51:58,960 --> 00:52:03,960
want to basically train over you also

1155
00:52:01,200 --> 00:52:06,400
attend to all of the previous tokens in

1156
00:52:03,960 --> 00:52:07,640
the previous segment but you don't do

1157
00:52:06,400 --> 00:52:10,319
back propop into

1158
00:52:07,640 --> 00:52:12,079
them so this is essentially truncated

1159
00:52:10,319 --> 00:52:14,480
backpropagation through time from the

1160
00:52:12,079 --> 00:52:17,760
Transformer

1161
00:52:14,480 --> 00:52:19,520
perspective this is also really nice

1162
00:52:17,760 --> 00:52:21,200
because what it allows you to do is if

1163
00:52:19,520 --> 00:52:25,880
you have a multi-layer

1164
00:52:21,200 --> 00:52:27,720
Transformer it allows you to attend far

1165
00:52:25,880 --> 00:52:30,520
back so if you look at the last layer

1166
00:52:27,720 --> 00:52:33,520
it's attending um to things in the

1167
00:52:30,520 --> 00:52:36,599
previous context window but the second

1168
00:52:33,520 --> 00:52:39,760
to last layer is attending to things in

1169
00:52:36,599 --> 00:52:41,520
the um not just one context window

1170
00:52:39,760 --> 00:52:44,079
before but multiple context windows

1171
00:52:41,520 --> 00:52:45,760
before and actually this allows you to

1172
00:52:44,079 --> 00:52:47,880
very effectively attend a very long

1173
00:52:45,760 --> 00:52:51,720
context because each time kind of the

1174
00:52:47,880 --> 00:52:54,799
context expands in an exponential

1175
00:52:51,720 --> 00:52:56,520
manner so um recently there's a popular

1176
00:52:54,799 --> 00:52:57,799
model called mistol that I'm sure a lot

1177
00:52:56,520 --> 00:52:59,480
of people have heard about and this is

1178
00:52:57,799 --> 00:53:01,920
using sliding window attention which is

1179
00:52:59,480 --> 00:53:04,160
essentially the same mechanism proposed

1180
00:53:01,920 --> 00:53:09,240
by Transformer XEL so this method is

1181
00:53:04,160 --> 00:53:09,240
still uh used in uh very practical

1182
00:53:10,400 --> 00:53:17,359
systems another paper that has been

1183
00:53:13,440 --> 00:53:19,319
pretty influential in this general area

1184
00:53:17,359 --> 00:53:21,079
is something called sparse

1185
00:53:19,319 --> 00:53:23,359
Transformers and the way sparse

1186
00:53:21,079 --> 00:53:25,960
Transformers work is instead of

1187
00:53:23,359 --> 00:53:29,520
attending to every single previous state

1188
00:53:25,960 --> 00:53:32,640
you attend to every n previous

1189
00:53:29,520 --> 00:53:34,599
States and what this allows you to do is

1190
00:53:32,640 --> 00:53:37,119
this allows you to essentially create

1191
00:53:34,599 --> 00:53:40,319
something like the strided uh

1192
00:53:37,119 --> 00:53:42,079
convolutions or um pyramidal recurrent

1193
00:53:40,319 --> 00:53:45,520
neural networks that I talked about

1194
00:53:42,079 --> 00:53:49,760
earlier um so what this looks like

1195
00:53:45,520 --> 00:53:51,079
essentially is you have um this like if

1196
00:53:49,760 --> 00:53:54,880
you have a particular state it might

1197
00:53:51,079 --> 00:53:56,480
attend to all of the previous end tokens

1198
00:53:54,880 --> 00:54:00,240
but then it

1199
00:53:56,480 --> 00:54:04,400
also attends to all of the

1200
00:54:00,240 --> 00:54:06,880
previous um kind of M chunks so you kind

1201
00:54:04,400 --> 00:54:08,920
of have a combination of local and

1202
00:54:06,880 --> 00:54:11,640
Global

1203
00:54:08,920 --> 00:54:14,760
attention or not local and Global but

1204
00:54:11,640 --> 00:54:16,760
local and kind of longer range attention

1205
00:54:14,760 --> 00:54:18,760
and this can be very effective because

1206
00:54:16,760 --> 00:54:22,319
you can attend to you know much longer

1207
00:54:18,760 --> 00:54:24,079
context with a minimal increase in a

1208
00:54:22,319 --> 00:54:26,520
computational

1209
00:54:24,079 --> 00:54:28,720
complexity

1210
00:54:26,520 --> 00:54:31,160
so another method that's a little bit

1211
00:54:28,720 --> 00:54:32,960
like this uh or it's very similar in

1212
00:54:31,160 --> 00:54:34,359
spirit but slightly different in

1213
00:54:32,960 --> 00:54:35,599
implementation is something called the

1214
00:54:34,359 --> 00:54:37,520
compressive

1215
00:54:35,599 --> 00:54:40,400
Transformer and in the compressive

1216
00:54:37,520 --> 00:54:43,000
Transformer you also have this idea of a

1217
00:54:40,400 --> 00:54:44,319
local memory and then a longer term

1218
00:54:43,000 --> 00:54:47,200
compressed

1219
00:54:44,319 --> 00:54:50,799
memory but you have an explicit

1220
00:54:47,200 --> 00:54:54,319
compression step that

1221
00:54:50,799 --> 00:54:58,079
directly essentially generates this uh

1222
00:54:54,319 --> 00:55:00,960
compressed mem M itself and so this is a

1223
00:54:58,079 --> 00:55:04,119
little bit more flexible I guess it

1224
00:55:00,960 --> 00:55:06,280
allows you to take all of the you know

1225
00:55:04,119 --> 00:55:09,000
relevant things from your local memory

1226
00:55:06,280 --> 00:55:12,000
and compress it down so it's another

1227
00:55:09,000 --> 00:55:12,000
method that's worth thinking

1228
00:55:12,760 --> 00:55:18,400
about finally uh there are some very

1229
00:55:15,799 --> 00:55:20,200
interesting methods that do low rank

1230
00:55:18,400 --> 00:55:23,039
approximations for

1231
00:55:20,200 --> 00:55:25,920
Transformers and so calculating the

1232
00:55:23,039 --> 00:55:29,119
attention Matrix is expensive but this

1233
00:55:25,920 --> 00:55:31,640
is a matrix and because it's a matrix we

1234
00:55:29,119 --> 00:55:32,640
can also approximate it with a lower

1235
00:55:31,640 --> 00:55:35,480
rank

1236
00:55:32,640 --> 00:55:38,559
Matrix and there's a couple methods that

1237
00:55:35,480 --> 00:55:40,599
do things uh like this uh the first one

1238
00:55:38,559 --> 00:55:42,680
is something called Blind forer which

1239
00:55:40,599 --> 00:55:44,520
adds low rank linear projections into

1240
00:55:42,680 --> 00:55:47,319
the model at appropriate

1241
00:55:44,520 --> 00:55:50,359
places and um there's another one called

1242
00:55:47,319 --> 00:55:52,200
NR forer which approximates using the ni

1243
00:55:50,359 --> 00:55:54,440
run method which is based on sampling

1244
00:55:52,200 --> 00:55:56,520
Landmark points but basically the

1245
00:55:54,440 --> 00:56:00,319
general IDE aide behind this is normally

1246
00:55:56,520 --> 00:56:03,400
we do this kind of softmax over you know

1247
00:56:00,319 --> 00:56:06,240
a very large attention Vector but

1248
00:56:03,400 --> 00:56:08,440
instead we can approximate the softmax

1249
00:56:06,240 --> 00:56:11,520
by having some low rank vectors kind of

1250
00:56:08,440 --> 00:56:12,799
like what we used in Laura and uh

1251
00:56:11,520 --> 00:56:16,440
nonetheless get a reasonable

1252
00:56:12,799 --> 00:56:16,440
approximation of the softmax used

1253
00:56:17,799 --> 00:56:24,039
inion okay so we're nearing the end of

1254
00:56:21,520 --> 00:56:26,000
what I want to talk about today and

1255
00:56:24,039 --> 00:56:29,720
finally the thing that I'd like to talk

1256
00:56:26,000 --> 00:56:33,240
about is benchmarks for long PEX models

1257
00:56:29,720 --> 00:56:35,000
and there's a few benchmarks one very

1258
00:56:33,240 --> 00:56:37,359
well-known one is something called long

1259
00:56:35,000 --> 00:56:40,599
range Arena this is a composite

1260
00:56:37,359 --> 00:56:43,000
Benchmark containing mostly non NLP

1261
00:56:40,599 --> 00:56:45,280
tasks and it's definitely used for long

1262
00:56:43,000 --> 00:56:46,760
sequence modeling but the results on the

1263
00:56:45,280 --> 00:56:49,400
long range Arena actually tend to

1264
00:56:46,760 --> 00:56:51,599
diverge uh somewhat from the results

1265
00:56:49,400 --> 00:56:54,440
that you get for longdistance language

1266
00:56:51,599 --> 00:56:56,520
modeling so in addition to this another

1267
00:56:54,440 --> 00:56:58,400
benchmark that I uh personally like and

1268
00:56:56,520 --> 00:57:01,960
have used a bit is something called

1269
00:56:58,400 --> 00:57:05,720
Scrolls which uh combines together a

1270
00:57:01,960 --> 00:57:07,960
whole bunch of kind of QA style or

1271
00:57:05,720 --> 00:57:10,920
summarization style tasks that have very

1272
00:57:07,960 --> 00:57:13,280
long contexts including over narratives

1273
00:57:10,920 --> 00:57:15,680
or books or government reports or other

1274
00:57:13,280 --> 00:57:17,280
things like that so you can also take a

1275
00:57:15,680 --> 00:57:20,680
look at this if you're interested in

1276
00:57:17,280 --> 00:57:20,680
kind of benchmarking longer range

1277
00:57:21,839 --> 00:57:28,280
models okay the final thing I'd like to

1278
00:57:24,559 --> 00:57:30,280
talk about is now that we have retriever

1279
00:57:28,280 --> 00:57:31,680
models we have reader models we maybe

1280
00:57:30,280 --> 00:57:34,000
even have reader models that can

1281
00:57:31,680 --> 00:57:35,520
effectively use very long contexts like

1282
00:57:34,000 --> 00:57:37,880
the ones that we retrieve over whole

1283
00:57:35,520 --> 00:57:39,240
documents how do we effectively use them

1284
00:57:37,880 --> 00:57:43,640
in our

1285
00:57:39,240 --> 00:57:46,680
models so there was a very nice paper um

1286
00:57:43,640 --> 00:57:48,880
by Nelson Leo at Stanford that about a

1287
00:57:46,680 --> 00:57:51,160
phenomenon that was kinded lost in the

1288
00:57:48,880 --> 00:57:53,079
middle and basically what it does is it

1289
00:57:51,160 --> 00:57:55,119
demonstrates that many many different

1290
00:57:53,079 --> 00:57:57,720
models including state-of-the-art model

1291
00:57:55,119 --> 00:58:00,799
models pay less attention to things in

1292
00:57:57,720 --> 00:58:03,960
the middle of long context windows and

1293
00:58:00,799 --> 00:58:06,760
so if we have an answer and we put it in

1294
00:58:03,960 --> 00:58:09,200
you know the first position in Doc in

1295
00:58:06,760 --> 00:58:12,280
you know a concatenated context or the

1296
00:58:09,200 --> 00:58:13,799
20th position in a concatenated context

1297
00:58:12,280 --> 00:58:15,240
it tends to attend more to the ones at

1298
00:58:13,799 --> 00:58:18,359
the beginning or the

1299
00:58:15,240 --> 00:58:19,480
end in contrast the ones in the middle

1300
00:58:18,359 --> 00:58:22,760
kind of get

1301
00:58:19,480 --> 00:58:26,680
lost hence the name lost in the middle

1302
00:58:22,760 --> 00:58:29,520
and the problem with this is you know if

1303
00:58:26,680 --> 00:58:32,480
we are doing something like retrieval in

1304
00:58:29,520 --> 00:58:34,160
Reading then that's maybe not such a

1305
00:58:32,480 --> 00:58:35,680
huge problem because we could just put

1306
00:58:34,160 --> 00:58:37,680
you know the highest scoring documents

1307
00:58:35,680 --> 00:58:39,920
at the beginning that might even be more

1308
00:58:37,680 --> 00:58:42,440
effective than uh you know concatenating

1309
00:58:39,920 --> 00:58:44,160
lots of low scoring documents together

1310
00:58:42,440 --> 00:58:45,559
but if we want to read a really long

1311
00:58:44,160 --> 00:58:48,839
document and synthesize something

1312
00:58:45,559 --> 00:58:52,200
without doing kind of another uh scoring

1313
00:58:48,839 --> 00:58:54,200
step uh that can be an issue and also

1314
00:58:52,200 --> 00:58:56,359
you know our retriever is not perfect so

1315
00:58:54,200 --> 00:58:58,799
we would like the model to the reader

1316
00:58:56,359 --> 00:59:00,520
model to do a good job with the outputs

1317
00:58:58,799 --> 00:59:04,839
that it

1318
00:59:00,520 --> 00:59:06,359
has so there are methods uh to ensure

1319
00:59:04,839 --> 00:59:09,440
use of relevant

1320
00:59:06,359 --> 00:59:12,119
context so of course better retrievers

1321
00:59:09,440 --> 00:59:14,880
make more relevant context you can do

1322
00:59:12,119 --> 00:59:16,240
you know reranking or other things like

1323
00:59:14,880 --> 00:59:17,280
that and only include the context that

1324
00:59:16,240 --> 00:59:19,680
looks most

1325
00:59:17,280 --> 00:59:22,880
relevant um or you know refine your

1326
00:59:19,680 --> 00:59:25,200
reader model but there's also methods

1327
00:59:22,880 --> 00:59:28,720
that can decide whether contact should

1328
00:59:25,200 --> 00:59:32,400
be used in the first place so um there

1329
00:59:28,720 --> 00:59:35,440
are methods uh to decide whether to use

1330
00:59:32,400 --> 00:59:37,559
whether to include passages or not and

1331
00:59:35,440 --> 00:59:39,920
also uh recently we proposed a method to

1332
00:59:37,559 --> 00:59:42,640
filter down to parts of retrieve

1333
00:59:39,920 --> 00:59:44,920
passages uh to have only appropriate

1334
00:59:42,640 --> 00:59:47,480
content and this is a model uh that we

1335
00:59:44,920 --> 00:59:49,319
called filco it basically filters the

1336
00:59:47,480 --> 00:59:52,160
context down to the most relevant

1337
00:59:49,319 --> 00:59:53,920
content that we think is appropriate and

1338
00:59:52,160 --> 00:59:56,960
that allows us to get better results

1339
00:59:53,920 --> 00:59:56,960
when it's fed to the

1340
00:59:57,079 --> 01:00:03,640
generator so that's all I have for today

1341
01:00:00,319 --> 01:00:06,200
um thank you for watching the video and

1342
01:00:03,640 --> 01:00:08,599
for people in the class I'll be happy to

1343
01:00:06,200 --> 01:00:13,079
take questions on Piaza or during the

1344
01:00:08,599 --> 01:00:13,079
office hours that I had planned thanks a

1345
01:00:15,319 --> 01:00:18,319
lot