User:TJones (WMF)/Notes/TextCat Optimization for ptwiki ruwiki and jawiki

July 2016 — See TJones_(WMF)/Notes for other projects. (Phabricator ticket: T138315)

Summary of Results
Using the default 3K models, the best options for each wiki are presented below:

ptwiki
 * languages: Portuguese, English, Russian, Hebrew, Arabic, Chinese, Korean, Greek
 * lang codes: pt, en, ru, he, ar, zh, ko, el
 * relevant poor-performing queries: 46%
 * f0.5: 96.9%

Background
See the earlier report on frwiki, eswiki, itwiki, and dewiki for information on how the corpora were created.

Portuguese Results
About 12% of the original 10K corpus was removed in the initial filtering. A 1000-query random sample was taken, and 48% of those queries were discarded, leaving a 524-query corpus. Thus only about 46% of low-performing queries are in an identifiable language.

Other languages searched on ptwiki
Based on the sample of 524 poor-performing queries on ptwiki that are in some language, about 80% are in Portuguese, 4% in English, and fewer than 1% each are in a handful of other languages.

Below are the results for ptwiki, with raw counts, percentage, and 95% margin of error. In order, those are Portuguese, English, Spanish, Tagalog, Russian, Dutch, Latin, and French.

We don’t have query-trained language models for all of the languages represented here, namely Tagalog and Latin. Since these each represent very small slices of our corpus (1 query each), we aren’t going to worry about them, and accept that they will not be detected correctly.

Looking at the larger corpus of 8797 remaining queries after the initial filtering, focusing on queries in other writing systems, there are also a small number of Hebrew, Arabic, Chinese, Korean, and Greek queries, and Burmese (for which we do not have models).

Analysis and Optimization
Using all of the language models available, I ran tests on various model sizes, in increments of 500 up to 5,000 and increments of 1,000 up to 10,000. Results for the 3K models, and some of the models that did better are here:

model size  3000    5000    6000    9000    10000 TOTAL  86.8%   87.4%   88.0%   88.2%   88.7% Portuguese  93.2%   93.6%   93.9%   94.2%   94.5% English  78.4%   80.0%   81.6%   76.6%   76.6% Spanish  13.1%   13.6%   13.8%   14.3%   15.1% Dutch  28.6%   25.0%   25.0%   28.6%   33.3% French  28.6%   33.3%   40.0%   33.3%   28.6% Latin   0.0%    0.0%    0.0%    0.0%    0.0% Russian 100.0%  100.0%  100.0%  100.0%  100.0% Tagalog   0.0%    0.0%    0.0%    0.0%    0.0%

Performance details for the 3K model are here (details for larger models are similar in terms of which language models perform the most poorly):

f0.5   f1      f2      recall  prec    total   hits    misses TOTAL    86.8%   86.8%   86.8%   86.8%   86.8%  524     455     69 Portuguese    97.2%   93.2%   89.6%   87.3%  100.0%  490     428     0 English    77.5%   78.4%   79.4%   80.0%   76.9%  25      20      6 Spanish     8.6%   13.1%   27.4%  100.0%    7.0%  4       4       53 Dutch    20.0%   28.6%   50.0%  100.0%   16.7%  1       1       5 French    20.0%   28.6%   50.0%  100.0%   16.7%  1       1       5 Latin     0.0%    0.0%    0.0%    0.0%    0.0%  1       0       0 Russian   100.0%  100.0%  100.0%  100.0%  100.0%  1       1       0 Tagalog     0.0%    0.0%    0.0%    0.0%    0.0%  1       0       0 f0.5   f1      f2      recall  prec    total   hits    misses

Spanish does very poorly, with way too many false positives. Dutch and French aren’t terrible in terms of raw false positives, but aren’t great, either.

As noted above, Hebrew, Arabic, Chinese, Korean, and Greek are present in the larger sample, and as our models for these languages are very high accuracy, I’ve included them.

The final language set is Portuguese, English, Russian, Hebrew, Arabic, Chinese, Korean, and Greek. With these languages, 3K is the optimal model size. The 3K results are shown below along with other top-performing model sizes:

model size   2500    3000    9000    10000 TOTAL   96.9%   96.9%   96.9%   96.9% Portuguese   98.9%   98.8%   98.7%   98.7% English   79.4%   80.6%   82.0%   81.4% Spanish    0.0%    0.0%    0.0%    0.0% Dutch    0.0%    0.0%    0.0%    0.0% French    0.0%    0.0%    0.0%    0.0% Latin    0.0%    0.0%    0.0%    0.0% Russian  100.0%  100.0%  100.0%  100.0% Tagalog    0.0%    0.0%    0.0%    0.0%

The detailed report for the 3K model is here:

f0.5   f1      f2      recall  prec    total   hits    misses TOTAL   96.9%   96.9%   96.9%   96.9%   96.9%  524     508     16 Portuguese   99.0%   98.8%   98.5%   98.4%   99.2%  490     482     4 English   72.3%   80.6%   91.2%  100.0%   67.6%  25      25      12 Spanish    0.0%    0.0%    0.0%    0.0%    0.0%  4       0       0 Dutch    0.0%    0.0%    0.0%    0.0%    0.0%  1       0       0 French    0.0%    0.0%    0.0%    0.0%    0.0%  1       0       0 Latin    0.0%    0.0%    0.0%    0.0%    0.0%  1       0       0 Russian  100.0%  100.0%  100.0%  100.0%  100.0%  1       1       0 Tagalog    0.0%    0.0%    0.0%    0.0%    0.0%  1       0       0 f0.5   f1      f2      recall  prec    total   hits    misses

Recall went up and precision went down for Portuguese and English, but overall performance improved. Queries in unrepresented languages were all identified as English, except for Spanish queries, which were identified as Portuguese (decreasing precision for both), but those now unused models are no longer generating lots of false positives and bringing down precision overall.

ptwiki: Best Options
The optimal settings for ptwiki, based on these experiments, would be to use models for Portuguese, English, Russian, Hebrew, Arabic, Chinese, Korean, Greek (pt, en, ru, he, ar, zh, ko, el), using the default 3000-ngram models.