Besides translating directly, the sequence to sequence paper uses its LSTM to rescore the candidate lists of a phrase-based statistical machine translation (SMT) system. For every source sentence the SMT system proposes an n-best list of translations with its own scores; the LSTM computes the log-probability of each candidate, and the final score is the even average of the two. Implement the rescoring and the comparison against the SMT system's own choice and against an oracle.
rescore(hyps) -> list
hyps: non-empty list of dicts, one per candidate, each with float keys "smt" (the SMT system's score), "lstm" (the LSTM log-probability) and "quality" (the candidate's quality against the reference, higher is better; not used here). The list is in no particular order.(index, combined) for every candidate, sorted by combined score from high to low, ties broken by the smaller index; combined rounded to 4 decimals.rescore_corpus(nbest_lists) -> dict
nbest_lists: list of n-best lists (one per source sentence), each in the format above."smt"), the rescored choice (first entry of rescore) and the oracle (highest "quality"). Ties always go to the smaller index.{"chosen": [rescored index per sentence], "changed": number of sentences where the rescored choice differs from the baseline, "baseline": mean quality of the baseline choices, "rescored": mean quality of the rescored choices, "oracle": mean quality of the oracle choices}, means rounded to 4 decimals.{"chosen": [], "changed": 0, "baseline": 0.0, "rescored": 0.0, "oracle": 0.0}.