Web Information Paper Review (4)

Yoshua Bengio, et al.:A Neural Probabilistic Language Model

Link:?word2vec 中的數(shù)學(xué)原理詳解(三)背景知識

In this paper, the author introduce how to use deep learning neural network to predict the word in sentence and compare it with the traditional n-gram method. The goal of nlp is to learn the probabilistic model to describe how words and sentences are generated. We want to know that in a document, what word will come next after a specific sequence of words. This can help computer better understand the human language.

The traditional method is called n-gram, which model the human language under the naive bayes assumption. The probability of a specific T sequence words are model as the product of consecutive bayes conditional probability. The probability is approximate to the frequency of the sequence of word in a corpora. However, this need a huge amount of count. If the T is very large, the count procedure will cost a lost. So a modified n-gram is proposed to reduce this. When consider bayes conditional probability, we only consider (n-1) word before the word we going to predict. Usually, n is chosen to 3. The drawbacks of this n-gram method are: (1) it don’t consider context farther than 3. (2) it don’t consider the potential relationship under the words. In nature language, context words can up to 10 or more. Also, latent semantic is very prevail among words. When counting word sequence in the corpora, we cannot ignore similar sentence but different words. The traditional way is use word vector to represent each word. But this is not effective and when corpora is very large, might introduce the curse of dimensionality, which means the vector to represent each word has too big dimension and not computable. In this paper, this two issues are solved by using distributed word feature vector and the neural network.

The distributed word feature vector provide a vector space to contain all the words in the corpora. It has m features (elements) which is specific by user and depended on the size of the corpora. Usually, the m is 60, which means each word can be described by using 60 parameters. And between similar meaning words, the vector degree is small. So when consider n words sentence, we concreate the each words vector together to form a n*m sentence vector. For similar sentences, the sentences’ vectors should have small degree. This is how we map the nature word to the input data of the neural network.

The basic idea of machine learning or the neural network is: first model the problem we want to solve. The model is control by a set of parameters. Then find the loss function or the likelihood function which describe how far is the prediction from the distribution's expectation. Then driven this evaluation function with the training data and the corresponding labels. So now the problem turn out to be to find the parameter make the evaluation function have the max/min value. Finally, use gradient descent or ascent to find a set of parameter satisfied this as the model parameters. Then we can use this model to predict in our problem.

In this paper, they use neural network to model this problem. They use a five layer recurrent neural network. The first layer is the input layer which do nothing just input (n-1) nature language words into the net. This also use the modified bayes model. The second layer is a hidden layer and also called word feature layer in the paper. This layer convert each input nature word to the m-feature vector space. Each words is map to a m-dimension vector C. Notice, this C is not pre-defined. It is also considered as a set of parameter in the net. We need to train the model to get C for each word. The next is a hidden layer, which map the concatenation of the (n-1)’s vector C to a row vector x and then use (d+Hx) to model this sentence vector. D is the layer bias which has the dimension of the neural number h in this layer. H is the weight of this hidden layer. The next layer is the output layer. This layer basic apply hyperbolic tangent to the output of the last layer and weighted with U, which is a |V|*h weight matrix. Also have a output bias of b which is |V| dimension. And a direct connection weight W which I will discuss at last. So the output of the output layer is a non-normalized probabilistic vector in respect to the |V| words in the corpora. The output function is: y = b + Wx + U tanh(d + Hx). Before we pick the final prediction, we need to normalized the probabilistic with the softmax function at the softmax layer and pick the largest p as our prediction. This is how to predict with neural network and also called forward phase.

After we define our model, we need to tranning the label data to get all of our parameters. We have PARAM=|V|(1+nm+h)+h(1+(n-1)m) free parameter need to specific. Now, let’s define the likelihood function to describe how confident we are about our prediction: L = 1/T∑log f(w_t, w_t-1...w_t-n ; theta) + R(theta). The method to find the theta make the L get max value is by using gradient ascent. However, at here, if we directly use gradient ascent, this will turn out to be a PARAM dimension problem which is hard to solve when PARAM is large. So we divide the model into layers and each time only train the parameters within a layer. This is how neural nets reduce the computation of traditional machine learning problems. BTW, R(theta) is the weight decay penalty which restrict the gradient ascent searching area after every epoch and don’t make it go too far and cannot converge.

To train this kind of net, we still have a very large computation. So the author come out with the parameter-parallel processing to train and predict the model. Suppose we have M CPU and |V| words in the corpora. So the output will be a |V| dimensional vector. We instead of divide the input data into subsets, they divide the output into subsets and every CPU take charge of |V|/M output units. The forward phase is basicly like what I describe above but each CPU calculate |V|/M outputs and merge together then softmax. What is most interesting is how they train the model with the parameter parallel processing.

