30

​NLP->NER | 对命名实体识别 5 大框架进行基准测试

 3 years ago
source link: http://mp.weixin.qq.com/s?__biz=MzAxMjMwODMyMQ%3D%3D&%3Bmid=2456345225&%3Bidx=2&%3Bsn=e5ea1c211a6d206f9f075dc61852e4a8
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

ya6B3mJ.jpg!web

  磐创AI分享   

来源 | Towards Data Science

作者 | Felix Laumann

编译 | VK

【作者导语】 NER是信息提取的一个子任务,它试图定位并将非结构化文本中提到的指定实体划分为预定义的类别,如人名、组织、位置、医疗代码、时间表达式、数量、货币。

我们创建了我们自己的小型测试数据集,其中11个示例来自谷歌的Taskmaster 2数据集,该数据集于2020年2月刚刚发布。我们将此数据集视为NER解决方案中未来研究和产品的基准数据集。我们用该数据集来探索TextSpace。

这个数据集中的句子可能在长度和包含的信息上有所不同,但是我们选择了其中包含大量实体的句子,因此我们可以根据最新的NER解决方案来区分优劣。我们测试集中的句子来自不同的领域,因为我们想看看我们在这篇文章中比较的解决方案有多灵活。请注意,这些示例中使用了Dialogflow聊天机器人,因此我们也希望Dialogflow在这些例子上能够执行得很好。

我们将首先详细地看两个例子,最后会有一个总结。

机票预订

让我们以一个想要预订航班的用户的句子为例:

"So, I would like to fly out sometime tonight and fly back in the evening in 4 days. From I’m looking to go to Denver. I’m flying out of San Francisco."
6RrmQ3B.png!web

IBM的MAX命名实体标记器执行得并不好,它只返回属于时间和位置类别的单词。不幸的是,它甚至在第二句的开头将"I"错误地归类为一个事件。

与此相比,StanfordNLP NER模型的性能要好得多。找到所有可能的实体,甚至返回正确的日期。然而,有一个小错误发生了,那就是没有意识到"in the evening in 4 days"是属于一起的。它把"evening"划分为今天的晚上,而不是四天里的晚上。

FJnmAb6.png!web

spaCy NER模型的性能与IBM相同,只返回属于时间、日期或位置类别的单词。它没有显示StanfordNLP的确切日期。

rIbuUbF.png!web

在本例中,我们的解决方案TextSpace执行得非常好,它提取了所有可能的具有确切日期的实体,类似于StanfordNLP。但是,TextSpace也会返回一个时间周期的时间间隔,它不是很具体,例如"evening"或"tonight"。这里第一个是地点:

qaUfeiA.png!web

和时间:

VVNVj2J.png!web

不幸的是,TextSpace也不承认"evening"和"4 days"属于一起,并返回当天的晚上,就像StanfordNLP所做的那样。

iQ7jYbN.png!web

我们使用Dialogflow聊天机器人预订,我们可以得到平庸的结果。它能正确识别日期和时间、出发城市和到达城市,但却完全忽略了"in 4 days"。非常令人失望,因为我们使用了谷歌数据集和Dialogflow的特定于域的聊天机器人来预测。

FnmmQjB.png!web

酒店预订

接下来,我们用下面的句子来比较这四种解决方案:

"I would like to book a room in the Park Hyatt Aviara Resort and it costs $279 per night. It’s rated 4.8 stars. It offers an 18-hole golf course, an outdoor pool & tennis courts plus a spa & fine dining."
aIzA7jM.png!web

我们再次从IBM的MAX实体标记器开始。我们想要入住的酒店被认为是一个地点,而"&"被错误地认为是一个组织。例如,完全忽略了"$279"的价格。与前面的机票预订示例一样,性能相当差。

StanfordNLP做了更好的工作,发现"279美元"是钱,停留的时间和star的数量。不幸的是,我们的酒店也被归类为一个地点,而不是一个组织,它可能对某些应用程序起作用,但当用户希望自动转发到酒店网站时,这可能不起作用。它也不承认279美元的价格属于"per night",而将"night"作为日期返回。

rU7Bfia.png!web

我们使用Dialogflow预先训练过的酒店预订机器人,这让我们自然地期望它的结果至少和StanfordNLP发现的一样好。不幸的是,情况并非如此,甚至连"279"。日期也没有找到了。

2am6Zzf.png!web

