多语言命名实体识别:从模型到实践
1. 数据检查与多语言模型概述
在进行命名实体识别(NER)任务之前,我们需要确保数据标签没有异常的不平衡。以下是计算每个实体在不同数据分割中的频率的代码:
from itertools import chain
from collections import Counter
split2freqs = {}
for split in panx_de.keys():
tag_names = []
for row in panx_de[split]["ner_tags_str"]:
tag_names.append([t.split("-")[1] for t in row if t.startswith("B")])
split2freqs[split] = Counter(chain.from_iterable(tag_names))
import pandas as pd
pd.DataFrame.from_dict(split2freqs, orient="index")
结果如下:
| | ORG | LOC | PER |
| — | — | — | — |
| validation | 2683 | 3172 | 2893 |
| test | 2573 | 3180 | 3071 |
| train | 5366 | 6186 | 5810 |
从结果可以看出,PER、LOC 和 ORG 频率在每个分割中的分布大致相同,这意味
超级会员免费看
订阅专栏 解锁全文

被折叠的 条评论
为什么被折叠?



