3

我正在训练斯坦福NER CRF模型,在自定义数据集上,但是用于训练模型的迭代次数现在已经达到了迭代次数 - 即,这个培训过程现在已经过去了几个小时。 下面是在该终端打印的信息 - 文件被使用在下面给出限制斯坦福大学NER的迭代次数

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 

回答

0

添加maxIterations=20到属性文件。

+2

我试过这个,它没有工作 – arop

1

我尝试通过Stanford CoreNLP CRF classifier对0123B所述的带有IOB标记的标记文本进行生物医学(BioNER)模型的培训。

我的语料库 - 来自下载源文件 - 非常大(约1.5M行; 6个功能:GENE; ...)。作为培训似乎无限期地跑,我绘制的值的比例来获得进展的想法:

plot of ratio of CRF training Values per Iteration

Grepping Java源代码,我发现默认TOLtolerance;用于确定何时终止训练课程)值为1E-6(0.000001),详见.../CoreNLP/src/edu/stanford/nlp/optimization/QNMinimizer.java

看看那个情节,我原来的培训课程永远不会完成。 [该图还显示,设置较大的值,例如, tolerance=0.05,将触发培训的提前终止,因为该值由培训课程开始附近出现的“噪音”触发。我在我的.prop文件中用tolerance=0.05条目证实了这一点;然而,0.01TOL值,0.005等是“OK”。]

添加“maxIterations=20”的属性文件由@StanfordNLPHelp(在此线程别处)中描述似乎被忽略,除非我还添加和改变tolerance=值,在我的bioner.prop属性文件中;例如

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