The training process is also called Backward/Update phase. They train the model from the back layer to the front layer and each time only train parameters within one layer. The learning rate (step) is e. First, the train the output layer. The parameters in the output layers are (b, W, U) and I still ignore the direct connection weight W. So the (b, U) can be represented by using a. Then for each CPU, use gradient ascent to find the a which can make the L has the maximum value. For b, since it is a constant bias, we compute partial derivative of the L to y_i to update b and start from the initial b. Y_i represent the input variable to the L in this layer. Eventually, we can get a b make L largest. The do the similar gradient ascent to U, but multiply with a. After all M CPU computation is done, we get M set of ?a=(b, U) as every parameter’s best solution. This layer parameter training has finished. The only information will pass to the next training layer, hidden layer with (d, H), is the partial derivative of L to a. In this hidden layer, we have h neurals so we use the back-propagation to get the partial derivative of L to o. O is (d+Hx) represent the input variables in this layer to the L function. Then still use gradient ascent to get d and H for each neural. Also update the partial derivative of L to x and pass to the next layer’s training. Then in the word feature layer, use gradient ascent to get C for each input word. Then we get distributed representation vector of (n-1) input word. We should training the whole corpora to get the C for each word. And when prediction, we can use them as the word feature layer’s parameter. Also, they use a method to avoid the exp in softmax is too much to compute.

The W is called direct connection weight, which means ignore the hidden layer and directly map the input C to the output layer and then use softmax to normalize. This might reduce the iteration converge times but not improve the model’s performance.

From this paper, I learn how the neural net are used in nlp problems and have a better understanding of the neural nets. I am very interested in this topic and will study further inside.


Tomas Mikolov, et al.:Distributed Representations of Words and Phrases and their Compositionality

Link:?深度學(xué)習(xí)word2vec筆記之算法篇,?文本深度表示模型Word2Vec,?Vector Representations of Words - TensorFlow

In this paper, the author introduces new model to analysis the nature language called word2vec. The word2vec has two model: CBOW and the Skip-gram model. CBOW is aim at predicting the next word based on the context. The Skip-gram model is aim at predicting a word around the target word. They are all based on the Huffman tree which can reduce the overall computation a lot. The paper also introduce the technique called subsampling and negative sampling which can reduce computation and the phrase based model.

The Skip-gram can be understanded as a 3 layer neural net. The input layer is just word. The hidden layer is map the word to the word vector. The output layer is basically a Huffman tree. All the words in the corpora are at the leaf and the node is only a word vector which can be understanded as a classifier of the word. Each word confront a node will be put into either left or the right path. This can roughly distinguish the word. And after pass through all the level in the Huffman tree, finally arrive at the specific word as final predict. The Skip-gram doesn’t consider the sequence of the word in a sentence, only consider the distance toward the target word. First, the author get the likelihood function. When training the parameters, the goal is to maximum the likelihood function. The likelihood function consider the word within c radius. Then the traditional method is model the p(W_0|W_i) by using the softmax and compute the degree between the two word vector. However, this is found not practical when corpora is large, so the author introduce the method below.

The first method is using the Hierarchical softmax. This make the output layer look like a tree instead of a vector with |V| elements. The tree is obtained during the training process and the most frequently use words are put at the leftmost leaf. You can also put at right most leaf, here word2vec use leftmost. So then the p(W_0|W_i) can be understand as the possibility of from the root to the word W_0. At each node, the input W_i can compute the degree between the W_i and the node vector. If the path from the root to the W_0 require the walk to goto the right child node, then the possibility is set negative. Because that the most frequently used words are located leftmost. This is kind of penalty on the possibility. The degrees are map by the sigmoid function. By using this way, the computation amount is only proportional to the log(|V|). This reduce the computation a lot.

Another way to reduce it is using the so-called negative sampling. This use the technique called Noise contrastive Estimation. This method assume that a good model should be able to differentiate data from noise by the mean of the logistic regression. So other than the computation of teh degree between W_0 and W_i, this also randomly generate k noise word vectors which is not belong to this corpora. The degree between the noise vector and the target word should be very large, so that the sigmoid function can map this penalty to almost 0. By using this method, each prediction’s computation only consume (k+1).

