
Decoding: 인코딩(encoding)된 벡터를 다시 텍스트로 변환하는 것 (텍스트를 생성하는 과제(text generation)에서는 주어진 토큰 이후에 어떻게 토큰을 출력해야 하는지 방식을 정해야 하므로 디코딩 방법이 필요)




-> beam of size k conatinas a set of active hypotheses
-> At each time step t, the decoder model produce a distribution over the target-language vocabulary V_T. THis produces a large matrix of dimensions k X |V_T|. Conceptually, a (row, column) entry (i,j) in this matrix contains the state obtained from starting from the ith state in the beam and generating the target word corresponding to the jth word of V_T.
≒ adding an additional dimension to the beam (base bim size k X the number of constraints)
We maintain a single beam of size k, as with unconstrained decoding, and dynamically allocate the slots of this beam across the constraint banks at each time step.

-> Algorithm 1의 KBEST function을 다음과 같이 대체
-> candidates = (current beam, new word, expected constraints set)
-> candidates (1) from the k best items, (2) from extending each hypothesis with all unfilled constraints, (3) from its single-best token (to ensure consideration of partially-completed hypotheses)
-> When allocating a size-k beam across C+1 constraint banks(the portion of the beam reserved for items having met the same number of constraints), where C may be greater than k, we use a simple allocation strategy, setting each bin size to [k/C], irrespective of the timestep. Any remaining slots are assigned to the "topmost" or maximally constrained bank, C. But! There is bank adjustment. An overfilled bank is one that has been allocated more slots than it has candidates to fill. Each such overfilled bank, in turn, gives its extra allotments to banks that have more candidates than slots, looking first to its immediate neighbors, and moving outward until it has distributed all of its extra slots. In this way, the beam is filled, up to the minimumu of the beam size or the number of candidates.
Hypotheses are not allowed to generate the end-of-sentence token, , unless they have met all of their constraints. when beam search is finished, the highest-scoring completed item is returned.

-> 회색으로 칠해진 word가 KBEST-DBA에서 candidates list에 포함한 beam h의 후보 word
<참고>
https://aws.amazon.com/blogs/machine-learning/train-neural-machine-translation-models-with-sockeye/
https://terms.naver.com/entry.naver?docId=6653720&cid=69974&categoryId=69974
https://blog.naver.com/eungang0301/223242740713
https://www.boostcourse.org/ai330/lecture/1455757?isDesc=false
https://showmiso.tistory.com/156
https://arxiv.org/pdf/1804.06609.pdf