我正在尝试根据自己的数据训练模型,并且正在使用Spacy库。
但是我对代码示例中的“ #token head index”感到困惑。
在这里究竟是什么意思?
# training data: texts, heads and dependency labels
# for no relation, we simply chose an arbitrary dependency label, e.g. '-'
TRAIN_DATA = [
(
"find a cafe with great wifi",
{
"heads": [0, 2, 0, 5, 5, 2], # index of token head
"deps": ["ROOT", "-", "PLACE", "-", "QUALITY", "ATTRIBUTE"],
},
)
在您的示例中,任务是重建tree of syntactic dependencies。这棵树为每个单词显示了其附加到的相应“头”单词以及附件的类型。描述这种树的一种特定格式称为CoNLL-U。
在您的示例中,例如“ wifi”(单词5)附加了“ great”(单词4,如果从0算起),并且“ great”是“ wifi”的quality。因此,heads
的第4个条目等于5,deps
的第4个条目等于“ QUALITY”。