Tuning

Since Ncoder implements a linear combination of multiple feature functions, the contribution of each feature in the overall search must be tuned to obtain quality results.

Therefore, the value of the weights (λi) shown in the first equation of Section features are optimized by means of the script mert-run.perl, which runs as follows:
$> mert-run.perl --working-dir=$optdir \
     --input=$testfiltered \
     --refs=$refs \
     --decoder-flags="$flags" \
     --lambdas="$lambdas" \
     --nbest=N &> log &
It takes as input the test file to decode (translate), the reference/s translations, the decoder set of flags (such as the number of threads, stack size, n-gram LM files, etc.), the initial values of the model weights to decode as well as the N-best size. The MERT (Minimum Error Rate Training) implementation that can be found in the Moses SMT system is employed to optimize. In Section A French-English sample you can see an example of tuning Ncoder.

You can use the script mert-say.perl to visualize the weights and BLEU score obtained in the multiple decoding iterations typically performed by MERT. For instance:
$> mert-say.perl log

lb0    lb1    lt0    la0    la1    la2    la3    lmc    lsc    ldc    lmp    lsp    ldp    ld     lp0    lp1    | BLEU
=======================================================================================================================
1      1      1      1      1      1      1      1      1      1      1      1      1      1      1      1      | 19.67
0.0530 0.0515 0.1257 0.0581 0.0601 0.0121 0.0437 0.0403 0.0415 0.0433 0.0033 0.0295 0.0065 -0.029 0.0490 0.3526 | 23.86
0.0776 0.0629 0.1475 0.0682 0.0623 0.0146 0.0512 0.0472 0.0487 0.0501 0.0039 0.0319 0.0076 -0.020 0.1274 0.1778 | 26.53
0.0736 0.0596 0.1397 0.0646 0.0590 0.0139 0.0486 0.0448 0.0114 0.0475 0.0046 0.0302 0.0004 -0.019 0.1412 0.2411 | 27.63
0.0737 0.0597 0.1399 0.0647 0.0591 0.0139 0.0486 0.0448 0.0114 0.0475 0.0046 0.0302 0.0018 -0.019 0.1414 0.2387 | 27.59
0.0737 0.0597 0.1400 0.0647 0.0591 0.0135 0.0486 0.0448 0.0114 0.0475 0.0046 0.0302 0.0018 -0.019 0.1414 0.2388 | 27.63
0.0737 0.0594 0.1400 0.0647 0.0591 0.0135 0.0487 0.0449 0.0114 0.0476 0.0046 0.0303 0.0018 -0.019 0.1415 0.2389 | 27.64*
0.0738 0.0594 0.1401 0.0648 0.0591 0.0135 0.0487 0.0449 0.0114 0.0476 0.0046 0.0303 0.0018 -0.019 0.1415 0.2386 | 27.62
=======================================================================================================================
[FINISHED]
Where it can be seen for the set of model weights used in the optimization the values on each iteration (showing the best value with a '*') and the fact that the iteration has been finished.

Once model weights are optimized, you can translate using the optimized set of weights using the mert-tst.perl script:
$> mert-tst.pl -i testfiltered -o outfile -optimal log -run [params]
The script parses the log file. It employs the same settings used in the optimization process ($flags) and the model weights used in the best iteration. In the example, the weights used in the seventh iteration. The test filtered file indicated (-i) is then translated into the output file (-o). Additional parameters ([params]) are passed to the decoder.