CRFに基づく形態素解析器のスコア計算の分割によるモデルサイズと解析速度の調整
Summary
The authors work with CRF-based Japanese morphological analyzers such as MeCab. These analyzers precompute scores for pairs of adjacent morphemes and store them in a connection table. With fine-grained features, as in UniDic, this table grows to hundreds of megabytes. This makes the model hard to run on embedded devices or in a web frontend. The authors propose splitting the computation of the 2-gram score into two parts. Some of the feature templates are computed in advance, and the rest are computed during analysis. The templates that inflate the table the most are selected with a greedy algorithm. For fast score lookup at runtime, a double array is used, and the lookup loop is vectorized with SIMD (AVX2). The method is implemented in Rust as a modification of Vibrato. The model was trained on BCCWJ and UniDic. The model parameters do not change, so analysis accuracy remains the same. What it adds is an adjustable trade-off between model size and speed. This makes it possible to distribute full-fledged models for resource-constrained environments.
Key points
- Scale of the problem. In UniDic 3.1.0 for contemporary written Japanese, the connection table is 15,626 × 15,388. With 16-bit scores, this amounts to about 459 MiB. By comparison, the IPAdic table is only 1,316 × 1,316.
- Data and tools. The model was trained on 60k sentences from the BCCWJ core (v1.1) with the UniDic 3.1.0 dictionary. Training used rucrf with L1 regularization via OWL-QN, and the baseline system is Vibrato. Speed was measured on 100k sentences outside the BCCWJ core, single-threaded on an Intel i9-12900K.
- Template selection. Three strategies were compared: Various, Greedy, and Greedy-2. With the greedy strategies, excluding just 5 templates from precomputation is enough to shrink the table to about 10% of its original size. The Various strategy had almost no effect.
- Size versus speed. The full table (Matrix) takes 350 MiB, and analysis takes 0.87 s. The Dual variant, in which 8 templates are computed during analysis, takes 41.1 MiB, i.e., ≤12% of Matrix, but is 2.4 times slower (2.13 s). The Raw variant, with no precomputation at all, takes 1.9 MiB (about 0.5%) but is 23 times slower (20.04 s).
- Effect of SIMD. Eight-lane AVX2 vectorization speeds up Dual to 1.80 s and Raw to 12.05 s. Even so, Dual is still more than twice as slow as Matrix.
Cite
@inproceedings{2023,
title = {{CRFに基づく形態素解析器のスコア計算の分割によるモデルサイズと解析速度の調整}},
author = {赤部晃一 and 神田峻介 and 小田悠介},
booktitle = {言語処理学会 第29回年次大会 発表論文集 (NLP2023)},
year = {2023},
url = {https://www.anlp.jp/proceedings/annual_meeting/2023/#C2-1}
}This page in Markdown → https://md.research.elamur.ai/free/en/papers/akabe-2023-splitting-score-computation-crf/