Edition 2019
Title: "Stanford CS224N: NLP with Deep Learning | Winter 2019 | Lecture 1 – Introduction and Word Vectors - YouTube"
Transcript: "Okay. Hello everyone. [LAUGHTER] Okay we should get started. Um, they're actually are still quite a few seats left. If you wanna be really bold, there are a couple of seats right in front of me in the front row. If you're less bolder a few over there. Um, but they're also on some of the rows are quite a few middle seat. So if people wanted to be really civic minded some people could sort of squeeze towards the edges and make more accessible um, some of the seats that still exist in the classroom. Okay. Um, so, um, it's really exciting and great to see so many people here. So I'm a hearty welcome to CS224N and occasionally also known as Ling 284 which is Natural Language Processing with Deep Learning. Um, as just a sort of a personal anecdote, is still sort of blows my mind that so many people turn up to this class these days. So, for about the first decade that I taught NLP here, you know the number of people I got each year was approximately 45. [LAUGHTER] So it's an order of [LAUGHTER] magnitude smaller than it is now but guess it says quite a lot on about what a revolutionary impact that artificial intelligence in general and machine learning, deep learning, NLP are starting to have in modern society. Okay. So this is our plan for today. So, um, um, we're really gonna get straight down to business today. So they'll be a brief, very brief introduction some of the sort of course logistics, very brief discussion and talk about human language and word meaning and then we wanna get right into talking about um, the first thing that we're doing which is coming up with word vectors and looking at the word2vec algorithm and that will then sort of fill up the rest of the class. There are still two seats right in the front row for someone who wants to sit right in front of me, just letting you know [LAUGHTER]. Okay. Okay. So here are the course logistics in brief. So I'm Christopher Manning, the person who bravely became the head TA is Abigail See is right there. And then we have quite a lot of wonderful TA's. To the people who are wonderful TA's just sort of stand up for one moment. So, um, [LAUGHTER] we have some sense for wonderful TAs. [LAUGHTER] Okay great. Um, okay. So you know when the lecture is because you made it here and so welcome also to SCPD people. This is also an SCPD class and you can watch it on video. But we love for Stanford students to turn up and show their beautiful faces in the classroom. Okay. So, um, the web-page has all the info about syllabus et cetera et cetera. Okay. So this class what do we hope to teach? So, one thing that we wanna teach is, uh, you know, an understanding of effective modern methods for deep learning. Starting off by reviewing some of the basics and then particularly talking about the kinds of techniques including um, recurrent networks and attention that are widely used for natural language processing models. A second thing we wanna teach is a big picture understanding of human languages and some of the difficulties in understanding and producing them. Of course if you wanna know a lot about human languages, there's a whole linguistics department and you can do a lot of courses of that. Um, but so I wanna give at least some appreciation so you have some clue of what are the challenges and difficulties and varieties of human languages. And then this is also kind of a practical class. Like we actually wanna teach you how you can build practical systems that work for some of the major parts of NLP. So if you go and get a job at one of those tech firms and they say "Hey, could you build us a named entity recognizer?" You can say "Sure, I can do that." And so for a bunch of problems, obviously we can't do everything, we're gonna do word meaning, dependency parsing, machine translation and you have an option to do question answering, I'm actually building systems for those. If you'd been talking to friends who did the class in the last couple of years, um, here are the differences for this year just to get things straight. Um, so we've updated some of the content of the course. So, uh, between me and guest lectures there's new content. Well that look bad. Wonder if that will keep happening, we'll find out. There's new content and on various topics that are sort of developing areas. One of the problems with this course is really big area of deep learning at the moment is still just developing really really quickly. So, it's sort of seems like one-year-old content is already things kind of data and we're trying to update things. A big change that we're making this year is we're having five-one week assignments instead of three-two week assignments at the beginning of the course and I'll say a bit more about that in a minute. Um, this year we're gonna use PyTorch instead of TensorFlow, and we'll talk about that more later too. Um, we're having the assignments due before class on either Tuesday or Thursday. So you're not distracted and can come to class. So starting off, um, yeah. So we're trying to give an easier, gentler ramp-up but on the other hand a fast ramp-up. So we've got this first assignment which is sort of easy, uh, but it's available right now and is due next Tuesday. And the final thing is we're not having a midterm this year. Um, okay. So this is what we're doing. So there are five of these assignments that I just mentioned. Um, So six percent for the first one, 12 percent for each of the other ones, um, and, I already said that. We're gonna use gradescope for grading. It'll be really help out the TAs if you could use your SUnet ID as your gradescope account ID. Um, so then for the This is not working right. Um, and so then at the end we have a final poster presentation session at which your attendance is expected, and we're gonna be having that Wednesday in the evening. Probably not quite five hours but it'll be within that window, we'll work out the details in a bit. Three percent for participation, see the website for details. For the homework should expect it to do them yourself. Of course you can chat to people in a general way about the problems. Okay. So that is the course. All good, and not even behind schedule yet. Okay. So the next section is human language and word meaning.Um. You know, if I was um, really going to tell you a lot about human language that would take a lot of time um, which I don't really have here. But we're doing some kind of you know probabilistic inference of guessing what people mean and we're using language not just for the information functions but for the social functions etc etc. Okay. And then here's my one other thought I had review about language. So, essentially if we want to have artificial intelligence that's intelligent, what we need to somehow get to the point of having compu- computers that have the knowledge of human beings, right? Because human beings have knowledge that gives them intelligence. You know, humans are basically pretty puny um, but they had this um, unbeatable advantage that they could communicate with each other and therefore work much more effectively in teams. And that sort of basically made human beings invincible. But you know, even then humans were kind of limited, right? That kind of got you to about the Stone Age right, where you could bang on your stones and with the right kind of stone make something sharp to cut with. And therefore, I can say a short message and communicate only a relatively short bit string and you can actually understand a lot. All right? So, I can say sort of whatever you know, imagine a busy shopping mall and that there are two guys standing in front of a makeup counter, and you know I've only said whatever that was sort of about 200 bits of information but that's enabled you to construct a whole visual scene that we're taking megabytes to um, represent as an image. So, if you wanted to do something like just get some stuff out of WordNet and show it, it's the perfect thing to use. Um, okay. So, um, from NLTK I'm importing WordNet and so then I can say, "Okay, um, for the word good tell me about the synonym sets with good participates in." And there's good goodness as a noun. And it turns out that you know WordNet doesn't actually do that that well because it just has these sort of fixed discrete synonym sets. So, if you have a words in a synonym said that there's sort of a synonym and maybe not exactly the same meaning, they're not in the same synonyms set, you kind of can't really measure the partial resemblance as a meaning for them. Right? Now all of these ways that you can bake bigger words by adding more stuff into it. Um, and so really you end up with an infinite space of words. Um, yeah. So that's a minor problem, right? We have very big vectors if we want to represent a sensible size vocabulary. Um, but there's a much bigger problem than that, which is, well, precisely what we want to do all the time, is we want to, sort of, understand relationships and the meaning of words. Um, and so that's the idea of distributional semantics. And it's been- so one of the most successful ideas in modern statistical NLP because it gives you a great way to learn about word meaning. And so what we're gonna do is we're going to say, haha, I want to know what the word banking means. He said or thought something. Um, they group together. Now, what am I actually showing you here? Um, you know, really this was built from, ah, 100 dimensional word vectors. And there is this problem is really hard to visualize 100 dimensional word vectors. So, what is actually happening here is these, um, 100 dimensional word vectors are being projected down into two-dimensions, and you're so- seeing the two-dimensional view, which I'll get back to later. So it wasn't the first work and having distributed representations of words. So there was older work from Yoshua Bengio that went back to about the sort of turn on the millennium, that somehow it's sort of hadn't really sort of hit the world over their head and had a huge impact and has really sort of Thomas Mikolov showed this very simple, very scalable way of learning vector representations of um words and that sort of really opened the flood gates. The meaning of banking is predicting the contexts in which banking occurs. Here's one context. Let's try and predict these words that occur around banking and see how we do and then we'll move on again from there. Okay. Um, sounds easy so far. Um, [NOISE] now we go on and sort of do a bit more stuff. Now, that's, that's almost true. It's not quite true. Um, we actually cheat slightly. Since we actually propose two vector representations for each word and this makes it simpler to do this. Um, you cannot do this, there are ways to get around it but this is the simplest way to do it. So we have one vector for word when it's the center word that's predicting other words but we have a second vector for each word when it's a context word, so that's one of the words in context. Yeah, so there's sort of in practice, there are two parts. There's the orange part which is this idea of using dot product and a vector space as our similarity measure between words and then the second part is all the rest of it where we feed it through what we refer to a news all the time as a softmax distribution. and it might just actually be good to do it concretely and get everyone up to speed right at the beginning. Yeah? [inaudible] how do we calculate [inaudible] specifically? Well, so, we- so the way we calculate the, the U and V vectors is we're literally going to start with a random vector for each word and then we iteratively going to change those vectors a little bit as we learn. And that vector knows what words occur in the context of, um, a word- of itself. And knowing what words occur in its context means, it can accurately give a high probability estimate to those words that occur in the context, and it will give low probability estimates to words that don't typically occur in the context. Right, the log of the x of u, o, T, v, c, over the sum of W equals one to V of the x of u, o, T, v, c. Okay, so this, um, so now we have a log of the division, so that's easy to rewrite, um, that we have a partial derivative of the log of the numerator minus and I can distribute the partial derivative. So, I can have minus the partial derivative, um, of the denominator, um, which is log of this thing. Okay. So, what we can say is here's you know, our function F and here is the body of the function, and so what we want to do is um, do it in two stages. Um, so that at the end of the day, we've got this V_c at the end. So, we have sort of some function here. There's ultimately a function of V_c, and so we gonna do with a chain rule. Let's call that put over here a U_x, and if we do that, sort of an interesting thing has happened because look right here, we've rediscovered exactly the same form that we use as our probability distribution for predicting the probability of words. So, this is now simply the probability of X given C according to our model. If you know about that from modelling words similarities that sort of grown as a good package um, for doing um, word vectors as well. So, it's quite often used for word vectors and word similarities that sort of efficient for doing things at large-scale. Um, yeah. So, I haven't yet told you about will next time we have our own homegrown form of word vectors which are the GloVe word vectors. And then we could say which word in our vector space as most similar in meaning to that word. And that would be a way of sort of doing analogies. Would be able to do the, um, analogy, man is the king as woman is to what? And so, the way we're gonna do that is to say we want to be similar to king and woman because they're both positive ones and far away from man."