Also the paper talk about the subsampling which can drop some frequent use but less meaningful word such as “a” and “the”. In the the subsampling, every word has a chance to be dropped and it is related to the frequence of the word. Finally the author talk about the phrase model. They think phrase model sometimes is more reliable than the word model. Since some phrase combination might be rare to see but the phrase itself is frequently used. They evaluated two words’ possibility of form a phrase using the basic count method. Here they only consider the bigram case.

One of the most interesting thing in the paper is the word vector calculation. They find that two set of word with same kind of relationship can be mapped to another by using a similar transfer function. Such that “Madrid”-”Spain”+”France”~”Paris”. This indicate that the distance between same relationship set of word might be same. This reveal an interesting way of studying nlp.

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子端姚,更是在濱河造成了極大的恐慌屿愚,老刑警劉巖肪康,帶你破解...
    沈念sama閱讀 207,113評論 6 481
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異谁尸,居然都是意外死亡括儒,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 88,644評論 2 381
  • 文/潘曉璐 我一進店門肮韧,熙熙樓的掌柜王于貴愁眉苦臉地迎上來融蹂,“玉大人,你說我怎么就攤上這事惹苗〉罱希” “怎么了?”我有些...
    開封第一講書人閱讀 153,340評論 0 344
  • 文/不壞的土叔 我叫張陵桩蓉,是天一觀的道長淋纲。 經(jīng)常有香客問我,道長院究,這世上最難降的妖魔是什么洽瞬? 我笑而不...
    開封第一講書人閱讀 55,449評論 1 279
  • 正文 為了忘掉前任,我火速辦了婚禮业汰,結(jié)果婚禮上伙窃,老公的妹妹穿的比我還像新娘。我一直安慰自己样漆,他們只是感情好为障,可當(dāng)我...
    茶點故事閱讀 64,445評論 5 374
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著放祟,像睡著了一般鳍怨。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上跪妥,一...
    開封第一講書人閱讀 49,166評論 1 284
  • 那天鞋喇,我揣著相機與錄音,去河邊找鬼眉撵。 笑死侦香,一個胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的纽疟。 我是一名探鬼主播罐韩,決...
    沈念sama閱讀 38,442評論 3 401
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼污朽!你這毒婦竟也來了伴逸?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 37,105評論 0 261
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎错蝴,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體颓芭,經(jīng)...
    沈念sama閱讀 43,601評論 1 300
  • 正文 獨居荒郊野嶺守林人離奇死亡顷锰,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 36,066評論 2 325
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了亡问。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片官紫。...
    茶點故事閱讀 38,161評論 1 334
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖州藕,靈堂內(nèi)的尸體忽然破棺而出束世,到底是詐尸還是另有隱情,我是刑警寧澤床玻,帶...
    沈念sama閱讀 33,792評論 4 323
  • 正文 年R本政府宣布毁涉,位于F島的核電站,受9級特大地震影響锈死,放射性物質(zhì)發(fā)生泄漏贫堰。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 39,351評論 3 307
  • 文/蒙蒙 一待牵、第九天 我趴在偏房一處隱蔽的房頂上張望其屏。 院中可真熱鬧,春花似錦缨该、人聲如沸偎行。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,352評論 0 19
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽蛤袒。三九已至,卻和暖如春壮不,著一層夾襖步出監(jiān)牢的瞬間汗盘,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 31,584評論 1 261
  • 我被黑心中介騙來泰國打工询一, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留隐孽,地道東北人。 一個月前我還...
    沈念sama閱讀 45,618評論 2 355
  • 正文 我出身青樓健蕊,卻偏偏與公主長得像菱阵,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子缩功,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 42,916評論 2 344

推薦閱讀更多精彩內(nèi)容

  • 「傳授工作」之后晴及,就要讓他做做看,那就是「試做」了嫡锌÷羌冢「試做」共分為四個主要的步驟: 一琳钉、讓他試做,一一改正錯誤 示...
    周明達老師閱讀 1,080評論 0 10
  • 童年蛛倦,家歌懒,那個孩子! 人無完人溯壶,誰沒有點陰暗面及皂,誰不曾因年少無知而自私妄為地傷害過他人,或多或少且改!但是我想我確實是...
    安古閱讀 230評論 0 0
  • 煩躁不安的時候验烧,總想睡很長很長的覺,可以回避很多不想面對的事又跛。 無聊低沉的時候碍拆,總會打很久很久的游戲,把負能量全部...
    蟲鳴一夏閱讀 83評論 0 0
  • 夜華拱手施了一禮:“有兩位上神在此幫襯鳳九效扫,我和淺淺也放心了些倔监。” 折顏和白真對視了一眼菌仁,神色皆凝重浩习。 夜華心里一...
    狐貍木木閱讀 4,884評論 0 14