正如前面的例子所示,spaCy的表现也同样糟糕。我们的酒店"Park Hyatt Aviara Resort"被归类为设施(FAC),这并不完全正确,但"279"被正确归类为金钱。不幸的是,"spa & fine"被错误地视为一个组织。

VjeM3yR.png!web

TextSpace在这五个解决方案中表现最好。它发现"Hyatt"作为一个组织,其货币价值为"279美元",跳过"night",因为它知道279美元是每晚的价格,能找到所有的数字。

QRjiIve.png!webeYzquaz.png!web

整体结果

正如所承诺的,我们现在比较所有这五个解决方案在我们的测试集的11个例子的表现来衡量。衡量方法很直接:我们知道哪些句子对应的划分方式,我们计算分类的相关信息。例如,在句子"So, I would like to fly out sometime tonight and fly back in the evening in 4 days. From I’m looking to go to Denver. I’m flying out of San Francisco."。如果一个解决方案将"tonight"和"in the evening in 4 days"划分为正确的日期和时间范围,将"Denver"和"San Francisco"作为地点或城市,那么该解决方案将实现100%的精确度和召回率。换句话说,所有潜在的实体都被发现了,并且都被正确地分类了。当其中一个单词被漏掉,比如"evening in 4 days",只有3/4的单词是正确的,召回率为75%。另外,如果一个词被错误分类,比如"I"是一个组织,那么准确率将下降到4/5,即80%。如果找到日期,但是只返回"time"或"date",而没有精确的日期或时间,我们将减去0.5。

与其他四种解决方案相比,TextSpace的NER表现最好,紧随其后的是StanfordNLP。IBM的MAX实体标记器总体上令人失望。

ZNRvYzQ.png!web

下面是这些柱状图上的数字:

vM3YZ3J.png!web

复制我们的结果

如果你想重现这些结果,以下是我们使用的11个英文句子:

  • Flight booking 1: "So, I would like to fly out sometime tonight and fly back in the evening in 4 days. From I’m looking to go to Denver. I’m flying out of San Francisco."

  • Flight booking 2: "Okay, you got it so it looks like United Airlines leaves at 9:20 p.m. that is nonstop the flight duration is 2 hours and 28 minutes and is priced at $337."

  • Flight booking 3: "I found a flight that leaves Seattle coming Monday at 7:35 a.m and arrives in Tampa at 4:10 p.m."

  • Hotel booking 1: "Park Hyatt Aviara resort Golf Club and Spa, it’s $279 per night. It‘s rated 4.8 stars. Resort offering an 18-hole golf course, an outdoor pool & tennis courts plus a spa & fine dining."

  • Hotel booking 2: "Staybridge Suites Carlsbad, it’s $145 per night. It’s rated 4.5 stars. Warm suites with kitchens in a relaxed property featuring an outdoor pool, a gym & a BBQ area."

  • Cinema 1: "The Mummy is playing at 4:30 pm this afternoon at Regal Davis Stadium 5."

  • Cinema 2: "I have Chips playing at 9:50 PM. I have Get Out playing at 10:15 PM. and Snaps playing at 10:25 PM."

  • Music 1: "Here’s a song diamonds originally by Rihanna Cover by One Voice Children’s Choir."

  • Restaurant 1: "Hi, currently I’m in IKEA, California. I’m looking for restaurant to eat dinner."

  • Restaurant 2: "I found a highly rated restaurant called Second Floor in Kitchen, it is 4.3 stars out of 5 and it’s described is New American tasting menus in a sophisticated setting. How does it sound?"

  • Sports 1: "On last Saturday, September 9th, LA Dodgers played against New York Red Bulls and it was a draw with the score 1–1."

有关实现的更多细节,请参见我们的GitHub存储库: https://github.com/kumar-shridhar/NER-Benchmarks

原文链接: https://towardsdatascience.com/benchmarking-named-entity-recognition-stanfordnlp-ibm-spacy-dialogflow-and-textspace-af6615eb7930

- End -

jiYbIzn.png!web

✄------------------------------------------------

看到这里,说明你喜欢这篇文章,请点击「 在看 」或顺手「 转发 」「 点赞 」。

欢迎微信搜索「 panchuangxx 」,添加小编 磐小小仙 微信,每日朋友圈更新一篇高质量推文(无广告),为您提供更多精彩内容。

▼       扫描二维码添加小编   ▼    ▼  

FRb6fmv.jpg!web


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK