【问题标题】:Limiting the number of iterations in Stanford NER限制斯坦福 NER 中的迭代次数
【发布时间】:2017-09-04 01:08:39
【问题描述】:

我正在自定义数据集上训练斯坦福 NER CRF 模型,但用于训练模型的迭代次数现已达到 333次迭代——即这个训练过程现在已经持续了几个小时。 下面是终端打印的消息-

Iter 335 evals 400 <D> [M 1.000E0] 2.880E3 38054.87s |5.680E1| {6.652E-6} 4.488E-4 - 
Iter 336 evals 401 <D> [M 1.000E0] 2.880E3 38153.66s |1.243E2| {1.456E-5} 4.415E-4 -
 - 

下面给出了正在使用的属性文件 - 有什么方法可以将迭代次数限制为 20 次。

location of the training file
trainFile = TRAIN5000.tsv
#location where you would like to save (serialize to) your
#classifier; adding .gz at the end automatically gzips the file,
#making it faster and smaller
serializeTo = ner-model_TRAIN5000.ser.gz

#structure of your training file; this tells the classifier
#that the word is in column 0 and the correct answer is in
#column 1
map = word=0,answer=1

#these are the features we'd like to train with
#some are discussed below, the rest can be
#understood by looking at NERFeatureFactory
useClassFeature=true
useWord=true
useNGrams=true
#no ngrams will be included that do not contain either the
#beginning or end of the word
noMidNGrams=true
useDisjunctive=true
maxNGramLeng=6
usePrev=true
useNext=true
useSequences=true
usePrevSequences=true
maxLeft=1
#the next 4 deal with word shape features
useTypeSeqs=true
useTypeSeqs2=true
useTypeySequences=true
wordShape=chris2useLC
saveFeatureIndexToDisk = true
printFeatures=true
flag useObservedSequencesOnly=true
featureDiffThresh=0.05

【问题讨论】:

    标签: nlp stanford-nlp named-entity-recognition crf stanford-parser


    【解决方案1】:

    在你的道具文件中使用maxQNItr=21。它将运行多达 20 次迭代。得到了David's answer的帮助

    【讨论】:

      【解决方案2】:

      简答:使用tolerance(默认为 1e-4)。还有一个参数maxIterations 被忽略了。

      【讨论】:

        【解决方案3】:

        我尝试通过 Stanford CoreNLP CRF classifier 在带有 IOB 标记的标记化文本上训练生物医学 (BioNER) 模型,如 https://nlp.stanford.edu/software/crf-faq.html 所述。

        我的语料库——来自下载的资源——非常大(约 150 万行;6 个特征:基因;...)。由于训练似乎无限期进行,我绘制了 Values 的比率以了解进度:

        抓取Java源码,发现默认TOLtolerance;用于决定何时终止训练)值为1E-6(0.000001),在.../CoreNLP/src/edu/stanford/nlp/optimization/QNMinimizer.java中指定。

        看看那个情节,我最初的训练课程永远不会完成。 [该图还显示设置更大的TOL 值,例如tolerance=0.05,将触发训练提前终止,因为 TOL 值是由训练开始附近出现的“噪音”触发的。我通过.prop 文件中的tolerance=0.05 条目确认了这一点;但是,TOL 的值 0.010.005 等都是“OK”。]

        将“maxIterations=20”添加到属性文件中,如@StanfordNLPHelp(在此线程的其他地方)所描述的,似乎被忽略了,除非我还在我的bioner.prop 属性文件中添加并更改了tolerance= 值;例如

        tolerance=0.005
        maxIterations=20    ## optional
        

        在这种情况下,分类器会快速训练模型 (bioner.ser.gz)。 [当我将maxIterations 行添加到我的.prop 文件中时,没有添加tolerance 行,模型就像以前一样“永远”运行。]

        可以在此处找到.prop 文件中可以包含的参数列表:

        https://nlp.stanford.edu/nlp/javadoc/javanlp-3.5.0/edu/stanford/nlp/ie/NERFeatureFactory.html

        【讨论】:

        • 我们如何使用生成的模型进行自己的预测?文档中没有提到
        【解决方案4】:

        maxIterations=20 添加到属性文件中。

        【讨论】:

        • maxIterations 未使用。它既不是调用的一部分,也不是最小化器的构造。
        猜你喜欢
        • 2020-04-28
        • 1970-01-01
        • 2019-03-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-06-06
        • 2015-09-11
        • 1970-01-01
        相关资源
        最近更新 更多