Before attention, a neural translation model read the whole source sentence into one fixed-length vector and decoded the translation from it. Score a given translation under such a model: return .
translation_log_prob(src, tgt, model) -> float
src: list of source token ids (may be empty).tgt: list of target token ids (may be empty).model: a dict of plain Python callables and values:
"h0": the initial encoder state (a NumPy array)."enc_step"(x, h) -> h: one encoder step, ."dec_init"(c) -> s: the initial decoder state computed from the context vector."dec_step"(s, y, c) -> s: one decoder step, ."readout"(y, s, c) -> p: a probability vector over the target vocabulary, ."bos": the token id fed in as before the first target word.The context vector is the encoder's last state, (or h0 when the source is empty). The same is passed to every decoder call. The probability of the translation factorises over target positions:
Return the sum as a Python float, unrounded. An empty target gives 0.0.