Error message here!

Hide Error message here!

Error message here!

Hide Error message here!

Error message here!

Close

条件随机场conditional random field

sdu20112013 2019-02-13 16:20:00 阅读数:178 评论数:0 点赞数:0 收藏数:0

Feature Functions in a CRF

In a CRF, each feature function is a function that takes in as input:

• a sentence s
• the position i of a word in the sentence
• the label li of the current word
• the label li−1 of the previous word

Features to Probabilities

$$score(l | s) = \sum_{j = 1}^m \sum_{i = 1}^n \lambda_j f_j(s, i, l_i, l_{i-1})$$
$$\lambda_j$$表示$$f_j$$的权重.这样对输入的一个有n个word的sentence s,我们有m个feature function,我们综合考虑这些feature function,则我们可以得到一个score。

That’s because CRFs are indeed basically the sequential version of logistic regression: whereas logistic regression is a log-linear model for classification, CRFs are a log-linear model for sequential labels.

• f1(s,i,li,li−1)=1 if li= ADVERB and the ith word ends in “-ly”; 0 otherwise. ** If the weight λ1 associated with this feature is large and positive, then this feature is essentially saying that we prefer labelings where words ending in -ly get labeled as ADVERB.

• f2(s,i,li,li−1)=1 if i=1, li= VERB, and the sentence ends in a question mark; 0 otherwise. ** Again, if the weight λ2 associated with this feature is large and positive, then labelings that assign VERB to the first word in a question (e.g., “Is this a sentence beginning with a verb?”) are preferred.

• f3(s,i,li,li−1)=1 if li−1= ADJECTIVE and li= NOUN; 0 otherwise. ** Again, a positive weight for this feature means that adjectives tend to be followed by nouns.

• f4(s,i,li,li−1)=1 if li−1= PREPOSITION and li= PREPOSITION. ** A negative weight λ4 for this function would mean that prepositions don’t tend to follow prepositions, so we should avoid labelings where this happens.

• 如果第i个词为副词,并且以ly结尾,则f1()=1,否则为0. 如果权重λ1很大,意味着我们倾向于认为ly结尾的词被认为是副词

• f2() if i=1,li=动词,句子以问号结尾.则f2=1,否则f2=0. 如果我们给这个函数一个正数权重λ2,意味着我们倾向于将问句的第一个词认为是动词,例如“Is this a sentence beginning with a verb?"中我们倾向于认为"is"是个动词

• f3() if li-1=形容词,li=名词,则f3()=1,否则f3()=0. 如果我们给这个函数一个正数权重,意味着我们倾向认为形容词后接的是名词

• f4() if li-1为介词,li为介词,则f4()=1. 我们给这个函数一个负数权重,意味着我们认为介词后面还接介词 这种情况不太可能

Learning Weights

• 对每一个feature function,计算概率梯度
• 梯度的第一项表示的是在真实label下特征函数f的贡献,第二项表示的是当前模型下的期望贡献.
• 将λi沿着梯度方向移动,`$$\alpha$$是学习率.
• 重复上述步骤直到停止条件满足

Finding the Optimal Labeling

https://www.cnblogs.com/sdu20112013/p/10370334.html