examples/faster/faster_generation/samples/mbart_sample.py
def postprocess_response(seq, bos_idx, eos_idx):
    """Post-process the decoded sequence."""
    eos_pos = len(seq) - 1
    for i, idx in enumerate(seq):
        if idx == eos_idx:
            eos_pos = i
            break
    seq = [
        idx for idx in seq[:eos_pos + 1] if idx != bos_idx and idx != eos_idx
    ]
    res = tokenizer.convert_ids_to_string(seq)
    return res
Post-process the decoded sequence.
Post-process the decoded sequence.
Post - process the decoded sequence .
def postprocess_response(seq, bos_idx, eos_idx):
    eos_pos = len(seq) - 1
    for i, idx in enumerate(seq):
        if idx == eos_idx:
            eos_pos = i
            break
    seq = [
        idx for idx in seq[:eos_pos + 1] if idx != bos_idx and idx != eos_idx
    ]
    res = tokenizer.convert_ids_to_string(seq)
    return res
def postprocess_response ( seq , bos_idx , eos_idx ) : eos_pos = len ( seq ) - 1 for i , idx in enumerate ( seq ) : if idx == eos_idx : eos_pos = i break seq = [ idx for idx in seq [ : eos_pos + 1 ] if idx != bos_idx and idx != eos_idx ] res = tokenizer . convert_ids_to_string ( seq ) return res
Post-process the decoded sequence.
Post - process the decoded sequence .
"""Post-process the decoded sequence."""
seq
bos_idx
eos_idx