CoreNLPセンチメント分析(下記)をスピードアップする方法を誰かが考えることができますか?CoreNLPセンチメント分析をスピードアップ
私はかつて、サーバーの起動時にCoreNLPパイプラインを初期化します。
// Initialize the CoreNLP text processing pipeline
public static Properties props = new Properties();
public static StanfordCoreNLP pipeline;
// Set text processing pipeline's annotators
props.setProperty("annotators", "tokenize, ssplit, pos, parse, sentiment");
// Use Shift-Reduce Constituency Parsing (O(n),
// http://nlp.stanford.edu/software/srparser.shtml) vs CoreNLP's default
// Probabilistic Context-Free Grammar Parsing (O(n^3))
props.setProperty("parse.model", "edu/stanford/nlp/models/srparser/englishSR.ser.gz");
pipeline = new StanfordCoreNLP(props);
は、その後、私は私のコントローラからのパイプラインを呼び出します。
String text = 'A sample string.'
Annotation annotation = pipeline.process(text);
List<CoreMap> sentences = annotation.get(CoreAnnotations.SentencesAnnotation.class);
for (CoreMap sentence : sentences) {
Tree tree = sentence.get(SentimentCoreAnnotations.SentimentAnnotatedTree.class);
int sentiment = RNNCoreAnnotations.getPredictedClass(tree);
...
}
私は、コードプロファイリングしました - ラインAnnotation annotation = pipeline.process(text)
を、どのCoreNLPの主要な処理呼び出しであり、非常に遅いです。私のコントローラへの100回の呼び出しの要求は、平均で1.07秒かかります。注釈は1コールにつき約7msかかる。私は〜2msに減らす必要があります。
感想がすべてのものに依存しているため、注釈を削除できません。私はすでにShift-Reduce Constituency Parserを使用しています。これはデフォルトのContext-Free Grammar Parserよりもはるかに高速です。
これを大幅にスピードアップするために調整できる他のパラメータはありますか?
...スピードを改善するための唯一の残りの方法は、トークナイザオプションで遊んでされるかもしれない、代わりにPCFGのSRパーサを使用するよりも、他の推測、それが最も可能性が高い実行不可能です大きな注釈付きコーパスはありませんが、おそらくあなたのドメインに特化した小さなモデルを再テストすることができます。 –