YouTube2Text

YouTube transcript (9vM4p9NN0Ts) — Transcript

19,443 words · 2,704 segments · language en · Watch on YouTube

Full transcript

  1. 0:05so let's get started uh so I'll be
  2. 0:07talking about building llms today um so
  3. 0:10I think a lot of you have heard of llms
  4. 0:12before uh but just as a quick recap uh
  5. 0:16llms standing for large language models
  6. 0:18are basically all the chat Bots uh that
  7. 0:20you've been hearing about recently so uh
  8. 0:24Chad GPT from open ey Claud from
  9. 0:27entropic Gemini and and lman other type
  10. 0:30of models like this and today we'll be
  11. 0:32talking about how do they actually work
  12. 0:34so it's going to be an overview because
  13. 0:35it's only one lecture and it's hard to
  14. 0:37compress everything but hopefully I'll
  15. 0:39touch a little bit about all the
  16. 0:40components that are needed to train uh
  17. 0:42some of these llms uh also if you have
  18. 0:44questions please interrupt me and ask uh
  19. 0:47if you have a question most likely other
  20. 0:49people in the room or on Zoom have other
  21. 0:52have the same question so please ask um
  22. 0:56great so what matters when training llms
  23. 0:59um so there a few key components that
  24. 1:01matter uh one is the architecture so as
  25. 1:04you probably all know LMS are newal
  26. 1:06networks and when you think about new
  27. 1:08networks you have to think about what
  28. 1:10architecture you're using and another
  29. 1:12component which is really important uh
  30. 1:13is the training loss and the training
  31. 1:15algorithm um so how you actually train
  32. 1:18these models then it's data so uh what
  33. 1:21do you train these models on um the
  34. 1:24evaluation which is how do you know
  35. 1:26whether you're actually making progress
  36. 1:28towards the goal of of uh llms and then
  37. 1:32the system component so that is like how
  38. 1:34do you actually make these models run on
  39. 1:37uh Modern Hardware which is really
  40. 1:38important because these models are
  41. 1:39really large um so now more than ever
  42. 1:42system is actually really an important
  43. 1:44topic um for
  44. 1:46llms so those five components um You
  45. 1:50probably all know that llms and if you
  46. 1:52don't know LMS are all based on
  47. 1:54Transformers or at least some version of
  48. 1:56Transformers uh I'm actually not going
  49. 1:58to talk about the AR lecture today uh
  50. 2:01one because I gave a SE lecture on um
  51. 2:04Transformers a few weeks ago and two
  52. 2:06because you can find so much information
  53. 2:08online on uh Transformers but I think
  54. 2:10you can it's there's much less
  55. 2:12information about the other four topics
  56. 2:14so I really want to talk about those um
  57. 2:17another thing to say is that most of
  58. 2:19Academia actually focuses on
  59. 2:21architecture and training algorithm and
  60. 2:23losses um as academics and I've done
  61. 2:26that for a lot big part of my career is
  62. 2:29simply we like thinking that this is uh
  63. 2:31like we make new architectures new
  64. 2:33models and it it seems like it's very
  65. 2:36important but in reality honestly what
  66. 2:38matters in practice is mostly the three
  67. 2:40other topics so data evaluation and
  68. 2:43systems uh which is what of most of
  69. 2:45Industry actually focuses on um so
  70. 2:48that's also one of the reason why I
  71. 2:49don't want to talk too much about the
  72. 2:51architecture uh because really the rest
  73. 2:52is super
  74. 2:53important um great so overview of the
  75. 2:56lecture I'll be talking about
  76. 2:57pre-training so pre-training uh you
  77. 2:59probably heard that word this is the
  78. 3:01general word this is kind of the
  79. 3:02classical language modeling uh Paradigm
  80. 3:06uh where you basically train your
  81. 3:07language model to essentially model all
  82. 3:09of internet and then there's a post
  83. 3:11training which is a more recent Paradigm
  84. 3:13which is taking these large language
  85. 3:14models and making them essentially AI
  86. 3:17assistants um so this is more of a
  87. 3:19recent Trend since Chad GPT uh so if you
  88. 3:23ever heard of gpt3 or gpt2 that's really
  89. 3:25pre-training land uh if you heard of
  90. 3:28chat GPT which you probably have this is
  91. 3:30really posttraining land uh so I'll be
  92. 3:32talking about both but I'll start with
  93. 3:34pre-training and uh specifically I'll
  94. 3:36talk about what is the task of
  95. 3:38pre-training llms and what is the laws
  96. 3:40that people actually
  97. 3:42use so language modeling this is a quick
  98. 3:45recap uh language models at a high level
  99. 3:48are simply models of probability
  100. 3:50distribution over sequences of tokens or
  101. 3:52of words so it's basically some uh model
  102. 3:56of P of X1 to XL where X1 is basically
  103. 3:59word one and Excel is the last one in
  104. 4:01the sequence or in the sentence um so
  105. 4:04very concretely if you have a sentence
  106. 4:06like the mouse ate the cheese what the
  107. 4:08language model gives you is simply a
  108. 4:10probability of this sentence being
  109. 4:13uttered by a human or being found on on
  110. 4:16online uh so if you have another
  111. 4:18sentence like the the mouse at cheese uh
  112. 4:22here there's grammatical mistakes so the
  113. 4:23model should know that this uh should
  114. 4:25have some syntactic knowledge so it
  115. 4:27should know that this has less
  116. 4:29likelihood of appearing
  117. 4:31online uh if you have another sentence
  118. 4:34like the cheese ate the mouse uh then
  119. 4:36the model should hopefully know about
  120. 4:38the fact that usually cheese don't eat
  121. 4:41Mouse um so there's some semantic
  122. 4:43knowledge and this is less likely than
  123. 4:44the first sentence so this is basically
  124. 4:46at a high level what language models are
  125. 4:49um one word that you probably have been
  126. 4:51hearing a lot in the news are generative
  127. 4:53models uh so this is just something that
  128. 4:55can generate models that can generate
  129. 4:57sentences or can generate some data uh
  130. 4:59the reason why we say language models
  131. 5:01are generative models is that once you
  132. 5:02have a model of a distribution you can
  133. 5:04simply sample from this model and now we
  134. 5:06can generate data uh so you can generate
  135. 5:08sentences uh using a language
  136. 5:11model so the type of models that uh
  137. 5:14people are all currently using are what
  138. 5:16we call Auto regressive language models
  139. 5:19and the key idea of autor regressive
  140. 5:21language models is that you take this
  141. 5:23distribution over words and you
  142. 5:26basically decompose it into the into the
  143. 5:28distribution of the first word multiply
  144. 5:31the by the distribution of or the
  145. 5:33likelihood of the distribution of the
  146. 5:34second word given the first word uh
  147. 5:37multiply by P of the third word given
  148. 5:39the first two words um so there's no
  149. 5:42approximation here this is just the
  150. 5:43chain rule of probability which you
  151. 5:44hopefully all know about uh really no
  152. 5:46approximation this is just one way of
  153. 5:48modeling a
  154. 5:49distribution uh so slightly more
  155. 5:51concisely you can write it as a product
  156. 5:53of U of PS of the next word given
  157. 5:56everything which happened in the past so
  158. 5:58of the context and uh so this this is
  159. 6:00what we call Auto regressive language
  160. 6:02models again this is really not the only
  161. 6:04way of modeling distribution this is
  162. 6:06just one way uh it has some benefits and
  163. 6:09some downsides one downside of
  164. 6:11autoaggressive language models is that
  165. 6:13when you actually sample from this
  166. 6:14autoaggressive language model you
  167. 6:16basically have a for Loop which
  168. 6:17generates the next word then conditions
  169. 6:20on that next word and then regenerate an
  170. 6:22other word so basically if you have a
  171. 6:24longer sentence that you want to
  172. 6:25generate you it takes more time to
  173. 6:27generate it uh so there are some
  174. 6:28downsides of this current Paradigm but
  175. 6:31that's what we currently have so I'm
  176. 6:33going to talk about this
  177. 6:34one uh great so Auto regressive language
  178. 6:37models at a high level um what the task
  179. 6:40of autoregressive language model is is
  180. 6:42simply predicting the next word as I
  181. 6:43just said so if you have a sentence like
  182. 6:45she likely prefers uh one potential next
  183. 6:48word might be dogs and the the way we do
  184. 6:51it is that we first tokenize so you take
  185. 6:55these words or subwords you tokenize
  186. 6:57them um and then you give an IDE for
  187. 7:00each token so here you have 1 2 three uh
  188. 7:03then you pass it through this black box
  189. 7:05as I already said we're not going to
  190. 7:06talk about the architecture you just
  191. 7:07pass it pass it through a model and you
  192. 7:10then get a distribution a probability
  193. 7:12distribution over the next word over the
  194. 7:15next token and then you sample uh from
  195. 7:19this distribution you get a new token
  196. 7:21and then you DET tokenize so you get a
  197. 7:23new ID you then DET toonize and that's
  198. 7:25how you basically sample from a language
  199. 7:27model uh one thing which is important to
  200. 7:29not is that the last two TS uh two steps
  201. 7:31are actually only need needed during
  202. 7:33inference uh when you do training you
  203. 7:35just need to predict uh the most likely
  204. 7:37token and you can just compare to the
  205. 7:39real token which happen in practice and
  206. 7:41then you basically change the weights of
  207. 7:43your model to increase the probability
  208. 7:45of generating that
  209. 7:48token um great so autoaggressive neural
  210. 7:51language models so to be slightly more
  211. 7:53specific still without talking about the
  212. 7:54architecture uh the first thing we do is
  213. 7:57that we have all of these oh sorry yes
  214. 7:59on the previous slide when you're
  215. 8:01predicting the probability of the next
  216. 8:02tokens does this mean that your final
  217. 8:04like output VOR has to be the same
  218. 8:06dimensionality as the number of tokens
  219. 8:08that you have yes how do you deal with
  220. 8:11like if you have more to like if you're
  221. 8:13adding more tokens to your cor something
  222. 8:16yeah so we're going to talk about
  223. 8:17tokenization actually later uh so you
  224. 8:19will get some sense of this you
  225. 8:22basically can deal with adding new
  226. 8:24tokens I am I'm kind of exaggerating
  227. 8:26there are methods for doing it but
  228. 8:27essentially people don't do it um so
  229. 8:30it's really important to think about how
  230. 8:32you tokenize your text and that's why
  231. 8:33we'll talk about that later but it's a
  232. 8:36very good point to notice that you
  233. 8:37basically the vocabulary size so the
  234. 8:38number of tokens that you have is
  235. 8:40essentially the output of your uh
  236. 8:42language model so it's actually pretty
  237. 8:44pretty
  238. 8:45large okay so autoaggressive new
  239. 8:47language models first thing you do is
  240. 8:49that you take every word or every token
  241. 8:52you embed them so you get a um some
  242. 8:55Vector representation for each of these
  243. 8:57tokens um you pass them through some ual
  244. 8:59Network as we said it's a Transformer
  245. 9:01then you get a representation for all
  246. 9:03the word in all the words in the context
  247. 9:06so it's basically representation of the
  248. 9:08entire sentence uh you pass it through a
  249. 9:10linear layer as you just said to
  250. 9:13basically map it to the number so that
  251. 9:16the output the number of outputs is the
  252. 9:17number of tokens uh you then pass it
  253. 9:20through some soft Max and you basically
  254. 9:22get uh probity distribution over the
  255. 9:25next words given every word in the
  256. 9:27context
  257. 9:30and the law that you use is basically
  258. 9:32it's essentially a task of classifying
  259. 9:34the next token so it's a very simple
  260. 9:36kind of machine learning task so you use
  261. 9:37the cross entry P loss where you
  262. 9:39basically you look at the actual Target
  263. 9:43that happened which is a target
  264. 9:45distribution which is a one hot encoding
  265. 9:46which here in this in this case says I
  266. 9:49saw uh the real word that happened is
  267. 9:51cat so that's a one hot um distribution
  268. 9:54over cat and here this is the actual uh
  269. 9:57do you see my mouse oh yeah this is the
  270. 9:59distribtion that you generated and
  271. 10:00basically you do cross entropy which
  272. 10:02really just increases the probability of
  273. 10:03generating cat and decreases all the the
  274. 10:05probility of generating all the other
  275. 10:07tokens one thing to notice is that as
  276. 10:10you all know again uh this is just
  277. 10:12equivalent to maximizing the text log
  278. 10:14like the text log likelihood because you
  279. 10:16can just rewrite the the max over the
  280. 10:20probability of um this autoregressive
  281. 10:22language moding task as just being this
  282. 10:25minimum over I just added the log here
  283. 10:27and minus which is just the minimum of
  284. 10:30the loss which is the cross enty loss so
  285. 10:31basically minimizing the loss is the
  286. 10:33same thing as maximizing the likelihood
  287. 10:35of your text any question
  288. 10:42questions
  289. 10:43okay
  290. 10:45tokenizer um so this is one thing that
  291. 10:48people usually don't talk that much
  292. 10:50about tokenizers are extremely important
  293. 10:53uh so it's really important that you
  294. 10:54kind of understand at least uh what they
  295. 10:56do at a high level so why do we need
  296. 10:58token in the first place uh first it's
  297. 11:01more General than words so one simple
  298. 11:04thing that you might think is oh we're
  299. 11:05just going to take every word that we
  300. 11:06will have you just say every word is a
  301. 11:09new is a token in its own um but then
  302. 11:11what happens is if there's a typo in
  303. 11:13your word then you might not have any
  304. 11:16token associated with this this word
  305. 11:19with a typo and then you don't know how
  306. 11:20to actually pass this word with a typo
  307. 11:22into a large language model so what do
  308. 11:24you do next and also even if you think
  309. 11:27about words words is a very like words
  310. 11:29are fine with like Latin based languages
  311. 11:32uh but if you think about a language
  312. 11:34like taii you won't have a simple way of
  313. 11:36tokenizing by spaces because there are
  314. 11:37no spaces between words um so really uh
  315. 11:41tokens are much more General Than Words
  316. 11:43first thing second thing that you might
  317. 11:45think is that you might tokenize every
  318. 11:47sentence character by character you
  319. 11:49might say a is one token b is another
  320. 11:51token uh that would actually work and
  321. 11:54probably very well the issue is that
  322. 11:56then your sequence becomes super long
  323. 11:58and as you probably remember from the
  324. 12:00lecture on on Transformers uh the
  325. 12:02complexity uh grows quadratically with
  326. 12:05the length of sequences so you really
  327. 12:07don't want to have a super long sequence
  328. 12:09um so tokenizers basically try to deal
  329. 12:13with those two problems and give common
  330. 12:17subsequences a certain token and usually
  331. 12:20how you should be think about is around
  332. 12:22uh an average every token is around
  333. 12:24three four letters
  334. 12:26um and there are many algorithm for
  335. 12:29tokenization I'll just talk about one of
  336. 12:31them to give you a high level which is
  337. 12:32what we call bite P en coding which is
  338. 12:34actually pretty common one of the two
  339. 12:35most common tokenizers and the way that
  340. 12:38you train a tokenizer is that first you
  341. 12:40start with a very large Corpus of text
  342. 12:42and here I'm really not talking about
  343. 12:44training a large language model yet this
  344. 12:45is purely for the tokenization step uh
  345. 12:48so this is my large Corpus of text with
  346. 12:50these five words um then you associate
  347. 12:54every character in this Corpus of text a
  348. 12:57different token uh so here I just split
  349. 12:59up every character with a different
  350. 13:01token uh and I just color coded all of
  351. 13:04those tokens and then what you do is
  352. 13:06that you go through your text and every
  353. 13:08time you see pairs of tokens that are
  354. 13:11very common the most common pair of
  355. 13:13token you just merge them so here you
  356. 13:15see three times the the the tokens T and
  357. 13:19O next to each other so you're just
  358. 13:21going to say this is a new token and
  359. 13:22then you continue you repeat that so now
  360. 13:24you have to talk which happens three
  361. 13:27times to with an E that happens sorry
  362. 13:31two times and an token which happens
  363. 13:34twice and then ex which also happen
  364. 13:36twice so this is that if you were to
  365. 13:39train a tokenizer on this Corpus of text
  366. 13:41which is very small that's how you would
  367. 13:43uh finish with a token with a pre like a
  368. 13:45trained tokenizer uh in reality you do
  369. 13:48it on on much larger corpuses of text um
  370. 13:51and this is the real tokenizer of uh
  371. 13:54actually I think this is gpt3 or chat
  372. 13:56GPT uh and here you see how it would
  373. 13:59actually separate these words so
  374. 14:00basically you see the same thing as what
  375. 14:01we gave in the previous example token
  376. 14:04becomes its own token so tokenizer is
  377. 14:08actually split up into two tokens token
  378. 14:10and iser um so yeah that's all about
  379. 14:14tokenizers any questions on that yeah
  380. 14:16how do you deal with spes and how do you
  381. 14:18deal
  382. 14:19with yeah so actually there's a a step
  383. 14:22before tokenizers which is what we call
  384. 14:24pre- tokenizers which is exactly what
  385. 14:26you just said uh so this is mostly
  386. 14:29in theory there's no reason to deal with
  387. 14:31spaces and punctuation separately you
  388. 14:34could just say every space gets its own
  389. 14:36token every um uh punctuation get its
  390. 14:39own token and you can just do all the
  391. 14:41merging the problem is that so there's
  392. 14:43an efficiency question actually training
  393. 14:45these tokenizes takes a long time uh so
  394. 14:48you better off because you have to
  395. 14:49consider every pair of token so what you
  396. 14:52end up doing is saying if there's a
  397. 14:53space this is very like pre- tokenizes
  398. 14:55are very English specific you say if
  399. 14:57there's a space we're not going to start
  400. 14:59looking at the the token that came
  401. 15:00before and the token that came
  402. 15:02afterwards so you're not merging in
  403. 15:04between spaces but this is just like a
  404. 15:07optimiz like a computation optimization
  405. 15:10you could theoretically just deal with
  406. 15:11it um the same way as you deal with any
  407. 15:13other character and yeah when you merge
  408. 15:17tokens do you delete the tokens that you
  409. 15:19merged away or do you keep the the
  410. 15:21smaller tokens that merge um you
  411. 15:23actually keep the smaller tokens I mean
  412. 15:25in reality it doesn't matter much
  413. 15:26because um usually on large Corpus of
  414. 15:31text you will have actually everything
  415. 15:32uh but you usually keep the small ones
  416. 15:34and the reason why you want to do that
  417. 15:35is because if in case there's as we said
  418. 15:37before you have some um some grammatical
  419. 15:40mistakes so some typos you still want to
  420. 15:42be able to represent these words by
  421. 15:44character um so yeah yes are the tokens
  422. 15:50unique so I mean say in this case T Ken
  423. 15:54is there only one occurrence or could do
  424. 15:56you need to leave multiple occurr so
  425. 15:59they could have take on different
  426. 16:00meanings or something oh oh I see what
  427. 16:02you say no no it's every token has its
  428. 16:05own uh unique ID um so a usual this is a
  429. 16:10great question for example if you think
  430. 16:11about a bank which could be bank for
  431. 16:14like money or bank like water um it will
  432. 16:16have the same token but the model will
  433. 16:18learn the Transformer will learn that
  434. 16:20based on the words that are around it it
  435. 16:23should associate that I'm saying I'm
  436. 16:25being very high wavy here but associate
  437. 16:27that with the with a with a
  438. 16:29representation that is either more like
  439. 16:31the bank money side or the Bank water
  440. 16:34side um but that's a Transformer that
  441. 16:35does that it's not a
  442. 16:37tokenizer yes yeah so you mentioned
  443. 16:40during tokenization keep the smaller
  444. 16:41tokens you started with right like if
  445. 16:44you start with a t you keep the T and
  446. 16:46then you build your tokenizer to the
  447. 16:48that you can now in token so let's say
  448. 16:50maybe you didn't train on token but like
  449. 16:52in your data you are trying to encode
  450. 16:54token so how does the tokenizer know to
  451. 16:57encode it with token or
  452. 17:00a great question you basically when you
  453. 17:01so when you tokenize so that's after
  454. 17:03training of the tokenizer when you
  455. 17:04actually apply the tokenizer you
  456. 17:06basically always choose the largest uh
  457. 17:09token that you can apply uh so if you
  458. 17:11can do token you will never do T you
  459. 17:13will always do token um but there's
  460. 17:16actually so people don't usually talk
  461. 17:18that much about tokenizers but uh
  462. 17:20there's a lot of of computational
  463. 17:22benefits uh or computational tricks that
  464. 17:24you can do for making these things
  465. 17:26faster uh so I really don't think we and
  466. 17:28honestly I think a lot of people think
  467. 17:29that we should just get away from
  468. 17:31tokenizers um and just kind of tokenize
  469. 17:34character by character or bites by bites
  470. 17:37uh but as I said right now there's this
  471. 17:38issue of like length uh but maybe one
  472. 17:40day like in five or 10 years we will
  473. 17:42have different architectures that don't
  474. 17:43scale quadratically with the length of
  475. 17:45the sequence and uh maybe we'll um yeah
  476. 17:49move away from tokenizes so can you
  477. 17:51share with us the drawback why do people
  478. 17:53want to move away from the tokenizer oh
  479. 17:56um yeah so think
  480. 18:00one good example is uh math if you think
  481. 18:03about math actually numbers right now
  482. 18:06are not tokenized so for example 327
  483. 18:08might have its own token which means
  484. 18:10that models when they see numbers they
  485. 18:13don't see them the same way as we do and
  486. 18:15this is very annoying because what I
  487. 18:17mean the reason why we can kind of
  488. 18:18generalize with math is because we can
  489. 18:20deal with every every letter separately
  490. 18:22and we can then do composition where you
  491. 18:24know that basically if you add stuff
  492. 18:26it's just the same thing as adding every
  493. 18:28one separately plus like whatever the
  494. 18:29unit that you add so they can do that um
  495. 18:32so then you have to do like special
  496. 18:34tokenization and like one of the big
  497. 18:36changes that GPT 4 did uh is changing
  498. 18:40the way that they tokenize uh code so
  499. 18:43for example uh if you have code you know
  500. 18:45you have like often in Python these four
  501. 18:46spaces at the beginning those were dealt
  502. 18:49with uh kind of strangely before um and
  503. 18:52as a result like the model couldn't
  504. 18:54really understand uh how to deal with
  505. 18:56code uh so so toiz actually a lot um
  506. 19:00okay so I'll move on right now but we
  507. 19:03can come back later on token Isis great
  508. 19:06so we talked about the task the L the
  509. 19:07tokenizer let's talk a little bit about
  510. 19:10evaluation uh so the way that LMS are
  511. 19:12usually evaluated is what we call is
  512. 19:14using what we call perplexity um at a
  513. 19:17high level it's basically just your
  514. 19:18validation loss uh the slight difference
  515. 19:20with perplexity is that we use something
  516. 19:22that is slightly more interpretable
  517. 19:24which is that we use the average per
  518. 19:26token loss and then you expon entiate it
  519. 19:29and the reason why you exponentiate it
  520. 19:31is because you want I mean the loss has
  521. 19:33a log inside and you like one humans are
  522. 19:36actually pretty bad at thinking in log
  523. 19:37space but two logs depend on the base of
  524. 19:40the log uh while when you exponentiate
  525. 19:42you basically have everything in the uh
  526. 19:45kind of the vocabulary size uh unit um
  527. 19:48and the average proten is just so that
  528. 19:50your your complexity is independent of
  529. 19:52the length of your sequence um so
  530. 19:54perplexity is just two to the power uh
  531. 19:56average of the loss of the sequence
  532. 19:59um so perplexity is between one and the
  533. 20:03length of the vocabulary of your
  534. 20:04tokenizer uh one it's simply well if you
  535. 20:07predict perfectly the thing which uh
  536. 20:09every word then every word will have
  537. 20:12basically product of ones uh so the best
  538. 20:15perplexity you can have is one if you
  539. 20:17really have no idea you basically
  540. 20:18predict with one divided by uh size of
  541. 20:21vocabulary um and then you do simple
  542. 20:23math and you basically get perplexity of
  543. 20:25size of vocabulary uh so the intuition
  544. 20:27of perplexity is that basically the
  545. 20:29number of tokens that your model is kind
  546. 20:31of hesitating between uh so if you if
  547. 20:33your model is perfect it doesn't
  548. 20:34hesitate it know exactly the word if it
  549. 20:37really has no idea then it hesitates
  550. 20:39between uh all of the
  551. 20:42vocabulary uh so perplexity really
  552. 20:45improved that's perplexity on a standard
  553. 20:48data set between 2017 and 2023 it it
  554. 20:51went from kind of 70 tokens to less than
  555. 20:5410 tokens over these five six years so
  556. 20:56that means that the models were
  557. 20:58previously as dating between 70 words
  558. 21:00every time it was generating a word and
  559. 21:02now it's as dating between like less
  560. 21:04than 10 words so that's much better
  561. 21:06perplexity is actually not used anymore
  562. 21:08in academic benchmarking mostly because
  563. 21:10it depends on the tokenizers that you
  564. 21:12use uh it depends on the actual data
  565. 21:14that people are evaluating on but it's
  566. 21:16still very important for development of
  567. 21:18llms so when you when you actually train
  568. 21:20your own llm people will still really
  569. 21:22look at the
  570. 21:24perplexity uh one common other way and
  571. 21:28now more common in Academia of
  572. 21:30evaluating these llms is just by taking
  573. 21:33all the classical NLP benchmarks and
  574. 21:35I'll give you a few examples later and
  575. 21:37just kind of aggregating everything um
  576. 21:39so collect as many automatically
  577. 21:41evaluatable benchmarks and just evaluate
  578. 21:44across all of them um so one such if uh
  579. 21:48or actually two such uh benchmarks of
  580. 21:51what we call uh Helm which is from
  581. 21:53Stanford and another one is the hugging
  582. 21:55face open LM leader board which are the
  583. 21:57probably two two most common ones right
  584. 21:58now um so just to give you an idea in
  585. 22:02Helm there are all of these type of
  586. 22:03tasks which are mostly things that can
  587. 22:06be easily evaluated uh like question
  588. 22:09answering so think about many different
  589. 22:11question answering uh tasks um and the
  590. 22:14benefit with question answering is that
  591. 22:15you usually know what is the real answer
  592. 22:18um so you can the way that you evaluate
  593. 22:20these models and I'll give you a
  594. 22:21concrete example in one second um is
  595. 22:23that you can just look at How likely the
  596. 22:25language model is to generate the real
  597. 22:28answer compared to some other answers
  598. 22:30and that's essentially at a high level
  599. 22:32how you evaluate these models um so to
  600. 22:34give you a specific example mlu is
  601. 22:36probably the most common um academic
  602. 22:39Benchmark for
  603. 22:41llms uh and this is just a collection of
  604. 22:44many question and answers in all of
  605. 22:46those domains for example College
  606. 22:48medicine College physics astronomy and
  607. 22:51these type of topics and the questions
  608. 22:53are things like so this in astronomy
  609. 22:55what is true for type 1 a supernova then
  610. 22:58you give uh four different potential
  611. 23:01answers and you just ask the model which
  612. 23:03one is more likely so there are many
  613. 23:05different ways of doing it either you
  614. 23:07can look at the likelihood of generating
  615. 23:09all these answers uh or you can ask the
  616. 23:11model which one is the most likely uh so
  617. 23:13there are different ways that you can
  618. 23:14promp the model but at a high level you
  619. 23:16know which one is correct and there are
  620. 23:17three other mistakes um yes kind
  621. 23:22creating is like unconstrained text as
  622. 23:24the output yeah how do you evaluate a
  623. 23:26model if it give something that's you
  624. 23:29know semantically completely identical
  625. 23:32but is not the exact token list that
  626. 23:35expect yeah so that's a great question
  627. 23:37I'll talk more about that later here in
  628. 23:39this case we don't do unconstrained so
  629. 23:41the way you would evaluate MML is
  630. 23:43basically either you you ask the first
  631. 23:46question and then you look at the
  632. 23:47likelihood of the model generating a the
  633. 23:50likelihood of the model generating b c
  634. 23:53and d and you look at which one is the
  635. 23:54most likely or you can as the model out
  636. 23:57of ABC d which one is the most likely
  637. 23:59and you look at whe the to the most
  638. 24:01likely next token is A B C or D so uh
  639. 24:04you can strain the model to say it can
  640. 24:06only answer these four things you say
  641. 24:09you constraint the model you mean you
  642. 24:11constraint The Prompt or do you mean of
  643. 24:13its whole probability distribution
  644. 24:15outputs you only comparing the outputs
  645. 24:18like you're only comparing the
  646. 24:20a so uh in the second case I gave you
  647. 24:23you would do exactly the I actually you
  648. 24:24would do both you would prompt the model
  649. 24:26saying ABC or D plus you would constrain
  650. 24:28to only uh look at these two these four
  651. 24:31tokens in the first case you don't even
  652. 24:33need to generate anything so in the
  653. 24:34first case you literally just look given
  654. 24:36that it's a language model it can give a
  655. 24:38distribution over sentences you just
  656. 24:40look at what is the likelihood of
  657. 24:42generating all of these words what is
  658. 24:45the likelihood of generating the second
  659. 24:47choice and you just look at whether the
  660. 24:49most likely sentence is actually the
  661. 24:52real answer so you don't actually sample
  662. 24:55from it you really just use P of x one
  663. 24:58to excel does that make sense uh that
  664. 25:01being said evaluation of open-ended
  665. 25:04questions is something we're going to
  666. 25:05talk about later and is actually really
  667. 25:07important and really challenging yes
  668. 25:10earlier you mentioned that um like um
  669. 25:13metrics like flexity are not are not
  670. 25:15like usually used because it depends on
  671. 25:17like how you do your terization some
  672. 25:19design choices I was wondering if you
  673. 25:21could speak more to that oh um yeah so
  674. 25:25think about perplexity I told you
  675. 25:27perplexity is between one and vocabulary
  676. 25:29size so now imagine that Chad GPT uses a
  677. 25:32tokenizer that has like 10,000 tokens
  678. 25:35but Gemini from Google uses a tokenizer
  679. 25:37that had 100,000 uh potential tokens
  680. 25:41then actually the Gemini one will will
  681. 25:44have like the upper bound of the the
  682. 25:46perplexity that you can get is actually
  683. 25:47worse for Gemini than for Chad GPT does
  684. 25:51that make sense so that's just an idea
  685. 25:54it's actually a little bit more
  686. 25:55complicated than that but that's just
  687. 25:56like one uh first or the bit of you can
  688. 25:58see that the tokenizer actually
  689. 26:01matters um
  690. 26:04great okay so evaluation challenges
  691. 26:07there are many I'll just talk about two
  692. 26:09really briefly uh one as I told you
  693. 26:11there are two ways of doing evaluation
  694. 26:13for these mlu actually there are many
  695. 26:15more than two but I give you two
  696. 26:16examples um and it happens that for a
  697. 26:19long time even though that was a very
  698. 26:21classical Benchmark that everyone used
  699. 26:23uh actually different uh different
  700. 26:26companies and different um different uh
  701. 26:30uh different organization were actually
  702. 26:32using different ways of evaluating mlu
  703. 26:35and as a result you could you get
  704. 26:36completely different results for example
  705. 26:38Lama
  706. 26:3965b uh which was the first model of meta
  707. 26:42in the Lama series uh had on Helm 63.7
  708. 26:47accuracy but on this other um Benchmark
  709. 26:50had like
  710. 26:5148.8 um so really the way that you
  711. 26:54evaluate and this is not even talking
  712. 26:56about prompting this is really just kind
  713. 26:58of the the way that you evaluate the uh
  714. 27:00the models prompting is another issue so
  715. 27:02really there are a lot of
  716. 27:03inconsistencies it's not as easy as it
  717. 27:06looks uh first thing yeah sorry how can
  718. 27:09we make sure that all these models AR
  719. 27:10trained on The Benchmark okay second
  720. 27:13thing this is a great question uh chain
  721. 27:15test contamination uh this is something
  722. 27:18which I would say is really important in
  723. 27:22Academia in uh given that the talk is
  724. 27:25mostly about training large language
  725. 27:26models uh for companies it's maybe not
  726. 27:29that important CU they know what they
  727. 27:31trained on uh for us we have no idea so
  728. 27:35for us it's a real problem uh so there
  729. 27:37are many different ways of trying to
  730. 27:39test whether uh the test set sorry
  731. 27:43whether the test set was actually in the
  732. 27:44training Set uh one kind of cute trick
  733. 27:48um that people uh in in the lab on T lab
  734. 27:52have found is that what you can do is
  735. 27:54that given that most of the data set
  736. 27:56online are not randomized
  737. 27:58you can just look at and in that
  738. 28:00language models what they do is just
  739. 28:02predict the next word um you can just
  740. 28:04look at the entire test Set uh what if
  741. 28:07you generate all the examples in order
  742. 28:10versus all the examples in a different
  743. 28:13order and if it's more likely to
  744. 28:15generate a thing in order given that
  745. 28:17there's no real order there then it
  746. 28:19means that probably was in a training
  747. 28:20set does that make sense um so there are
  748. 28:23many that's like one of them there are
  749. 28:24many other ways of doing it train test
  750. 28:27contamination again not that important
  751. 28:28for development really important for
  752. 28:30academic
  753. 28:32benchmarking great so there are many
  754. 28:34other challenges but uh I'll move on for
  755. 28:36now great data um so data is another
  756. 28:41really big topic um at a high level
  757. 28:44people just say oh you basically train
  758. 28:46large language models on all of Internet
  759. 28:48what does that even mean um so or people
  760. 28:51sometimes say all of clean internet
  761. 28:53which is even less defined um so
  762. 28:56internet is very dirty and really not
  763. 28:58representative of what we want in
  764. 29:00practice if I download a random website
  765. 29:03right now you would be shocked at what
  766. 29:05is in there it's definitely not your
  767. 29:07Wikipedia um so I'll go really briefly
  768. 29:12on like what people do um I can answer
  769. 29:14some questions but I mean data is on its
  770. 29:17own is a huge topic uh basically first
  771. 29:20what you do is download all of Internet
  772. 29:22what that means is that you use uh web
  773. 29:24crowlers that will go on every web page
  774. 29:27on Internet or every web page that is um
  775. 29:30on Google uh and that is around 250
  776. 29:34billion pages right now um and that's
  777. 29:36around one petabyte of of data so this
  778. 29:39is actually a common common C is one web
  779. 29:42crowler so people will usually write
  780. 29:43their own web crowlers what they do is
  781. 29:45that they use standard web crowlers and
  782. 29:47we common crawl is one of them uh that
  783. 29:50basically every month adds all the new
  784. 29:52websites that were added on uh internet
  785. 29:55that are found by by Google and they put
  786. 29:57it in a big uh basically a big data set
  787. 30:00um so that's on common call you have
  788. 30:02around 250 billion pages right now so 1
  789. 30:05E6 gigabytes of data once you have this
  790. 30:09uh so this is a random web page like
  791. 30:11literally random uh from this common
  792. 30:13craw and what you see is that one it
  793. 30:15really doesn't look at type of things
  794. 30:17that you would usually see but actually
  795. 30:19so this is an HTML page uh it's hard to
  796. 30:22see but if you look through you will see
  797. 30:25some content for example here here uh
  798. 30:29tesing world is your ultimate source for
  799. 30:32the system X high performance server and
  800. 30:34then you have three dots so you don't
  801. 30:35even the sentence is not even finished
  802. 30:37that's how a random internet looks like
  803. 30:40uh so of course it's not that useful if
  804. 30:42you just train a like large language
  805. 30:44model to generate things like this so
  806. 30:46what are some of the steps that are
  807. 30:47needed first one you extract the text
  808. 30:50from the HTML so that's what I just try
  809. 30:52to do by looking at uh basically the
  810. 30:54correct text uh there are a lot of
  811. 30:56challenges by through this for example
  812. 30:58extracting math is actually very
  813. 31:00complicated but pretty important for
  814. 31:01training large language models um or for
  815. 31:04example boiler plates a lot of your
  816. 31:06forums will have the same type of
  817. 31:07headers the same type of Footers uh you
  818. 31:10don't want to repeat all of this in your
  819. 31:12data um then you will filter undesirable
  820. 31:15content uh so not safe for work harmful
  821. 31:19content pii uh so usually every company
  822. 31:21has basically a a black list of websites
  823. 31:25that they don't want to train the models
  824. 31:27on that Black List is very long and you
  825. 31:29basically say if it comes from there we
  826. 31:31don't train on this there are other ways
  827. 31:32of doing these things is that you can
  828. 31:34train a small model for classifying what
  829. 31:36is pii removing these things um it's
  830. 31:40hard every Point here that I'm going to
  831. 31:42show you is like a hard amount of work
  832. 31:46uh but I'm going to go go quickly
  833. 31:47through it so filter undesirable content
  834. 31:50second or fourth is the dup D
  835. 31:53duplication as I said um you might have
  836. 31:56things like headers and Footers in
  837. 31:58forums that are always the same you want
  838. 32:00to remove that another thing that you
  839. 32:01might have is a lot of URLs that are
  840. 32:04different but actually show the same
  841. 32:06website um and you might also have a lot
  842. 32:10of like U um paragraphs that come from
  843. 32:13like common books that are basically
  844. 32:14duplicated a thousand times or 10,000
  845. 32:17times on internet so you have to
  846. 32:19duplicate also very challenging uh
  847. 32:22because you have to do that at scale
  848. 32:24once you do duplication you will do some
  849. 32:26heuristic filtering you will try to
  850. 32:28remove low quality documents uh the way
  851. 32:31you do that are things like rules-based
  852. 32:33um filtering for example if you see that
  853. 32:36there are some outlier tokens if the
  854. 32:38distribution of tokens in the website is
  855. 32:39very different than the usual
  856. 32:40distribution of tokens then it's
  857. 32:42probably some outlier if you see that
  858. 32:44the length of the words in this website
  859. 32:46is super long there's something strange
  860. 32:48going on on that website if you see that
  861. 32:50the the website has only three words
  862. 32:52maybe is it worth training on it maybe
  863. 32:54not if it has like 10 million words
  864. 32:56maybe there's something also
  865. 32:58wrong going on that page um so a lot of
  866. 33:00rules like this yes why we filter out
  867. 33:03undesirable content from our dat set
  868. 33:05instead of kind
  869. 33:06of putting it in is like a supervised
  870. 33:09loss right like can we not just say like
  871. 33:12you know here's this like hate speech
  872. 33:13website let's actively try to Let's
  873. 33:17actively penalize the for generating
  874. 33:19we'll do exactly that but not at this
  875. 33:22step that's where the posttraining will
  876. 33:24come from uh pre-training um the idea is
  877. 33:28just to say I want to model kind of how
  878. 33:32humans speak essentially um and I want
  879. 33:35to remove all these like headers photos
  880. 33:36and and menus and things like this but
  881. 33:38it's a very good uh like idea that you
  882. 33:41just had and that's exactly what we'll
  883. 33:42do
  884. 33:44later Next Step modelbased filtering so
  885. 33:47once you filtered a lot of data what you
  886. 33:49will do uh that's actually a very cute
  887. 33:51trick uh you will take all of Wikipedia
  888. 33:53and you will look at all the links that
  889. 33:56are linked through Wikipedia p
  890. 33:58because probably if something is
  891. 33:59referenced by Wikipedia it's probably
  892. 34:01some high quality website and you will
  893. 34:03train a classifier to predict whether
  894. 34:06something comes from whether a document
  895. 34:09comes from one of these references uh
  896. 34:12from Wikipedia or whether it's from the
  897. 34:14random web and you will try to basically
  898. 34:16say I want more of the things that come
  899. 34:19from Wikipedia references does that make
  900. 34:22sense so yeah so you will train a a
  901. 34:25machine learning uh model usually also
  902. 34:27very simp simple models because you need
  903. 34:28to do that really at scale I mean just
  904. 34:30think about the 250 billion
  905. 34:32Pages uh next one you will try to
  906. 34:36classify your data into different
  907. 34:38different um domains you will say okay
  908. 34:41this is entertainment this is books this
  909. 34:43is code this is like these type of
  910. 34:45domains and then you will try to either
  911. 34:49um up or down weight some of the domains
  912. 34:52uh for example you might say uh you
  913. 34:54might see that actually if you train
  914. 34:56more on code then actually your model
  915. 34:58becomes bettered on reasoning so that's
  916. 34:59something that people usually say in a
  917. 35:01very handwavy way if you train your
  918. 35:03model more code actually it helps
  919. 35:04reasoning so you want to upweight the
  920. 35:07coding uh distribution because that
  921. 35:09helps for General language modeling
  922. 35:10skills uh books is usually also another
  923. 35:13one that people usually um upweight
  924. 35:16entertainment they usually downweight uh
  925. 35:18so things like this of course you want
  926. 35:20to do it so people used to do it maybe
  927. 35:23uh kind of theistically now there's
  928. 35:25entire pipelines that we'll talk about
  929. 35:28of how to do these things uh slightly
  930. 35:30more um
  931. 35:32automatically and then at the end of
  932. 35:34training uh usually train um after
  933. 35:38training on all of this data that we saw
  934. 35:40usually train on very high quality data
  935. 35:42at the end of of training your large
  936. 35:45language model where you decrease your
  937. 35:46learning rate uh and that basically
  938. 35:48means that you're kind of overfitting
  939. 35:50your model on a very high quality data
  940. 35:52so usually what you do there is like
  941. 35:54Wikipedia you basically overfit on
  942. 35:57Wikipedia yeah and you overfit on like
  943. 36:00human uh data that was collected um the
  944. 36:04other things like continual pre-training
  945. 36:06for getting longer context I'm I'm going
  946. 36:08to skip over all of these things uh but
  947. 36:10I just to give you a sense of how hard
  948. 36:12it is when people just say oh I'm going
  949. 36:13to train on internet that's a lot of
  950. 36:16work um and really we haven't figured it
  951. 36:18out yet so collecting World data is a
  952. 36:22huge part of practical large language
  953. 36:24model uh some might say it's actually
  954. 36:26the key yes
  955. 36:28about data so basic question so usually
  956. 36:30when you start with like the terabyte of
  957. 36:33data after I go through all that steps
  958. 36:35the typical amount of data you have in
  959. 36:37and then like how how large a team does
  960. 36:40it typically think to go through all the
  961. 36:42steps you talk about so how is the
  962. 36:44question how large is the data after you
  963. 36:46filter yeah after you filter and then to
  964. 36:48go through all the step how large a team
  965. 36:50do you need to go through like the the
  966. 36:52other fation sttion uh how slow is it or
  967. 36:56how like how how many people would you
  968. 36:58need to be able to do this uh okay
  969. 37:02that's a great question I'm going to
  970. 37:04somewhat answer about the data uh how
  971. 37:06large is the data set uh at the end of
  972. 37:08this slide uh for number of people that
  973. 37:12work on
  974. 37:13it um that's a good question I'm
  975. 37:15actually not quite sure but I would
  976. 37:18say yeah I actually don't quite no but I
  977. 37:22would say it's probably even bigger than
  978. 37:24the number of people that work on kind
  979. 37:26of the two tuning of the pre-training of
  980. 37:28the model uh so the data is bigger than
  981. 37:31kind of the modeling aspect um yeah I I
  982. 37:35don't think I have a good sense I would
  983. 37:38say probably in Lama's team which have
  984. 37:40like 70 years people I would say maybe
  985. 37:4215 work on data uh I yeah all these
  986. 37:47things you don't need that many people
  987. 37:48you need a lot of computer so because
  988. 37:49for data you need a lot of CPUs um so
  989. 37:53yeah and I'll answer the second question
  990. 37:54at the end of this slide so as I just
  991. 37:57kind of alluded to really we haven't
  992. 38:00solved data at all for pre-training so
  993. 38:02there's a lot of research that that has
  994. 38:03to be done first how do you process
  995. 38:05these things super efficiently uh second
  996. 38:07how do you balance kind of like all of
  997. 38:09these different domains uh can you do
  998. 38:11synthetic data generation that's
  999. 38:12actually a big one right now uh and
  1000. 38:15because we don't have uh we'll talk
  1001. 38:16about that later we don't have enough
  1002. 38:18data on the internet um can you use
  1003. 38:21multimodal data instead of just text
  1004. 38:23data and how does that improve even your
  1005. 38:25text performance um
  1006. 38:28there's a lot of seccy because really
  1007. 38:30this is the key of most of the pre-train
  1008. 38:32pre-trained large language models so for
  1009. 38:34competitive Dynamics uh usually these
  1010. 38:37these um these companies don't talk
  1011. 38:40about how they do the data collection
  1012. 38:41and also there's a copyright liability
  1013. 38:43issue they definitely don't want to tell
  1014. 38:44you that they've trained on books even
  1015. 38:46though they did um because if not you
  1016. 38:48can uh sue them uh common academic
  1017. 38:51benchmarks uh so that will kind of
  1018. 38:53answer what you asked um it started so
  1019. 38:55those are the smaller ones it's the
  1020. 38:57names are not that important but it
  1021. 38:59started from around 150 billion tokens
  1022. 39:02which around uh 800 GB of data now it's
  1023. 39:05around 15 trillion of to 15 trillion
  1024. 39:07tokens which is also uh the size of the
  1025. 39:10models that are right now the best
  1026. 39:12models are probably trained on that
  1027. 39:13amount of data so 15 trillion tokens uh
  1028. 39:16which is probably I guess two order of
  1029. 39:19manage bigger than that so 80 uh E3 gab
  1030. 39:23so that would be
  1031. 39:25around 100 to thousand times uh
  1032. 39:28filtering of the common crawl if I'm not
  1033. 39:31mistaken um so yeah one very one very uh
  1034. 39:35famous one is the pile so this is
  1035. 39:37academic Benchmark of the pile and we
  1036. 39:39can just look at what distribution of
  1037. 39:41data they have it's things like um
  1038. 39:44archive PBM Central uh which is all the
  1039. 39:47the biology stuff uh here it's Wikipedia
  1040. 39:52you see stack exchange um some GitHub
  1041. 39:56and some books and things like this um
  1042. 39:58again this is on the smaller side so
  1043. 40:00this is if we look at here this is on
  1044. 40:01280b so in reality it's like 100 times
  1045. 40:04bigger so you cannot have that much of
  1046. 40:05GitHub and and of
  1047. 40:07Wikipedia um in terms of close Source
  1048. 40:10models just to give you an idea uh Lama
  1049. 40:132 um it was trained on 20 two trillion
  1050. 40:16tokens lamb 3 15 trillion tokens which
  1051. 40:19is currently the best model that we know
  1052. 40:21on how much it was trained on which is
  1053. 40:22the same thing as this the the the best
  1054. 40:25academic or the biggest academic
  1055. 40:27Benchmark which is 15 trillion tokens
  1056. 40:29GPD 4 we don't really know but it's
  1057. 40:30probably in the same water of magnitude
  1058. 40:32or it's probably around that actually
  1059. 40:33it's probably around 13 um from leaks if
  1060. 40:36the leaks are true
  1061. 40:39um great so scaling laws um any other
  1062. 40:43questions on Data before you go to
  1063. 40:45scaling
  1064. 40:48laws sorry I know I'm giving you a lot
  1065. 40:50of information but uh there's a lot into
  1066. 40:52training at large language models great
  1067. 40:55scaling laws so so the idea is that what
  1068. 40:58people saw um around 2020 or at least
  1069. 41:01from a long time but they've been able
  1070. 41:03to kind of theoretically show it or
  1071. 41:06impurely show it since 2020 is that the
  1072. 41:08more data you train your models on and
  1073. 41:10the larger the models the better the
  1074. 41:11performance this is actually pretty
  1075. 41:13different than what you've seen in this
  1076. 41:15class in this class we teach you about
  1077. 41:16overfitting overfitting doesn't happen
  1078. 41:18with large language models uh larger
  1079. 41:21models better performance um it's
  1080. 41:24something that really took a long time
  1081. 41:25for the community who took this type of
  1082. 41:27class to realize um but for the exam
  1083. 41:31overfitting
  1084. 41:32exists so okay the idea of scaling laws
  1085. 41:36is that if given that you know that more
  1086. 41:38data and larger models will always give
  1087. 41:41you better performance can we predict
  1088. 41:44how much better your performance will be
  1089. 41:46if you increase the amount of data and
  1090. 41:48the size of your model and surprisingly
  1091. 41:51it works uh so here you see three plots
  1092. 41:53from a very famous paper called scaling
  1093. 41:55loss from openi um here you see on the
  1094. 41:58x-axis compute so how much did you train
  1095. 42:01like how much compute did you did you
  1096. 42:02spend for training and here you see test
  1097. 42:04loss so this is essentially I mean it's
  1098. 42:07not perplexity but it's your validation
  1099. 42:08loss um so it's a log of the perplexity
  1100. 42:11and if you put these two on uh log scale
  1101. 42:15uh then you see that uh the the
  1102. 42:17performance or like the this the sorry
  1103. 42:20the the scaling law is linear uh that
  1104. 42:22means that if you increase your compute
  1105. 42:25by a certain amount you can you can say
  1106. 42:26by how much your test loss will actually
  1107. 42:29decrease same thing with data and same
  1108. 42:32thing for parameters if you increase the
  1109. 42:34data set size your loss will will
  1110. 42:36decrease by an amount that is somewhat
  1111. 42:39predictable if you increase the number
  1112. 42:40of parameters it will decre the loss
  1113. 42:43will decrease by amount which is
  1114. 42:44somewhat predictable this is really
  1115. 42:46amazing um very surprising I mean it
  1116. 42:49looks in nocuous when you look at these
  1117. 42:51type of plots but that's crazy because
  1118. 42:53it means that you can predict uh how
  1119. 42:55well we're going to perform in 2 3 years
  1120. 42:58depending on how much compute we will
  1121. 42:59add assuming that these things will hold
  1122. 43:01there's nothing theoretical about it um
  1123. 43:04yes two things one what is the loss that
  1124. 43:07they're using here is this perplexity or
  1125. 43:09so it's it's you know I said perplexity
  1126. 43:11was like two to the power of the LW so
  1127. 43:13this is the the the power of the
  1128. 43:16perplexity and then the second thing is
  1129. 43:18when you like increase the number of
  1130. 43:20parameters or you increase the total
  1131. 43:21data set size going dat times doesn't
  1132. 43:25that just inherently increase your
  1133. 43:27compute like do all this work to
  1134. 43:31just specific no this is a great
  1135. 43:33question so the compute here is actually
  1136. 43:35a factor of two things the data and the
  1137. 43:37parameter what I'm showing here is that
  1138. 43:39you can um well actually we're going to
  1139. 43:40talk about that in details but basically
  1140. 43:42if you increase the number of parameters
  1141. 43:44you should increase the number of data
  1142. 43:46that you have um so you actually don't
  1143. 43:49go multiple times through the same data
  1144. 43:50set no one does EPO in a lar at least
  1145. 43:55not yet uh because we have still kind of
  1146. 43:58enough data um so yeah this is all the
  1147. 44:01same Trend which is increase compute
  1148. 44:03decrease
  1149. 44:04loss yes have we seen the numbers for
  1150. 44:07the last two years or is it still
  1151. 44:10holding it is still holding I I don't
  1152. 44:14have like good numbers to show you uh
  1153. 44:16but it is still holding
  1154. 44:20surprisingly yes is there no evidence
  1155. 44:22like empirical evidence that you
  1156. 44:25plateau expected PL
  1157. 44:28no empirical evidence of plateauing
  1158. 44:30anytime soon um why we don't know um
  1159. 44:36will it happen probably I mean it
  1160. 44:38doesn't need to because it's actually in
  1161. 44:39log scale so it's not like as if it had
  1162. 44:43to go it had to Plateau like
  1163. 44:45mathematically it could continue
  1164. 44:46decreasing like this I mean most people
  1165. 44:48think that it will probably Plateau at
  1166. 44:49some point we don't know
  1167. 44:51when um okay so that's I'll talk more
  1168. 44:55about scaling laws now
  1169. 44:57so why are scaling laws really cool
  1170. 45:00imagine that I give you um you're very
  1171. 45:02fortunate I gave you 10,000 gpus for
  1172. 45:04this month what model will you train how
  1173. 45:07do you even go about answering that
  1174. 45:08question and I mean this is a a
  1175. 45:11hypothetical but that's exactly what
  1176. 45:13these companies are faced with uh the
  1177. 45:16old pipeline um which was basically you
  1178. 45:19tune High parameters on the big models
  1179. 45:21so let's say I have 30 days I will train
  1180. 45:2430 models for one day each I will pick
  1181. 45:27the best one uh and that will be the
  1182. 45:29final model that I will use in
  1183. 45:31production um that means that the model
  1184. 45:33that I actually used was only trained
  1185. 45:34for one day the new pipeline is that you
  1186. 45:38first find a scaling recipe so you find
  1187. 45:40something that tells you for example oh
  1188. 45:43like one common thing is that if you
  1189. 45:44increase the size of your model you
  1190. 45:46should decrease your learning rate so
  1191. 45:47you find a scaling recipe such that you
  1192. 45:49know if I increase the the the the size
  1193. 45:52of my model here's what I should do with
  1194. 45:53some high parameters then you tune your
  1195. 45:56high parameter
  1196. 45:57on smaller models of different sizes
  1197. 46:00let's say I will say for 3 Days of my 30
  1198. 46:03days I will train many different models
  1199. 46:05and I would do highper parameter tuning
  1200. 46:07on these small models each of different
  1201. 46:08sizes then I will fit a scaling law and
  1202. 46:11try to extrapolate from these smaller
  1203. 46:14models which one will be the best if I
  1204. 46:17if I train it for much longer or sorry
  1205. 46:20if I train it for a larger model and
  1206. 46:23then I will train the final huge model
  1207. 46:24for 27 days instead of just one day
  1208. 46:27um so the new pipeline is not train
  1209. 46:31things or do high prity tuning on the
  1210. 46:33real scale of the model that you're
  1211. 46:34going to use in practice but do things
  1212. 46:36on smaller ones at different scales try
  1213. 46:39to predict how well they will perform
  1214. 46:41once you make them bigger I will give I
  1215. 46:43will give you a very concrete example
  1216. 46:45right now uh let's say Transformers
  1217. 46:48versus lstms let's say you you have
  1218. 46:50these 10,000 gpus you will not sure
  1219. 46:52which one you should be using should I
  1220. 46:53be using Transformer based model or LCM
  1221. 46:55based model what I will do is I will
  1222. 46:57train Transformers at different skills
  1223. 47:00so here you see different parameters on
  1224. 47:01the x-axis Y axis is my test loss I will
  1225. 47:04then train different different lstms at
  1226. 47:07different scales once I have these
  1227. 47:09points I will see oh it kind of fits a
  1228. 47:11scaling law I will fit my scaling law
  1229. 47:13and then I will be able to predict oh if
  1230. 47:16I had 10 times more compute here's how
  1231. 47:19well I would perform for the LM it's
  1232. 47:21actually slightly less linear for the
  1233. 47:22lstm but like you could probably try to
  1234. 47:25predict where you would end up and
  1235. 47:26clearly from this plot you would see
  1236. 47:28that Transformers are better um one
  1237. 47:31thing to notice when you read these type
  1238. 47:32of scaling laws is that are two things
  1239. 47:34that are important uh one is really your
  1240. 47:38scaling rate uh which is kind of the uh
  1241. 47:42the slope of the the slope of the
  1242. 47:45scaling law the other thing is your um
  1243. 47:48your intercept like you could start
  1244. 47:51worse but actually become better over
  1245. 47:53time it just happens that lstms are
  1246. 47:55worse for both uh but I could show you
  1247. 47:57another one where things you can predict
  1248. 47:59that actually after a certain scale
  1249. 48:01you're better off using that type of
  1250. 48:03model than others uh so that's why
  1251. 48:05scaling laws are actually really
  1252. 48:07useful any questions on
  1253. 48:11that yeah so these are all kind of very
  1254. 48:15how how sensitive are these to like
  1255. 48:17small differences in the architecture
  1256. 48:18like one one like Transformer
  1257. 48:21architecture versus another Transformer
  1258. 48:23architecture you basically have to like
  1259. 48:25fit your own curve and make basically
  1260. 48:27say like oh scaling law has tell me
  1261. 48:28there should be some like logarithmic
  1262. 48:30function let me extrapolate that for my
  1263. 48:34own yeah so uh usually for example if
  1264. 48:37you're an academic and you want to now
  1265. 48:39at least that's like pretty recent and
  1266. 48:41you want to propose a new like
  1267. 48:42activation uh that's exactly what you
  1268. 48:44will do you will fit a scaling law show
  1269. 48:46another scaling law with the standard
  1270. 48:48like I don't know G and you will say
  1271. 48:50that it's better in reality once you
  1272. 48:51start thinking about it in scaling loss
  1273. 48:53terms you really realize that actually
  1274. 48:55all the architecture differences that we
  1275. 48:57can make like the small minor ones all
  1276. 48:59they do is maybe change a little bit the
  1277. 49:01The
  1278. 49:02Intercept but really that doesn't matter
  1279. 49:05uh cuz just train it for 10 hours longer
  1280. 49:07or like wait for the next uh for the
  1281. 49:09next Compu gpus and these things are
  1282. 49:11really secondary which is exactly why I
  1283. 49:12was telling you originally people spend
  1284. 49:14too much time on the architecture and
  1285. 49:15losses um in reality these things don't
  1286. 49:18matter as much data though if you use
  1287. 49:20good data you will have much better
  1288. 49:22scaling loss than if use bad data so
  1289. 49:24that really matters
  1290. 49:27uh another really cool thing you can do
  1291. 49:28with scaling laws is that you can ask
  1292. 49:30yourself uh how to optimally allocate
  1293. 49:33training resources should I train larger
  1294. 49:36models because we saw that it's better
  1295. 49:38when you train larger models but we saw
  1296. 49:40that it's also better when you use more
  1297. 49:41data so which one should I do should I
  1298. 49:44just train on more data a smaller model
  1299. 49:45or should I train a larger model on less
  1300. 49:47data um so chinchilla is a very famous
  1301. 49:52paper that first showed this uh the way
  1302. 49:54they did it I want to give you a little
  1303. 49:55bit of a sense of what these plots are
  1304. 49:58uh here you see training loss again on
  1305. 50:00the x-axis you see parameter parameter
  1306. 50:02differences uh sorry parameter size uh
  1307. 50:04number of parameters so the size of the
  1308. 50:05model and here all these curves are what
  1309. 50:07we call isof flops which is that all the
  1310. 50:11models on this curve H have been trained
  1311. 50:14with the same amount of
  1312. 50:16compute um the way that you do that is
  1313. 50:18that you train you change sorry you vary
  1314. 50:20the number of tokens that we trained on
  1315. 50:22and the size of the models but you vary
  1316. 50:24in such a way that the total compute is
  1317. 50:26constant
  1318. 50:27okay so all these curves that you see
  1319. 50:28with different colors have different
  1320. 50:30amount of computers that were trained on
  1321. 50:32then you take the best one for each of
  1322. 50:34those curves once you have the best one
  1323. 50:36for each of those curves um you can ask
  1324. 50:40you can plot um how much flops it was
  1325. 50:44and which curve were you on and how much
  1326. 50:46parameters did you actually use for
  1327. 50:49training that specific point you put
  1328. 50:51that on the on the log log uh scale
  1329. 50:54again and now you fit a scaling law
  1330. 50:56again so now I have something which
  1331. 50:58tells me if I want to train a model of
  1332. 51:0110^ 23 flops here's exactly the number
  1333. 51:04of parameters that I should be using 100
  1334. 51:07100b and you can do the same thing with
  1335. 51:09flops and
  1336. 51:10tokens so now you can predict if if I
  1337. 51:14tell you exactly I have one month of
  1338. 51:16compute what size of model should I be
  1339. 51:18training F your scaling law and I tell
  1340. 51:20you um of course that all looks
  1341. 51:23beautiful in reality like there's like
  1342. 51:25there's a lot of like small things of
  1343. 51:26like should you be counting like
  1344. 51:27embedding parameters like there's
  1345. 51:29there's a lot of complexities but if you
  1346. 51:31do things well these things actually do
  1347. 51:34hold um so the optimal number of
  1348. 51:37parameters that that chinchilla Pap have
  1349. 51:39found is to use 20 tokens for every
  1350. 51:42parameter that you train uh so if you
  1351. 51:44add one more parameter you should add
  1352. 51:45you should train your thing on your
  1353. 51:47model on 20 more tokens so one caveat
  1354. 51:50here is that this is optimal training
  1355. 51:52resources so that is telling me if you
  1356. 51:54have 10^ 23 FL
  1357. 51:57or if you have like 100 I don't know how
  1358. 51:58much that is100 million or 10 no that's
  1359. 52:02much less actually let's say I have $5
  1360. 52:03million to to train my best model that
  1361. 52:06gets the lowest loss how how what would
  1362. 52:08I train on in reality these companies
  1363. 52:11need to think about inference also if
  1364. 52:13you have a smaller model they will spend
  1365. 52:16less over time um so actually if you
  1366. 52:18consider the inference cost you have
  1367. 52:20other papers that Tred to show that um
  1368. 52:22it's around
  1369. 52:24150 uh parameters per sorry tokens per
  1370. 52:27parameters because you prefer having a
  1371. 52:29smaller model cuz over time you're going
  1372. 52:32to you're going to actually um spend
  1373. 52:35less money on inference of these models
  1374. 52:37so 150 to one that's around what the
  1375. 52:40best models are trained on right now at
  1376. 52:43least the ones that are that are used um
  1377. 52:46in practice for in
  1378. 52:49production
  1379. 52:51great any question on
  1380. 52:55chin great oh sorry in practice how
  1381. 52:58expensive is inference for these models
  1382. 53:01rela to
  1383. 53:02train actually very expensive uh I will
  1384. 53:05not talk about inference because that
  1385. 53:06would be another entire lecture but just
  1386. 53:09think about Chad GPT where they have I
  1387. 53:12don't know how much it is now like 600
  1388. 53:14million people that used it um like
  1389. 53:19that's a lot
  1390. 53:21um yeah so it's actually very expensive
  1391. 53:24there's a lot of optimization you can do
  1392. 53:26for in though um and that's an entire
  1393. 53:28other lecture so I'm going to skip that
  1394. 53:30uh this time but it's very
  1395. 53:32interesting okay tuning um as I said
  1396. 53:35there are many things that you can uh
  1397. 53:37answer with scaling laws I just try to
  1398. 53:39give you two examples uh but really
  1399. 53:41there are many things what data do you
  1400. 53:43use what mixture what data mixing
  1401. 53:45waiting you use data mixtures that's
  1402. 53:47what we talked about before uh what
  1403. 53:49architecture you use whether you should
  1404. 53:51make your models uh wider or deeper um
  1405. 53:54should you be paying for more gpus or
  1406. 53:56actually collecting more data um all
  1407. 53:59these things are things you can try to
  1408. 54:00answer with scaling
  1409. 54:02laws one thing I want to say is the bit
  1410. 54:05lesson if you ever heard of Richard
  1411. 54:07sudden a very famous blog post in 2019
  1412. 54:10um what he realized uh which I think not
  1413. 54:15enough people realize I didn't
  1414. 54:17definitely did not realize at that time
  1415. 54:19um is that once you see these type of
  1416. 54:21scaling laws you know that the more
  1417. 54:23compute you have the better models you
  1418. 54:25will get so with skill you will get
  1419. 54:27better model and you also know by Mo law
  1420. 54:30or these type of variant of Mo law that
  1421. 54:32you will always have better compute then
  1422. 54:34the only thing that matters is just to
  1423. 54:37have architectures that can leverage
  1424. 54:39computation so what matters is basically
  1425. 54:41systems data and less so the
  1426. 54:44architecture like the small architecture
  1427. 54:46differences like your your your
  1428. 54:47activation and things like this uh so I
  1429. 54:50think that's like one of the reasons why
  1430. 54:51most of research focuses on um some
  1431. 54:54things that for industry matters less
  1432. 54:56and I was one of those researchers for a
  1433. 54:59large part of my my career um so don't
  1434. 55:02spend time over complicating do the
  1435. 55:05simple things do it well seal them
  1436. 55:08that's really what openi taught us with
  1437. 55:10um with chat gpg and with all the gpts
  1438. 55:14before okay I want to give you some
  1439. 55:16backup the envelope computation so I
  1440. 55:19might be off by a few factors here but I
  1441. 55:20just want to give you a sense of how
  1442. 55:22costly it is to train some of these
  1443. 55:24models I'll give as an example
  1444. 55:26Lama 3 400b which is currently the best
  1445. 55:29open source model that you can get uh it
  1446. 55:32was trained on 15.6 tokens it has 45
  1447. 55:36billion parameters so just now that you
  1448. 55:38know what is like this uh optimal tokens
  1449. 55:41per parameter that's around 40 so that's
  1450. 55:43a little bit more than chinchilla but
  1451. 55:45less than this like inference uh optimal
  1452. 55:49um model so they went for training
  1453. 55:52optimality uh flops for this model so
  1454. 55:55one simple uh way to compute flops is
  1455. 55:57six uh times the number of parameters
  1456. 56:00times the number of data you train on uh
  1457. 56:03so if you do the simple calculation here
  1458. 56:04it's 3.8 e25 flops the reason why this
  1459. 56:08is important is that if you follow the
  1460. 56:10little bit the news there's an executive
  1461. 56:11order from Biden that basically says
  1462. 56:13that once you have uh 1 e26 parameters
  1463. 56:17uh sorry flops uh then you have special
  1464. 56:20scrutiny on your models so they went 2x
  1465. 56:22less than that so they really went right
  1466. 56:24below this to not have special scrutiny
  1467. 56:27so 38 uh I might be off by a little bit
  1468. 56:29but it's definitely under the 1
  1469. 56:3426 oh um so paramet p is parameters n is
  1470. 56:40data number of tokens this is a uh this
  1471. 56:43is just an
  1472. 56:44approximation we
  1473. 56:47yeah okay uh compute and we know that
  1474. 56:51they trained on 16,000
  1475. 56:53h100s um and we know the throughput but
  1476. 56:56they they said it too uh so if you do
  1477. 56:59the computation it takes around 70 days
  1478. 57:02um or 26 million GPU hours at least
  1479. 57:05that's with my uh back of the envelope
  1480. 57:07computation they actually said that they
  1481. 57:09use 30 million instead of 26 million GPU
  1482. 57:12hours um so maybe they had like some uh
  1483. 57:16some challenges I don't really know but
  1484. 57:18if you follow the simple computation
  1485. 57:20it's around 70 days um cost uh I mean
  1486. 57:24this it's hard to to approximate but I'm
  1487. 57:27just going to say it's kind of the rent
  1488. 57:29like what if I were to rent h100s that
  1489. 57:32many h100s for that many days how much
  1490. 57:35will I pay uh h100 a lower bound on the
  1491. 57:38on the renting uh cost of h100 is around
  1492. 57:412 hours uh $2 per hour so if you
  1493. 57:44multiply this by 26 million uh hours uh
  1494. 57:48you get 52 million uh dollars so they
  1495. 57:51probably pay less than that but not
  1496. 57:53actually much less because all these um
  1497. 57:57all these services that actually rent
  1498. 57:58gpus they don't make that much money so
  1499. 58:00it's it's probably slightly less but not
  1500. 58:02that much less um now salary I said 50
  1501. 58:06employees 500k per
  1502. 58:09year say yeah it's probably the right
  1503. 58:11ballpark 25 million uh so if you put all
  1504. 58:14together around 75 million um dollars
  1505. 58:17for
  1506. 58:18training uh this Slammer model I'm
  1507. 58:21probably off by like 10 million but but
  1508. 58:23that's kind of right uh bpk
  1509. 58:27carbon emitted um a lot of people might
  1510. 58:30ask like also the cost is not the only
  1511. 58:32thing that is important so I did the
  1512. 58:34computation um it's around 4 uh 4,000 um
  1513. 58:40tons of CO2 equivalent that is actually
  1514. 58:43only 2,000 return tickets from JFK to uh
  1515. 58:46London so right now uh carbon emitted is
  1516. 58:50actually not uh I mean it's huge but
  1517. 58:52it's not like um meaningful yeah yet I
  1518. 58:56think in maybe GPT 6 gpt7 once you
  1519. 59:01multiply this by 100 that might become a
  1520. 59:03real issue right now it's still not uh I
  1521. 59:06think um an issue in the grand scheme of
  1522. 59:08things next model the way you should be
  1523. 59:11thinking about these models is that
  1524. 59:12every new generation the number of flops
  1525. 59:15essentially uh multiplies 10x or at
  1526. 59:17least that's what they try uh if they
  1527. 59:19have enough energy and if they can buy
  1528. 59:21enough
  1529. 59:22gpus uh great any question on these back
  1530. 59:25of the envelope math
  1531. 59:29no
  1532. 59:31okay so now we talked about pre-training
  1533. 59:34I wanted to also chat about systems
  1534. 59:36because now we know computer is really
  1535. 59:38important so there's a question of how
  1536. 59:39do you optimize the how do you optimize
  1537. 59:42your computer I will leave that for the
  1538. 59:44end because I'm not sure how much time
  1539. 59:45we will have I think it's important but
  1540. 59:47hopefully I I'll be able to to talk
  1541. 59:49about it later it's slightly different
  1542. 59:51than what we've been talking about right
  1543. 59:53now so I'll move on to post training for
  1544. 59:55now
  1545. 59:56so the task of post training ER the
  1546. 59:59reason why we need to do Post training
  1547. 1:00:01is as I told you before um it's to make
  1548. 1:00:04AI assistants so language modeling is
  1549. 1:00:07not uh really the thing that you want
  1550. 1:00:10when you have an AI assistant uh for
  1551. 1:00:12example if you ask to gbd3 which is a
  1552. 1:00:15purely language Model A pure language
  1553. 1:00:17model not a um not an aligned one if you
  1554. 1:00:20ask a question like explain the moon
  1555. 1:00:22landing to a
  1556. 1:00:23six-year-old the completion that you
  1557. 1:00:25would get is something like explain the
  1558. 1:00:27theory of gravity to a six-year-old
  1559. 1:00:29because what it learned is that on on on
  1560. 1:00:31internet if you have one question you
  1561. 1:00:33usually have maybe another bullet point
  1562. 1:00:35of other similar questions you don't
  1563. 1:00:37usually have question and then answer
  1564. 1:00:38later uh this is not what you want from
  1565. 1:00:41an AI assistant so how do we uh do this
  1566. 1:00:45alignment which is this post training
  1567. 1:00:46and making these models
  1568. 1:00:48assistance um so the goal of this
  1569. 1:00:51alignment is to basically get LMS follow
  1570. 1:00:54the instructions that are given um by
  1571. 1:00:56users and and maybe some designers kind
  1572. 1:01:00of desires um so think about moderation
  1573. 1:01:03you don't want the model like open ey
  1574. 1:01:05definitely doesn't want the model to say
  1575. 1:01:07stuff that is very
  1576. 1:01:08toxic um so here you see on the left
  1577. 1:01:11hand side uh that when you ask a
  1578. 1:01:13question it actually provides a a real
  1579. 1:01:15answer so it's not like uh before the
  1580. 1:01:17llm and on the right hand side you see
  1581. 1:01:19that it would if you ask to write a
  1582. 1:01:21tweet describing how a certain part of
  1583. 1:01:25the population are evil it will say that
  1584. 1:01:27it cannot do that um so that's kind of
  1585. 1:01:31this
  1586. 1:01:31alignment uh the background here is that
  1587. 1:01:35uh basically the data that you want for
  1588. 1:01:38training some of these models um is like
  1589. 1:01:41we know what we want which is just
  1590. 1:01:43asking humans this is a question this is
  1591. 1:01:44the answer that you want uh but the
  1592. 1:01:46thing is that it's very expensive to
  1593. 1:01:48collect that data and it's hard to find
  1594. 1:01:49it online uh in contrast pre-training
  1595. 1:01:52data is not what you want but there's a
  1596. 1:01:55lot of it um so what what we will do a
  1597. 1:01:57the main idea is simply take a pre-train
  1598. 1:02:00large language model pre-train all of
  1599. 1:02:02internet and then you just fine tune so
  1600. 1:02:03you just change a little bit of weights
  1601. 1:02:05on the type of data that you actually
  1602. 1:02:06want and hopefully given it you already
  1603. 1:02:08pre-train it on all of Internet it
  1604. 1:02:10basically learns or knows how to speak
  1605. 1:02:12in English and and knows a standard um
  1606. 1:02:16language syntax uh then you can really
  1607. 1:02:19find tune in with very little
  1608. 1:02:22data okay sft so supervis fine tuning is
  1609. 1:02:26really exactly what I just said which is
  1610. 1:02:27the idea of fine-tuning the large
  1611. 1:02:29language model on uh basically the
  1612. 1:02:32desired answers that are collected from
  1613. 1:02:34humans um so why is it called supervis
  1614. 1:02:37fine tuning because you basically want
  1615. 1:02:38to do language modeling on the real
  1616. 1:02:41ansers so language modeling is this like
  1617. 1:02:42next word prediction and and that's the
  1618. 1:02:44fine-tuning part and then you want to do
  1619. 1:02:46it on desired answers given by humans so
  1620. 1:02:48that's why we call it
  1621. 1:02:50supervis so how do we collect this data
  1622. 1:02:52well we I just said it you just ask
  1623. 1:02:54humans uh to to tell you this is the
  1624. 1:02:56this is a question this is the answer
  1625. 1:02:58that you uh you would want from some of
  1626. 1:03:00these models so this is an example um
  1627. 1:03:03sorry I can't read very well on my
  1628. 1:03:04computer but uh my kid uh needs to do a
  1629. 1:03:07science um no let's read this one can
  1630. 1:03:09you write a short introduction about the
  1631. 1:03:12relevance of the term monopsony and then
  1632. 1:03:14it says monopsony refers to a market
  1633. 1:03:15structure blah blah blah and that's a
  1634. 1:03:16human that wrote that um so actually
  1635. 1:03:19this is open Assistant which was a a way
  1636. 1:03:22to collect um uh data online by
  1637. 1:03:27humans so this type of supervised fine
  1638. 1:03:30tuning or alignment is really the key of
  1639. 1:03:32Chad GPT this is what made uh the big
  1640. 1:03:35jump from gpt3 which was mostly
  1641. 1:03:37something that was known by AI
  1642. 1:03:39researchers to Chad GPT which became
  1643. 1:03:42known by basically
  1644. 1:03:44everyone
  1645. 1:03:46um so the problem with uh human data is
  1646. 1:03:51that it's uh very slow to collect and
  1647. 1:03:54very expensive um so
  1648. 1:03:57one possible simple idea is to use llms
  1649. 1:04:01to scale data collection uh so that's
  1650. 1:04:03exactly what we did with alpaca uh one
  1651. 1:04:06year ago what we did is that we asked uh
  1652. 1:04:08humans or we use a data set of human uh
  1653. 1:04:11question answers so there were 175 uh
  1654. 1:04:14question answers here and we asked the
  1655. 1:04:15best mod at the time so text3 to
  1656. 1:04:18basically generate many more of these
  1657. 1:04:21question and answers so all we did is
  1658. 1:04:23like this is what humans would write now
  1659. 1:04:25write similar answers and similar
  1660. 1:04:26questions and we collected 52,000 LM
  1661. 1:04:30generated question answers and then what
  1662. 1:04:32we did is simply we took Lama 7B which
  1663. 1:04:34was the best pre-train model at the time
  1664. 1:04:36and we just fine- tuned this with
  1665. 1:04:38supervised fine tuning as I told you and
  1666. 1:04:40that's how we got um the Alpac s7b
  1667. 1:04:43model uh and this is the type of data
  1668. 1:04:46that we collected so things like what
  1669. 1:04:48does algorithm mean an algorithm is a
  1670. 1:04:50step by a stepbystep uh set of
  1671. 1:04:52instruction used to solve a problem or
  1672. 1:04:54achieve a goal blah blah blah blah so
  1673. 1:04:56the data is not actually it's actually
  1674. 1:04:58pretty good given it was LM generated by
  1675. 1:05:00LMS from essentially two generations ago
  1676. 1:05:04um so that really started at least for
  1677. 1:05:07us kind of as an academic replication of
  1678. 1:05:09chat GPT uh now it really there's a big
  1679. 1:05:12field of like synthetic data generation
  1680. 1:05:14of how to use llms to basically make
  1681. 1:05:18development of llms faster um and by
  1682. 1:05:21basically by decreasing the amount of of
  1683. 1:05:23human hours that you need
  1684. 1:05:27quantity of data so we talked about what
  1685. 1:05:29type of data and how we collect it um
  1686. 1:05:31one thing which is surprising with sft
  1687. 1:05:33is that you don't need that much data uh
  1688. 1:05:36so what this paper showed this is called
  1689. 1:05:38Lima is that if you have if you scale
  1690. 1:05:41the amount of data that use from uh
  1691. 1:05:43supervised fine training from 2,000 to
  1692. 1:05:4532,000 it really doesn't help much so
  1693. 1:05:48here scaling laws definitely don't help
  1694. 1:05:50um so the the intuition here is that all
  1695. 1:05:53you learn um is is you learn how to
  1696. 1:05:56format your desired answers another way
  1697. 1:05:59of saying it is that your pre-trained
  1698. 1:06:01models they essentially model the
  1699. 1:06:03distribution of every user on internet
  1700. 1:06:05one that might write bullet points
  1701. 1:06:07another one that might answer qu answer
  1702. 1:06:09question with an answer so all you tell
  1703. 1:06:11your model is like wait you should
  1704. 1:06:13actually be optimizing more for this
  1705. 1:06:15type of user than another one so you're
  1706. 1:06:17not actually teaching it and you're not
  1707. 1:06:19teaching anything through this um sft uh
  1708. 1:06:23so supervis fine tuning all you do is
  1709. 1:06:25you tell the model to kind of optimize
  1710. 1:06:27for one type of user that it saw already
  1711. 1:06:29in a pre-train data set so the knowledge
  1712. 1:06:31is already in the pre-train llm uh and
  1713. 1:06:33you basically just specialize to one
  1714. 1:06:35type of
  1715. 1:06:36user great any question on
  1716. 1:06:40sft yes so I know it's a big issue with
  1717. 1:06:44synthetic data where uh if you keep
  1718. 1:06:47generating data from the same
  1719. 1:06:49distribution eventually you're not
  1720. 1:06:50learning a new distribution you're
  1721. 1:06:51essentially playing with it it just
  1722. 1:06:52bootstrapping that yeah surely
  1723. 1:06:56you can't scale that forever right you
  1724. 1:06:57can't keep going on and generating from
  1725. 1:06:59the same distribution you hope to learn
  1726. 1:07:01something new yeah uh so are there it's
  1727. 1:07:03an active area of research but any
  1728. 1:07:05thoughts that you have around how people
  1729. 1:07:07are maybe thinking around this and uh
  1730. 1:07:10better ways to bootstrap or to give up
  1731. 1:07:12on this idea and and realize that the
  1732. 1:07:14chart shows you don't need that many so
  1733. 1:07:16just get humans to generate 2,000 really
  1734. 1:07:18good uh yeah so that's a very good
  1735. 1:07:20question uh so for the data stuff so I'm
  1736. 1:07:23saying it's not that important for sft
  1737. 1:07:24but there will be another thing we'll
  1738. 1:07:25talk about right after where actually
  1739. 1:07:28data does
  1740. 1:07:29matter my intuition based on not that
  1741. 1:07:32much empirical results is that you can
  1742. 1:07:34still get um even though you use your
  1743. 1:07:37LMS if you use purely LM generated text
  1744. 1:07:40and you do that for like three four
  1745. 1:07:42generations of llms I agree with you
  1746. 1:07:43that probably you won't improve much but
  1747. 1:07:46for me what is important is how do you
  1748. 1:07:47use like human in the loop with llms not
  1749. 1:07:50purely LMS not purely uh humans but
  1750. 1:07:53maybe what you can do is just have the
  1751. 1:07:54model generate some new text and just uh
  1752. 1:07:57humans write a few Edits edits are much
  1753. 1:07:59faster than writing the entire text and
  1754. 1:08:02I think that if you have that type of
  1755. 1:08:03collaboration then from like kind of an
  1756. 1:08:05information theoretical point of view
  1757. 1:08:07you still get additional information but
  1758. 1:08:09you still much faster than if you use
  1759. 1:08:11humans and I think that as a field we'll
  1760. 1:08:13probably move towards these type of
  1761. 1:08:14things uh which is um really just
  1762. 1:08:17finding the examples that are important
  1763. 1:08:19and and asking humans it's kind of
  1764. 1:08:21active learning just asking humans
  1765. 1:08:22exactly when uh you need to to get
  1766. 1:08:27inputs yes do we train with like the
  1767. 1:08:29same loss function the same like General
  1768. 1:08:32training algorithm for the supervis
  1769. 1:08:33tuning bit as we do for the for the
  1770. 1:08:35pre-training right because like the
  1771. 1:08:37examples you showed I think the the
  1772. 1:08:39important thing of the good examples is
  1773. 1:08:43they're like supera accurate there's
  1774. 1:08:45these more complex still just like chain
  1775. 1:08:48same so that's why here I yeah I didn't
  1776. 1:08:51maybe didn't emphasize enough this is
  1777. 1:08:52just language modeling fine tun the LM
  1778. 1:08:54with language model on the desired
  1779. 1:08:56answers so this is literally the same
  1780. 1:08:57loss um it will be different in two
  1781. 1:09:01seconds but the first step of sft is
  1782. 1:09:03literally the same loss where you just
  1783. 1:09:05say Okay I want to actually specialize
  1784. 1:09:07on that type of data so there's even a
  1785. 1:09:09question of like what is pre-training
  1786. 1:09:10what is post-training because in reality
  1787. 1:09:12it's just like a different data that you
  1788. 1:09:13use the reason why we usually call it
  1789. 1:09:15post training is that the way we collect
  1790. 1:09:16that data is very
  1791. 1:09:18different great great questions uh yes
  1792. 1:09:22maybe it's the same question but why
  1793. 1:09:23would these 2,000 examples have such an
  1794. 1:09:26overweighted
  1795. 1:09:28influence you tun so that's why we uh
  1796. 1:09:31also that's another reason why we call
  1797. 1:09:33it post training is that we use
  1798. 1:09:34different type of hyper parameters so
  1799. 1:09:35you know I told you basically at the end
  1800. 1:09:37of pre training you essentially end up
  1801. 1:09:38with a learning rate of zero and here
  1802. 1:09:40you're going to increase your learning
  1803. 1:09:41rate so like 1 eus 5 one E Yeah and and
  1804. 1:09:44so um the weight that you give to them
  1805. 1:09:47is actually
  1806. 1:09:49different
  1807. 1:09:51um okay uh Second Step or second part of
  1808. 1:09:56this post training um is what we call
  1809. 1:09:59reinforcement learning from Human
  1810. 1:10:00feedback or rhf uh some of you might
  1811. 1:10:03have heard of that um the idea is that
  1812. 1:10:06sft has a problem namely that uh you do
  1813. 1:10:09behavioral cloning which means that you
  1814. 1:10:11just try to clone what the humans would
  1815. 1:10:14say and that had that has many issues
  1816. 1:10:16one of them is that you're bound by
  1817. 1:10:18human abilities so if um like humans
  1818. 1:10:23actually humans won't generate the
  1819. 1:10:26things that they think is actually the
  1820. 1:10:27best thing to generate so if you ask me
  1821. 1:10:29to write a book I mean I can definitely
  1822. 1:10:31enjoy a book I can probably say one book
  1823. 1:10:33is better than another but I'm
  1824. 1:10:34definitely not going to be as good as
  1825. 1:10:36writing the book that I want to read uh
  1826. 1:10:38so you're going to be bound by the human
  1827. 1:10:39ability to generate things even though
  1828. 1:10:41the humans might be better at
  1829. 1:10:42distinguishing between things that's one
  1830. 1:10:44issue issue number two uh I find that
  1831. 1:10:46actually pretty interesting is that it
  1832. 1:10:48might if you ever heard of the word
  1833. 1:10:50hallucination so this is llms generating
  1834. 1:10:53F like false information
  1835. 1:10:56hallucination might these people have um
  1836. 1:10:58hypothesized that that can come from the
  1837. 1:11:00supervised fine tuning even if you do
  1838. 1:11:02supervised fine tuning on data that is
  1839. 1:11:05correct and the reason why that is is
  1840. 1:11:08that if uh given I told you that
  1841. 1:11:10basically sftt is with very little data
  1842. 1:11:13and it's with data that doesn't the
  1843. 1:11:15model doesn't learn anything new so what
  1844. 1:11:17if the human gives an answer that the
  1845. 1:11:20model didn't know was true from the
  1846. 1:11:23model perspective you the human
  1847. 1:11:25basically is telling the the model uh
  1848. 1:11:28generate this thing that seems plausible
  1849. 1:11:31but actually have no idea if it's true
  1850. 1:11:32or not um so just to give you a very
  1851. 1:11:35concrete example if we go back to this
  1852. 1:11:37uh monopsony example can you write blah
  1853. 1:11:39blah blah about monopsony uh imagine
  1854. 1:11:42that a human uh wrote a reference on
  1855. 1:11:44this type of book um and that book might
  1856. 1:11:47exist that might be a correct reference
  1857. 1:11:49but what if the llm never saw this
  1858. 1:11:51reference during pre-training then it
  1859. 1:11:53doesn't know that it's a correct
  1860. 1:11:54reference so really what you tell the
  1861. 1:11:55model is to generate or make up some
  1862. 1:11:58plausibly sounding reference um rather
  1863. 1:12:01than actually tell the real reference
  1864. 1:12:03that it saw during pre-training uh so
  1865. 1:12:06hallucination might be um uh a re like
  1866. 1:12:10might be caused by this sft that's
  1867. 1:12:12problem number two does that all make
  1868. 1:12:14sense great problem number three price
  1869. 1:12:18generating the ideal answers is very
  1870. 1:12:21pricey and that comes back to your
  1871. 1:12:22question um of like humans writing
  1872. 1:12:25answer is actually pretty
  1873. 1:12:27expensive um so that's where rhf comes
  1874. 1:12:29in the idea is that instead of cloning
  1875. 1:12:32the behaviors of humans we're going to
  1876. 1:12:34maximize human preference um and the way
  1877. 1:12:37we're going to do that so the pipeline
  1878. 1:12:39is that for a certain for every
  1879. 1:12:41instruction you're going to ask a model
  1880. 1:12:43to generate two answers um and usually
  1881. 1:12:47use a pretty good model so you usually
  1882. 1:12:48don't use an LM here you use a sft uh
  1883. 1:12:52fine tune you use a fine tuned llm
  1884. 1:12:54already to give like pretty good answers
  1885. 1:12:57and then you ask labelers which of these
  1886. 1:12:59two answers was better so select the
  1887. 1:13:01preferred one and then with different
  1888. 1:13:04type of algorithms we're going to talk
  1889. 1:13:05about the algorithms um you just
  1890. 1:13:07fine-tune the model to generate more of
  1891. 1:13:09the green thing than the red thing so
  1892. 1:13:10more of the good stuff uh so now the
  1893. 1:13:13question is how and we're going to talk
  1894. 1:13:14about that right
  1895. 1:13:16now so there are two ways that we're
  1896. 1:13:19going to talk about and two that are
  1897. 1:13:20mainly used in the community um the
  1898. 1:13:23first one is simply the idea of of using
  1899. 1:13:25reinforcement learning so hopefully you
  1900. 1:13:26all know what reinforcement learning is
  1901. 1:13:28now um so when you think about using
  1902. 1:13:32reinforcement learning one important
  1903. 1:13:33question is like what is the reward that
  1904. 1:13:35we're optimizing uh so in this case
  1905. 1:13:37there are really two options that I
  1906. 1:13:38could think about the first one you
  1907. 1:13:40could just say I'm going to compare the
  1908. 1:13:42output generated by some baseline the
  1909. 1:13:44output generated by my model U and I'm
  1910. 1:13:46just going to ask the human to say which
  1911. 1:13:48one is better and I'm going to use this
  1912. 1:13:51as a reward so if I'm better than the
  1913. 1:13:52Baseline this is a plus one if not it's
  1914. 1:13:54a minus one one uh so now it's binary
  1915. 1:13:56reward the problem with binary reward is
  1916. 1:13:58that it's very sparse and you don't get
  1917. 1:14:00much information out of it uh like maybe
  1918. 1:14:02your answer was slightly better maybe it
  1919. 1:14:04was like way better and you don't really
  1920. 1:14:07know from this um how much better it was
  1921. 1:14:11so option two is that you can train what
  1922. 1:14:13we call a reward model which is simply a
  1923. 1:14:15classifier uh so you use machine
  1924. 1:14:17learning to to classify how much better
  1925. 1:14:21uh two outputs are from the preference
  1926. 1:14:24from the perspective of the human um so
  1927. 1:14:27this is a little bit meta but what you
  1928. 1:14:29basically do is that you train uh you
  1929. 1:14:31take um a reward model R which is a uh
  1930. 1:14:34just a large also a large um a large
  1931. 1:14:38classifier and you basically ask this
  1932. 1:14:40reward model you give it the input and
  1933. 1:14:42the actual output that you have one of
  1934. 1:14:44the two outputs uh and you just um
  1935. 1:14:47exponentiate that so that's the soft Max
  1936. 1:14:49law that you all know about and now you
  1937. 1:14:51divide by um the the exponential
  1938. 1:14:55reward uh on the first example sorry on
  1939. 1:14:59the first output and this is on the
  1940. 1:15:00second output and you basically train so
  1941. 1:15:02the reason why you do that is that you
  1942. 1:15:04train your your model you train this
  1943. 1:15:06reward model to be able to classify um
  1944. 1:15:10how much better one output is to another
  1945. 1:15:13one so another uh slightly less
  1946. 1:15:15convoluted way of saying it is that your
  1947. 1:15:16reward model will output some reward
  1948. 1:15:19that will be used as the logits of your
  1949. 1:15:21soft Max so now if you have high logic
  1950. 1:15:25in your softmax it means that you highly
  1951. 1:15:27likely this um output is
  1952. 1:15:31better uh so that's what we call Bradley
  1953. 1:15:33ter model yes is this reward model going
  1954. 1:15:36over the entire output or is it
  1955. 1:15:39going um so this takes the
  1956. 1:15:43entire uh yeah this takes the entire
  1957. 1:15:46output at once so it takes all the input
  1958. 1:15:47and all the output and it gives one
  1959. 1:15:49number
  1960. 1:15:52yes would human be sorry with the reward
  1961. 1:15:56model where would a human be like oh I
  1962. 1:15:59see okay sorry maybe I wasn't clear um
  1963. 1:16:03you train this reward model to fit this
  1964. 1:16:06green and and red preference from humans
  1965. 1:16:09so basically you train a classifier to
  1966. 1:16:12say whether the humans prefer red or
  1967. 1:16:14green uh but instead of using the binary
  1968. 1:16:17reward which is what the human would
  1969. 1:16:19tell you you basically use the logits of
  1970. 1:16:22the soft Max and the thing with the
  1971. 1:16:23logits is that that logits are
  1972. 1:16:25continuous so now you know that if your
  1973. 1:16:27reward model said it has high logits
  1974. 1:16:30then in some ways the human highly
  1975. 1:16:32prefer this answer to some other
  1976. 1:16:36answer great um so as I just said
  1977. 1:16:39continuous information so it's better so
  1978. 1:16:41that's what people uh use in practice or
  1979. 1:16:43at least used to use in practice I'll
  1980. 1:16:45tell you about uh the other algorithm
  1981. 1:16:47later uh so what you do at the end is
  1982. 1:16:49that you basically try to just use
  1983. 1:16:51reinforcement learning that you know
  1984. 1:16:53about now we know we have reward what
  1985. 1:16:55you sample through is the generation
  1986. 1:16:58from your large language model um and
  1987. 1:17:00then you just use some regularization
  1988. 1:17:01term so the reason why you do this
  1989. 1:17:03regularization term is for avoiding what
  1990. 1:17:05we call over optimization so this reward
  1991. 1:17:07model might not be really represent like
  1992. 1:17:09might not perfectly model human
  1993. 1:17:11preferences so you don't want to
  1994. 1:17:12maximize this thing to essentially
  1995. 1:17:15Infinity um and you do it using uh po
  1996. 1:17:19which is a common uh reinforcement
  1997. 1:17:22learning algorithm um one thing to note
  1998. 1:17:25here because it will be important for
  1999. 1:17:26later is that when we use maximum
  2000. 1:17:29likelihood
  2001. 1:17:31um sorry now the large language models
  2002. 1:17:35are actually a policy for your
  2003. 1:17:37reinforcement learning it's not
  2004. 1:17:39maximizing maximum likelihood anymore
  2005. 1:17:41which means that you're not modeling any
  2006. 1:17:42distribution anymore and the reason why
  2007. 1:17:44this is important is that models that
  2008. 1:17:46went through this type of Po actually
  2009. 1:17:49don't give you likelihoods of text that
  2010. 1:17:51are meaningful cuz what you optimize
  2011. 1:17:53them to do is B basically just optimized
  2012. 1:17:55for generating the most likely thing not
  2013. 1:17:58optimize for modeling like all the
  2014. 1:18:00answers that humans might say another
  2015. 1:18:02way of saying that is that there's
  2016. 1:18:04nothing that incentivizes here the model
  2017. 1:18:06to not give a like a um a single
  2018. 1:18:10possible generation nothing here says
  2019. 1:18:13it's good if you have some distribution
  2020. 1:18:15with some
  2021. 1:18:16entropy um okay if you haven't followed
  2022. 1:18:18it's not that important but just good to
  2023. 1:18:21knowe great so PO is exact what chat GPT
  2024. 1:18:26did originally so here's the on the blog
  2025. 1:18:28post or what they have is step one do
  2026. 1:18:32supervise fine training which now you
  2027. 1:18:33all know about step two train a reward
  2028. 1:18:36model on human preferences step three do
  2029. 1:18:39po multiple steps which is where you see
  2030. 1:18:41this this blue arrow so you continue you
  2031. 1:18:43train the model once with po you collect
  2032. 1:18:45new data you continue uh and that's why
  2033. 1:18:48and that's exactly what Chad GPT did uh
  2034. 1:18:50that was a big breakthrough between gpt3
  2035. 1:18:53and Chad GPT
  2036. 1:18:55one thing to note is that uh P has many
  2037. 1:18:58challenges reinforcement learning is
  2038. 1:19:00something that's super nice
  2039. 1:19:01theoretically in practice anyone who
  2040. 1:19:03ever worked with reinforcement learning
  2041. 1:19:04knows it's such a mess uh there's a lot
  2042. 1:19:07of things like roll outs out of Loops
  2043. 1:19:08clipping so many complications um so
  2044. 1:19:12it's messy this is the idealized PO used
  2045. 1:19:14for LM settings so that's already much
  2046. 1:19:16more complicated than this expectation
  2047. 1:19:18we saw before and in practice it's
  2048. 1:19:19actually much more complicated so we
  2049. 1:19:21have one implementation of it that we
  2050. 1:19:22had to do and I'm not going to go
  2051. 1:19:24through it but basically you have like
  2052. 1:19:26so much stuff that you have to think
  2053. 1:19:27about when you implement that type of of
  2054. 1:19:30uh po algorithm so you have clipping
  2055. 1:19:32everywhere you have a lot of
  2056. 1:19:34complexities and things are not well
  2057. 1:19:36documented all this to say um that we're
  2058. 1:19:40going to there was a new method that was
  2059. 1:19:41proposed uh also from Sanford one year
  2060. 1:19:44ago called DPO which is essentially a
  2061. 1:19:46simplification of Po um and the way uh
  2062. 1:19:51what they did or the idea that they have
  2063. 1:19:53is that instead of using reinforcement
  2064. 1:19:55learning you can just maximize the
  2065. 1:19:57probability of generating the stuff that
  2066. 1:19:58you like and minimizing the probability
  2067. 1:20:00of the stuff that you don't like uh so
  2068. 1:20:02if you think about the human preference
  2069. 1:20:04the red and green maximize uh green
  2070. 1:20:07minimize red um so the loss is actually
  2071. 1:20:10this one uh where what you see this is
  2072. 1:20:12simply um some log of the model so this
  2073. 1:20:17is the likelihood of a model generating
  2074. 1:20:18the things that the human preferred
  2075. 1:20:20given the the inputs um and what you try
  2076. 1:20:24to do is basically
  2077. 1:20:26maximize uh the likelihood of generating
  2078. 1:20:29the things that you like minimize the
  2079. 1:20:31likelihood of the things that you don't
  2080. 1:20:32like um all the rest of the terms here
  2081. 1:20:35it's not too important it's actually
  2082. 1:20:37really not that complicated to
  2083. 1:20:39understand but at a high level it's
  2084. 1:20:41really just maximizing the things you
  2085. 1:20:42like minimizing the the rest um and one
  2086. 1:20:46thing to note uh which I was going to
  2087. 1:20:48say just here is that actually all the
  2088. 1:20:50rest is chosen such that um the global
  2089. 1:20:53Minima of of Po and a global Minima of
  2090. 1:20:57like this DPO under some assumptions are
  2091. 1:20:59essentially equivalent so this is the
  2092. 1:21:02right thing to do mathematically I'm not
  2093. 1:21:04going to go through the derivations but
  2094. 1:21:06that's the right thing to do uh it's
  2095. 1:21:08pretty different with Po in the sense
  2096. 1:21:09that now and with P what you had to do
  2097. 1:21:11is collect the human preferences then
  2098. 1:21:13train a uh reward model with maximum
  2099. 1:21:15likelihood then use reinforcement
  2100. 1:21:17learning now all you do is basically
  2101. 1:21:18maximum likelihood much simpler yes I
  2102. 1:21:21mean yeah so it seems like this is a
  2103. 1:21:23much simpler and B like what you just
  2104. 1:21:25intuitively do if this why did they
  2105. 1:21:28start with this reward model like what
  2106. 1:21:30what led them doing that I think it's a
  2107. 1:21:32great question uh I don't really know
  2108. 1:21:34what I can tell you is that at open ey
  2109. 1:21:37the people who did the um uh who did
  2110. 1:21:40basically this PP uh sorry who did Chad
  2111. 1:21:43GPT initially are the ones who actually
  2112. 1:21:46wrote Po and I think they were just like
  2113. 1:21:48there are a lot of reinforcement
  2114. 1:21:49learning people and I think that for
  2115. 1:21:51them it was very intuitive um so there's
  2116. 1:21:55also some additional like potential
  2117. 1:21:57benefits for example I don't want to
  2118. 1:22:01yeah for example if you use the reward
  2119. 1:22:02model uh the cool thing here with
  2120. 1:22:04reinforcement learning is that you can
  2121. 1:22:05use unlabeled data with the reward model
  2122. 1:22:08so here you can only use the label data
  2123. 1:22:10for doing DPO um for PP for po you first
  2124. 1:22:14train your reward model and then you can
  2125. 1:22:16use unlabeled data uh where the reward
  2126. 1:22:18model will basically label this
  2127. 1:22:20unlabeled data so there there's
  2128. 1:22:21additional kind of potential uh
  2129. 1:22:25there could be potential improvements in
  2130. 1:22:27practice it happens at down and on and I
  2131. 1:22:29think just that a lot of people in this
  2132. 1:22:32team were reinforcement learning experts
  2133. 1:22:34including uh the main author of Po John
  2134. 1:22:37hman um so much simpler in poo and is
  2135. 1:22:41basically performs as well uh so now
  2136. 1:22:43this is the standard uh thing that
  2137. 1:22:45people use at least in the open source
  2138. 1:22:47Community I believe it's actually the
  2139. 1:22:48standard also in in Industry so that's
  2140. 1:22:52called DPO gains
  2141. 1:22:55um so those are all the papers on the
  2142. 1:22:57left here this is on a summarization
  2143. 1:22:59task you see all I want to show you is
  2144. 1:23:01that basically the pre-train models uh
  2145. 1:23:03were okay and they improve with scale if
  2146. 1:23:05you do supervised fine tuning you
  2147. 1:23:07improve them a little bit more if you do
  2148. 1:23:09po or something with all HF with human
  2149. 1:23:11feedback you get performance that are as
  2150. 1:23:14often times depending on a benchmark
  2151. 1:23:16even better than uh humans so this is
  2152. 1:23:19the human uh reference summaries same
  2153. 1:23:21thing this is on a uh on a paper that we
  2154. 1:23:23have Alpaca Farm
  2155. 1:23:25where we see uh the evaluation here is
  2156. 1:23:27not too important but basically you see
  2157. 1:23:28pre-train model you jump to sft and then
  2158. 1:23:31you jump to PPO and popo have the exact
  2159. 1:23:34same
  2160. 1:23:35performance so basically all HF helps
  2161. 1:23:38that's kind of the conclusion and DPO is
  2162. 1:23:41simple uh data uh the way that you
  2163. 1:23:44collect that type of data um first idea
  2164. 1:23:47is just use humans as we already talked
  2165. 1:23:50about uh guidelines are very complicated
  2166. 1:23:52for what humans should be labeling and
  2167. 1:23:54and it's really not that easy and
  2168. 1:23:55actually if you ever do some of the
  2169. 1:23:57labeling you will see that it's
  2170. 1:24:00extremely complicated like if I zoom in
  2171. 1:24:02to this uh here I have a question tell
  2172. 1:24:05tell me about self-driving cars and you
  2173. 1:24:07read both self-driving cars are vehicles
  2174. 1:24:09that are capable of detecting their
  2175. 1:24:10surroundings blah blah blah self-driving
  2176. 1:24:12cars are cars that are equipped with
  2177. 1:24:13sensors blah blah blah to navigate
  2178. 1:24:15without the need for a driver I mean
  2179. 1:24:17both seem okay like which one is better
  2180. 1:24:19it's actually hard to say at a glance um
  2181. 1:24:22and as a result uh the problem with
  2182. 1:24:23humans is that you will start optimizing
  2183. 1:24:27a lot of like high level features for
  2184. 1:24:28example the second one is longer I can
  2185. 1:24:30guarantee you that most humans will
  2186. 1:24:31choose second one even though I mean
  2187. 1:24:34maybe the first one is better I don't
  2188. 1:24:35know I haven't read it carefully so
  2189. 1:24:38challenges with humans first slow and
  2190. 1:24:41expensive uh second as I just mentioned
  2191. 1:24:44it's hard to focus on things that matter
  2192. 1:24:46like correctness and people uh usually
  2193. 1:24:49look at things that don't matter as much
  2194. 1:24:51like the form like length uh and as a
  2195. 1:24:54result so what I show here is that uh
  2196. 1:24:55when you do lhf the more you do of lhf
  2197. 1:24:58the longer the output of the of the
  2198. 1:25:00models become so if you've ever been
  2199. 1:25:02annoyed at chat GPT answering you super
  2200. 1:25:04long sentences this is because of all
  2201. 1:25:07rhf um annotator distribution shift uh
  2202. 1:25:11like the distribution of annotators that
  2203. 1:25:13you use matters a lot and you have to
  2204. 1:25:15think like what is what is even the
  2205. 1:25:17humans that we want to represent in
  2206. 1:25:18these models uh now the question is like
  2207. 1:25:20crowdsourcing ethics uh like usually
  2208. 1:25:23these basically a lot of the the
  2209. 1:25:25labeling that is done um like the people
  2210. 1:25:28who do them are not paid well and they
  2211. 1:25:30have to go through a lot of toxic data
  2212. 1:25:32uh because you basically want the model
  2213. 1:25:34to avoid saying the toxic data um so
  2214. 1:25:37crowdsourcing ethics
  2215. 1:25:39too so many challenges with human data
  2216. 1:25:42um so what we did also last year is
  2217. 1:25:45again the same thing as alpaca just the
  2218. 1:25:47idea of like oh well they're challenges
  2219. 1:25:49with humans maybe we can just replace
  2220. 1:25:50them with llms uh so what we did is
  2221. 1:25:53simply replace
  2222. 1:25:54um oh I see that I'm just realizing that
  2223. 1:25:57the slides are not sented anyways uh you
  2224. 1:26:00replace a human preference with LM
  2225. 1:26:01preferences uh so here on this uh figure
  2226. 1:26:04you see on the xaxis the price that we
  2227. 1:26:06paid uh for collecting human data it's
  2228. 1:26:09around
  2229. 1:26:10$300 for 1,000 examples and this is on
  2230. 1:26:13mechanical turkers which are usually
  2231. 1:26:15like cheaper than than maybe some of the
  2232. 1:26:17other um companies that you could go
  2233. 1:26:20through and on the Y AIS it's basically
  2234. 1:26:22the agreement with uh other humans with
  2235. 1:26:25the mode of other humans and what you
  2236. 1:26:27see is that actually as I told you
  2237. 1:26:28before labeling is really complicated
  2238. 1:26:30humans agree with themselves only around
  2239. 1:26:3366% of the time on a binary Tas and it's
  2240. 1:26:36not that the humans are not good here
  2241. 1:26:38because uh we were five main authors on
  2242. 1:26:40this paper we tried to label this data
  2243. 1:26:43ourselves and we only had like say 67 or
  2244. 1:26:4668% accuracy even though we talk like we
  2245. 1:26:48talk for like 3 hours of how we should
  2246. 1:26:50be doing labeling really it's
  2247. 1:26:52complicated it's not an easy task um and
  2248. 1:26:54here I just showed many different models
  2249. 1:26:56and um basically you see that models are
  2250. 1:26:58much cheaper and they can actually get
  2251. 1:27:00higher agreement with the mode of humans
  2252. 1:27:02than human humans themselves and the
  2253. 1:27:04reason why is because humans have a lot
  2254. 1:27:06of varant models have no varant so they
  2255. 1:27:08might be a little bit more biased but
  2256. 1:27:09have less virence uh so it works
  2257. 1:27:12surprisingly well and now it's kind of
  2258. 1:27:14the standard in open uh Source Community
  2259. 1:27:16I think even in Industry a lot of people
  2260. 1:27:18use both humans and llms for improving
  2261. 1:27:21uh the colle collection of allf data
  2262. 1:27:24um and this is like this is the paper
  2263. 1:27:26from last year but honestly now it's
  2264. 1:27:28more like that llms would be around this
  2265. 1:27:30agreement and this cost so around I
  2266. 1:27:32would say 50x cheaper than humans and
  2267. 1:27:34better agreement with human than humans
  2268. 1:27:38themselves okay so that gets us to
  2269. 1:27:41evaluation of post
  2270. 1:27:43training um that goes back to your
  2271. 1:27:46initial question at the beginning of the
  2272. 1:27:47lecture how do you evaluate something
  2273. 1:27:49like chpt uh the answers that chpt could
  2274. 1:27:51give are basically unbounded and it's
  2275. 1:27:54not that there one right answer there
  2276. 1:27:56are many answers that are just as good
  2277. 1:27:58um so there are many challenges one you
  2278. 1:28:01can't use validation loss because one
  2279. 1:28:05method might use po the other one might
  2280. 1:28:06use DPO validation loss is not
  2281. 1:28:08comparable second you can't use Cal uh
  2282. 1:28:10sorry perplexity that's the thing I told
  2283. 1:28:12you before these models uh are not
  2284. 1:28:15calibrated they don't give distributions
  2285. 1:28:17they they just optimize for one thing so
  2286. 1:28:19you can't use perplexity for actually
  2287. 1:28:21evaluating uh these type of models once
  2288. 1:28:23they're aligned sorry one Z lined third
  2289. 1:28:27uh there's a large diversity of
  2290. 1:28:28questions that human might ask to these
  2291. 1:28:30models generation open QA like some
  2292. 1:28:33question answering some summarization
  2293. 1:28:35and all of these things so there's so
  2294. 1:28:36many things you have to cover um then
  2295. 1:28:39the tasks are really open-ended so it's
  2296. 1:28:41very hard to automate so that's what you
  2297. 1:28:43were alluding to before so the idea uh
  2298. 1:28:46is that instead of trying to come up
  2299. 1:28:48with really easily automated uh
  2300. 1:28:50benchmarks uh it's just we're going to
  2301. 1:28:52ask questions that that users actually
  2302. 1:28:54ask to these models in practice and
  2303. 1:28:56we're just going to ask annotators to
  2304. 1:28:58say between these two models which one
  2305. 1:29:01is better like what's the what's the
  2306. 1:29:02better output so basically do exact same
  2307. 1:29:04thing as um basically the data from rhf
  2308. 1:29:08but you use it now for evaluation yes
  2309. 1:29:10I'm not sure I understand what you mean
  2310. 1:29:12by like can't use perplexity and not
  2311. 1:29:13calibrated right like LM is still doing
  2312. 1:29:16like next token
  2313. 1:29:18prediction so I can't so think about um
  2314. 1:29:23the optim solution after doing PO is
  2315. 1:29:26basically one model that gives you uh
  2316. 1:29:28essentially a Delta um like basically
  2317. 1:29:31says that there's only one sentence that
  2318. 1:29:33is that could be generated for that
  2319. 1:29:36question so now if you use it on
  2320. 1:29:38something that is slightly semantically
  2321. 1:29:39differently different it would actually
  2322. 1:29:41give a likelihood of zero for that
  2323. 1:29:43answer so in reality it's not that
  2324. 1:29:45extreme because as you say it's still a
  2325. 1:29:47distribution but I just shows you that
  2326. 1:29:48there's a there's a fundamental issue
  2327. 1:29:50with perplexity once these models are
  2328. 1:29:53not llms anymore they were not trained
  2329. 1:29:56at least with P they were not trained to
  2330. 1:29:57to do maximum likelihood anymore they
  2331. 1:29:59were trained to be
  2332. 1:30:02policies okay um so probably the most
  2333. 1:30:05common or like the most um yeah the most
  2334. 1:30:08common Benchmark or the most trusted one
  2335. 1:30:11is what we call Chad uh sorry chatbot
  2336. 1:30:12Arena uh which is basically go on
  2337. 1:30:15internet have random users on the
  2338. 1:30:17internet blindly talk with two chat Bots
  2339. 1:30:19just ask many questions see the two
  2340. 1:30:21answers and rate which one is better and
  2341. 1:30:24and you do that over hundred of
  2342. 1:30:25thousands of users and then you get uh
  2343. 1:30:27the actual preferences and you get
  2344. 1:30:29rankings of models uh so you can go
  2345. 1:30:31right now on chatbot Arena and actually
  2346. 1:30:34interact with these models um one
  2347. 1:30:36potential issue just to highlight is
  2348. 1:30:38that while people who want to do these
  2349. 1:30:40type of things are usually more like
  2350. 1:30:41Tech driven um or like techsavvy uh so a
  2351. 1:30:44lot of the questions that you will ask
  2352. 1:30:46are more like Tech stuff discussing
  2353. 1:30:47software errors inquiries about AI tools
  2354. 1:30:50and all these things um so another issue
  2355. 1:30:53is cost and speed if you really want to
  2356. 1:30:55use something like this for development
  2357. 1:30:57process um it will be too costly because
  2358. 1:30:59you would need to basically pay a lot of
  2359. 1:31:01humans to do that so one simple idea is
  2360. 1:31:06again as we said many times just use LM
  2361. 1:31:08instead of humans uh you probably know
  2362. 1:31:11the drill at this point uh steps for
  2363. 1:31:13every instruction generate outputs by
  2364. 1:31:15some baseline and the model that you
  2365. 1:31:17want to evaluate um so here you imagine
  2366. 1:31:20that I I'm comparing an answer from Chad
  2367. 1:31:22GPT and from
  2368. 1:31:24I'm just asking a model uh another model
  2369. 1:31:28uh which one is better and I just
  2370. 1:31:30basically average that out uh yeah I
  2371. 1:31:32asked gp4 which one is better I average
  2372. 1:31:35that out over my entire distribution
  2373. 1:31:37over my entire Benchmark or data set and
  2374. 1:31:39that gives me a RN rate so RN
  2375. 1:31:41probability for one model compared to
  2376. 1:31:43another one and now you can rank models
  2377. 1:31:46uh and this is the Alpa eval uh
  2378. 1:31:49leaderboard so the benefits of this is
  2379. 1:31:52that actually we show we get 98%
  2380. 1:31:54correlation with Chad B Arena so very
  2381. 1:31:56high correlation with humans um so this
  2382. 1:31:59is yeah comparison with correlation with
  2383. 1:32:01other benchmarks and it takes less than
  2384. 1:32:03three minutes and less than $10 to run
  2385. 1:32:05so it's pretty cheap um there are
  2386. 1:32:07downsides though uh one of them is purus
  2387. 1:32:10correlation um so as we already saw
  2388. 1:32:13before LMS prefer this is one SP
  2389. 1:32:15correlation not many I'll just talk
  2390. 1:32:17about one LMS prefer longer outputs
  2391. 1:32:18actually humans also prefer longer
  2392. 1:32:20outputs but the problem or the issue
  2393. 1:32:22once you use llms is that once there
  2394. 1:32:24bias you will continue optimizing that
  2395. 1:32:26humans at some point I can guarantee you
  2396. 1:32:28if I ask a simple question and you give
  2397. 1:32:29me five pages of answers I'll be like no
  2398. 1:32:31I don't like that answer but LMS if they
  2399. 1:32:33have this bius and they were trained for
  2400. 1:32:34that they will continue preferring
  2401. 1:32:36longer outputs so uh here we see um the
  2402. 1:32:41the preference just showing that like
  2403. 1:32:43humans and models prefer longer outputs
  2404. 1:32:45um and here is another view of the
  2405. 1:32:48initial apaka eval data uh Benchmark
  2406. 1:32:51where when we asked um when we we rank
  2407. 1:32:54gp4 when we look at the Run rate of gp4
  2408. 1:32:56versus actually uh gp4 itself if we com
  2409. 1:33:00if we use the standard GPT 4 it gets 50%
  2410. 1:33:02kind of by definition because we're
  2411. 1:33:03comparing GPT 4 versus gp4 but if we ask
  2412. 1:33:07a gbd4 to be slightly more verose so we
  2413. 1:33:09just say in the prompt be Vos in your
  2414. 1:33:11answers then it gets a r rate of
  2415. 1:33:1364.4% so really there's a huge variance
  2416. 1:33:16and if we ask it to be concise it gets
  2417. 1:33:1820% so there's a huge variance depending
  2418. 1:33:20on um whether you ask it to be concise
  2419. 1:33:23of
  2420. 1:33:24that's very annoying um so one possible
  2421. 1:33:27solution which is what we did is uh just
  2422. 1:33:29use some regression analysis I'm not
  2423. 1:33:31going to go into details but basically
  2424. 1:33:33use Cal inference tools to control for
  2425. 1:33:35length and right now uh actually length
  2426. 1:33:37matters much less so if you ask it to be
  2427. 1:33:39veros we still get some gains but much
  2428. 1:33:43less great so that's all about post
  2429. 1:33:46training and now for the next eight
  2430. 1:33:48minutes I might talk about systems or
  2431. 1:33:50just answer questions yes can you um go
  2432. 1:33:54back to your post training in terms of
  2433. 1:33:56post training how did we tune those
  2434. 1:33:58parameters using the small body of
  2435. 1:34:01fine-tuning data and have such big
  2436. 1:34:04effect on the model you mentioned
  2437. 1:34:05earlier that there's a different set of
  2438. 1:34:07hyperparameters are we changing just
  2439. 1:34:10some of the weights the later weights or
  2440. 1:34:11all the weights what's actually
  2441. 1:34:13happening yeah uh yeah I I kind of
  2442. 1:34:15skimmed through all of this you change
  2443. 1:34:17all the weights actually um industry
  2444. 1:34:19would change all the weights in open
  2445. 1:34:21source land you might have heard of
  2446. 1:34:23Laura which is going to change basically
  2447. 1:34:26only some of the weights or it actually
  2448. 1:34:28to be more specific it's going to add
  2449. 1:34:30some differences to the output of every
  2450. 1:34:32of every layer but but in Industry
  2451. 1:34:34you're going to just fine tune all the
  2452. 1:34:36weights um and also to say something
  2453. 1:34:39else about the data actually the SL St
  2454. 1:34:41all HF you usually going to collect uh a
  2455. 1:34:44lot more data than with sft so if fft is
  2456. 1:34:46like 5,000 10,000 maybe 50,000 with rhf
  2457. 1:34:51I think you're going to be more around
  2458. 1:34:52like the 1 million
  2459. 1:34:54uh order of magnitude it's still much
  2460. 1:34:55less than pre-training though yeah
  2461. 1:34:57because pre-training is 15 trillion
  2462. 1:34:59tokens I mean this is like that's not
  2463. 1:35:01even a drop and yet you influence the
  2464. 1:35:04weight a lot so because you do it I mean
  2465. 1:35:06you have to think that how you do it is
  2466. 1:35:08you use um I mean as I said the learning
  2467. 1:35:12rate that you're going to use is going
  2468. 1:35:13to be different but also you only do
  2469. 1:35:15that so just imagine if I train even if
  2470. 1:35:18I train on one sentence but over and
  2471. 1:35:20over again all at some point my model
  2472. 1:35:23will only that sentence even if uh it
  2473. 1:35:26was just one sentence instead of the 15
  2474. 1:35:28trillion tokens so if you use a large
  2475. 1:35:30enough learning rate and for enough time
  2476. 1:35:32you will basically overfit that sentence
  2477. 1:35:35so the the the key thing to to remember
  2478. 1:35:37is that um the data is not I it's not as
  2479. 1:35:40if you mix some posttraining data and
  2480. 1:35:42some pre-training data you do
  2481. 1:35:44pre-training and then you just start
  2482. 1:35:46fine-tuning only on the post trining so
  2483. 1:35:48another way maybe another perspective is
  2484. 1:35:50that the post the pre-training is just
  2485. 1:35:52the initialization of your model
  2486. 1:35:54and once you view it that way that this
  2487. 1:35:55is just initialization of Weights then
  2488. 1:35:58there's nothing special like you don't
  2489. 1:36:00need to remember that you train a lot of
  2490. 1:36:01data before the only thing that matters
  2491. 1:36:03is that you had an initialization and
  2492. 1:36:05now I actually train a model so maybe
  2493. 1:36:06think about it that way like there's a
  2494. 1:36:08there's a mark of property in some way
  2495. 1:36:10just like you had your weights this is
  2496. 1:36:11my initialization now I'm training that
  2497. 1:36:13one does that kind of answer your
  2498. 1:36:15question kind of but you said something
  2499. 1:36:19just now about it's almost the
  2500. 1:36:21equivalence of just rerunning the find
  2501. 1:36:23tuning data many times is it actually is
  2502. 1:36:26that what actually happens in order to
  2503. 1:36:29give so much more preference
  2504. 1:36:32um you might I actually don't know right
  2505. 1:36:36now how they do it in Industry when we
  2506. 1:36:38did alpaca we had to do three box so you
  2507. 1:36:40did run it three times to it
  2508. 1:36:43um but I mean even the number of times
  2509. 1:36:46that you run it through it's actually
  2510. 1:36:47not important the only thing like the
  2511. 1:36:49only thing is the is kind of the
  2512. 1:36:51effective learning rate that what
  2513. 1:36:53matters
  2514. 1:36:54um so
  2515. 1:36:56yeah
  2516. 1:36:57great so I think I have five minutes
  2517. 1:37:02[Music]
  2518. 1:37:05right okay I might try to give a high
  2519. 1:37:10level Overview at least from one of the
  2520. 1:37:12systems trick systems as we said uh for
  2521. 1:37:17everyone Bott neck is a sorry compute is
  2522. 1:37:20the huge bottleneck uh one question you
  2523. 1:37:22might ask is why not buy more gpus uh
  2524. 1:37:25gpus are expensive but also are scarce
  2525. 1:37:26even if you have $10 million right now
  2526. 1:37:28you cannot buy the best gpus um
  2527. 1:37:32there's oh yeah there's also some
  2528. 1:37:34physical limitations when you have when
  2529. 1:37:36you have multiple gpus you have to
  2530. 1:37:37communicate between them that takes time
  2531. 1:37:40um so just buying more gpus is not that
  2532. 1:37:42easy um so it's really important to
  2533. 1:37:44think about how do you allocate
  2534. 1:37:46resources and how do you optimize your
  2535. 1:37:47pipeline so system 101 on gpus I'm sorry
  2536. 1:37:51I'm going slightly faster I hope for
  2537. 1:37:53that some of you at least can follow uh
  2538. 1:37:55gpus are basically optimized for
  2539. 1:37:57throughput CPUs are optimized uh for
  2540. 1:38:00latency so gpus the way you have to
  2541. 1:38:03think about it is that there's one Comm
  2542. 1:38:04there's one command that is run on many
  2543. 1:38:07many Calles at the same time on
  2544. 1:38:08different type of data um so this is how
  2545. 1:38:12you see a GPU you see there are many
  2546. 1:38:14different CES we call them streaming
  2547. 1:38:16multiprocessors which is very different
  2548. 1:38:18than the usual CPU architecture so just
  2549. 1:38:20think High throughput paralyzation for
  2550. 1:38:23gpus uh gpus are optimized for fast
  2551. 1:38:26matrix multiplication so every time you
  2552. 1:38:28will do uh you will do something on GPU
  2553. 1:38:30if you can do it with a a matrix
  2554. 1:38:32multiplication it's going to be 10 times
  2555. 1:38:34faster than with anything else uh that
  2556. 1:38:37is a little bit annoying because it
  2557. 1:38:38means that we're kind of uh bottlenecked
  2558. 1:38:40to doing anything with Matrix
  2559. 1:38:43multiplications um another thing to note
  2560. 1:38:45with gpus is that compute has been
  2561. 1:38:47improving faster than memory and
  2562. 1:38:49communication so right now gpus usually
  2563. 1:38:53are hard to keep uh like the data that
  2564. 1:38:56you send that send to gpus is actually
  2565. 1:38:59hard to keep up with the processess so
  2566. 1:39:00most of your gpus are actually going to
  2567. 1:39:02be idle if you just run normal code if
  2568. 1:39:05you don't optimize your code so
  2569. 1:39:06communication and this will continue
  2570. 1:39:09over time another thing to know about
  2571. 1:39:11gpus is that there's a memory hierarchy
  2572. 1:39:13this is the same thing actually with
  2573. 1:39:14CPUs but basically the closer you are to
  2574. 1:39:17your cuse the less memory there is but
  2575. 1:39:19the faster things run if you're further
  2576. 1:39:21more memory slower
  2577. 1:39:24um okay I'm going to skip that okay
  2578. 1:39:26actually I'm going to say it I told you
  2579. 1:39:28about this uh the fact of communication
  2580. 1:39:31uh the metric that people usually look
  2581. 1:39:32at is model flop utilization so what is
  2582. 1:39:34the theoretical maximum that GPU could
  2583. 1:39:37run at no more flops that you could use
  2584. 1:39:38per second divide sorry the number of OB
  2585. 1:39:41observed through put divided by this
  2586. 1:39:43theoretical um maximum and in general if
  2587. 1:39:47you reach 50% you're very happy like
  2588. 1:39:49Facebook I looked at Lama was at 45 or
  2589. 1:39:51something like this so that that means
  2590. 1:39:54that data doesn't come fast enough even
  2591. 1:39:56for these big
  2592. 1:39:58companies so one simple trick and that
  2593. 1:40:00might be the only one I'm going to tell
  2594. 1:40:02you about is low Precision one simple
  2595. 1:40:05idea is that well if I'm going to put my
  2596. 1:40:07floats in lower Precision then there's
  2597. 1:40:09going to be fewer bits that I have to
  2598. 1:40:11send to my gpus if there's fewer bits
  2599. 1:40:13it's faster communication lower memory
  2600. 1:40:15consumption things are going to go
  2601. 1:40:16faster uh and for deep learning it just
  2602. 1:40:19happens that de decimal is not that
  2603. 1:40:21important uh so so when you do matrix
  2604. 1:40:24multiplication when you do like for
  2605. 1:40:26example SGD there's already so much
  2606. 1:40:27noise that if you update something by
  2607. 1:40:290.01 or
  2608. 1:40:310.015 who cares uh so basically instead
  2609. 1:40:34of using uh 32 bits per float which is
  2610. 1:40:38um what people used to use or 64 for
  2611. 1:40:41example which is what you would use in
  2612. 1:40:42other domains you use 16 bits uh for
  2613. 1:40:45matrix multiplication so for every float
  2614. 1:40:47you use 16 bits um and for training you
  2615. 1:40:50have this type of like uh what we call
  2616. 1:40:53aut atic mix Precision which is that uh
  2617. 1:40:55some of the things are in 32 bits others
  2618. 1:40:57are in 60 bit in 16 bits um generally
  2619. 1:41:00the way you should be thinking about it
  2620. 1:41:02is that your weights are stored of your
  2621. 1:41:04model are stored in 32 bits um but just
  2622. 1:41:07before the computation you put
  2623. 1:41:08everything in 16 16 bits like this you
  2624. 1:41:10do computation super fast and at the end
  2625. 1:41:13you update your weights in 32 Bits And
  2626. 1:41:16the reason why you do all the updates in
  2627. 1:41:1732 bits it's just think that if your
  2628. 1:41:19learning rate for example is very small
  2629. 1:41:21you still want to be able to like make a
  2630. 1:41:23difference in your weights uh so all the
  2631. 1:41:25computation is done in 16 bits but the
  2632. 1:41:28weights are actually stored in 32 bits
  2633. 1:41:30so that's like the standard way that
  2634. 1:41:32people are doing it um okay I'll
  2635. 1:41:35actually talk just about this and then
  2636. 1:41:37I'll skip all the rest operator Fusion
  2637. 1:41:38because I think this is actually pretty
  2638. 1:41:39cool as I just said communication is
  2639. 1:41:41very slow and actually every time you
  2640. 1:41:44use a pie torch line it basically moves
  2641. 1:41:46variable to Global memory of your GPU so
  2642. 1:41:49when you have something like this x do
  2643. 1:41:52cosine uh equal X1 and then you do X1 do
  2644. 1:41:55cosine what is happening behind the
  2645. 1:41:57scenes is that you take the X which is
  2646. 1:41:59data you ship it to your um to your
  2647. 1:42:02actual processes of your gpus you apply
  2648. 1:42:04the coign you ship it back to the main
  2649. 1:42:06memory of your GPU and then you see the
  2650. 1:42:08next sign you ship it back to the
  2651. 1:42:10computer to the GPU processor you apply
  2652. 1:42:12another cosign and you ship it back
  2653. 1:42:14again um so another way to see that is
  2654. 1:42:17that you go from your Dam which is your
  2655. 1:42:18Global memory in your GPU and you ship
  2656. 1:42:21it to compute you ship it back for every
  2657. 1:42:23line This is a naive way of doing it
  2658. 1:42:25this seems very wasteful um so the idea
  2659. 1:42:29simple idea of operative Fusion is just
  2660. 1:42:32communicate do all the computation ship
  2661. 1:42:34it back once and this is exactly what
  2662. 1:42:37fuse kernels are um so if you ever want
  2663. 1:42:40to make your comp your computations in
  2664. 1:42:44pytorch much faster just apply torch.
  2665. 1:42:47compile on your model this is going to
  2666. 1:42:49make your model around two times faster
  2667. 1:42:52and what it does is simply that it
  2668. 1:42:53rewrites your code uh your P like your
  2669. 1:42:57py torch code basically in C++ in Cuda
  2670. 1:43:01uh to to do the communication only once
  2671. 1:43:04then do all the operations then uh ship
  2672. 1:43:06it back okay I'm not going to have time
  2673. 1:43:09to talk about tiling tiling is important
  2674. 1:43:11paration paration is important um and
  2675. 1:43:16mixture of experts mixture of experts is
  2676. 1:43:18important Outlook there are many things
  2677. 1:43:20we haven't T talked about we haven't
  2678. 1:43:23talked about architectures we definitely
  2679. 1:43:25haven't talked about inference um there
  2680. 1:43:27are many other things that are important
  2681. 1:43:29with LMS what is the UI that you use I
  2682. 1:43:31mean arguably chat jpt the big novelty
  2683. 1:43:33was just have a simple UI to use it
  2684. 1:43:35multimodality what are all the misuses
  2685. 1:43:37you could have uh the fact that there
  2686. 1:43:39might not be enough data on the internet
  2687. 1:43:41to train all these models legality of
  2688. 1:43:43data collection so many other things if
  2689. 1:43:45you are interested in all these topics
  2690. 1:43:47uh I would suggest three classes cs224n
  2691. 1:43:50is probably the one that touches the
  2692. 1:43:52least on uh LMS uh but it gives some
  2693. 1:43:55background and historical context um of
  2694. 1:43:58all the LMS and gives kind of some
  2695. 1:44:00adjacent material CS 324 I think it's
  2696. 1:44:03called Uh I think it's just called large
  2697. 1:44:06language models uh more in-depth reading
  2698. 1:44:08and lectures on everything I talked
  2699. 1:44:09about CS 336 which is large language
  2700. 1:44:12model from scratch you actually build
  2701. 1:44:14your own llm uh it's an amazing class
  2702. 1:44:18also given by my two supervisors very
  2703. 1:44:20heavy workload so be careful and um
  2704. 1:44:23great

About this transcript

This page contains the full transcript of YouTube transcript (9vM4p9NN0Ts) , generated from the public captions YouTube serves with the video. The transcript has 19,443 words across 2,704 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.

What you can do with it

Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to choose a caption track available on the video.

Free YouTube transcript tool

YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, caption language selection, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.